summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-13 20:33:24 (UTC)
committer zecke <zecke>2002-06-13 20:33:24 (UTC)
commit21ad567831e0be83156d5023d93aac42a60a2af3 (patch) (unidiff)
treec7b0094910e4a82cd2d2b738f2c88cd7eddfce26
parented10b73df98c1b4c41a0b940e4f8729fe28c2b8a (diff)
downloadopie-21ad567831e0be83156d5023d93aac42a60a2af3.zip
opie-21ad567831e0be83156d5023d93aac42a60a2af3.tar.gz
opie-21ad567831e0be83156d5023d93aac42a60a2af3.tar.bz2
OBEX receiving is supporte
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/obex/obeximpl.cc40
-rw-r--r--core/applets/obex/obeximpl.h4
2 files changed, 38 insertions, 6 deletions
diff --git a/core/applets/obex/obeximpl.cc b/core/applets/obex/obeximpl.cc
index 0c137af..1a1c922 100644
--- a/core/applets/obex/obeximpl.cc
+++ b/core/applets/obex/obeximpl.cc
@@ -1,106 +1,136 @@
1 1
2#include <qdatastream.h> 2#include <qdatastream.h>
3#include <qmessagebox.h> 3#include <qmessagebox.h>
4 4
5
5#include <qpe/qcom.h> 6#include <qpe/qcom.h>
7#include <qpe/applnk.h>
8
6#include <qlabel.h> 9#include <qlabel.h>
7 10
8#include "obex.h" 11#include "obex.h"
9#include "obeximpl.h" 12#include "obeximpl.h"
10 13
11 14
12 15
13using namespace OpieObex; 16using namespace OpieObex;
14 17
15ObexImpl::ObexImpl( ) 18ObexImpl::ObexImpl( )
16 : QObject() { 19 : QObject() {
17 // register to a channel 20 // register to a channel
18 qWarning( "c'tor" ); 21 qWarning( "c'tor" );
19 m_obex = new Obex(this, "obex"); 22 m_obex = new Obex(this, "obex");
20 m_sendgui = new ObexDlg(); 23 m_sendgui = new ObexDlg();
21 m_recvgui = new ObexInc(); 24 m_recvgui = new ObexInc();
22 m_chan = new QCopChannel("QPE/Obex" ); 25 m_chan = new QCopChannel("QPE/Obex" );
23 connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 26 connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
24 this, SLOT(slotMessage(const QCString&, const QByteArray&) ) ); 27 this, SLOT(slotMessage(const QCString&, const QByteArray&) ) );
28 connect(m_obex, SIGNAL(receivedFile(const QString& ) ),
29 this, SLOT(slotReceivedFile(const QString& ) ) );
25} 30}
26ObexImpl::~ObexImpl() { 31ObexImpl::~ObexImpl() {
27 delete m_obex; 32 delete m_obex;
28 delete m_chan; 33 delete m_chan;
29 delete m_sendgui; 34 delete m_sendgui;
30} 35}
31QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { 36QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
32 *iface = 0; 37 *iface = 0;
33 if( uuid == IID_QUnknown ) 38 if( uuid == IID_QUnknown )
34 *iface = this; 39 *iface = this;
35 else if( uuid == IID_ObexInterface ) 40 else if( uuid == IID_ObexInterface )
36 *iface = this; 41 *iface = this;
37 42
38 qWarning("query" ); 43 qWarning("query" );
39 if(*iface ) 44 if(*iface )
40 (*iface)->addRef(); 45 (*iface)->addRef();
41 return QS_OK; 46 return QS_OK;
42 47
43} 48}
44void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { 49void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) {
45 QDataStream stream( data, IO_ReadOnly ); 50 QDataStream stream( data, IO_ReadOnly );
46 qWarning("Message %s", msg.data() ); 51 qWarning("Message %s", msg.data() );
47 if(msg == "send(QString,QString,QString)" ) { 52 if(msg == "send(QString,QString,QString)" ) {
48 QString desc; 53 QString desc;
49 stream >> desc; 54 stream >> desc;
50 QString filename; 55 stream >> m_name;
51 stream >> filename;
52 m_sendgui->raise(); // should be on top 56 m_sendgui->raise(); // should be on top
53 m_sendgui->showMaximized(); 57 m_sendgui->showMaximized();
54 m_sendgui->lblPath->setText(filename); 58 m_sendgui->lblPath->setText(m_name);
55 connect( (QObject*)m_sendgui->PushButton2, SIGNAL(clicked()), 59 connect( (QObject*)m_sendgui->PushButton2, SIGNAL(clicked()),
56 this, SLOT(slotCancelSend())); 60 this, SLOT(slotCancelSend()));
57 m_obex->send(filename ); 61 m_obex->send(m_name );
58 connect( (QObject*)m_obex, SIGNAL( sent() ), this, 62 connect( (QObject*)m_obex, SIGNAL( sent() ), this,
59 SLOT( slotSent() ) ); 63 SLOT( slotSent() ) );
64 connect( (QObject*)m_obex, SIGNAL( error(int) ), this,
65 SLOT( slotSent() ) );
60 }else if(msg == "receive(int)" ) { // open a GUI 66 }else if(msg == "receive(int)" ) { // open a GUI
61 m_recvgui->showMaximized(); 67 m_recvgui->showMaximized();
62 int receiveD = 0; 68 int receiveD = 0;
63 stream >> receiveD; 69 stream >> receiveD;
64 if ( receiveD == 1) 70 if ( receiveD == 1)
65 m_obex->receive(); 71 m_obex->receive();
66 else 72 else
67 m_obex->setReceiveEnabled( false ); 73 m_obex->setReceiveEnabled( false );
68 74
69 } else if (msg =="done(QString)") { 75 } else if (msg =="done(QString)") {
70 QString text; 76 QString text;
71 stream >> text; 77 stream >> text;
72 m_sendgui->lblPath->setText(tr("Done transfering " + text)); 78 m_sendgui->lblPath->setText(tr("Done transfering " + text));
73 79
74 } 80 }
75} 81}
76 82
77void ObexImpl::slotCancelSend() { 83void ObexImpl::slotCancelSend() {
78 // cancel sync process too 84 // cancel sync process too
79 //m_obex->cancel(); // not ready yet 85 //m_obex->cancel(); // not ready yet
80 m_sendgui->hide(); 86 m_sendgui->hide();
81} 87}
82 88
83void ObexImpl::slotDone(bool) { 89void ObexImpl::slotDone(bool) {
84 QCopEnvelope e ("QPE/Obex", "done(QString)" ); //but this into a slot 90 QCopEnvelope e ("QPE/Obex", "done(QString)" ); //but this into a slot
85 e << "Done!"; 91 e << m_name;
86} 92}
87 93
88void ObexImpl::slotSent() { 94void ObexImpl::slotSent() {
89 m_sendgui->lblPath->setText("Done!"); 95 m_sendgui->lblPath->setText("Done!");
90 m_sendgui->hide(); 96 m_sendgui->hide();
91} 97}
92 98
93void ObexImpl::slotError( int errorCode) { 99void ObexImpl::slotError( int errorCode) {
94 100
95 QString errorString = ""; 101 QString errorString = "";
96 if (errorCode == -1) { 102 if (errorCode == -1) {
97 errorString = "test"; 103 errorString = "test";
98 } 104 }
99 qDebug("Error: " + errorString); 105 qDebug("Error: " + errorString);
100 m_sendgui->hide(); 106 m_sendgui->hide();
101} 107}
108// Received a file via beam
109// check for mime type and then either
110// add to App via setDocument
111void ObexImpl::slotReceivedFile( const QString &fileName ) {
112 qWarning("filename %s", fileName.latin1() );
113 DocLnk lnk( fileName );
114 QString exec = lnk.exec();
115 qWarning("executing %s", exec.latin1() );
116 if ( exec.isEmpty() || exec == "" ) {
117 qWarning("empty");
118 if ( fileName.right(4) == ".vcf" )
119 exec = "addressbook";
120 else if ( fileName.right(4) == ".vcs" ) {
121 exec = "datebook";
122 }
123 } // now prompt and then add it
124 QCString str= "QPE/Application/";
125 str += exec.latin1();
126 qWarning("channel %s", str.data() );
127 QCopEnvelope e(str , "setDocument(QString)" );
128 e << fileName;
129
130}
131
102 132
103Q_EXPORT_INTERFACE() 133Q_EXPORT_INTERFACE()
104{ 134{
105 Q_CREATE_INSTANCE( ObexImpl ) 135 Q_CREATE_INSTANCE( ObexImpl )
106} 136}
diff --git a/core/applets/obex/obeximpl.h b/core/applets/obex/obeximpl.h
index 4e5109f..8d10cf1 100644
--- a/core/applets/obex/obeximpl.h
+++ b/core/applets/obex/obeximpl.h
@@ -1,36 +1,38 @@
1 1
2#ifndef OpieObexImpl_H 2#ifndef OpieObexImpl_H
3#define OpieObexImpl_H 3#define OpieObexImpl_H
4 4
5#include <qobject.h> 5#include <qobject.h>
6#include "../obexinterface.h" 6#include "../obexinterface.h"
7#include "obexdlg.h" 7#include "obexdlg.h"
8#include "obexinc.h" 8#include "obexinc.h"
9#include <qpe/qcopenvelope_qws.h> 9#include <qpe/qcopenvelope_qws.h>
10 10
11namespace OpieObex { 11namespace OpieObex {
12 class Obex; 12 class Obex;
13 class ObexImpl : public QObject, public ObexInterface { 13 class ObexImpl : public QObject, public ObexInterface {
14 Q_OBJECT 14 Q_OBJECT
15 public: 15 public:
16 ObexImpl(); 16 ObexImpl();
17 virtual ~ObexImpl(); 17 virtual ~ObexImpl();
18 QRESULT queryInterface( const QUuid&, QUnknownInterface** ); 18 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
19 Q_REFCOUNT // for reference counting (macro ) 19 Q_REFCOUNT // for reference counting (macro )
20 private: 20 private:
21 ulong ref; 21 ulong ref;
22 Obex* m_obex; // obex lib 22 Obex* m_obex; // obex lib
23 QCopChannel *m_chan; 23 QCopChannel *m_chan;
24 ObexDlg *m_sendgui; 24 ObexDlg *m_sendgui;
25 ObexInc *m_recvgui; 25 ObexInc *m_recvgui;
26 QString m_name;
26 private slots: 27 private slots:
27 void slotCancelSend(); 28 void slotCancelSend();
28 void slotMessage( const QCString&, const QByteArray& ); 29 void slotMessage( const QCString&, const QByteArray& );
29 void slotError(int ); 30 void slotError(int );
30 // void slotCurrentTry( unsigned int ); */ 31 // void slotCurrentTry( unsigned int ); */
31 void slotDone(bool); 32 void slotDone(bool);
32 //void slotReceivedFile(const QString & ); 33 void slotReceivedFile(const QString & );
33 void slotSent(); 34 void slotSent();
35
34 }; 36 };
35}; 37};
36#endif 38#endif