summaryrefslogtreecommitdiff
path: root/core/obex/btobex.cpp
Unidiff
Diffstat (limited to 'core/obex/btobex.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/btobex.cpp85
1 files changed, 71 insertions, 14 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
@@ -2,2 +2,4 @@
2#include "btobex.h" 2#include "btobex.h"
3#include <manager.h>
4#include <services.h>
3 5
@@ -9,4 +11,5 @@
9#include <qfileinfo.h> 11#include <qfileinfo.h>
10 12#include <qstring.h>
11 13#include <qmap.h>
14#include <qmessagebox.h>
12 15
@@ -16,2 +19,3 @@ using namespace Opie::Core;
16/* TRANSLATOR OpieObex::Obex */ 19/* TRANSLATOR OpieObex::Obex */
20using namespace OpieTooth;
17 21
@@ -28,4 +32,8 @@ BtObex::BtObex( QObject *parent, const char* name )
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;
@@ -33,2 +41,3 @@ BtObex::~BtObex() {
33} 41}
42
34void BtObex::receive() { 43void BtObex::receive() {
@@ -70,4 +79,50 @@ void BtObex::send( const QString& fileName, const QString& bdaddr) {
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(){
@@ -79,12 +134,12 @@ void BtObex::sendNow(){
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
@@ -92,7 +147,6 @@ void BtObex::sendNow(){
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;
@@ -108,2 +162,4 @@ void BtObex::sendNow(){
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
@@ -142,3 +198,3 @@ void BtObex::sendEnd() {
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
@@ -156,3 +212,3 @@ void BtObex::sendEnd() {
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;
@@ -161,2 +217,3 @@ QString BtObex::parseOut( ){
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" ) ) {