Diffstat (limited to 'noncore/net/opietooth/manager/obexftpdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/obexftpdialog.cpp | 99 |
1 files changed, 88 insertions, 11 deletions
diff --git a/noncore/net/opietooth/manager/obexftpdialog.cpp b/noncore/net/opietooth/manager/obexftpdialog.cpp index c77d49d..80a81b4 100644 --- a/noncore/net/opietooth/manager/obexftpdialog.cpp +++ b/noncore/net/opietooth/manager/obexftpdialog.cpp | |||
@@ -14,2 +14,6 @@ | |||
14 | #include <sys/stat.h> | 14 | #include <sys/stat.h> |
15 | #include <sys/types.h> | ||
16 | #include <unistd.h> | ||
17 | #include <string.h> | ||
18 | #include <errno.h> | ||
15 | #include <qpushbutton.h> | 19 | #include <qpushbutton.h> |
@@ -17,2 +21,4 @@ | |||
17 | #include <qmultilineedit.h> | 21 | #include <qmultilineedit.h> |
22 | #include <qspinbox.h> | ||
23 | #include <qcombobox.h> | ||
18 | #include <qlistview.h> | 24 | #include <qlistview.h> |
@@ -51,2 +57,3 @@ ObexFtpDialog::ObexFtpDialog(const QString& device, int port, | |||
51 | client = NULL; | 57 | client = NULL; |
58 | nRetries = 3; | ||
52 | transport = OBEX_TRANS_BLUETOOTH; | 59 | transport = OBEX_TRANS_BLUETOOTH; |
@@ -70,2 +77,3 @@ ObexFtpDialog::ObexFtpDialog(const QString& device, int port, | |||
70 | localLayout->addWidget(destFile); | 77 | localLayout->addWidget(destFile); |
78 | nReries->setValue(nRetries); | ||
71 | connect(browseOK, SIGNAL(clicked()), SLOT(slotBrowse())); | 79 | connect(browseOK, SIGNAL(clicked()), SLOT(slotBrowse())); |
@@ -76,2 +84,5 @@ ObexFtpDialog::ObexFtpDialog(const QString& device, int port, | |||
76 | SLOT(getFile())); | 84 | SLOT(getFile())); |
85 | connect(putButton, | ||
86 | SIGNAL(clicked()), | ||
87 | SLOT(putFile())); | ||
77 | connect(destFile, | 88 | connect(destFile, |
@@ -96,7 +107,8 @@ void ObexFtpDialog::slotBrowse() | |||
96 | void *dir; //Directory to read | 107 | void *dir; //Directory to read |
97 | const uint8_t use_uuid[] = __UUID_FBS_bytes; | 108 | const uint8_t* use_uuid; //uuid |
98 | int len = sizeof(UUID_FBS); | 109 | int len; //uuid length |
99 | FileListItem* root; //root node | 110 | FileListItem* root; //root node |
100 | stat_entry_t* st; //File statistics | ||
101 | int fsize; //file size | 111 | int fsize; //file size |
112 | bool numOk; //true if the string is a number | ||
113 | int tmp; //just a temp var | ||
102 | 114 | ||
@@ -107,3 +119,20 @@ void ObexFtpDialog::slotBrowse() | |||
107 | progressStatus = 0; | 119 | progressStatus = 0; |
120 | fileProgress->setTotalSteps(MAX_PROGRESS); | ||
108 | fileProgress->reset(); | 121 | fileProgress->reset(); |
122 | |||
123 | //Get parameters | ||
124 | tmp = nReries->text().toInt(&numOk); | ||
125 | if (numOk) | ||
126 | nRetries = tmp; | ||
127 | if (uuidType->currentText() == "FBS") { | ||
128 | use_uuid = UUID_FBS; | ||
129 | len = sizeof(UUID_FBS); | ||
130 | } else if (uuidType->currentText() == "S45") { | ||
131 | use_uuid = UUID_S45; | ||
132 | len = sizeof(UUID_S45); | ||
133 | } else { | ||
134 | use_uuid = UUID_FBS; | ||
135 | len = sizeof(UUID_FBS); | ||
136 | } | ||
137 | |||
109 | if (!cli_connect_uuid(use_uuid, len)) { | 138 | if (!cli_connect_uuid(use_uuid, len)) { |
@@ -123,9 +152,6 @@ void ObexFtpDialog::slotBrowse() | |||
123 | FileListItem* a; //List view item | 152 | FileListItem* a; //List view item |
124 | #if 0 //Causes sigsegv | ||
125 | if (ent->mode != 16877) { | 153 | if (ent->mode != 16877) { |
126 | st = obexftp_stat(client, ent->name); | 154 | fsize = ent->size; |
127 | fsize = st->size; | ||
128 | } | 155 | } |
129 | else | 156 | else |
130 | #endif | ||
131 | fsize = 0; | 157 | fsize = 0; |
@@ -224,2 +250,6 @@ void ObexFtpDialog::getFile() | |||
224 | if (file->gettype() == IS_FILE) { | 250 | if (file->gettype() == IS_FILE) { |
251 | if (client == NULL) { | ||
252 | errBox("No connection established"); | ||
253 | return; | ||
254 | } | ||
225 | file2get += curdir; | 255 | file2get += curdir; |
@@ -231,2 +261,3 @@ void ObexFtpDialog::getFile() | |||
231 | progressStatus = 0; | 261 | progressStatus = 0; |
262 | fileProgress->setTotalSteps(file->getsize() / 1024); | ||
232 | fileProgress->reset(); | 263 | fileProgress->reset(); |
@@ -247,2 +278,50 @@ void ObexFtpDialog::getFile() | |||
247 | 278 | ||
279 | /* | ||
280 | * Put the file | ||
281 | */ | ||
282 | void ObexFtpDialog::putFile() | ||
283 | { | ||
284 | int result; //OPeration result | ||
285 | int idx; //Index of a symbol in the string | ||
286 | struct stat localFStat; //Local file information | ||
287 | |||
288 | if (client == NULL) { | ||
289 | errBox("No connection established"); | ||
290 | return; | ||
291 | } | ||
292 | local = destFile->selectedName(); | ||
293 | if (local == "") { | ||
294 | errBox("No file slected"); | ||
295 | return; | ||
296 | } | ||
297 | result = stat(local, &localFStat); | ||
298 | if (result < 0) { | ||
299 | errBox(tr("Wrong file selected ") + local + tr(" ") + | ||
300 | tr(strerror(errno))); | ||
301 | return; | ||
302 | } | ||
303 | idx = local.findRev('/'); | ||
304 | if (idx > 0) { | ||
305 | file2get = local.right(local.length() - idx - 1); | ||
306 | } | ||
307 | else | ||
308 | file2get = local; | ||
309 | |||
310 | odebug << "Copy " << local << " to " << file2get << oendl; | ||
311 | progressStatus = 0; | ||
312 | fileProgress->setTotalSteps(localFStat.st_size / 1024); | ||
313 | fileProgress->reset(); | ||
314 | status(tr("Sending file ") + local); | ||
315 | result = obexftp_put_file(client, local, file2get); | ||
316 | if (result < 0) { | ||
317 | log(local + QString(" send ERROR")); | ||
318 | errBox(local + QString(" send ERROR")); | ||
319 | status(local + QString(" send ERROR")); | ||
320 | } | ||
321 | else { | ||
322 | log(local + QString(" sent")); | ||
323 | status(local + QString(" sent")); | ||
324 | } | ||
325 | } | ||
326 | |||
248 | /* connect with given uuid. re-connect every time */ | 327 | /* connect with given uuid. re-connect every time */ |
@@ -263,3 +342,3 @@ int ObexFtpDialog::cli_connect_uuid(const uint8_t *uuid, int uuid_len) | |||
263 | client->quirks &= ~OBEXFTP_SPLIT_SETPATH; | 342 | client->quirks &= ~OBEXFTP_SPLIT_SETPATH; |
264 | for (retry = 0; retry < 3; retry++) { | 343 | for (retry = 0; retry < nRetries; retry++) { |
265 | /* Connect */ | 344 | /* Connect */ |
@@ -311,7 +390,5 @@ void ObexFtpDialog::incProgress() | |||
311 | { | 390 | { |
312 | odebug << "Progress " << progressStatus << oendl; | 391 | if (progressStatus < fileProgress->totalSteps()) |
313 | if (progressStatus < MAX_PROGRESS) { | ||
314 | fileProgress->setProgress(progressStatus++); | 392 | fileProgress->setProgress(progressStatus++); |
315 | } | 393 | } |
316 | } | ||
317 | 394 | ||