summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/btobex.cpp85
-rw-r--r--core/obex/btobex.h8
-rw-r--r--core/obex/obex.pro4
-rw-r--r--core/obex/obexsend.cpp26
4 files changed, 94 insertions, 29 deletions
diff --git a/core/obex/btobex.cpp b/core/obex/btobex.cpp
index a2866f6..bb5c06d 100644
--- a/core/obex/btobex.cpp
+++ b/core/obex/btobex.cpp
@@ -1,4 +1,6 @@
1 1
2#include "btobex.h" 2#include "btobex.h"
3#include <manager.h>
4#include <services.h>
3 5
4/* OPIE */ 6/* OPIE */
@@ -8,6 +10,7 @@
8/* QT */ 10/* QT */
9#include <qfileinfo.h> 11#include <qfileinfo.h>
10 12#include <qstring.h>
11 13#include <qmap.h>
14#include <qmessagebox.h>
12 15
13using namespace OpieObex; 16using namespace OpieObex;
@@ -15,4 +18,5 @@ using namespace OpieObex;
15using namespace Opie::Core; 18using namespace Opie::Core;
16/* TRANSLATOR OpieObex::Obex */ 19/* TRANSLATOR OpieObex::Obex */
20using namespace OpieTooth;
17 21
18BtObex::BtObex( QObject *parent, const char* name ) 22BtObex::BtObex( QObject *parent, const char* name )
@@ -27,9 +31,14 @@ BtObex::BtObex( QObject *parent, const char* name )
27 connect( this, SIGNAL(sent(bool) ), 31 connect( this, SIGNAL(sent(bool) ),
28 SLOT(slotError() ) ); 32 SLOT(slotError() ) );
33 btManager = NULL;
29}; 34};
35
30BtObex::~BtObex() { 36BtObex::~BtObex() {
37 if (btManager)
38 delete btManager;
31 delete m_rec; 39 delete m_rec;
32 delete m_send; 40 delete m_send;
33} 41}
42
34void BtObex::receive() { 43void BtObex::receive() {
35 m_receive = true; 44 m_receive = true;
@@ -69,6 +78,52 @@ void BtObex::send( const QString& fileName, const QString& bdaddr) {
69 } 78 }
70 } 79 }
80 //Now we need to find out if the OBEX push is supported for this device
81 //And get the port number
82 if (!btManager) {
83 btManager = new Manager("hci0");
84 connect(btManager,
85 SIGNAL(foundServices(const QString&, Services::ValueList)),
86 this, SLOT(slotFoundServices(const QString&, Services::ValueList)));
87 }
88 btManager->searchServices(bdaddr);
89}
90
91/**
92 * This function reacts on the service discovery finish
93 */
94void BtObex::slotFoundServices(const QString&, Services::ValueList svcList)
95{
96 QValueList<OpieTooth::Services>::Iterator it;
97 QMap<int, QString> classList; //The classes list
98 QMap<int, QString>::Iterator classIt; //Iterator in the class list
99 int portNum = -1; //The desired port number
100 odebug << "BtObex slotFoundServices" << oendl;
101 if (svcList.isEmpty()) {
102 QMessageBox::critical(NULL, tr("Object send"), tr("No services found"));
103 emit error(-1);
104 return;
105 }
106 for (it = svcList.begin(); it != svcList.end(); it++) {
107 classList = (*it).classIdList();
108 classIt = classList.begin();
109 if (classIt == classList.end())
110 continue;
111////We really need symbolic names for service IDs
112 //Ok, we have found the object push service
113 if (classIt.key() == 4357) {
114 portNum = (*it).protocolDescriptorList().last().port();
115 break;
116 }
117 }
118 if (portNum == -1) {
119 QMessageBox::critical(NULL, tr("Object send"),
120 tr("No OBEX Push service"));
121 emit error(-1);
122 return;
123 }
124 m_port = portNum;
71 sendNow(); 125 sendNow();
72} 126}
127
73void BtObex::sendNow(){ 128void BtObex::sendNow(){
74 if ( m_count >= 25 ) { // could not send 129 if ( m_count >= 25 ) { // could not send
@@ -78,22 +133,21 @@ void BtObex::sendNow(){
78 } 133 }
79 // OProcess inititialisation 134 // OProcess inititialisation
80 m_send = new OProcess(); 135 m_send = new OProcess(0, "ussp-push");
81 m_send->setWorkingDirectory( QFileInfo(m_file).dirPath(true) ); 136 m_send->setWorkingDirectory( QFileInfo(m_file).dirPath(true) );
82 137
83 // obextool push file <bdaddr> [channel] 138 // ussp-push --timeo 30 <btaddr:port> file file
84 // 9 for phones. 139 *m_send << "ussp-push" << "--timeo 30";
85 // Palm T3 accepts pictures on 1 140 *m_send << m_bdaddr + "@" + QString::number(m_port);
86 *m_send << "obextool" << "push";
87 *m_send << QFile::encodeName(QFileInfo(m_file).fileName()); 141 *m_send << QFile::encodeName(QFileInfo(m_file).fileName());
88 *m_send << m_bdaddr << "9"; 142 *m_send << QFile::encodeName(QFileInfo(m_file).fileName());
89 143 m_send->setUseShell(true);
144
90 // connect to slots Exited and and StdOut 145 // connect to slots Exited and and StdOut
91 connect(m_send, SIGNAL(processExited(Opie::Core::OProcess*) ), 146 connect(m_send, SIGNAL(processExited(Opie::Core::OProcess*) ),
92 this, SLOT(slotExited(Opie::Core::OProcess*)) ); 147 this, SLOT(slotExited(Opie::Core::OProcess*)) );
93 connect(m_send, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int )), 148 connect(m_send, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)),
94 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) ); 149 this, SLOT(slotStdOut(Opie::Core::OProcess*, char*, int) ) );
95
96 // now start it 150 // now start it
97 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { 151 if (!m_send->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
98 m_count = 25; 152 m_count = 25;
99 emit error(-1 ); 153 emit error(-1 );
@@ -107,4 +161,6 @@ void BtObex::sendNow(){
107 161
108void BtObex::slotExited(OProcess* proc ){ 162void BtObex::slotExited(OProcess* proc ){
163 odebug << proc->name() << " exited with result "
164 << proc->exitStatus() << oendl;
109 if (proc == m_rec ) // receive process 165 if (proc == m_rec ) // receive process
110 received(); 166 received();
@@ -141,5 +197,5 @@ void BtObex::sendEnd() {
141 m_send=0; 197 m_send=0;
142 emit sent(true); 198 emit sent(true);
143 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready 199 }else if (m_send->exitStatus() != 0 ) { // it failed maybe the other side wasn't ready
144 // let's try it again 200 // let's try it again
145 delete m_send; 201 delete m_send;
@@ -155,9 +211,10 @@ void BtObex::sendEnd() {
155 211
156// This probably doesn't do anything useful for bt. 212// This probably doesn't do anything useful for bt.
157QString BtObex::parseOut( ){ 213QString BtObex::parseOut(){
158 QString path; 214 QString path;
159 QStringList list = QStringList::split("\n", m_outp); 215 QStringList list = QStringList::split("\n", m_outp);
160 QStringList::Iterator it; 216 QStringList::Iterator it;
161 for (it = list.begin(); it != list.end(); ++it ) { 217 for (it = list.begin(); it != list.end(); ++it ) {
218 odebug << (*it) << oendl;
162 if ( (*it).startsWith("Wrote" ) ) { 219 if ( (*it).startsWith("Wrote" ) ) {
163 int pos = (*it).findRev('(' ); 220 int pos = (*it).findRev('(' );
diff --git a/core/obex/btobex.h b/core/obex/btobex.h
index 5ab591c..099f04a 100644
--- a/core/obex/btobex.h
+++ b/core/obex/btobex.h
@@ -5,7 +5,10 @@
5 5
6#include <qobject.h> 6#include <qobject.h>
7#include <services.h>
8#include <manager.h>
7 9
8namespace Opie {namespace Core {class OProcess;}} 10namespace Opie {namespace Core {class OProcess;}}
9class QCopChannel; 11class QCopChannel;
12using namespace OpieTooth;
10namespace OpieObex { 13namespace OpieObex {
11 // Maybe this should be derved from Obex. 14 // Maybe this should be derved from Obex.
@@ -56,7 +59,9 @@ namespace OpieObex {
56 QString m_outp; 59 QString m_outp;
57 QString m_bdaddr; 60 QString m_bdaddr;
61 int m_port;
58 Opie::Core::OProcess *m_send; 62 Opie::Core::OProcess *m_send;
59 Opie::Core::OProcess *m_rec; 63 Opie::Core::OProcess *m_rec;
60 bool m_receive : 1; 64 bool m_receive : 1;
65 OpieTooth::Manager* btManager;
61 void shutDownReceive(); 66 void shutDownReceive();
62 67
@@ -64,7 +69,8 @@ private slots:
64 69
65 // the process exited 70 // the process exited
66 void slotExited(Opie::Core::OProcess* proc) ; 71 void slotExited(Opie::Core::OProcess*) ;
67 void slotStdOut(Opie::Core::OProcess*, char*, int); 72 void slotStdOut(Opie::Core::OProcess*, char*, int);
68 void slotError(); 73 void slotError();
74 void slotFoundServices(const QString&, Services::ValueList);
69 75
70 private: 76 private:
diff --git a/core/obex/obex.pro b/core/obex/obex.pro
index d6b527c..33cb957 100644
--- a/core/obex/obex.pro
+++ b/core/obex/obex.pro
@@ -6,7 +6,7 @@ TARGET = opieobex
6 DESTDIR = $(OPIEDIR)/plugins/obex 6 DESTDIR = $(OPIEDIR)/plugins/obex
7INTERFACES = obexsendbase.ui 7INTERFACES = obexsendbase.ui
8INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/core/launcher 8INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/core/launcher $(OPIEDIR)/noncore/net/opietooth/lib
9DEPENDPATH += 9DEPENDPATH +=
10LIBS += -lqpe -lopiecore2 10LIBS += -lopietooth1 -lqpe -lopiecore2
11 VERSION = 0.0.3 11 VERSION = 0.0.3
12 12
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp
index 9cd9972..dbbb7b3 100644
--- a/core/obex/obexsend.cpp
+++ b/core/obex/obexsend.cpp
@@ -21,6 +21,6 @@ using namespace Opie::Core;
21#include <qpixmap.h> 21#include <qpixmap.h>
22#include <qlistview.h> 22#include <qlistview.h>
23#include <qtimer.h>
24 23
24#include <unistd.h>
25/* TRANSLATOR OpieObex::SendWidget */ 25/* TRANSLATOR OpieObex::SendWidget */
26 26
@@ -84,5 +84,5 @@ int SendWidget::addReceiver(const char *r, const char *icon)
84bool SendWidget::receiverSelected(int id) 84bool SendWidget::receiverSelected(int id)
85{ 85{
86 return receivers[id]->pixmap(2); 86 return (bool)(receivers[id]->pixmap(2) != NULL);
87} 87}
88 88
@@ -142,5 +142,5 @@ void SendWidget::slotStartIrda() {
142 if ( !m_irDa.count() ) return; 142 if ( !m_irDa.count() ) return;
143 if ( m_irDaIt == m_irDa.end() ) { 143 if ( m_irDaIt == m_irDa.end() ) {
144 irdaStatus->setText(tr("complete.")); 144 irdaStatus->setText(tr("complete."));
145 return; 145 return;
146 } 146 }
@@ -174,5 +174,5 @@ void SendWidget::slotStartBt() {
174 ++m_btIt; 174 ++m_btIt;
175 if (m_btIt == m_bt.end() ) { 175 if (m_btIt == m_bt.end() ) {
176 btStatus->setText(tr("complete.")); 176 btStatus->setText(tr("complete."));
177 return; 177 return;
178 } 178 }
@@ -188,5 +188,6 @@ void SendWidget::send_to_receivers() {
188void SendWidget::scan_for_receivers() 188void SendWidget::scan_for_receivers()
189{ 189{
190 //FIXME: Clean ListBox prior to (re)scan 190 receiverList->clear();
191 receivers.clear();
191 sendButton->setDisabled( true ); 192 sendButton->setDisabled( true );
192 193
@@ -220,19 +221,20 @@ void SendWidget::toggle_receiver(QListViewItem* item)
220 // toggle the state of an individual receiver. 221 // toggle the state of an individual receiver.
221 if(item->pixmap(2)) 222 if(item->pixmap(2))
222 item->setPixmap(2,QPixmap()); 223 item->setPixmap(2,QPixmap());
223 else 224 else
224 item->setPixmap(2,Resource::loadPixmap("backup/check.png")); 225 item->setPixmap(2,Resource::loadPixmap("backup/check.png"));
225} 226}
226 227
227 228
228void SendWidget::closeEvent( QCloseEvent* e) { 229void SendWidget::closeEvent( QCloseEvent* e) {
229 e->accept(); // make sure 230 obexSendBase::closeEvent(e);
230 QTimer::singleShot(0, this, SLOT(userDone() ) );
231}
232void SendWidget::userDone() {
233 QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); 231 QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()");
234 QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); 232 QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()");
235 emit done();
236} 233}
234
235void SendWidget::userDone() {
236 close();
237}
238
237QString SendWidget::file()const { 239QString SendWidget::file()const {
238 return m_file; 240 return m_file;