author | korovkin <korovkin> | 2006-05-10 13:32:46 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-05-10 13:32:46 (UTC) |
commit | 5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f (patch) (unidiff) | |
tree | e9ea63a2fe15982e98886af727649dc6a513faac /noncore/net/opietooth | |
parent | 620d55ae3b94fa8d2fa696b6626893e4520c3a02 (diff) | |
download | opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.zip opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.tar.gz opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.tar.bz2 |
OBEX push functionality moved to libbluetooth1.
Made some reformatting in device.cc
In bluezapplet.cpp /etc/init.d/bluetooth is started synchronously if it's called from QCopMessage.
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.cpp | 8 | ||||
-rw-r--r-- | noncore/net/opietooth/applet/bluezapplet.h | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/device.cc | 16 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/lib.pro | 7 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/obexpush.cpp | 108 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/obexpush.h | 77 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexdialog.cpp | 62 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexdialog.h | 15 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexftpdialog.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexpopup.cpp | 8 |
10 files changed, 238 insertions, 67 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index 90b0c6d..6351d4e 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -113,13 +113,13 @@ namespace OpieTooth { | |||
113 | } else { | 113 | } else { |
114 | odebug << "btDevice is ZERO" << oendl; | 114 | odebug << "btDevice is ZERO" << oendl; |
115 | return false; | 115 | return false; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | int BluezApplet::setBluezStatus(int c) { | 119 | int BluezApplet::setBluezStatus(int c, bool sync) { |
120 | 120 | ||
121 | if ( c == 1 ) { | 121 | if ( c == 1 ) { |
122 | switch ( ODevice::inst()->model() ) { | 122 | switch ( ODevice::inst()->model() ) { |
123 | case Model_iPAQ_H39xx: | 123 | case Model_iPAQ_H39xx: |
124 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); | 124 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); |
125 | break; | 125 | break; |
@@ -135,14 +135,18 @@ namespace OpieTooth { | |||
135 | #endif | 135 | #endif |
136 | 136 | ||
137 | default: | 137 | default: |
138 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 138 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | if (sync) { | ||
142 | ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null"); | ||
143 | } else { | ||
141 | QCopEnvelope e("QPE/System", "execute(QString)"); | 144 | QCopEnvelope e("QPE/System", "execute(QString)"); |
142 | e << QString("/etc/init.d/bluetooth start"); | 145 | e << QString("/etc/init.d/bluetooth start"); |
146 | } | ||
143 | } else { | 147 | } else { |
144 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); | 148 | ::system("/etc/init.d/bluetooth stop >/dev/null 2>/dev/null"); |
145 | if ( btManager ) { | 149 | if ( btManager ) { |
146 | delete btManager; | 150 | delete btManager; |
147 | btManager = 0; | 151 | btManager = 0; |
148 | } | 152 | } |
@@ -166,13 +170,13 @@ namespace OpieTooth { | |||
166 | // receiver for QCopChannel("QPE/Bluetooth") messages. | 170 | // receiver for QCopChannel("QPE/Bluetooth") messages. |
167 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) | 171 | void BluezApplet::slotMessage( const QCString& str, const QByteArray& ) |
168 | { | 172 | { |
169 | if ( str == "enableBluetooth()") { | 173 | if ( str == "enableBluetooth()") { |
170 | m_wasOn = checkBluezStatus(); | 174 | m_wasOn = checkBluezStatus(); |
171 | if (!m_wasOn) { | 175 | if (!m_wasOn) { |
172 | setBluezStatus(1); | 176 | setBluezStatus(1, true); |
173 | sleep(2); | 177 | sleep(2); |
174 | } | 178 | } |
175 | } | 179 | } |
176 | else if ( str == "disableBluetooth()") { | 180 | else if ( str == "disableBluetooth()") { |
177 | /* | 181 | /* |
178 | * We can down BT only if it was started by qcop. We don't want | 182 | * We can down BT only if it was started by qcop. We don't want |
diff --git a/noncore/net/opietooth/applet/bluezapplet.h b/noncore/net/opietooth/applet/bluezapplet.h index 90bee3b..1937934 100644 --- a/noncore/net/opietooth/applet/bluezapplet.h +++ b/noncore/net/opietooth/applet/bluezapplet.h | |||
@@ -52,13 +52,13 @@ public slots: | |||
52 | 52 | ||
53 | private: | 53 | private: |
54 | void mousePressEvent( QMouseEvent * ); | 54 | void mousePressEvent( QMouseEvent * ); |
55 | void paintEvent( QPaintEvent* ); | 55 | void paintEvent( QPaintEvent* ); |
56 | void launchManager(); | 56 | void launchManager(); |
57 | bool checkBluezStatus(); | 57 | bool checkBluezStatus(); |
58 | int setBluezStatus(int); | 58 | int setBluezStatus(int, bool sync = false); |
59 | int checkBluezDiscoveryStatus(); | 59 | int checkBluezDiscoveryStatus(); |
60 | int setBluezDiscoveryStatus(int); | 60 | int setBluezDiscoveryStatus(int); |
61 | 61 | ||
62 | private: | 62 | private: |
63 | Device* btDevice; | 63 | Device* btDevice; |
64 | Manager *btManager; | 64 | Manager *btManager; |
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc index 40acbd2..2f04d46 100644 --- a/noncore/net/opietooth/lib/device.cc +++ b/noncore/net/opietooth/lib/device.cc | |||
@@ -19,27 +19,25 @@ namespace { | |||
19 | int parsePid( const QCString& par ) | 19 | int parsePid( const QCString& par ) |
20 | { | 20 | { |
21 | int id=0; | 21 | int id=0; |
22 | QString string( par ); | 22 | QString string( par ); |
23 | QStringList list = QStringList::split( '\n', string ); | 23 | QStringList list = QStringList::split( '\n', string ); |
24 | 24 | ||
25 | for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 25 | for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
26 | { | ||
27 | owarn << "parsePID: " << (*it).latin1() << oendl; | 26 | owarn << "parsePID: " << (*it).latin1() << oendl; |
28 | 27 | ||
29 | // FIXME mbhaynie: Surely there is a better way to skip | 28 | // FIXME mbhaynie: Surely there is a better way to skip |
30 | // verbosity (E.g. the TI device configuration | 29 | // verbosity (E.g. the TI device configuration |
31 | // script). Apparently the PID is always on a line by | 30 | // script). Apparently the PID is always on a line by |
32 | // itself, or is at least the first word of a line. Does | 31 | // itself, or is at least the first word of a line. Does |
33 | // QString have somethine like startsWithRegex("[0-9]+")? | 32 | // QString have somethine like startsWithRegex("[0-9]+")? |
34 | if( (*it).startsWith("#") ) continue; | 33 | if( (*it).startsWith("#") ) continue; |
35 | if( (*it).startsWith("TI") ) continue; | 34 | if( (*it).startsWith("TI") ) continue; |
36 | if( (*it).startsWith("Loading") ) continue; | 35 | if( (*it).startsWith("Loading") ) continue; |
37 | if( (*it).startsWith("BTS") ) continue; | 36 | if( (*it).startsWith("BTS") ) continue; |
38 | if( !(*it).startsWith("CSR") ) | 37 | if( !(*it).startsWith("CSR") ) { |
39 | { | ||
40 | id = (*it).toInt(); | 38 | id = (*it).toInt(); |
41 | break; | 39 | break; |
42 | } | 40 | } |
43 | } | 41 | } |
44 | return id; | 42 | return id; |
45 | } | 43 | } |
@@ -72,40 +70,38 @@ void Device::attach(){ | |||
72 | m_process = new OProcess(); | 70 | m_process = new OProcess(); |
73 | *m_process << "hciattach"; | 71 | *m_process << "hciattach"; |
74 | *m_process << "-p"; | 72 | *m_process << "-p"; |
75 | 73 | ||
76 | // FIXME -- this is a hack for an odd hciattach interface. | 74 | // FIXME -- this is a hack for an odd hciattach interface. |
77 | if ( ODevice::inst()->modelString() == "HX4700" ) | 75 | if ( ODevice::inst()->modelString() == "HX4700" ) |
78 | { | ||
79 | *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas"; | 76 | *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas"; |
80 | } | ||
81 | else | 77 | else |
82 | { | ||
83 | *m_process << m_device << m_mode << m_speed; | 78 | *m_process << m_device << m_mode << m_speed; |
84 | } | ||
85 | connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), | 79 | connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), |
86 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); | 80 | this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); |
87 | connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ), | 81 | connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ), |
88 | this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) ); | 82 | this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) ); |
89 | connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ), | 83 | connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ), |
90 | this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) ); | 84 | this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) ); |
91 | if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){ | 85 | if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){ |
92 | owarn << "Could not start" << oendl; | 86 | owarn << "Could not start" << oendl; |
93 | delete m_process; | 87 | delete m_process; |
94 | m_process = 0; | 88 | m_process = 0; |
95 | } | 89 | } |
96 | }; | 90 | } |
97 | } | 91 | } |
98 | void Device::detach(){ | 92 | void Device::detach(){ |
99 | delete m_hci; | 93 | delete m_hci; |
94 | m_hci = 0; | ||
100 | delete m_process; | 95 | delete m_process; |
96 | m_process = 0; | ||
101 | // kill the pid we got | 97 | // kill the pid we got |
102 | if(m_attached ){ | 98 | if(m_attached ){ |
103 | //kill the pid | 99 | //kill the pid |
104 | owarn << "killing" << oendl; | 100 | owarn << "killing" << oendl; |
105 | kill(pid, 9); | 101 | ::kill(pid, 9); |
106 | } | 102 | } |
107 | owarn << "detached" << oendl; | 103 | owarn << "detached" << oendl; |
108 | } | 104 | } |
109 | bool Device::isLoaded()const{ | 105 | bool Device::isLoaded()const{ |
110 | return m_attached; | 106 | return m_attached; |
111 | } | 107 | } |
diff --git a/noncore/net/opietooth/lib/lib.pro b/noncore/net/opietooth/lib/lib.pro index 781bf15..e11af9a 100644 --- a/noncore/net/opietooth/lib/lib.pro +++ b/noncore/net/opietooth/lib/lib.pro | |||
@@ -1,12 +1,15 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on | 2 | CONFIG += qte warn_on |
3 | HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h \ | 3 | HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h \ |
4 | startpanconnection.h startdunconnection.h bt-serial.h forwarder.h | 4 | startpanconnection.h startdunconnection.h obexpush.h \ |
5 | bt-serial.h forwarder.h | ||
5 | SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc \ | 6 | SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc \ |
6 | startpanconnection.cpp startdunconnection.cpp bt-serial.c forwarder.cc | 7 | startpanconnection.cpp startdunconnection.cpp obexpush.cpp \ |
8 | bt-serial.c forwarder.cc | ||
9 | |||
7 | TARGET = opietooth1 | 10 | TARGET = opietooth1 |
8 | INCLUDEPATH += $(OPIEDIR)/include . | 11 | INCLUDEPATH += $(OPIEDIR)/include . |
9 | DESTDIR = $(OPIEDIR)/lib | 12 | DESTDIR = $(OPIEDIR)/lib |
10 | LIBS += -lopiecore2 | 13 | LIBS += -lopiecore2 |
11 | 14 | ||
12 | include( $(OPIEDIR)/include.pro ) | 15 | include( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/net/opietooth/lib/obexpush.cpp b/noncore/net/opietooth/lib/obexpush.cpp new file mode 100644 index 0000000..e0a4bee --- a/dev/null +++ b/noncore/net/opietooth/lib/obexpush.cpp | |||
@@ -0,0 +1,108 @@ | |||
1 | /* $Id$ */ | ||
2 | /* OBEX push functions implementation */ | ||
3 | /*************************************************************************** | ||
4 | * * | ||
5 | * This program is free software; you can redistribute it and/or modify * | ||
6 | * it under the terms of the GNU General Public License as published by * | ||
7 | * the Free Software Foundation; either version 2 of the License, or * | ||
8 | * (at your option) any later version. * | ||
9 | * * | ||
10 | ***************************************************************************/ | ||
11 | #include "obexpush.h" | ||
12 | |||
13 | #include <qfileinfo.h> | ||
14 | #include <qfile.h> | ||
15 | |||
16 | #include <opie2/odebug.h> | ||
17 | #include <opie2/odebug.h> | ||
18 | |||
19 | using namespace Opie::Core; | ||
20 | using namespace OpieTooth; | ||
21 | |||
22 | ObexPush::ObexPush() | ||
23 | { | ||
24 | pushProc = new OProcess(); | ||
25 | connect(pushProc, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
26 | this, SLOT(slotPushExited(Opie::Core::OProcess*))); | ||
27 | connect(pushProc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), | ||
28 | this, SLOT(slotPushOut(Opie::Core::OProcess*, char*, int))); | ||
29 | connect(pushProc, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)), | ||
30 | this, SLOT(slotPushErr(Opie::Core::OProcess*, char*, int))); | ||
31 | |||
32 | } | ||
33 | |||
34 | ObexPush::~ObexPush() | ||
35 | { | ||
36 | if (pushProc->isRunning()) | ||
37 | pushProc->kill(); | ||
38 | delete pushProc; | ||
39 | pushProc = NULL; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * Function that sends a file | ||
44 | * @param mac destination device MAC address | ||
45 | * @param port service port number | ||
46 | * @param src source file name | ||
47 | * @param dst destination file name | ||
48 | * @return 0 on success, -1 on error, 1 if sending process is running | ||
49 | */ | ||
50 | int ObexPush::send(QString& mac, int port, QString& src, QString& dst) | ||
51 | { | ||
52 | QString dev = mac; | ||
53 | QString execName = "ussp-push"; | ||
54 | if (pushProc->isRunning()) | ||
55 | return 1; | ||
56 | pushProc->clearArguments(); | ||
57 | dev += "@"; | ||
58 | dev += QString::number(port); | ||
59 | if (!dst.isEmpty()) | ||
60 | *pushProc << execName << "--timeo 30" << dev | ||
61 | << QFile::encodeName(src) << QFile::encodeName(dst); | ||
62 | else | ||
63 | *pushProc << execName << "--timeo 30" << dev | ||
64 | << QFile::encodeName(src) | ||
65 | << QFile::encodeName(QFileInfo(src).fileName()); | ||
66 | odebug << execName << " " << dev << " " << src << " " | ||
67 | << ((!dst.isEmpty())? dst: QFileInfo(src).fileName()) << oendl; | ||
68 | pushProc->setUseShell(true); | ||
69 | if (!pushProc->start(OProcess::NotifyOnExit, OProcess::All)) | ||
70 | return -1; | ||
71 | else | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | void ObexPush::slotPushExited(Opie::Core::OProcess* proc) | ||
76 | { | ||
77 | if (pushProc != proc) | ||
78 | return; | ||
79 | odebug << "Process exited" << oendl; | ||
80 | if (pushProc->normalExit()) | ||
81 | emit sendComplete(pushProc->exitStatus()); | ||
82 | else | ||
83 | emit sendError(-1); | ||
84 | } | ||
85 | |||
86 | /** | ||
87 | * Function makes a notification from slotPushOut and slotPushErr | ||
88 | */ | ||
89 | void ObexPush::notifyInfo(Opie::Core::OProcess* proc, char* buf, int len) | ||
90 | { | ||
91 | if (proc != pushProc) | ||
92 | return; | ||
93 | QCString str(buf, len); | ||
94 | odebug << str << oendl; | ||
95 | emit status(str); | ||
96 | } | ||
97 | |||
98 | void ObexPush::slotPushOut(Opie::Core::OProcess* proc, char* buf, int len) | ||
99 | { | ||
100 | notifyInfo(proc, buf, len); | ||
101 | } | ||
102 | |||
103 | void ObexPush::slotPushErr(Opie::Core::OProcess* proc, char* buf, int len) | ||
104 | { | ||
105 | notifyInfo(proc, buf, len); | ||
106 | } | ||
107 | |||
108 | //eof | ||
diff --git a/noncore/net/opietooth/lib/obexpush.h b/noncore/net/opietooth/lib/obexpush.h new file mode 100644 index 0000000..8147643 --- a/dev/null +++ b/noncore/net/opietooth/lib/obexpush.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* $Id$ */ | ||
2 | /* OBEX push functions declarations */ | ||
3 | /*************************************************************************** | ||
4 | * * | ||
5 | * This program is free software; you can redistribute it and/or modify * | ||
6 | * it under the terms of the GNU General Public License as published by * | ||
7 | * the Free Software Foundation; either version 2 of the License, or * | ||
8 | * (at your option) any later version. * | ||
9 | * * | ||
10 | ***************************************************************************/ | ||
11 | #ifndef _OBEXPUSH_H_ | ||
12 | #define _OBEXPUSH_H_ | ||
13 | #include <qobject.h> | ||
14 | #include <qstring.h> | ||
15 | #include "services.h" | ||
16 | #include <opie2/oprocess.h> | ||
17 | namespace OpieTooth { | ||
18 | class ObexPush : public QObject { | ||
19 | Q_OBJECT | ||
20 | public: | ||
21 | /** | ||
22 | * Constructor which creates an object | ||
23 | */ | ||
24 | ObexPush(); | ||
25 | |||
26 | /** | ||
27 | * Public destructor | ||
28 | */ | ||
29 | ~ObexPush(); | ||
30 | |||
31 | /** | ||
32 | * Function that sends a file | ||
33 | * @param mac destination device MAC address | ||
34 | * @param port service port number | ||
35 | * @param src source file name | ||
36 | * @param dst destination file name | ||
37 | * @return 0 on success, -1 on error, 1 if sending process is running | ||
38 | */ | ||
39 | int send(QString& mac, int port, QString& src, QString& dst); | ||
40 | |||
41 | /** | ||
42 | * @return true if it's sending and false otherwise | ||
43 | */ | ||
44 | bool isSending() { return pushProc->isRunning(); } | ||
45 | signals: | ||
46 | /** | ||
47 | * Informs that the sending process has completed | ||
48 | * @param status the finish status | ||
49 | */ | ||
50 | void sendComplete(int); | ||
51 | |||
52 | /** | ||
53 | * Informs that the sending process has finished with error | ||
54 | * @param status the finish status | ||
55 | */ | ||
56 | void sendError(int); | ||
57 | |||
58 | /** | ||
59 | * Informs that we have a string status update | ||
60 | * @param str status string | ||
61 | */ | ||
62 | void status(QCString&); | ||
63 | protected slots: | ||
64 | void slotPushOut(Opie::Core::OProcess*, char*, int); | ||
65 | void slotPushErr(Opie::Core::OProcess*, char*, int); | ||
66 | void slotPushExited(Opie::Core::OProcess* proc); | ||
67 | protected: | ||
68 | /** | ||
69 | * Function makes a notification from slotPushOut and slotPushErr | ||
70 | */ | ||
71 | void notifyInfo(Opie::Core::OProcess*, char*, int); | ||
72 | protected: | ||
73 | Opie::Core::OProcess* pushProc; //The push process | ||
74 | }; | ||
75 | }; | ||
76 | #endif | ||
77 | //eof | ||
diff --git a/noncore/net/opietooth/manager/obexdialog.cpp b/noncore/net/opietooth/manager/obexdialog.cpp index 8d7b593..4b795b7 100644 --- a/noncore/net/opietooth/manager/obexdialog.cpp +++ b/noncore/net/opietooth/manager/obexdialog.cpp | |||
@@ -17,23 +17,25 @@ using namespace Opie::Core; | |||
17 | 17 | ||
18 | using namespace OpieTooth; | 18 | using namespace OpieTooth; |
19 | 19 | ||
20 | using namespace Opie::Core; | 20 | using namespace Opie::Core; |
21 | using namespace Opie::Ui; | 21 | using namespace Opie::Ui; |
22 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
23 | ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name, bool modal, WFlags fl) | 23 | ObexDialog::ObexDialog(const QString& device, int port, |
24 | QWidget* parent, const char* name, bool modal, WFlags fl) | ||
24 | : QDialog( parent, name, modal, fl ) { | 25 | : QDialog( parent, name, modal, fl ) { |
25 | 26 | ||
26 | if ( !name ) | 27 | if ( !name ) |
27 | setName( "ObexDialog" ); | 28 | setName( "ObexDialog" ); |
28 | setCaption( tr( "beam files " ) ) ; | 29 | setCaption( tr( "beam files " ) ) ; |
29 | 30 | ||
30 | m_device = device; | 31 | m_device = device; |
32 | m_port = port; | ||
31 | 33 | ||
32 | layout = new QVBoxLayout( this ); | 34 | layout = new QVBoxLayout( this ); |
33 | obexSend = new OProcess(); | 35 | obexSend = new ObexPush(); |
34 | 36 | ||
35 | info = new QLabel( this ); | 37 | info = new QLabel( this ); |
36 | info->setText( tr("Which file should be beamed?") ); | 38 | info->setText( tr("Which file should be beamed?") ); |
37 | 39 | ||
38 | statLine = new QLabel(this); | 40 | statLine = new QLabel(this); |
39 | statLine->setText( tr("Ready") ); | 41 | statLine->setText( tr("Ready") ); |
@@ -59,24 +61,22 @@ ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name | |||
59 | layout->addWidget(chNameLine); | 61 | layout->addWidget(chNameLine); |
60 | layout->addWidget(sendButton); | 62 | layout->addWidget(sendButton); |
61 | layout->addWidget(statLine); | 63 | layout->addWidget(statLine); |
62 | 64 | ||
63 | connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) ); | 65 | connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) ); |
64 | 66 | ||
65 | connect(obexSend, SIGNAL(processExited(Opie::Core::OProcess*)), | 67 | connect(obexSend, SIGNAL(sendComplete(int)), |
66 | this, SLOT(slotProcessExited(Opie::Core::OProcess*))); | 68 | this, SLOT(slotPushComplete(int))); |
67 | connect(obexSend, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), | 69 | connect(obexSend, SIGNAL(sendError(int)), |
68 | this, SLOT(slotPushOut(Opie::Core::OProcess*, char*, int))); | 70 | this, SLOT(slotPushError(int))); |
69 | connect(obexSend, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)), | 71 | connect(obexSend, SIGNAL(status(QCString&)), |
70 | this, SLOT(slotPushErr(Opie::Core::OProcess*, char*, int))); | 72 | this, SLOT(slotPushStatus(QCString&))); |
71 | 73 | ||
72 | } | 74 | } |
73 | 75 | ||
74 | ObexDialog::~ObexDialog() { | 76 | ObexDialog::~ObexDialog() { |
75 | if (obexSend->isRunning()) | ||
76 | obexSend->kill(); | ||
77 | delete obexSend; | 77 | delete obexSend; |
78 | obexSend = NULL; | 78 | obexSend = NULL; |
79 | } | 79 | } |
80 | 80 | ||
81 | void ObexDialog::browse() { | 81 | void ObexDialog::browse() { |
82 | 82 | ||
@@ -88,53 +88,35 @@ void ObexDialog::browse() { | |||
88 | QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); | 88 | QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); |
89 | cmdLine->setText( str ); | 89 | cmdLine->setText( str ); |
90 | statLine->setText( tr("Ready") ); | 90 | statLine->setText( tr("Ready") ); |
91 | } | 91 | } |
92 | 92 | ||
93 | void ObexDialog::sendData() { | 93 | void ObexDialog::sendData() { |
94 | int result; //function call result | ||
94 | QString fileURL = cmdLine->text(); | 95 | QString fileURL = cmdLine->text(); |
95 | QString file = QFileInfo( fileURL ).fileName(); | ||
96 | QString modifiedName = chNameLine->text(); | 96 | QString modifiedName = chNameLine->text(); |
97 | QString execName = "ussp-push"; | 97 | result = obexSend->send(m_device, m_port, fileURL, modifiedName); |
98 | 98 | if (result > 0) | |
99 | if (obexSend->isRunning()) | ||
100 | return; | 99 | return; |
101 | obexSend->clearArguments(); | 100 | else if (result < 0) |
102 | // vom popupmenu beziehen | ||
103 | if ( !modifiedName.isEmpty() ) { | ||
104 | *obexSend << execName << "--timeo 30" << m_device << fileURL << modifiedName; | ||
105 | } else { | ||
106 | *obexSend << execName << "--timeo 30" << m_device << fileURL << file; | ||
107 | } | ||
108 | obexSend->setUseShell(true); | ||
109 | if (!obexSend->start(OProcess::NotifyOnExit, OProcess::All) ) { | ||
110 | statLine->setText( tr("Error: couln't start process") ); | 101 | statLine->setText( tr("Error: couln't start process") ); |
111 | } | ||
112 | else | 102 | else |
113 | statLine->setText( tr("Sending") ); | 103 | statLine->setText( tr("Sending") ); |
114 | } | 104 | } |
115 | 105 | ||
116 | void ObexDialog::slotPushOut(OProcess*, char* buf, int len) { | 106 | void ObexDialog::slotPushStatus(QCString& str) { |
117 | QCString str(buf, len); | ||
118 | status->append(str); | 107 | status->append(str); |
119 | } | 108 | } |
120 | 109 | ||
121 | void ObexDialog::slotPushErr(OProcess*, char* buf, int len) { | 110 | void ObexDialog::slotPushComplete(int result) { |
122 | QCString str(buf, len); | ||
123 | status->append(str); | ||
124 | } | ||
125 | |||
126 | void ObexDialog::slotProcessExited(OProcess*) { | ||
127 | if (obexSend == NULL) | ||
128 | return; | ||
129 | if (obexSend->normalExit()) { | ||
130 | status->append( tr("Finished with result ") ); | 111 | status->append( tr("Finished with result ") ); |
131 | status->append( QString::number(obexSend->exitStatus()) ); | 112 | status->append( QString::number(result) ); |
132 | status->append( tr("\n") ); | 113 | status->append( tr("\n") ); |
133 | odebug << obexSend->exitStatus() << oendl; | 114 | odebug << result << oendl; |
134 | statLine->setText( tr("Finished: ") + tr(strerror(obexSend->exitStatus())) ); | 115 | statLine->setText( tr("Finished: ") + tr(strerror(result)) ); |
135 | } | 116 | } |
136 | else { | 117 | |
118 | void ObexDialog::slotPushError(int) { | ||
137 | status->append( tr("Exited abnormally\n") ); | 119 | status->append( tr("Exited abnormally\n") ); |
138 | statLine->setText( tr("Exited abnormally") ); | 120 | statLine->setText( tr("Exited abnormally") ); |
139 | } | 121 | } |
140 | } | 122 | //eof |
diff --git a/noncore/net/opietooth/manager/obexdialog.h b/noncore/net/opietooth/manager/obexdialog.h index 44a26f3..063b7f1 100644 --- a/noncore/net/opietooth/manager/obexdialog.h +++ b/noncore/net/opietooth/manager/obexdialog.h | |||
@@ -1,14 +1,14 @@ | |||
1 | #ifndef OBEXDIALOG_H | 1 | #ifndef OBEXDIALOG_H |
2 | #define OBEXDIALOG_H | 2 | #define OBEXDIALOG_H |
3 | 3 | ||
4 | 4 | ||
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | #include <opie2/oprocess.h> | ||
7 | #include <qlabel.h> | 6 | #include <qlabel.h> |
8 | #include <qmultilineedit.h> | 7 | #include <qmultilineedit.h> |
8 | #include "obexpush.h" | ||
9 | 9 | ||
10 | class QVBoxLayout; | 10 | class QVBoxLayout; |
11 | class QPushButton; | 11 | class QPushButton; |
12 | class QMultiLineEdit; | 12 | class QMultiLineEdit; |
13 | class QLineEdit; | 13 | class QLineEdit; |
14 | 14 | ||
@@ -17,32 +17,35 @@ namespace OpieTooth { | |||
17 | 17 | ||
18 | class ObexDialog : public QDialog { | 18 | class ObexDialog : public QDialog { |
19 | 19 | ||
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | 21 | ||
22 | public: | 22 | public: |
23 | ObexDialog( const QString& device = 0, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0); | 23 | ObexDialog( const QString& device = 0, int port = 0, |
24 | QWidget* parent = 0, const char* name = 0, | ||
25 | bool modal = TRUE, WFlags fl = 0); | ||
24 | ~ObexDialog(); | 26 | ~ObexDialog(); |
25 | 27 | ||
26 | 28 | ||
27 | private slots: | 29 | private slots: |
28 | void browse(); | 30 | void browse(); |
29 | void sendData(); | 31 | void sendData(); |
30 | void slotPushOut(Opie::Core::OProcess*, char*, int); | 32 | void slotPushStatus(QCString&); |
31 | void slotPushErr(Opie::Core::OProcess*, char*, int); | 33 | void slotPushComplete(int); |
32 | void slotProcessExited(Opie::Core::OProcess* proc); | 34 | void slotPushError(int); |
33 | 35 | ||
34 | protected: | 36 | protected: |
35 | QVBoxLayout* layout; | 37 | QVBoxLayout* layout; |
36 | QLineEdit* cmdLine; | 38 | QLineEdit* cmdLine; |
37 | QLineEdit* chNameLine; | 39 | QLineEdit* chNameLine; |
38 | QPushButton* sendButton; | 40 | QPushButton* sendButton; |
39 | QLabel* info; | 41 | QLabel* info; |
40 | QMultiLineEdit* status; | 42 | QMultiLineEdit* status; |
41 | QLabel* statLine; | 43 | QLabel* statLine; |
42 | private: | 44 | private: |
43 | // Device that is used | 45 | // Device that is used |
44 | QString m_device; | 46 | QString m_device; |
45 | Opie::Core::OProcess *obexSend; | 47 | int m_port; //Port used |
48 | ObexPush* obexSend; | ||
46 | }; | 49 | }; |
47 | } | 50 | } |
48 | #endif | 51 | #endif |
diff --git a/noncore/net/opietooth/manager/obexftpdialog.cpp b/noncore/net/opietooth/manager/obexftpdialog.cpp index efb3ff2..2a578ac 100644 --- a/noncore/net/opietooth/manager/obexftpdialog.cpp +++ b/noncore/net/opietooth/manager/obexftpdialog.cpp | |||
@@ -240,13 +240,13 @@ void ObexFtpDialog::slotCd(QListViewItem* item) | |||
240 | else { | 240 | else { |
241 | if (curdir != "" && curdir.right(1) != "/") | 241 | if (curdir != "" && curdir.right(1) != "/") |
242 | curdir += "/"; | 242 | curdir += "/"; |
243 | curdir += file->text(0); | 243 | curdir += file->text(0); |
244 | } | 244 | } |
245 | odebug << "Browse " << curdir << oendl; | 245 | odebug << "Browse " << curdir << oendl; |
246 | if (obexftp_setpath(client, curdir, 0) < 0) | 246 | if (obexftp_setpath(client, QFile::encodeName(curdir), 0) < 0) |
247 | log(tr("CD failed: ") + tr(strerror(errno))); | 247 | log(tr("CD failed: ") + tr(strerror(errno))); |
248 | doBrowse(); | 248 | doBrowse(); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | /* | 252 | /* |
diff --git a/noncore/net/opietooth/manager/obexpopup.cpp b/noncore/net/opietooth/manager/obexpopup.cpp index d1d1b4a..759a452 100644 --- a/noncore/net/opietooth/manager/obexpopup.cpp +++ b/noncore/net/opietooth/manager/obexpopup.cpp | |||
@@ -15,13 +15,13 @@ using namespace OpieTooth; | |||
15 | /* | 15 | /* |
16 | * c'tor init the QAction | 16 | * c'tor init the QAction |
17 | */ | 17 | */ |
18 | ObexPopup::ObexPopup(const OpieTooth::Services& service, OpieTooth::BTDeviceItem* item) | 18 | ObexPopup::ObexPopup(const OpieTooth::Services& service, OpieTooth::BTDeviceItem* item) |
19 | : QPopupMenu(), m_service(service) | 19 | : QPopupMenu(), m_service(service) |
20 | { | 20 | { |
21 | owarn << "ObexPopup c'tor" << oendl; | 21 | odebug << "ObexPopup c'tor" << oendl; |
22 | 22 | ||
23 | m_item = item; | 23 | m_item = item; |
24 | /* connect action */ | 24 | /* connect action */ |
25 | m_push = new QAction( ); // so it's get deleted | 25 | m_push = new QAction( ); // so it's get deleted |
26 | m_push->setText("Push file"); | 26 | m_push->setText("Push file"); |
27 | m_push->addTo( this ); | 27 | m_push->addTo( this ); |
@@ -36,14 +36,12 @@ ObexPopup::~ObexPopup() | |||
36 | 36 | ||
37 | 37 | ||
38 | void ObexPopup::slotPush() | 38 | void ObexPopup::slotPush() |
39 | { | 39 | { |
40 | QString device = m_item->mac(); | 40 | QString device = m_item->mac(); |
41 | int port = m_service.protocolDescriptorList().last().port(); | 41 | int port = m_service.protocolDescriptorList().last().port(); |
42 | device += "@"; | 42 | odebug << "push something to " << device << " " << port << oendl; |
43 | device += QString::number(port); | 43 | ObexDialog obexDialog(device, port); |
44 | owarn << "push something to " << device << oendl; | ||
45 | ObexDialog obexDialog(device); | ||
46 | QPEApplication::execDialog( &obexDialog ); | 44 | QPEApplication::execDialog( &obexDialog ); |
47 | } | 45 | } |
48 | 46 | ||
49 | 47 | ||