summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-04-25 20:17:22 (UTC)
committer korovkin <korovkin>2006-04-25 20:17:22 (UTC)
commitc5e86199c46839e6952b8ec3dec1447e5f60a279 (patch) (unidiff)
tree9cf9c5b247022ab1135c673456871f4604f9f369
parent8856190fa34ad67488adc137dc7c8646d0689795 (diff)
downloadopie-c5e86199c46839e6952b8ec3dec1447e5f60a279.zip
opie-c5e86199c46839e6952b8ec3dec1447e5f60a279.tar.gz
opie-c5e86199c46839e6952b8ec3dec1447e5f60a279.tar.bz2
Dedicated to Natalia Korovkina, my best friend and wife.
Added remove file functionality to OBEX FT dialog.
Diffstat (more/less context) (ignore 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
@@ -77,32 +77,35 @@ ObexFtpDialog::ObexFtpDialog(const QString& device, int port,
77 destFile = new OFileSelector(localFs, 77 destFile = new OFileSelector(localFs,
78 OFileSelector::FileSelector, 78 OFileSelector::FileSelector,
79 OFileSelector::ExtendedAll, localCurdir, ""); 79 OFileSelector::ExtendedAll, localCurdir, "");
80 destFile->setCloseVisible(false); 80 destFile->setCloseVisible(false);
81 destFile->setNewVisible(false); 81 destFile->setNewVisible(false);
82 localLayout->addWidget(destFile); 82 localLayout->addWidget(destFile);
83 nReries->setValue(nRetries); 83 nReries->setValue(nRetries);
84 connect(browseOK, SIGNAL(clicked()), SLOT(slotBrowse())); 84 connect(browseOK, SIGNAL(clicked()), SLOT(slotBrowse()));
85 connect(fileList, SIGNAL(clicked(QListViewItem*)), 85 connect(fileList, SIGNAL(clicked(QListViewItem*)),
86 SLOT(slotCd(QListViewItem*))); 86 SLOT(slotCd(QListViewItem*)));
87 connect(getButton, 87 connect(getButton,
88 SIGNAL(clicked()), 88 SIGNAL(clicked()),
89 SLOT(getFile())); 89 SLOT(getFile()));
90 connect(putButton, 90 connect(putButton,
91 SIGNAL(clicked()), 91 SIGNAL(clicked()),
92 SLOT(putFile())); 92 SLOT(putFile()));
93 connect(delButton,
94 SIGNAL(clicked()),
95 SLOT(delFile()));
93 connect(destFile, 96 connect(destFile,
94 SIGNAL(dirSelected (const QString&)), 97 SIGNAL(dirSelected (const QString&)),
95 SLOT(updateDir(const QString&))); 98 SLOT(updateDir(const QString&)));
96 connect(saveButton, 99 connect(saveButton,
97 SIGNAL(clicked()), 100 SIGNAL(clicked()),
98 SLOT(slotSaveLog())); 101 SLOT(slotSaveLog()));
99 connect(browseButton, 102 connect(browseButton,
100 SIGNAL(clicked()), 103 SIGNAL(clicked()),
101 SLOT(slotBrowseLog())); 104 SLOT(slotBrowseLog()));
102} 105}
103 106
104ObexFtpDialog::~ObexFtpDialog() 107ObexFtpDialog::~ObexFtpDialog()
105{ 108{
106 if (client != NULL) { 109 if (client != NULL) {
107 obexftp_disconnect(client); 110 obexftp_disconnect(client);
108 obexftp_close(client); 111 obexftp_close(client);
@@ -229,79 +232,79 @@ void ObexFtpDialog::slotCd(QListViewItem* item)
229 else 232 else
230 curdir = ""; 233 curdir = "";
231 } 234 }
232 else { 235 else {
233 if (curdir != "" && curdir.right(1) != "/") 236 if (curdir != "" && curdir.right(1) != "/")
234 curdir += "/"; 237 curdir += "/";
235 curdir += file->text(0); 238 curdir += file->text(0);
236 } 239 }
237 odebug << "Browse " << curdir << oendl; 240 odebug << "Browse " << curdir << oendl;
238 if (obexftp_setpath(client, curdir, 0) < 0) 241 if (obexftp_setpath(client, curdir, 0) < 0)
239 log(tr("CD failed: ") + tr(strerror(errno))); 242 log(tr("CD failed: ") + tr(strerror(errno)));
240 slotBrowse(); 243 slotBrowse();
241 } 244 }
242} 245}
243 246
244/* 247/*
245 * Get the file 248 * Copy file from a remote device to the local device
246 */ 249 */
247void ObexFtpDialog::getFile() 250void ObexFtpDialog::getFile()
248{ 251{
249 FileListItem* file = (FileListItem*)fileList->selectedItem(); 252 FileListItem* file = (FileListItem*)fileList->selectedItem();
250 int result; 253 int result;
251 if (file == NULL) 254 if (file == NULL)
252 return; 255 return;
253 file2get = "/"; 256 file2get = "/";
254 local = localCurdir; 257 local = localCurdir;
255 if (local == "") { 258 if (local == "") {
256 errBox("Select a destination first"); 259 errBox("Select a destination first");
257 return; 260 return;
258 } 261 }
259 if (local.right(1) != "/") 262 if (local.right(1) != "/")
260 local += "/"; 263 local += "/";
261 if (file->gettype() == IS_FILE) { 264 if (file->gettype() == IS_FILE) {
262 if (client == NULL) { 265 if (client == NULL) {
263 errBox("No connection established"); 266 errBox("No connection established");
264 return; 267 return;
265 } 268 }
266 file2get += curdir; 269 file2get += curdir;
267 if (curdir != "" && curdir.right(1) != "/") 270 if (curdir != "" && curdir.right(1) != "/")
268 file2get += "/"; 271 file2get += "/";
269 file2get += file->text(0); 272 file2get += file->text(0);
270 local += file->text(0); 273 local += file->text(0);
271 odebug << "Copy " << file2get << " to " << local << oendl; 274 odebug << "Copy " << file2get << " to " << local << oendl;
272 progressStatus = 0; 275 progressStatus = 0;
273 fileProgress->setTotalSteps(file->getsize() / 1024); 276 fileProgress->setTotalSteps(file->getsize() / 1024);
274 fileProgress->reset(); 277 fileProgress->reset();
275 status(tr("Receiving file ") + file2get); 278 status(tr("Receiving file ") + file2get);
276 result = obexftp_get(client, local, file2get); 279 result = obexftp_get(client, local, file2get);
277 if (result < 0) { 280 if (result < 0) {
278 log(file2get + QString(" receive ERROR: ") + tr(strerror(errno))); 281 log(file2get + QString(" receive ERROR:\n") + tr(strerror(errno)));
279 errBox(file2get + QString(" receive ERROR")); 282 errBox(file2get + QString(" receive ERROR"));
280 status(file2get + QString(" receive ERROR")); 283 status(file2get + QString(" receive ERROR"));
281 } 284 }
282 else { 285 else {
283 log(file2get + QString(" received")); 286 log(file2get + QString(" received"));
284 status(file2get + QString(" received")); 287 status(file2get + QString(" received"));
285 destFile->reread(); 288 destFile->reread();
286 } 289 }
287 } 290 }
288} 291}
289 292
290/* 293/*
291 * Put the file 294 * Copy file from the local device to a remote device
292 */ 295 */
293void ObexFtpDialog::putFile() 296void ObexFtpDialog::putFile()
294{ 297{
295 int result; //OPeration result 298 int result; //OPeration result
296 int idx; //Index of a symbol in the string 299 int idx; //Index of a symbol in the string
297 struct stat localFStat; //Local file information 300 struct stat localFStat; //Local file information
298 301
299 if (client == NULL) { 302 if (client == NULL) {
300 errBox("No connection established"); 303 errBox("No connection established");
301 return; 304 return;
302 } 305 }
303 local = destFile->selectedName(); 306 local = destFile->selectedName();
304 if (local == "") { 307 if (local == "") {
305 errBox("No file slected"); 308 errBox("No file slected");
306 return; 309 return;
307 } 310 }
@@ -312,42 +315,81 @@ void ObexFtpDialog::putFile()
312 return; 315 return;
313 } 316 }
314 idx = local.findRev('/'); 317 idx = local.findRev('/');
315 if (idx > 0) { 318 if (idx > 0) {
316 file2get = local.right(local.length() - idx - 1); 319 file2get = local.right(local.length() - idx - 1);
317 } 320 }
318 else 321 else
319 file2get = local; 322 file2get = local;
320 323
321 odebug << "Copy " << local << " to " << file2get << oendl; 324 odebug << "Copy " << local << " to " << file2get << oendl;
322 progressStatus = 0; 325 progressStatus = 0;
323 fileProgress->setTotalSteps(localFStat.st_size / 1024); 326 fileProgress->setTotalSteps(localFStat.st_size / 1024);
324 fileProgress->reset(); 327 fileProgress->reset();
325 status(tr("Sending file ") + local); 328 status(tr("Sending file ") + local);
326 result = obexftp_put_file(client, local, file2get); 329 result = obexftp_put_file(client, local, file2get);
327 if (result < 0) { 330 if (result < 0) {
328 log(local + QString(" send ERROR: ") + tr(strerror(errno))); 331 log(local + QString(" send ERROR:\n") + tr(strerror(errno)));
329 errBox(local + QString(" send ERROR")); 332 errBox(local + QString(" send ERROR"));
330 status(local + QString(" send ERROR")); 333 status(local + QString(" send ERROR"));
331 } 334 }
332 else { 335 else {
336 slotBrowse();
333 log(local + QString(" sent")); 337 log(local + QString(" sent"));
334 status(local + QString(" sent")); 338 status(local + QString(" sent"));
335 } 339 }
336} 340}
337 341
342/*
343 * Delete file on a remote device
344 */
345void ObexFtpDialog::delFile()
346{
347 FileListItem* file = (FileListItem*)fileList->selectedItem();
348 int result;
349 if (file == NULL)
350 return;
351 file2get = "/";
352 if (file->gettype() == IS_FILE) {
353 if (client == NULL) {
354 errBox("No connection established");
355 return;
356 }
357 file2get += curdir;
358 if (curdir != "" && curdir.right(1) != "/")
359 file2get += "/";
360 file2get += file->text(0);
361 }
362 result = QMessageBox::warning(this, tr("Remove File"),
363 tr("Do you want to remove\n") + file2get, "Yes", "No");
364 if (result != 0)
365 return;
366 odebug << "Remove " << file2get << oendl;
367 result = obexftp_del(client, file2get);
368 if (result < 0) {
369 log(file2get + QString(" remove ERROR\n") + tr(strerror(errno)));
370 errBox(file2get + QString(" remove ERROR"));
371 status(file2get + QString(" remove ERROR"));
372 }
373 else {
374 slotBrowse();
375 log(file2get + QString(" removed"));
376 status(file2get + QString(" removed"));
377 }
378}
379
338/* connect with given uuid. re-connect every time */ 380/* connect with given uuid. re-connect every time */
339int ObexFtpDialog::cli_connect_uuid(const uint8_t *uuid, int uuid_len) 381int ObexFtpDialog::cli_connect_uuid(const uint8_t *uuid, int uuid_len)
340{ 382{
341 int retry; 383 int retry;
342 if (client != NULL) 384 if (client != NULL)
343 return TRUE; 385 return TRUE;
344 /* Open */ 386 /* Open */
345 client = obexftp_open (transport, NULL, info_cb, this); 387 client = obexftp_open (transport, NULL, info_cb, this);
346 if(client == NULL) { 388 if(client == NULL) {
347 errBox("Error opening obexftp-client"); 389 errBox("Error opening obexftp-client");
348 return FALSE; 390 return FALSE;
349 } 391 }
350 if (!use_conn) 392 if (!use_conn)
351 client->quirks &= ~OBEXFTP_CONN_HEADER; 393 client->quirks &= ~OBEXFTP_CONN_HEADER;
352 if (!use_path) 394 if (!use_path)
353 client->quirks &= ~OBEXFTP_SPLIT_SETPATH; 395 client->quirks &= ~OBEXFTP_SPLIT_SETPATH;
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
@@ -49,22 +49,23 @@ namespace OpieTooth {
49 bool use_conn; 49 bool use_conn;
50 bool use_path; 50 bool use_path;
51 obexftp_client_t* client; //Obex ftp client handler 51 obexftp_client_t* client; //Obex ftp client handler
52 QString curdir; //Current directory on device 52 QString curdir; //Current directory on device
53 QString localCurdir; //Local current directory 53 QString localCurdir; //Local current directory
54 QString file2get; //Remote file name 54 QString file2get; //Remote file name
55 QString local; //Local file name 55 QString local; //Local file name
56 int progressStatus; //Progress status 56 int progressStatus; //Progress status
57 Opie::Ui::OFileSelector* destFile; //Destination file or directory 57 Opie::Ui::OFileSelector* destFile; //Destination file or directory
58 QVBoxLayout* localLayout; //Window layout 58 QVBoxLayout* localLayout; //Window layout
59 int nRetries; //Number of retries (on connection) 59 int nRetries; //Number of retries (on connection)
60 private slots: 60 private slots:
61 void slotBrowse(); 61 void slotBrowse();
62 void slotCd(QListViewItem* item); 62 void slotCd(QListViewItem* item);
63 void getFile(); 63 void getFile();
64 void putFile(); 64 void putFile();
65 void delFile();
65 void updateDir(const QString& newdir); 66 void updateDir(const QString& newdir);
66 void slotSaveLog(); 67 void slotSaveLog();
67 void slotBrowseLog(); 68 void slotBrowseLog();
68 }; 69 };
69}; 70};
70#endif 71#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
@@ -1,30 +1,30 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>ObexFtpDialogBase</class> 2<class>ObexFtpDialogBase</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>ObexFtpDialogBase</cstring> 7 <cstring>ObexFtpDialogBase</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>283</width> 14 <width>347</width>
15 <height>312</height> 15 <height>312</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>sizePolicy</name> 19 <name>sizePolicy</name>
20 <sizepolicy> 20 <sizepolicy>
21 <hsizetype>7</hsizetype> 21 <hsizetype>7</hsizetype>
22 <vsizetype>7</vsizetype> 22 <vsizetype>7</vsizetype>
23 </sizepolicy> 23 </sizepolicy>
24 </property> 24 </property>
25 <property stdset="1"> 25 <property stdset="1">
26 <name>caption</name> 26 <name>caption</name>
27 <string>Browse device</string> 27 <string>Browse device</string>
28 </property> 28 </property>
29 <property> 29 <property>
30 <name>layoutMargin</name> 30 <name>layoutMargin</name>
@@ -59,84 +59,62 @@
59 <name>name</name> 59 <name>name</name>
60 <cstring>files</cstring> 60 <cstring>files</cstring>
61 </property> 61 </property>
62 <attribute> 62 <attribute>
63 <name>title</name> 63 <name>title</name>
64 <string>Device</string> 64 <string>Device</string>
65 </attribute> 65 </attribute>
66 <grid> 66 <grid>
67 <property stdset="1"> 67 <property stdset="1">
68 <name>margin</name> 68 <name>margin</name>
69 <number>0</number> 69 <number>0</number>
70 </property> 70 </property>
71 <property stdset="1"> 71 <property stdset="1">
72 <name>spacing</name> 72 <name>spacing</name>
73 <number>0</number> 73 <number>0</number>
74 </property> 74 </property>
75 <widget row="1" column="0" rowspan="1" colspan="3" > 75 <widget row="1" column="0" rowspan="1" colspan="4" >
76 <class>QProgressBar</class> 76 <class>QProgressBar</class>
77 <property stdset="1"> 77 <property stdset="1">
78 <name>name</name> 78 <name>name</name>
79 <cstring>fileProgress</cstring> 79 <cstring>fileProgress</cstring>
80 </property> 80 </property>
81 </widget> 81 </widget>
82 <widget row="3" column="0" rowspan="1" colspan="3" > 82 <widget row="3" column="0" rowspan="1" colspan="4" >
83 <class>QLabel</class> 83 <class>QLabel</class>
84 <property stdset="1"> 84 <property stdset="1">
85 <name>name</name> 85 <name>name</name>
86 <cstring>statusBar</cstring> 86 <cstring>statusBar</cstring>
87 </property> 87 </property>
88 <property stdset="1"> 88 <property stdset="1">
89 <name>text</name> 89 <name>text</name>
90 <string></string> 90 <string></string>
91 </property> 91 </property>
92 </widget> 92 </widget>
93 <widget row="2" column="0" > 93 <widget row="2" column="0" >
94 <class>QPushButton</class> 94 <class>QPushButton</class>
95 <property stdset="1"> 95 <property stdset="1">
96 <name>name</name> 96 <name>name</name>
97 <cstring>browseOK</cstring> 97 <cstring>browseOK</cstring>
98 </property> 98 </property>
99 <property stdset="1"> 99 <property stdset="1">
100 <name>text</name> 100 <name>text</name>
101 <string>Browse</string> 101 <string>Browse</string>
102 </property> 102 </property>
103 </widget> 103 </widget>
104 <widget row="2" column="1" > 104 <widget row="0" column="0" rowspan="1" colspan="4" >
105 <class>QPushButton</class>
106 <property stdset="1">
107 <name>name</name>
108 <cstring>getButton</cstring>
109 </property>
110 <property stdset="1">
111 <name>text</name>
112 <string>Get file</string>
113 </property>
114 </widget>
115 <widget row="2" column="2" >
116 <class>QPushButton</class>
117 <property stdset="1">
118 <name>name</name>
119 <cstring>putButton</cstring>
120 </property>
121 <property stdset="1">
122 <name>text</name>
123 <string>Put file</string>
124 </property>
125 </widget>
126 <widget row="0" column="0" rowspan="1" colspan="3" >
127 <class>QListView</class> 105 <class>QListView</class>
128 <column> 106 <column>
129 <property> 107 <property>
130 <name>text</name> 108 <name>text</name>
131 <string>Name</string> 109 <string>Name</string>
132 </property> 110 </property>
133 <property> 111 <property>
134 <name>clickable</name> 112 <name>clickable</name>
135 <bool>true</bool> 113 <bool>true</bool>
136 </property> 114 </property>
137 <property> 115 <property>
138 <name>resizeable</name> 116 <name>resizeable</name>
139 <bool>true</bool> 117 <bool>true</bool>
140 </property> 118 </property>
141 </column> 119 </column>
142 <column> 120 <column>
@@ -145,32 +123,65 @@
145 <string>Size</string> 123 <string>Size</string>
146 </property> 124 </property>
147 <property> 125 <property>
148 <name>clickable</name> 126 <name>clickable</name>
149 <bool>true</bool> 127 <bool>true</bool>
150 </property> 128 </property>
151 <property> 129 <property>
152 <name>resizeable</name> 130 <name>resizeable</name>
153 <bool>true</bool> 131 <bool>true</bool>
154 </property> 132 </property>
155 </column> 133 </column>
156 <property stdset="1"> 134 <property stdset="1">
157 <name>name</name> 135 <name>name</name>
158 <cstring>fileList</cstring> 136 <cstring>fileList</cstring>
159 </property> 137 </property>
160 </widget> 138 </widget>
139 <widget row="2" column="2" >
140 <class>QPushButton</class>
141 <property stdset="1">
142 <name>name</name>
143 <cstring>putButton</cstring>
144 </property>
145 <property stdset="1">
146 <name>text</name>
147 <string>Put</string>
148 </property>
149 </widget>
150 <widget row="2" column="1" >
151 <class>QPushButton</class>
152 <property stdset="1">
153 <name>name</name>
154 <cstring>getButton</cstring>
155 </property>
156 <property stdset="1">
157 <name>text</name>
158 <string>Get</string>
159 </property>
160 </widget>
161 <widget row="2" column="3" >
162 <class>QPushButton</class>
163 <property stdset="1">
164 <name>name</name>
165 <cstring>delButton</cstring>
166 </property>
167 <property stdset="1">
168 <name>text</name>
169 <string>Del</string>
170 </property>
171 </widget>
161 </grid> 172 </grid>
162 </widget> 173 </widget>
163 <widget> 174 <widget>
164 <class>QWidget</class> 175 <class>QWidget</class>
165 <property stdset="1"> 176 <property stdset="1">
166 <name>name</name> 177 <name>name</name>
167 <cstring>localFs</cstring> 178 <cstring>localFs</cstring>
168 </property> 179 </property>
169 <attribute> 180 <attribute>
170 <name>title</name> 181 <name>title</name>
171 <string>Local</string> 182 <string>Local</string>
172 </attribute> 183 </attribute>
173 </widget> 184 </widget>
174 <widget> 185 <widget>
175 <class>QWidget</class> 186 <class>QWidget</class>
176 <property stdset="1"> 187 <property stdset="1">