summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/obex/obeximpl.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/core/applets/obex/obeximpl.cc b/core/applets/obex/obeximpl.cc
index eb0e67b..7331bba 100644
--- a/core/applets/obex/obeximpl.cc
+++ b/core/applets/obex/obeximpl.cc
@@ -1,152 +1,150 @@
1 1
2#include <qdatastream.h> 2#include <qdatastream.h>
3#include <qmessagebox.h> 3#include <qmessagebox.h>
4 4
5 5
6#include <qpe/qcom.h> 6#include <qpe/qcom.h>
7#include <qpe/applnk.h> 7#include <qpe/applnk.h>
8 8
9#include <qlabel.h> 9#include <qlabel.h>
10 10
11#include "obex.h" 11#include "obex.h"
12#include "obeximpl.h" 12#include "obeximpl.h"
13 13
14 14
15 15
16using namespace OpieObex; 16using namespace OpieObex;
17 17
18ObexImpl::ObexImpl( ) 18ObexImpl::ObexImpl( )
19 : QObject() { 19 : QObject() {
20 // register to a channel 20 // register to a channel
21 qWarning( "c'tor" ); 21 qWarning( "c'tor" );
22 m_obex = new Obex(this, "obex"); 22 m_obex = new Obex(this, "obex");
23 m_sendgui = new ObexDlg(); 23 m_sendgui = new ObexDlg();
24 m_recvgui = new ObexInc(); 24 m_recvgui = new ObexInc();
25 m_chan = new QCopChannel("QPE/Obex" ); 25 m_chan = new QCopChannel("QPE/Obex" );
26 connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 26 connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
27 this, SLOT(slotMessage(const QCString&, const QByteArray&) ) ); 27 this, SLOT(slotMessage(const QCString&, const QByteArray&) ) );
28 connect(m_obex, SIGNAL(receivedFile(const QString& ) ), 28 connect(m_obex, SIGNAL(receivedFile(const QString& ) ),
29 this, SLOT(slotReceivedFile(const QString& ) ) ); 29 this, SLOT(slotReceivedFile(const QString& ) ) );
30 connect((QObject*) m_recvgui->InsertButton, SIGNAL(clicked()), 30 connect((QObject*) m_recvgui->InsertButton, SIGNAL(clicked()),
31 m_recvgui, SLOT( accept() )); 31 m_recvgui, SLOT( accept() ));
32 connect((QObject*) m_recvgui->RejectButton, SIGNAL(clicked()), 32 connect((QObject*) m_recvgui->RejectButton, SIGNAL(clicked()),
33 m_recvgui, SLOT( reject() )); 33 m_recvgui, SLOT( reject() ));
34} 34}
35 35
36ObexImpl::~ObexImpl() { 36ObexImpl::~ObexImpl() {
37 delete m_obex; 37 delete m_obex;
38 delete m_chan; 38 delete m_chan;
39 delete m_sendgui; 39 delete m_sendgui;
40 delete m_recvgui; 40 delete m_recvgui;
41} 41}
42 42
43QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { 43QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
44 *iface = 0; 44 *iface = 0;
45 if( uuid == IID_QUnknown ) 45 if( uuid == IID_QUnknown )
46 *iface = this; 46 *iface = this;
47 else if( uuid == IID_ObexInterface ) 47 else if( uuid == IID_ObexInterface )
48 *iface = this; 48 *iface = this;
49 49
50 qWarning("query" ); 50 qWarning("query" );
51 if(*iface ) 51 if(*iface )
52 (*iface)->addRef(); 52 (*iface)->addRef();
53 return QS_OK; 53 return QS_OK;
54} 54}
55 55
56void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { 56void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) {
57 QDataStream stream( data, IO_ReadOnly ); 57 QDataStream stream( data, IO_ReadOnly );
58 qWarning("Message %s", msg.data() ); 58 qWarning("Message %s", msg.data() );
59 if(msg == "send(QString,QString,QString)" ) { 59 if(msg == "send(QString,QString,QString)" ) {
60 QString desc; 60 QString desc;
61 stream >> desc; 61 stream >> desc;
62 stream >> m_name; 62 stream >> m_name;
63 m_sendgui->raise(); // should be on top 63 m_sendgui->raise(); // should be on top
64 m_sendgui->showMaximized(); 64 m_sendgui->showMaximized();
65 m_sendgui->lblPath->setText(m_name); 65 m_sendgui->lblPath->setText(m_name);
66 connect( (QObject*)m_sendgui->PushButton2, SIGNAL(clicked()), 66 connect( (QObject*)m_sendgui->PushButton2, SIGNAL(clicked()),
67 this, SLOT(slotCancelSend())); 67 this, SLOT(slotCancelSend()));
68 m_obex->send(m_name ); 68 m_obex->send(m_name );
69 connect( (QObject*)m_obex, SIGNAL( sent() ), this, 69 connect( (QObject*)m_obex, SIGNAL( sent() ), this,
70 SLOT( slotSent() ) ); 70 SLOT( slotSent() ) );
71 connect( (QObject*)m_obex, SIGNAL( error(int) ), this, 71 connect( (QObject*)m_obex, SIGNAL( error(int) ), this,
72 SLOT( slotSent() ) ); 72 SLOT( slotSent() ) );
73 }else if(msg == "receive(int)" ) { // open a GUI 73 }else if(msg == "receive(int)" ) { // open a GUI
74 //m_recvgui->showMaximized(); 74 //m_recvgui->showMaximized();
75 int receiveD = 0; 75 int receiveD = 0;
76 stream >> receiveD; 76 stream >> receiveD;
77 if ( receiveD == 1) 77 if ( receiveD == 1)
78 m_obex->receive(); 78 m_obex->receive();
79 else 79 else
80 m_obex->setReceiveEnabled( false ); 80 m_obex->setReceiveEnabled( false );
81 81
82 } else if (msg =="done(QString)") { 82 } else if (msg =="done(QString)") {
83 QString text; 83 QString text;
84 stream >> text; 84 stream >> text;
85 m_sendgui->lblPath->setText(tr("Done transfering " + text)); 85 m_sendgui->lblPath->setText(tr("Done transfering " + text));
86 86
87 } 87 }
88} 88}
89 89
90void ObexImpl::slotCancelSend() { 90void ObexImpl::slotCancelSend() {
91 // cancel sync process too 91 // cancel sync process too
92 //m_obex->cancel(); // not ready yet 92 //m_obex->cancel(); // not ready yet
93 m_sendgui->hide(); 93 m_sendgui->hide();
94} 94}
95 95
96void ObexImpl::slotDone(bool) { 96void ObexImpl::slotDone(bool) {
97 QCopEnvelope e ("QPE/Obex", "done(QString)" ); //but this into a slot 97 QCopEnvelope e ("QPE/Obex", "done(QString)" ); //but this into a slot
98 e << m_name; 98 e << m_name;
99} 99}
100 100
101void ObexImpl::slotSent() { 101void ObexImpl::slotSent() {
102 m_sendgui->lblPath->setText("Done!"); 102 m_sendgui->lblPath->setText("Done!");
103 m_sendgui->hide(); 103 m_sendgui->hide();
104} 104}
105 105
106void ObexImpl::slotError( int errorCode) { 106void ObexImpl::slotError( int errorCode) {
107 107
108 QString errorString = ""; 108 QString errorString = "";
109 if (errorCode == -1) { 109 if (errorCode == -1) {
110 errorString = "test"; 110 errorString = "test";
111 } 111 }
112 qDebug("Error: " + errorString); 112 qDebug("Error: " + errorString);
113 m_sendgui->hide(); 113 m_sendgui->hide();
114} 114}
115 115
116// Received a file via beam 116// Received a file via beam
117// check for mime type and then either 117// check for mime type and then either
118// add to App via setDocument 118// add to App via setDocument
119void ObexImpl::slotReceivedFile( const QString &fileName ) { 119void ObexImpl::slotReceivedFile( const QString &fileName ) {
120 qWarning("filename %s", fileName.latin1() ); 120 qWarning("filename %s", fileName.latin1() );
121 DocLnk lnk( fileName ); 121 DocLnk lnk( fileName );
122 QString exec = lnk.exec(); 122 QString exec = lnk.exec();
123 qWarning("executing %s", exec.latin1() ); 123 qWarning("executing %s", exec.latin1() );
124 if ( exec.isEmpty() || exec == "" ) { 124 if ( exec.isEmpty() || exec == "" ) {
125 qWarning("empty"); 125 qWarning("empty");
126 if ( fileName.right(4) == ".vcf" ) 126 if ( fileName.right(4) == ".vcf" )
127 exec = "addressbook"; 127 exec = "addressbook";
128 else if ( fileName.right(4) == ".vcs" ) { 128 else if ( fileName.right(4) == ".vcs" ) {
129 exec = "datebook"; 129 exec = "datebook";
130 } 130 }
131 } // now prompt and then add it 131 } // now prompt and then add it
132 132
133 m_recvgui->PixmapLabel->setPixmap(lnk.pixmap()); 133 m_recvgui->PixmapLabel->setPixmap( lnk.pixmap() );
134 m_recvgui->AppLabel->setText(lnk.name()); 134 m_recvgui->AppLabel->setText( "<b>" + exec + "<b>" );
135 m_recvgui->FileLabel->setText(fileName); 135 m_recvgui->FileLabel->setText( lnk.name() );
136 m_recvgui->showMaximized(); 136 m_recvgui->showMaximized();
137 if( m_recvgui->exec() != -1 ) { 137 if( m_recvgui->exec() != -1 ) {
138 QCString str= "QPE/Application/"; 138 QCString str= "QPE/Application/";
139 str += exec.latin1(); 139 str += exec.latin1();
140 qWarning("channel %s", str.data() ); 140 qWarning("channel %s", str.data() );
141 QCopEnvelope e(str , "setDocument(QString)" ); 141 QCopEnvelope e(str , "setDocument(QString)" );
142 e << fileName; 142 e << fileName;
143 } 143 }
144
145} 144}
146 145
147 146
148 147
149Q_EXPORT_INTERFACE() 148Q_EXPORT_INTERFACE() {
150{
151 Q_CREATE_INSTANCE( ObexImpl ) 149 Q_CREATE_INSTANCE( ObexImpl )
152} 150}