author | zecke <zecke> | 2002-06-13 20:33:24 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-13 20:33:24 (UTC) |
commit | 21ad567831e0be83156d5023d93aac42a60a2af3 (patch) (unidiff) | |
tree | c7b0094910e4a82cd2d2b738f2c88cd7eddfce26 | |
parent | ed10b73df98c1b4c41a0b940e4f8729fe28c2b8a (diff) | |
download | opie-21ad567831e0be83156d5023d93aac42a60a2af3.zip opie-21ad567831e0be83156d5023d93aac42a60a2af3.tar.gz opie-21ad567831e0be83156d5023d93aac42a60a2af3.tar.bz2 |
OBEX receiving is supporte
-rw-r--r-- | core/applets/obex/obeximpl.cc | 40 | ||||
-rw-r--r-- | core/applets/obex/obeximpl.h | 4 |
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 | |||
@@ -2,7 +2,10 @@ | |||
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" |
@@ -22,6 +25,8 @@ ObexImpl::ObexImpl( ) | |||
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 | } |
26 | ObexImpl::~ObexImpl() { | 31 | ObexImpl::~ObexImpl() { |
27 | delete m_obex; | 32 | delete m_obex; |
@@ -47,16 +52,17 @@ void ObexImpl::slotMessage( const QCString& msg, const QByteArray&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; |
@@ -82,7 +88,7 @@ void ObexImpl::slotCancelSend() { | |||
82 | 88 | ||
83 | void ObexImpl::slotDone(bool) { | 89 | void 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 | ||
88 | void ObexImpl::slotSent() { | 94 | void ObexImpl::slotSent() { |
@@ -99,6 +105,30 @@ void ObexImpl::slotError( int errorCode) { | |||
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 | ||
111 | void 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 | ||
103 | Q_EXPORT_INTERFACE() | 133 | Q_EXPORT_INTERFACE() |
104 | { | 134 | { |
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 | |||
@@ -23,14 +23,16 @@ namespace OpieObex { | |||
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 |