00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "ir.h"
00022
00023 #include "qcopenvelope_qws.h"
00024 #include "applnk.h"
00025
00046 Ir::Ir( QObject *parent, const char *name )
00047 : QObject( parent, name )
00048 {
00049 #ifndef QT_NO_COP
00050 ch = new QCopChannel( "QPE/Obex" );
00051 connect( ch, SIGNAL(received(const QCString&,const QByteArray&)),
00052 this, SLOT(obexMessage(const QCString&,const QByteArray&)) );
00053 #endif
00054 }
00055
00060 bool Ir::supported()
00061 {
00062 #ifndef QT_NO_COP
00063 return QCopChannel::isRegistered( "QPE/Obex" );
00064 #endif
00065 }
00066
00076 void Ir::send( const QString &fn, const QString &description, const QString &mimetype)
00077 {
00078 if ( !filename.isEmpty() ) return;
00079 filename = fn;
00080 #ifndef QT_NO_COP
00081 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
00082 e << description << filename << mimetype;
00083 #endif
00084 }
00085
00093 void Ir::send( const DocLnk &doc, const QString &description )
00094 {
00095 send( doc.file(), description, doc.type() );
00096 }
00097
00106 void Ir::obexMessage( const QCString &msg, const QByteArray &data)
00107 {
00108 if ( msg == "done(QString)" ) {
00109 QString fn;
00110 QDataStream stream( data, IO_ReadOnly );
00111 stream >> fn;
00112 if ( fn == filename )
00113 emit done( this );
00114 }
00115 }
00116