summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-05-06 18:37:33 (UTC)
committer korovkin <korovkin>2006-05-06 18:37:33 (UTC)
commit2d9247d6c2917fd967d0d01d4d9aa6de4fb820f1 (patch) (side-by-side diff)
treed42ffb6e48f3d0f3b6b53b6c1b628e28e0783ceb
parent0430a18e64df0cdfc1e468a7f7bbe77efc63d0ca (diff)
downloadopie-2d9247d6c2917fd967d0d01d4d9aa6de4fb820f1.zip
opie-2d9247d6c2917fd967d0d01d4d9aa6de4fb820f1.tar.gz
opie-2d9247d6c2917fd967d0d01d4d9aa6de4fb820f1.tar.bz2
Browse button forces reconnection.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/obexftpdialog.cpp29
-rw-r--r--noncore/net/opietooth/manager/obexftpdialog.h4
2 files changed, 24 insertions, 9 deletions
diff --git a/noncore/net/opietooth/manager/obexftpdialog.cpp b/noncore/net/opietooth/manager/obexftpdialog.cpp
index 2f04ecf..efb3ff2 100644
--- a/noncore/net/opietooth/manager/obexftpdialog.cpp
+++ b/noncore/net/opietooth/manager/obexftpdialog.cpp
@@ -109,16 +109,21 @@ ObexFtpDialog::~ObexFtpDialog()
if (client != NULL) {
obexftp_disconnect(client);
obexftp_close(client);
}
}
+void ObexFtpDialog::slotBrowse()
+{
+ doBrowse(TRUE);
+}
+
/*
* Do device browsing
*/
-void ObexFtpDialog::slotBrowse()
+void ObexFtpDialog::doBrowse(bool reconnect)
{
stat_entry_t* ent; //Directory entry
void *dir; //Directory to read
const uint8_t* use_uuid; //uuid
int len; //uuid length
FileListItem* root; //root node
@@ -146,13 +151,13 @@ void ObexFtpDialog::slotBrowse()
len = sizeof(UUID_S45);
} else {
use_uuid = UUID_FBS;
len = sizeof(UUID_FBS);
}
- if (!cli_connect_uuid(use_uuid, len)) {
+ if (!cli_connect_uuid(use_uuid, len, reconnect)) {
log(tr("Connection failed: ") + tr(strerror(errno)));
errBox("Connection failed");
status("Connection failed");
return;
}
else {
@@ -237,13 +242,13 @@ void ObexFtpDialog::slotCd(QListViewItem* item)
curdir += "/";
curdir += file->text(0);
}
odebug << "Browse " << curdir << oendl;
if (obexftp_setpath(client, curdir, 0) < 0)
log(tr("CD failed: ") + tr(strerror(errno)));
- slotBrowse();
+ doBrowse();
}
}
/*
* Copy file from a remote device to the local device
*/
@@ -330,13 +335,13 @@ void ObexFtpDialog::putFile()
if (result < 0) {
log(local + QString(" send ERROR:\n") + tr(strerror(errno)));
errBox(local + QString(" send ERROR"));
status(local + QString(" send ERROR"));
}
else {
- slotBrowse();
+ doBrowse();
log(local + QString(" sent"));
status(local + QString(" sent"));
}
}
/*
@@ -368,24 +373,32 @@ void ObexFtpDialog::delFile()
if (result < 0) {
log(file2get + QString(" remove ERROR\n") + tr(strerror(errno)));
errBox(file2get + QString(" remove ERROR"));
status(file2get + QString(" remove ERROR"));
}
else {
- slotBrowse();
+ doBrowse();
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 ObexFtpDialog::cli_connect_uuid(const uint8_t *uuid, int uuid_len,
+ bool reconnect)
{
int retry;
- if (client != NULL)
- return TRUE;
+ if (client != NULL) {
+ if (reconnect) {
+ obexftp_disconnect(client);
+ obexftp_close(client);
+ sleep(3);
+ }
+ else
+ 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 75ee95b..45699d2 100644
--- a/noncore/net/opietooth/manager/obexftpdialog.h
+++ b/noncore/net/opietooth/manager/obexftpdialog.h
@@ -32,19 +32,21 @@ namespace OpieTooth {
void log(QCString str);
void log(const char* str);
void log(QString& str);
void incProgress();
void doneProgress();
protected:
- int cli_connect_uuid(const uint8_t *uuid, int uuid_len);
+ int cli_connect_uuid(const uint8_t *uuid, int uuid_len,
+ bool reconnect = FALSE);
int errBox(QCString msg); //Error message box
int errBox(QString msg); //Error message box
int errBox(const char* msg); //Error message box
void status(QCString msg); //Text in the status bar
void status(QString msg); //Text in the status bar
void status(const char* msg); //Text in the status bar
+ void doBrowse(bool reconnect = FALSE); //Browse device
protected:
QString m_device; //device MAC address
int m_port; //port
int transport; //transport type
bool use_conn;
bool use_path;