Diffstat (limited to 'noncore/net/opietooth/manager/obexftpdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/obexftpdialog.cpp | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/noncore/net/opietooth/manager/obexftpdialog.cpp b/noncore/net/opietooth/manager/obexftpdialog.cpp index f479ca2..fd2015e 100644 --- a/noncore/net/opietooth/manager/obexftpdialog.cpp +++ b/noncore/net/opietooth/manager/obexftpdialog.cpp @@ -87,12 +87,15 @@ ObexFtpDialog::ObexFtpDialog(const QString& device, int port, connect(getButton, SIGNAL(clicked()), SLOT(getFile())); connect(putButton, SIGNAL(clicked()), SLOT(putFile())); + connect(delButton, + SIGNAL(clicked()), + SLOT(delFile())); connect(destFile, SIGNAL(dirSelected (const QString&)), SLOT(updateDir(const QString&))); connect(saveButton, SIGNAL(clicked()), SLOT(slotSaveLog())); @@ -239,13 +242,13 @@ void ObexFtpDialog::slotCd(QListViewItem* item) log(tr("CD failed: ") + tr(strerror(errno))); slotBrowse(); } } /* - * Get the file + * Copy file from a remote device to the local device */ void ObexFtpDialog::getFile() { FileListItem* file = (FileListItem*)fileList->selectedItem(); int result; if (file == NULL) @@ -272,26 +275,26 @@ void ObexFtpDialog::getFile() progressStatus = 0; fileProgress->setTotalSteps(file->getsize() / 1024); fileProgress->reset(); status(tr("Receiving file ") + file2get); result = obexftp_get(client, local, file2get); if (result < 0) { - log(file2get + QString(" receive ERROR: ") + tr(strerror(errno))); + log(file2get + QString(" receive ERROR:\n") + tr(strerror(errno))); errBox(file2get + QString(" receive ERROR")); status(file2get + QString(" receive ERROR")); } else { log(file2get + QString(" received")); status(file2get + QString(" received")); destFile->reread(); } } } /* - * Put the file + * Copy file from the local device to a remote device */ void ObexFtpDialog::putFile() { int result; //OPeration result int idx; //Index of a symbol in the string struct stat localFStat; //Local file information @@ -322,22 +325,61 @@ void ObexFtpDialog::putFile() progressStatus = 0; fileProgress->setTotalSteps(localFStat.st_size / 1024); fileProgress->reset(); status(tr("Sending file ") + local); result = obexftp_put_file(client, local, file2get); if (result < 0) { - log(local + QString(" send ERROR: ") + tr(strerror(errno))); + log(local + QString(" send ERROR:\n") + tr(strerror(errno))); errBox(local + QString(" send ERROR")); status(local + QString(" send ERROR")); } else { + slotBrowse(); log(local + QString(" sent")); status(local + QString(" sent")); } } +/* + * Delete file on a remote device + */ +void ObexFtpDialog::delFile() +{ + FileListItem* file = (FileListItem*)fileList->selectedItem(); + int result; + if (file == NULL) + return; + file2get = "/"; + if (file->gettype() == IS_FILE) { + if (client == NULL) { + errBox("No connection established"); + return; + } + file2get += curdir; + if (curdir != "" && curdir.right(1) != "/") + file2get += "/"; + file2get += file->text(0); + } + result = QMessageBox::warning(this, tr("Remove File"), + tr("Do you want to remove\n") + file2get, "Yes", "No"); + if (result != 0) + return; + odebug << "Remove " << file2get << oendl; + result = obexftp_del(client, file2get); + if (result < 0) { + log(file2get + QString(" remove ERROR\n") + tr(strerror(errno))); + errBox(file2get + QString(" remove ERROR")); + status(file2get + QString(" remove ERROR")); + } + else { + slotBrowse(); + log(file2get + QString(" removed")); + status(file2get + QString(" removed")); + } +} + /* connect with given uuid. re-connect every time */ int ObexFtpDialog::cli_connect_uuid(const uint8_t *uuid, int uuid_len) { int retry; if (client != NULL) return TRUE; |