summaryrefslogtreecommitdiff
path: root/core/applets/obex
authorzecke <zecke>2002-06-13 20:33:24 (UTC)
committer zecke <zecke>2002-06-13 20:33:24 (UTC)
commit21ad567831e0be83156d5023d93aac42a60a2af3 (patch) (unidiff)
treec7b0094910e4a82cd2d2b738f2c88cd7eddfce26 /core/applets/obex
parented10b73df98c1b4c41a0b940e4f8729fe28c2b8a (diff)
downloadopie-21ad567831e0be83156d5023d93aac42a60a2af3.zip
opie-21ad567831e0be83156d5023d93aac42a60a2af3.tar.gz
opie-21ad567831e0be83156d5023d93aac42a60a2af3.tar.bz2
OBEX receiving is supporte
Diffstat (limited to 'core/applets/obex') (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,11 +1,14 @@
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
@@ -19,12 +22,14 @@ ObexImpl::ObexImpl( )
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}
@@ -44,22 +49,23 @@ QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
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();
@@ -79,13 +85,13 @@ void ObexImpl::slotCancelSend() {
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}
@@ -96,11 +102,35 @@ void ObexImpl::slotError( int errorCode) {
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
@@ -20,17 +20,19 @@ namespace OpieObex {
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