summaryrefslogtreecommitdiff
path: root/noncore/net/opie-smb/qsmb.cpp
Unidiff
Diffstat (limited to 'noncore/net/opie-smb/qsmb.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opie-smb/qsmb.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/noncore/net/opie-smb/qsmb.cpp b/noncore/net/opie-smb/qsmb.cpp
index e2ddc7f..7f3ae89 100644
--- a/noncore/net/opie-smb/qsmb.cpp
+++ b/noncore/net/opie-smb/qsmb.cpp
@@ -191,17 +191,21 @@ void Qsmb::hostSelected(int /*index*/ )
191 191
192 while ( !s.atEnd() ) { 192 while ( !s.atEnd() ) {
193 QString share; 193 QString share;
194 QString comment; 194 QString comment;
195 QString mount;
195 QString tmp = s.readLine(); 196 QString tmp = s.readLine();
196 197
197 if( tmp.find("$") == -1 && tmp.find("Disk") != -1) { 198 if( tmp.find("$") == -1 && tmp.find("Disk") != -1) {
198 QStringList token = QStringList::split(' ', tmp ); 199 QStringList token = QStringList::split(' ', tmp );
199 share = token[0]; 200 share = token[0];
200 comment = token[2]; 201 comment = token[2];
201 share = share.stripWhiteSpace(); 202 share = share.stripWhiteSpace();
202 comment = comment.stripWhiteSpace(); 203 comment = comment.stripWhiteSpace();
203 element = new QListViewItem(ListViewScan, share, comment); 204// if(isMounted(share))
205
206 mount = getMount(share);
207 element = new QListViewItem(ListViewScan, share, comment, mount);
204 element->setOpen(true); 208 element->setOpen(true);
205// top_element = element; 209// top_element = element;
206// parent = element; 210// parent = element;
207 } 211 }
@@ -319,10 +323,8 @@ void Qsmb::DoIt()
319 ccmd << mount; 323 ccmd << mount;
320 ccmd << "-o"; 324 ccmd << "-o";
321 ccmd << "username="+username->text()+",password="+password->text()+""; 325 ccmd << "username="+username->text()+",password="+password->text()+"";
322 326
323 TextViewOutput->append(ccmd.join(" ").latin1());
324
325 if(onbootBtn->isChecked()) { 327 if(onbootBtn->isChecked()) {
326 qWarning("Saving Setting permanently..."); 328 qWarning("Saving Setting permanently...");
327 QFile sambenv("/opt/QtPalmtop/etc/samba.env"); 329 QFile sambenv("/opt/QtPalmtop/etc/samba.env");
328 QTextStream smbv(&sambenv); 330 QTextStream smbv(&sambenv);
@@ -334,9 +336,9 @@ void Qsmb::DoIt()
334 noerr = runCommand(ccmd); 336 noerr = runCommand(ccmd);
335 337
336 LScan->setText(""); 338 LScan->setText("");
337 339
338 if(noerr) { 340 if(noerr && isMounted(mount)) {
339 element->setText(2, mount); 341 element->setText(2, mount);
340 TextViewOutput->append("\n\n================CheckMounts==================\n"); 342 TextViewOutput->append("\n\n================CheckMounts==================\n");
341 ccmd = "/bin/mount"; 343 ccmd = "/bin/mount";
342 runCommand(ccmd); 344 runCommand(ccmd);
@@ -397,20 +399,39 @@ bool Qsmb::runCommand(const QStringList & command) {
397 return r; 399 return r;
398} 400}
399 401
400 402
401bool Qsmb::isMounted(const QString &mountPoint) { 403bool Qsmb::isMounted(const QString &mountPoint)
404{
402 struct mntent *me; 405 struct mntent *me;
403 bool mounted = false; 406 bool mounted = false;
404 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 407 FILE *mntfp = setmntent( "/etc/mtab", "r" );
405 if ( mntfp ){ 408 if ( mntfp ){
406 while ( (me = getmntent( mntfp )) != 0 ) { 409 while ( (me = getmntent( mntfp )) != 0 ) {
407 QString deviceName = me->mnt_fsname; 410 QString deviceName = me->mnt_fsname;
408 QString mountDir = me->mnt_dir; 411 QString mountDir = me->mnt_dir;
409 QString fsType = me->mnt_type; 412 QString fsType = me->mnt_type;
410 if( fsType == "smbfs" && mountDir.find(mountPoint) !=-1) 413 if( fsType == "smbfs" && (mountDir.find(mountPoint) != -1 | deviceName.find(mountPoint) != -1))
411 mounted = true; 414 mounted = true;
412 } 415 }
413 } 416 }
414 endmntent( mntfp ); 417 endmntent( mntfp );
415 return mounted; 418 return mounted;
416} 419}
420
421QString Qsmb::getMount(const QString &shareName)
422{
423 struct mntent *me;
424 QString mount;
425 FILE *mntfp = setmntent( "/etc/mtab", "r" );
426 if ( mntfp ){
427 while ( (me = getmntent( mntfp )) != 0 ) {
428 QString deviceName = me->mnt_fsname;
429 QString mountDir = me->mnt_dir;
430 QString fsType = me->mnt_type;
431 if( fsType == "smbfs" && deviceName.find(shareName) != -1)
432 mount = mountDir;
433 }
434 }
435 endmntent( mntfp );
436 return mount;
437}