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/manager | |
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/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 |
4 files changed, 35 insertions, 52 deletions
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 | |||
@@ -1,140 +1,122 @@ | |||
1 | 1 | ||
2 | #include "obexdialog.h" | 2 | #include "obexdialog.h" |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
5 | #include <qmultilineedit.h> | 5 | #include <qmultilineedit.h> |
6 | #include <qlineedit.h> | 6 | #include <qlineedit.h> |
7 | #include <qlayout.h> | 7 | #include <qlayout.h> |
8 | #include <qlabel.h> | 8 | #include <qlabel.h> |
9 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
10 | 10 | ||
11 | #include <qpe/resource.h> | 11 | #include <qpe/resource.h> |
12 | 12 | ||
13 | #include <opie2/oprocess.h> | 13 | #include <opie2/oprocess.h> |
14 | #include <opie2/ofiledialog.h> | 14 | #include <opie2/ofiledialog.h> |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | using namespace Opie::Core; | 16 | 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") ); |
40 | 42 | ||
41 | status = new QMultiLineEdit(this); | 43 | status = new QMultiLineEdit(this); |
42 | status->setReadOnly(true); | 44 | status->setReadOnly(true); |
43 | 45 | ||
44 | cmdLine = new QLineEdit( this ); | 46 | cmdLine = new QLineEdit( this ); |
45 | 47 | ||
46 | QPushButton *browserButton; | 48 | QPushButton *browserButton; |
47 | browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); | 49 | browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); |
48 | connect( browserButton, SIGNAL(released() ), this , SLOT(browse() ) ); | 50 | connect( browserButton, SIGNAL(released() ), this , SLOT(browse() ) ); |
49 | 51 | ||
50 | chNameLine = new QLineEdit( this ); | 52 | chNameLine = new QLineEdit( this ); |
51 | 53 | ||
52 | sendButton = new QPushButton( this ); | 54 | sendButton = new QPushButton( this ); |
53 | sendButton->setText( tr( "Send" ) ); | 55 | sendButton->setText( tr( "Send" ) ); |
54 | 56 | ||
55 | layout->addWidget(info); | 57 | layout->addWidget(info); |
56 | layout->addWidget(status); | 58 | layout->addWidget(status); |
57 | layout->addWidget(cmdLine); | 59 | layout->addWidget(cmdLine); |
58 | layout->addWidget(browserButton); | 60 | layout->addWidget(browserButton); |
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 | ||
83 | MimeTypes types; | 83 | MimeTypes types; |
84 | QStringList all; | 84 | QStringList all; |
85 | all << "*/*"; | 85 | all << "*/*"; |
86 | types.insert("All Files", all ); | 86 | types.insert("All Files", all ); |
87 | 87 | ||
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,48 +1,51 @@ | |||
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 | ||
15 | namespace Opie {namespace Core {class OProcess;}} | 15 | namespace Opie {namespace Core {class OProcess;}} |
16 | namespace OpieTooth { | 16 | 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 | |||
@@ -222,49 +222,49 @@ void ObexFtpDialog::status(const char* msg) | |||
222 | */ | 222 | */ |
223 | void ObexFtpDialog::slotCd(QListViewItem* item) | 223 | void ObexFtpDialog::slotCd(QListViewItem* item) |
224 | { | 224 | { |
225 | FileListItem* file = (FileListItem*)item; | 225 | FileListItem* file = (FileListItem*)item; |
226 | int idx; | 226 | int idx; |
227 | if (file == NULL) | 227 | if (file == NULL) |
228 | return; | 228 | return; |
229 | odebug << "Item " << file->text(0) << " clicked" << oendl; | 229 | odebug << "Item " << file->text(0) << " clicked" << oendl; |
230 | if (file->gettype() == IS_DIR) { | 230 | if (file->gettype() == IS_DIR) { |
231 | if (file->text(0) == "../") { | 231 | if (file->text(0) == "../") { |
232 | if (curdir.right(1) == "/") | 232 | if (curdir.right(1) == "/") |
233 | curdir.remove(curdir.length() - 1, 1); | 233 | curdir.remove(curdir.length() - 1, 1); |
234 | idx = curdir.findRev('/'); | 234 | idx = curdir.findRev('/'); |
235 | if (idx >= 0) | 235 | if (idx >= 0) |
236 | curdir.remove(idx, curdir.length() - idx); | 236 | curdir.remove(idx, curdir.length() - idx); |
237 | else | 237 | else |
238 | curdir = ""; | 238 | curdir = ""; |
239 | } | 239 | } |
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 | /* |
253 | * Copy file from a remote device to the local device | 253 | * Copy file from a remote device to the local device |
254 | */ | 254 | */ |
255 | void ObexFtpDialog::getFile() | 255 | void ObexFtpDialog::getFile() |
256 | { | 256 | { |
257 | FileListItem* file = (FileListItem*)fileList->selectedItem(); | 257 | FileListItem* file = (FileListItem*)fileList->selectedItem(); |
258 | int result; | 258 | int result; |
259 | if (file == NULL) | 259 | if (file == NULL) |
260 | return; | 260 | return; |
261 | file2get = "/"; | 261 | file2get = "/"; |
262 | local = localCurdir; | 262 | local = localCurdir; |
263 | if (local == "") { | 263 | if (local == "") { |
264 | errBox("Select a destination first"); | 264 | errBox("Select a destination first"); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | if (local.right(1) != "/") | 267 | if (local.right(1) != "/") |
268 | local += "/"; | 268 | local += "/"; |
269 | if (file->gettype() == IS_FILE) { | 269 | if (file->gettype() == IS_FILE) { |
270 | if (client == NULL) { | 270 | if (client == NULL) { |
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 | |||
@@ -1,49 +1,47 @@ | |||
1 | 1 | ||
2 | #include "obexdialog.h" | 2 | #include "obexdialog.h" |
3 | #include "obexpopup.h" | 3 | #include "obexpopup.h" |
4 | 4 | ||
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | using namespace Opie::Core; | 8 | using namespace Opie::Core; |
9 | 9 | ||
10 | /* QT */ | 10 | /* QT */ |
11 | #include <qtimer.h> | 11 | #include <qtimer.h> |
12 | 12 | ||
13 | using namespace OpieTooth; | 13 | using namespace OpieTooth; |
14 | 14 | ||
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 ); |
28 | connect(m_push, SIGNAL(activated()), SLOT(slotPush())); | 28 | connect(m_push, SIGNAL(activated()), SLOT(slotPush())); |
29 | } | 29 | } |
30 | 30 | ||
31 | 31 | ||
32 | ObexPopup::~ObexPopup() | 32 | ObexPopup::~ObexPopup() |
33 | { | 33 | { |
34 | delete m_push; | 34 | delete m_push; |
35 | } | 35 | } |
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 | ||