-rw-r--r-- | noncore/net/opie-smb/qsmb.cpp | 198 | ||||
-rw-r--r-- | noncore/net/opie-smb/qsmb.h | 22 | ||||
-rw-r--r-- | noncore/net/opie-smb/qsmbbase.ui | 59 |
3 files changed, 170 insertions, 109 deletions
diff --git a/noncore/net/opie-smb/qsmb.cpp b/noncore/net/opie-smb/qsmb.cpp index 422b9f3..b978b46 100644 --- a/noncore/net/opie-smb/qsmb.cpp +++ b/noncore/net/opie-smb/qsmb.cpp | |||
@@ -1,60 +1,66 @@ | |||
1 | #include "qsmb.h" | 1 | #include "qsmb.h" |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
4 | 4 | ||
5 | #include <string.h> | 5 | #include <string.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | 7 | #include <qstringlist.h> |
8 | #include <qdir.h> | 8 | #include <qdir.h> |
9 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
10 | #include <qtabwidget.h> | ||
10 | 11 | ||
11 | #include <qpe/process.h> | 12 | #include <qpe/process.h> |
12 | #include <qlabel.h> | 13 | #include <qlabel.h> |
13 | #include <qlineedit.h> | 14 | #include <qlineedit.h> |
14 | #include <qcombobox.h> | 15 | #include <qcombobox.h> |
15 | #include <qstringlist.h> | 16 | #include <qstringlist.h> |
16 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
17 | #include <qtextview.h> | 18 | #include <qtextview.h> |
18 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
19 | #include <qtextstream.h> | 20 | #include <qtextstream.h> |
20 | 21 | ||
21 | 22 | ||
22 | #include <pthread.h> | 23 | #include <pthread.h> |
23 | #include <signal.h> | 24 | #include <signal.h> |
24 | #include <ctype.h> | 25 | #include <ctype.h> |
25 | 26 | ||
26 | 27 | ||
27 | #include <netinet/in.h> | 28 | #include <netinet/in.h> |
28 | #include <arpa/inet.h> | 29 | #include <arpa/inet.h> |
29 | |||
30 | #include <rpc/clnt.h> | 30 | #include <rpc/clnt.h> |
31 | 31 | ||
32 | #include <sys/vfs.h> | ||
33 | #include <mntent.h> | ||
32 | 34 | ||
33 | #include <opie2/odebug.h> | 35 | // #include <opie2/odebug.h> |
34 | using namespace Opie::Core; | 36 | // using namespace Opie::Core; |
35 | 37 | ||
36 | 38 | ||
37 | Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) | 39 | Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) |
38 | : FormQPESMBBase( parent, name, fl ) | 40 | : FormQPESMBBase( parent, name, fl ) |
39 | { | 41 | { |
40 | connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); | 42 | connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); |
41 | connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); | 43 | connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); |
44 | connect(UnmountBtn, SIGNAL(clicked()), this, SLOT(umountIt())); | ||
42 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); | 45 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); |
43 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); | 46 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); |
44 | 47 | ||
48 | mountpt->setEditable(true); | ||
45 | mountpt->insertItem("/mnt/samba1",-1); | 49 | mountpt->insertItem("/mnt/samba1",-1); |
46 | mountpt->insertItem("/mnt/samba2",-1); | 50 | mountpt->insertItem("/mnt/samba2",-1); |
47 | mountpt->insertItem("/mnt/samba3",-1); | 51 | mountpt->insertItem("/mnt/samba3",-1); |
48 | 52 | ||
53 | // TextViewOutput | ||
54 | |||
49 | top_element = NULL; | 55 | top_element = NULL; |
50 | scanning = false; | 56 | scanning = false; |
51 | } | 57 | } |
52 | 58 | ||
53 | Qsmb::~Qsmb() | 59 | Qsmb::~Qsmb() |
54 | { | 60 | { |
55 | } | 61 | } |
56 | 62 | ||
57 | void Qsmb::clear() | 63 | void Qsmb::clear() |
58 | { | 64 | { |
59 | if (scanning) return; | 65 | if (scanning) return; |
60 | ListViewScan->clear(); | 66 | ListViewScan->clear(); |
@@ -62,63 +68,61 @@ void Qsmb::clear() | |||
62 | top_element = NULL; | 68 | top_element = NULL; |
63 | } | 69 | } |
64 | 70 | ||
65 | void Qsmb::scanClicked() | 71 | void Qsmb::scanClicked() |
66 | { | 72 | { |
67 | if (scanning) return; | 73 | if (scanning) return; |
68 | pthread_create(&tpid, NULL, runit, (void *)this); | 74 | pthread_create(&tpid, NULL, runit, (void *)this); |
69 | } | 75 | } |
70 | 76 | ||
71 | void Qsmb::DoItClicked() | 77 | void Qsmb::DoItClicked() |
72 | { | 78 | { |
73 | 79 | ||
74 | if(! ListViewScan->selectedItem()) { | 80 | if( !ListViewScan->selectedItem()) { |
75 | QMessageBox::warning(this, tr("Error"),tr("<p>No share selected!</p>")); | 81 | QMessageBox::warning(this, tr("Error"),tr("<p>No share selected!</p>")); |
76 | return; | 82 | return; |
77 | } | 83 | } |
78 | if (scanning) return; | 84 | if (scanning) return; |
79 | pthread_create(&tpid, NULL, runitm, (void *)this); | 85 | pthread_create(&tpid, NULL, runitm, (void *)this); |
80 | } | 86 | } |
81 | 87 | ||
82 | void* runit(void* arg) | 88 | void* runit(void* arg) |
83 | { | 89 | { |
84 | Qsmb* caller = (Qsmb*)arg; | 90 | Qsmb* caller = (Qsmb*)arg; |
85 | caller->scan(); | 91 | caller->scan(); |
86 | return(0); | 92 | return(0); |
87 | } | 93 | } |
88 | 94 | ||
89 | void* runitm(void* arg) | 95 | void* runitm(void* arg) |
90 | { | 96 | { |
91 | Qsmb* caller = (Qsmb*)arg; | 97 | Qsmb* caller = (Qsmb*)arg; |
92 | caller->DoIt(); | 98 | caller->DoIt(); |
93 | return(0); | 99 | return(0); |
94 | } | 100 | } |
95 | 101 | ||
96 | void Qsmb::scan() | 102 | void Qsmb::scan() |
97 | { | 103 | { |
98 | // int i; | ||
99 | |||
100 | if (scanning) return; | 104 | if (scanning) return; |
101 | scanning = true; | 105 | scanning = true; |
102 | 106 | ||
103 | QString match; | 107 | QString match; |
104 | QString cmd; | 108 | QString cmd; |
105 | LScan->setText("Scanning..."); | 109 | LScan->setText("Scanning..."); |
106 | qApp->processEvents(); | 110 | qApp->processEvents(); |
107 | 111 | ||
108 | sockaddr_in my_addr; | 112 | sockaddr_in my_addr; |
109 | get_myaddress( &my_addr); | 113 | get_myaddress( &my_addr); |
110 | 114 | ||
111 | QString ip = inet_ntoa( my_addr.sin_addr); | 115 | QString ip = inet_ntoa( my_addr.sin_addr); |
112 | owarn << "IP Address : " << ip<< oendl; | 116 | qWarning("IP Address : "+ip); |
113 | 117 | ||
114 | match = ip.left(5); | 118 | match = ip.left(5); |
115 | 119 | ||
116 | QStringList ccmd; | 120 | QStringList ccmd; |
117 | TextViewOutput->append("smbfind"); | 121 | TextViewOutput->append("smbfind"); |
118 | 122 | ||
119 | QFile lmhosts("/etc/samba/lmhosts"); | 123 | QFile lmhosts("/etc/samba/lmhosts"); |
120 | QTextStream lms(&lmhosts); | 124 | QTextStream lms(&lmhosts); |
121 | lmhosts.open(IO_WriteOnly); | 125 | lmhosts.open(IO_WriteOnly); |
122 | lms << "127.0.0.1 localhost\n"; | 126 | lms << "127.0.0.1 localhost\n"; |
123 | 127 | ||
124 | /* parse output and display in ListViewScan */ | 128 | /* parse output and display in ListViewScan */ |
@@ -138,31 +142,31 @@ void Qsmb::scan() | |||
138 | host = token[1]; | 142 | host = token[1]; |
139 | CBHost->insertItem( host, -1); | 143 | CBHost->insertItem( host, -1); |
140 | lms << ip_addr+" "+host+"\n"; | 144 | lms << ip_addr+" "+host+"\n"; |
141 | } | 145 | } |
142 | } | 146 | } |
143 | lmhosts.close(); | 147 | lmhosts.close(); |
144 | 148 | ||
145 | TextViewOutput->append("\n\n============================================\n"); | 149 | TextViewOutput->append("\n\n============================================\n"); |
146 | LScan->setText(""); | 150 | LScan->setText(""); |
147 | scanning = false; | 151 | scanning = false; |
148 | } | 152 | } |
149 | 153 | ||
150 | void Qsmb::hostSelected(int index) | 154 | void Qsmb::hostSelected(int /*index*/ ) |
151 | { | 155 | { |
152 | owarn << "hostSelected" << oendl; | ||
153 | QListViewItem *element; | 156 | QListViewItem *element; |
154 | QListViewItem *parent; | 157 | // QListViewItem *parent; |
155 | 158 | ||
156 | QString text = CBHost->currentText(); | 159 | QString text = CBHost->currentText(); |
160 | ListViewScan->clear(); | ||
157 | 161 | ||
158 | if (scanning) return; | 162 | if (scanning) return; |
159 | scanning = true; | 163 | scanning = true; |
160 | 164 | ||
161 | QString cmd; | 165 | QString cmd; |
162 | QStringList ccmd; | 166 | QStringList ccmd; |
163 | 167 | ||
164 | LScan->setText("Scanning..."); | 168 | LScan->setText("Scanning..."); |
165 | 169 | ||
166 | ccmd << "/usr/bin/smbclient"; | 170 | ccmd << "/usr/bin/smbclient"; |
167 | ccmd << "-L"; | 171 | ccmd << "-L"; |
168 | ccmd << CBHost->currentText(); | 172 | ccmd << CBHost->currentText(); |
@@ -177,25 +181,27 @@ void Qsmb::hostSelected(int index) | |||
177 | runCommand(ccmd); | 181 | runCommand(ccmd); |
178 | QTextStream s(&out, IO_ReadOnly); | 182 | QTextStream s(&out, IO_ReadOnly); |
179 | 183 | ||
180 | while ( !s.atEnd() ) { | 184 | while ( !s.atEnd() ) { |
181 | QString share; | 185 | QString share; |
182 | QString comment; | 186 | QString comment; |
183 | QString tmp = s.readLine(); | 187 | QString tmp = s.readLine(); |
184 | 188 | ||
185 | if( tmp.find("$") == -1 && tmp.find("Disk") != -1) { | 189 | if( tmp.find("$") == -1 && tmp.find("Disk") != -1) { |
186 | QStringList token = QStringList::split(' ', tmp ); | 190 | QStringList token = QStringList::split(' ', tmp ); |
187 | share = token[0]; | 191 | share = token[0]; |
188 | comment = token[2]; | 192 | comment = token[2]; |
189 | element = new QListViewItem(ListViewScan,share, comment); | 193 | share = share.stripWhiteSpace(); |
194 | comment = comment.stripWhiteSpace(); | ||
195 | element = new QListViewItem(ListViewScan, share, comment); | ||
190 | element->setOpen(true); | 196 | element->setOpen(true); |
191 | // top_element = element; | 197 | // top_element = element; |
192 | // parent = element; | 198 | // parent = element; |
193 | } | 199 | } |
194 | 200 | ||
195 | } | 201 | } |
196 | // owarn << "i="<< index << "cmd:" << cmd << oendl; | 202 | // owarn << "i="<< index << "cmd:" << cmd << oendl; |
197 | 203 | ||
198 | TextViewOutput->append(cmd); | 204 | TextViewOutput->append(cmd); |
199 | 205 | ||
200 | /* run smbclient & read output */ | 206 | /* run smbclient & read output */ |
201 | // if ((pipe = popen(cmd.latin1(), "r")) == NULL) { | 207 | // if ((pipe = popen(cmd.latin1(), "r")) == NULL) { |
@@ -241,134 +247,162 @@ void Qsmb::hostSelected(int index) | |||
241 | // element->setOpen(true); | 247 | // element->setOpen(true); |
242 | // top_element = element; | 248 | // top_element = element; |
243 | // parent = element; | 249 | // parent = element; |
244 | // } | 250 | // } |
245 | // } | 251 | // } |
246 | // } | 252 | // } |
247 | 253 | ||
248 | TextViewOutput->append("\n\n============================================\n"); | 254 | TextViewOutput->append("\n\n============================================\n"); |
249 | LScan->setText(""); | 255 | LScan->setText(""); |
250 | scanning = false; | 256 | scanning = false; |
251 | } | 257 | } |
252 | 258 | ||
259 | |||
253 | void Qsmb::DoIt() | 260 | void Qsmb::DoIt() |
254 | { | 261 | { |
262 | |||
255 | QListViewItem *element; | 263 | QListViewItem *element; |
256 | element = ListViewScan->selectedItem(); | 264 | element = ListViewScan->selectedItem(); |
257 | if(!element) { | 265 | if(!element) { |
258 | QMessageBox::warning(this, tr("Error!!"),tr("<p><b>No</b> share selected!!</p>")); | ||
259 | return; | 266 | return; |
260 | } | 267 | } |
261 | 268 | ||
262 | if (scanning) return; | 269 | if (scanning) return; |
263 | scanning = true; | 270 | scanning = true; |
264 | 271 | ||
265 | int i; | 272 | QString mount = mountpt->currentText(); |
266 | bool err = false; | 273 | if(isMounted(mount)) { |
274 | qWarning(mount +" is already mounted"); | ||
275 | TextViewOutput->append(mount +" is already mounted"); | ||
276 | return; | ||
277 | } | ||
278 | |||
279 | bool noerr = false; | ||
267 | 280 | ||
268 | char share[512]; | 281 | QString share; |
269 | QString cmd; | 282 | QString cmd; |
270 | QString cmd2; | 283 | QString cmd2; |
271 | char result[256]; | ||
272 | // QString result; | ||
273 | QString text = mountpt->currentText(); | 284 | QString text = mountpt->currentText(); |
274 | 285 | QStringList ccmd; | |
275 | FILE *pipe,*pipe2; | ||
276 | 286 | ||
277 | LScan->setText("Mounting..."); | 287 | LScan->setText("Mounting..."); |
278 | qApp->processEvents(); | 288 | qApp->processEvents(); |
279 | 289 | ||
280 | 290 | if( !QFileInfo(text).exists()) { | |
281 | if(! QFileInfo(text).exists()) { | ||
282 | QStringList ccmd; | ||
283 | ccmd << "mkdir"; | 291 | ccmd << "mkdir"; |
284 | ccmd << "-p"; | 292 | ccmd << "-p"; |
285 | ccmd << text; | 293 | ccmd << text; |
286 | 294 | ||
287 | owarn<<"cmd: "<< ccmd << oendl; | 295 | qWarning( "cmd: "+ ccmd.join(" ")); |
288 | runCommand(ccmd); | 296 | runCommand(ccmd); |
289 | } | 297 | } |
290 | 298 | ||
299 | share = element->text(0); | ||
300 | qWarning("selected share is "+share); | ||
291 | 301 | ||
292 | strcpy(share,(const char *)element->text(0)); | 302 | QString service = CBHost->currentText(); |
293 | 303 | service = service.stripWhiteSpace(); | |
294 | for(i = 0; i < 256; i++) { | 304 | if(mount.left(1) != "/") |
295 | if(isalpha( share[i])) { | 305 | mount = QDir::currentDirPath()+"/"+mount; |
296 | strcpy( share, share + i); | 306 | mount = mount.stripWhiteSpace(); |
297 | break; | 307 | ccmd.clear(); |
298 | } | 308 | |
299 | } | 309 | ccmd << "/usr/bin/smbmount"; |
300 | 310 | ccmd << "//"+ service+"/"+share; | |
301 | cmd = "/usr/bin/smbmount //"+CBHost->currentText()+"/"+share+" "+mountpt->currentText()+" -o username="+username->text()+",password="+password->text(); | 311 | ccmd << mount; |
302 | 312 | ccmd << "-o"; | |
303 | owarn << "cmd: " << cmd << oendl; | 313 | ccmd << "username="+username->text()+",password="+password->text()+""; |
304 | TextViewOutput->append(cmd.latin1()); | ||
305 | 314 | ||
315 | TextViewOutput->append(ccmd.join(" ").latin1()); | ||
306 | 316 | ||
307 | if(onbootBtn->isChecked()) { | 317 | if(onbootBtn->isChecked()) { |
308 | owarn << "Saving Setting permanently..." << oendl; | 318 | qWarning("Saving Setting permanently..."); |
309 | cmd2 = "echo '" + cmd + "'>/opt/QtPalmtop/etc/samba.env"; | 319 | QFile sambenv("/opt/QtPalmtop/etc/samba.env"); |
310 | /* run command & read output */ | 320 | QTextStream smbv(&sambenv); |
311 | if ((pipe = popen(cmd2.latin1(), "r")) == NULL) { | 321 | sambenv.open(IO_WriteOnly); |
312 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 322 | smbv << ccmd.join(" ") ; |
313 | return; | 323 | sambenv.close(); |
314 | } | ||
315 | /* parse output and display in ListViewScan */ | ||
316 | while(fgets(result, 256, pipe) != NULL) { | ||
317 | } | ||
318 | } | ||
319 | |||
320 | |||
321 | /* run command & read output */ | ||
322 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { | ||
323 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | ||
324 | TextViewOutput->append(result); | ||
325 | return; | ||
326 | } | ||
327 | |||
328 | /* parse output and display in ListViewScan */ | ||
329 | while(fgets(result, 256, pipe) != NULL) { | ||
330 | /* put result into TextViewOutput */ | ||
331 | TextViewOutput->append(result); | ||
332 | } | 324 | } |
333 | 325 | ||
326 | noerr = runCommand(ccmd); | ||
334 | 327 | ||
335 | TextViewOutput->append("\n\n================CheckMounts==================\n"); | ||
336 | LScan->setText(""); | 328 | LScan->setText(""); |
337 | 329 | ||
338 | cmd = "/bin/mount 2>&1"; | 330 | if(noerr) { |
339 | owarn << "cmd: " << cmd << oendl; | 331 | element->setText(2, mount); |
340 | 332 | TextViewOutput->append("\n\n================CheckMounts==================\n"); | |
341 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { | 333 | ccmd = "/bin/mount"; |
334 | runCommand(ccmd); | ||
335 | TextViewOutput->append("\n\n============================================\n"); | ||
336 | qApp->processEvents(); | ||
337 | } else { | ||
338 | //do nothing | ||
339 | } | ||
342 | 340 | ||
343 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 341 | scanning = false; |
344 | // result = "Error: Can't run "+ cmd; | 342 | } |
345 | 343 | ||
346 | TextViewOutput->append(result); | 344 | void Qsmb::umountIt() |
345 | { | ||
346 | QString mount = mountpt->currentText(); | ||
347 | if(!isMounted(mount)) { | ||
348 | qWarning(mount +" is not mounted"); | ||
349 | TextViewOutput->append(mount +" is not mounted"); | ||
347 | return; | 350 | return; |
348 | } | 351 | } |
349 | /* parse output and display in ListViewScan */ | ||
350 | while(fgets(result, 256, pipe2) != NULL) { | ||
351 | /* put result into TextViewOutput */ | ||
352 | TextViewOutput->append(result); | ||
353 | } | ||
354 | 352 | ||
355 | TextViewOutput->append("\n\n============================================\n"); | 353 | QStringList ccmd; |
356 | scanning = false; | 354 | QString share; |
355 | QListViewItem *element; | ||
356 | element = ListViewScan->selectedItem(); | ||
357 | share = element->text(0); | ||
358 | qWarning("selected share is "+share); | ||
359 | |||
360 | if(mount.left(1) != "/") | ||
361 | mount = QDir::currentDirPath()+"/"+mount; | ||
362 | mount = mount.stripWhiteSpace(); | ||
363 | |||
364 | ccmd << "/usr/bin/smbumount"; | ||
365 | ccmd << mount; | ||
366 | runCommand(ccmd); | ||
367 | |||
368 | element->setText(2, ""); | ||
369 | |||
370 | ccmd = "/bin/mount"; | ||
371 | runCommand(ccmd); | ||
357 | } | 372 | } |
358 | 373 | ||
359 | bool Qsmb::runCommand(const QStringList & command) { | 374 | bool Qsmb::runCommand(const QStringList & command) { |
360 | owarn << "runCommand " << command.join(" ") << oendl; | 375 | qWarning( "runCommand " + command.join(" ") ); |
376 | TextViewOutput->append(command.join(" ")); | ||
361 | out = ""; | 377 | out = ""; |
362 | Process ipkg_status( command); | 378 | Process ipkg_status( command); |
363 | bool r = ipkg_status.exec("",out); | 379 | bool r = ipkg_status.exec("",out); |
364 | 380 | ||
365 | if(!r) { | 381 | qWarning("result is %d"+ r ); |
366 | QMessageBox::warning(this, tr("Error!!"),tr("<p>"+out+"</p>")); | 382 | qWarning("Output " + out ); |
367 | } | 383 | TextViewOutput->append(out); |
368 | 384 | ||
369 | owarn << "Output " << out << oendl; | 385 | //very hacky |
370 | TextViewOutput->append(out.latin1()); | 386 | if(out.find("failed") !=-1) { |
387 | r = false; | ||
388 | } | ||
371 | return r; | 389 | return r; |
372 | } | 390 | } |
373 | 391 | ||
374 | 392 | ||
393 | bool Qsmb::isMounted(const QString &mountPoint) { | ||
394 | struct mntent *me; | ||
395 | bool mounted = false; | ||
396 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | ||
397 | if ( mntfp ){ | ||
398 | while ( (me = getmntent( mntfp )) != 0 ) { | ||
399 | QString deviceName = me->mnt_fsname; | ||
400 | QString mountDir = me->mnt_dir; | ||
401 | QString fsType = me->mnt_type; | ||
402 | if( fsType == "smbfs" && mountDir.find(mountPoint) !=-1) | ||
403 | mounted = true; | ||
404 | } | ||
405 | } | ||
406 | endmntent( mntfp ); | ||
407 | return mounted; | ||
408 | } | ||
diff --git a/noncore/net/opie-smb/qsmb.h b/noncore/net/opie-smb/qsmb.h index b406a1e..fba94d0 100644 --- a/noncore/net/opie-smb/qsmb.h +++ b/noncore/net/opie-smb/qsmb.h | |||
@@ -3,40 +3,42 @@ | |||
3 | 3 | ||
4 | #include "qsmbbase.h" | 4 | #include "qsmbbase.h" |
5 | 5 | ||
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | 9 | ||
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <pthread.h> | 11 | #include <pthread.h> |
12 | 12 | ||
13 | class Qsmb : public FormQPESMBBase | 13 | class Qsmb : public FormQPESMBBase |
14 | { | 14 | { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | 16 | ||
17 | public: | 17 | public: |
18 | static QString appName() { return QString::fromLatin1("opie-smb"); } | 18 | static QString appName() { return QString::fromLatin1("opie-smb"); } |
19 | Qsmb( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 19 | Qsmb( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
20 | ~Qsmb(); | 20 | ~Qsmb(); |
21 | void scan(); | 21 | void scan(); |
22 | void DoIt(); | 22 | void DoIt(); |
23 | 23 | ||
24 | private: | 24 | private: |
25 | QListViewItem *top_element; | 25 | QListViewItem *top_element; |
26 | QComboBox *hosts; | 26 | QComboBox *hosts; |
27 | pthread_t tpid; | 27 | pthread_t tpid; |
28 | bool scanning; | 28 | bool scanning; |
29 | bool isMounted(const QString &); | ||
29 | 30 | ||
30 | public slots: | 31 | public slots: |
31 | void clear(); | 32 | void clear(); |
32 | void scanClicked(); | 33 | void scanClicked(); |
33 | void hostSelected(int); | 34 | void hostSelected(int); |
34 | void DoItClicked(); | 35 | void DoItClicked(); |
36 | void umountIt(); | ||
35 | QString out; | 37 | QString out; |
36 | bool runCommand(const QStringList &); | 38 | bool runCommand(const QStringList &); |
37 | 39 | ||
38 | }; | 40 | }; |
39 | void* runit(void *arg); | 41 | void* runit(void *arg); |
40 | void* runitm(void *arg); | 42 | void* runitm(void *arg); |
41 | 43 | ||
42 | #endif // QSMB_H | 44 | #endif // QSMB_H |
diff --git a/noncore/net/opie-smb/qsmbbase.ui b/noncore/net/opie-smb/qsmbbase.ui index 297eb2a..4692282 100644 --- a/noncore/net/opie-smb/qsmbbase.ui +++ b/noncore/net/opie-smb/qsmbbase.ui | |||
@@ -2,26 +2,26 @@ | |||
2 | <class>FormQPESMBBase</class> | 2 | <class>FormQPESMBBase</class> |
3 | <widget> | 3 | <widget> |
4 | <class>QWidget</class> | 4 | <class>QWidget</class> |
5 | <property stdset="1"> | 5 | <property stdset="1"> |
6 | <name>name</name> | 6 | <name>name</name> |
7 | <cstring>FormQPESMBBase</cstring> | 7 | <cstring>FormQPESMBBase</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>250</width> | 14 | <width>259</width> |
15 | <height>352</height> | 15 | <height>395</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>font</name> | 19 | <name>font</name> |
20 | <font> | 20 | <font> |
21 | </font> | 21 | </font> |
22 | </property> | 22 | </property> |
23 | <property stdset="1"> | 23 | <property stdset="1"> |
24 | <name>caption</name> | 24 | <name>caption</name> |
25 | <string>Opie Smb</string> | 25 | <string>Opie Smb</string> |
26 | </property> | 26 | </property> |
27 | <property> | 27 | <property> |
@@ -59,25 +59,25 @@ | |||
59 | </property> | 59 | </property> |
60 | <attribute> | 60 | <attribute> |
61 | <name>title</name> | 61 | <name>title</name> |
62 | <string>Scan</string> | 62 | <string>Scan</string> |
63 | </attribute> | 63 | </attribute> |
64 | <grid> | 64 | <grid> |
65 | <property stdset="1"> | 65 | <property stdset="1"> |
66 | <name>margin</name> | 66 | <name>margin</name> |
67 | <number>2</number> | 67 | <number>2</number> |
68 | </property> | 68 | </property> |
69 | <property stdset="1"> | 69 | <property stdset="1"> |
70 | <name>spacing</name> | 70 | <name>spacing</name> |
71 | <number>0</number> | 71 | <number>2</number> |
72 | </property> | 72 | </property> |
73 | <widget row="1" column="0" rowspan="1" colspan="4" > | 73 | <widget row="1" column="0" rowspan="1" colspan="4" > |
74 | <class>QComboBox</class> | 74 | <class>QComboBox</class> |
75 | <property stdset="1"> | 75 | <property stdset="1"> |
76 | <name>name</name> | 76 | <name>name</name> |
77 | <cstring>CBHost</cstring> | 77 | <cstring>CBHost</cstring> |
78 | </property> | 78 | </property> |
79 | </widget> | 79 | </widget> |
80 | <widget row="4" column="1" rowspan="1" colspan="3" > | 80 | <widget row="4" column="1" rowspan="1" colspan="3" > |
81 | <class>QComboBox</class> | 81 | <class>QComboBox</class> |
82 | <property stdset="1"> | 82 | <property stdset="1"> |
83 | <name>name</name> | 83 | <name>name</name> |
@@ -127,24 +127,38 @@ | |||
127 | <name>text</name> | 127 | <name>text</name> |
128 | <string>Comment</string> | 128 | <string>Comment</string> |
129 | </property> | 129 | </property> |
130 | <property> | 130 | <property> |
131 | <name>clickable</name> | 131 | <name>clickable</name> |
132 | <bool>true</bool> | 132 | <bool>true</bool> |
133 | </property> | 133 | </property> |
134 | <property> | 134 | <property> |
135 | <name>resizeable</name> | 135 | <name>resizeable</name> |
136 | <bool>true</bool> | 136 | <bool>true</bool> |
137 | </property> | 137 | </property> |
138 | </column> | 138 | </column> |
139 | <column> | ||
140 | <property> | ||
141 | <name>text</name> | ||
142 | <string>Mount</string> | ||
143 | </property> | ||
144 | <property> | ||
145 | <name>clickable</name> | ||
146 | <bool>true</bool> | ||
147 | </property> | ||
148 | <property> | ||
149 | <name>resizeable</name> | ||
150 | <bool>true</bool> | ||
151 | </property> | ||
152 | </column> | ||
139 | <property stdset="1"> | 153 | <property stdset="1"> |
140 | <name>name</name> | 154 | <name>name</name> |
141 | <cstring>ListViewScan</cstring> | 155 | <cstring>ListViewScan</cstring> |
142 | </property> | 156 | </property> |
143 | <property stdset="1"> | 157 | <property stdset="1"> |
144 | <name>allColumnsShowFocus</name> | 158 | <name>allColumnsShowFocus</name> |
145 | <bool>true</bool> | 159 | <bool>true</bool> |
146 | </property> | 160 | </property> |
147 | </widget> | 161 | </widget> |
148 | <widget row="0" column="0" rowspan="1" colspan="2" > | 162 | <widget row="0" column="0" rowspan="1" colspan="2" > |
149 | <class>QPushButton</class> | 163 | <class>QPushButton</class> |
150 | <property stdset="1"> | 164 | <property stdset="1"> |
@@ -169,36 +183,25 @@ | |||
169 | </widget> | 183 | </widget> |
170 | <widget row="3" column="0" rowspan="1" colspan="3" > | 184 | <widget row="3" column="0" rowspan="1" colspan="3" > |
171 | <class>QCheckBox</class> | 185 | <class>QCheckBox</class> |
172 | <property stdset="1"> | 186 | <property stdset="1"> |
173 | <name>name</name> | 187 | <name>name</name> |
174 | <cstring>onbootBtn</cstring> | 188 | <cstring>onbootBtn</cstring> |
175 | </property> | 189 | </property> |
176 | <property stdset="1"> | 190 | <property stdset="1"> |
177 | <name>text</name> | 191 | <name>text</name> |
178 | <string>Reconnect on boot</string> | 192 | <string>Reconnect on boot</string> |
179 | </property> | 193 | </property> |
180 | </widget> | 194 | </widget> |
181 | <widget row="5" column="0" rowspan="1" colspan="2" > | 195 | <widget row="5" column="2" rowspan="2" colspan="2" > |
182 | <class>QPushButton</class> | ||
183 | <property stdset="1"> | ||
184 | <name>name</name> | ||
185 | <cstring>DoItBtn</cstring> | ||
186 | </property> | ||
187 | <property stdset="1"> | ||
188 | <name>text</name> | ||
189 | <string>&Mount</string> | ||
190 | </property> | ||
191 | </widget> | ||
192 | <widget row="5" column="2" rowspan="1" colspan="2" > | ||
193 | <class>QLayoutWidget</class> | 196 | <class>QLayoutWidget</class> |
194 | <property stdset="1"> | 197 | <property stdset="1"> |
195 | <name>name</name> | 198 | <name>name</name> |
196 | <cstring>Layout6</cstring> | 199 | <cstring>Layout6</cstring> |
197 | </property> | 200 | </property> |
198 | <grid> | 201 | <grid> |
199 | <property stdset="1"> | 202 | <property stdset="1"> |
200 | <name>margin</name> | 203 | <name>margin</name> |
201 | <number>0</number> | 204 | <number>0</number> |
202 | </property> | 205 | </property> |
203 | <property stdset="1"> | 206 | <property stdset="1"> |
204 | <name>spacing</name> | 207 | <name>spacing</name> |
@@ -267,44 +270,66 @@ | |||
267 | </widget> | 270 | </widget> |
268 | <widget> | 271 | <widget> |
269 | <class>QLineEdit</class> | 272 | <class>QLineEdit</class> |
270 | <property stdset="1"> | 273 | <property stdset="1"> |
271 | <name>name</name> | 274 | <name>name</name> |
272 | <cstring>username</cstring> | 275 | <cstring>username</cstring> |
273 | </property> | 276 | </property> |
274 | </widget> | 277 | </widget> |
275 | </hbox> | 278 | </hbox> |
276 | </widget> | 279 | </widget> |
277 | </grid> | 280 | </grid> |
278 | </widget> | 281 | </widget> |
282 | <widget row="6" column="0" rowspan="1" colspan="2" > | ||
283 | <class>QPushButton</class> | ||
284 | <property stdset="1"> | ||
285 | <name>name</name> | ||
286 | <cstring>UnmountBtn</cstring> | ||
287 | </property> | ||
288 | <property stdset="1"> | ||
289 | <name>text</name> | ||
290 | <string>&Umount</string> | ||
291 | </property> | ||
292 | </widget> | ||
293 | <widget row="5" column="0" rowspan="1" colspan="2" > | ||
294 | <class>QPushButton</class> | ||
295 | <property stdset="1"> | ||
296 | <name>name</name> | ||
297 | <cstring>DoItBtn</cstring> | ||
298 | </property> | ||
299 | <property stdset="1"> | ||
300 | <name>text</name> | ||
301 | <string>&Mount</string> | ||
302 | </property> | ||
303 | </widget> | ||
279 | </grid> | 304 | </grid> |
280 | </widget> | 305 | </widget> |
281 | <widget> | 306 | <widget> |
282 | <class>QWidget</class> | 307 | <class>QWidget</class> |
283 | <property stdset="1"> | 308 | <property stdset="1"> |
284 | <name>name</name> | 309 | <name>name</name> |
285 | <cstring>tab</cstring> | 310 | <cstring>tab</cstring> |
286 | </property> | 311 | </property> |
287 | <attribute> | 312 | <attribute> |
288 | <name>title</name> | 313 | <name>title</name> |
289 | <string>SMB Output</string> | 314 | <string>SMB Output</string> |
290 | </attribute> | 315 | </attribute> |
291 | <grid> | 316 | <grid> |
292 | <property stdset="1"> | 317 | <property stdset="1"> |
293 | <name>margin</name> | 318 | <name>margin</name> |
294 | <number>11</number> | 319 | <number>2</number> |
295 | </property> | 320 | </property> |
296 | <property stdset="1"> | 321 | <property stdset="1"> |
297 | <name>spacing</name> | 322 | <name>spacing</name> |
298 | <number>6</number> | 323 | <number>2</number> |
299 | </property> | 324 | </property> |
300 | <widget row="0" column="0" > | 325 | <widget row="0" column="0" > |
301 | <class>QTextView</class> | 326 | <class>QTextView</class> |
302 | <property stdset="1"> | 327 | <property stdset="1"> |
303 | <name>name</name> | 328 | <name>name</name> |
304 | <cstring>TextViewOutput</cstring> | 329 | <cstring>TextViewOutput</cstring> |
305 | </property> | 330 | </property> |
306 | <property stdset="1"> | 331 | <property stdset="1"> |
307 | <name>textFormat</name> | 332 | <name>textFormat</name> |
308 | <enum>PlainText</enum> | 333 | <enum>PlainText</enum> |
309 | </property> | 334 | </property> |
310 | </widget> | 335 | </widget> |