summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/obexftpdialog.cpp50
-rw-r--r--noncore/net/opietooth/manager/obexftpdialog.h1
-rw-r--r--noncore/net/opietooth/manager/obexftpdialogbase.ui63
3 files changed, 84 insertions, 30 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
@@ -81,24 +81,27 @@ ObexFtpDialog::ObexFtpDialog(const QString& device, int port,
destFile->setNewVisible(false);
localLayout->addWidget(destFile);
nReries->setValue(nRetries);
connect(browseOK, SIGNAL(clicked()), SLOT(slotBrowse()));
connect(fileList, SIGNAL(clicked(QListViewItem*)),
SLOT(slotCd(QListViewItem*)));
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()));
connect(browseButton,
SIGNAL(clicked()),
SLOT(slotBrowseLog()));
}
ObexFtpDialog::~ObexFtpDialog()
@@ -233,25 +236,25 @@ void ObexFtpDialog::slotCd(QListViewItem* item)
if (curdir != "" && curdir.right(1) != "/")
curdir += "/";
curdir += file->text(0);
}
odebug << "Browse " << curdir << oendl;
if (obexftp_setpath(client, curdir, 0) < 0)
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)
return;
file2get = "/";
local = localCurdir;
if (local == "") {
errBox("Select a destination first");
return;
@@ -266,38 +269,38 @@ void ObexFtpDialog::getFile()
file2get += curdir;
if (curdir != "" && curdir.right(1) != "/")
file2get += "/";
file2get += file->text(0);
local += file->text(0);
odebug << "Copy " << file2get << " to " << local << oendl;
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
if (client == NULL) {
errBox("No connection established");
return;
}
local = destFile->selectedName();
@@ -316,34 +319,73 @@ void ObexFtpDialog::putFile()
file2get = local.right(local.length() - idx - 1);
}
else
file2get = local;
odebug << "Copy " << local << " to " << file2get << oendl;
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;
/* Open */
client = obexftp_open (transport, NULL, info_cb, this);
if(client == NULL) {
errBox("Error opening obexftp-client");
return FALSE;
}
diff --git a/noncore/net/opietooth/manager/obexftpdialog.h b/noncore/net/opietooth/manager/obexftpdialog.h
index 81c8921..75ee95b 100644
--- a/noncore/net/opietooth/manager/obexftpdialog.h
+++ b/noncore/net/opietooth/manager/obexftpdialog.h
@@ -53,18 +53,19 @@ namespace OpieTooth {
QString localCurdir; //Local current directory
QString file2get; //Remote file name
QString local; //Local file name
int progressStatus; //Progress status
Opie::Ui::OFileSelector* destFile; //Destination file or directory
QVBoxLayout* localLayout; //Window layout
int nRetries; //Number of retries (on connection)
private slots:
void slotBrowse();
void slotCd(QListViewItem* item);
void getFile();
void putFile();
+ void delFile();
void updateDir(const QString& newdir);
void slotSaveLog();
void slotBrowseLog();
};
};
#endif
diff --git a/noncore/net/opietooth/manager/obexftpdialogbase.ui b/noncore/net/opietooth/manager/obexftpdialogbase.ui
index 2447007..83078d5 100644
--- a/noncore/net/opietooth/manager/obexftpdialogbase.ui
+++ b/noncore/net/opietooth/manager/obexftpdialogbase.ui
@@ -2,25 +2,25 @@
<class>ObexFtpDialogBase</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>ObexFtpDialogBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>283</width>
+ <width>347</width>
<height>312</height>
</rect>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>caption</name>
@@ -63,76 +63,54 @@
<name>title</name>
<string>Device</string>
</attribute>
<grid>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>0</number>
</property>
- <widget row="1" column="0" rowspan="1" colspan="3" >
+ <widget row="1" column="0" rowspan="1" colspan="4" >
<class>QProgressBar</class>
<property stdset="1">
<name>name</name>
<cstring>fileProgress</cstring>
</property>
</widget>
- <widget row="3" column="0" rowspan="1" colspan="3" >
+ <widget row="3" column="0" rowspan="1" colspan="4" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>statusBar</cstring>
</property>
<property stdset="1">
<name>text</name>
<string></string>
</property>
</widget>
<widget row="2" column="0" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>browseOK</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Browse</string>
</property>
</widget>
- <widget row="2" column="1" >
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>getButton</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Get file</string>
- </property>
- </widget>
- <widget row="2" column="2" >
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>putButton</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Put file</string>
- </property>
- </widget>
- <widget row="0" column="0" rowspan="1" colspan="3" >
+ <widget row="0" column="0" rowspan="1" colspan="4" >
<class>QListView</class>
<column>
<property>
<name>text</name>
<string>Name</string>
</property>
<property>
<name>clickable</name>
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
@@ -149,24 +127,57 @@
<bool>true</bool>
</property>
<property>
<name>resizeable</name>
<bool>true</bool>
</property>
</column>
<property stdset="1">
<name>name</name>
<cstring>fileList</cstring>
</property>
</widget>
+ <widget row="2" column="2" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>putButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Put</string>
+ </property>
+ </widget>
+ <widget row="2" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>getButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Get</string>
+ </property>
+ </widget>
+ <widget row="2" column="3" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>delButton</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Del</string>
+ </property>
+ </widget>
</grid>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>localFs</cstring>
</property>
<attribute>
<name>title</name>
<string>Local</string>
</attribute>