author | llornkcor <llornkcor> | 2005-08-16 09:32:25 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-08-16 09:32:25 (UTC) |
commit | 8c44cc4fdb67ea6b96cf7e49ec648de4049a9f1c (patch) (unidiff) | |
tree | 28fbe8466b5b93173513402f7b46e6c7ce5222ac | |
parent | 2176aa6c353e794798aa8ecddc28be365e94989c (diff) | |
download | opie-8c44cc4fdb67ea6b96cf7e49ec648de4049a9f1c.zip opie-8c44cc4fdb67ea6b96cf7e49ec648de4049a9f1c.tar.gz opie-8c44cc4fdb67ea6b96cf7e49ec648de4049a9f1c.tar.bz2 |
add current mount when selecting server
-rw-r--r-- | noncore/net/opie-smb/qsmb.cpp | 33 | ||||
-rw-r--r-- | noncore/net/opie-smb/qsmb.h | 1 |
2 files changed, 28 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 | |||
@@ -193,4 +193,5 @@ void Qsmb::hostSelected(int /*index*/ ) | |||
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 | ||
@@ -201,5 +202,8 @@ void Qsmb::hostSelected(int /*index*/ ) | |||
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; |
@@ -321,6 +325,4 @@ void Qsmb::DoIt() | |||
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..."); |
@@ -336,5 +338,5 @@ void Qsmb::DoIt() | |||
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"); |
@@ -399,5 +401,6 @@ bool Qsmb::runCommand(const QStringList & command) { | |||
399 | 401 | ||
400 | 402 | ||
401 | bool Qsmb::isMounted(const QString &mountPoint) { | 403 | bool Qsmb::isMounted(const QString &mountPoint) |
404 | { | ||
402 | struct mntent *me; | 405 | struct mntent *me; |
403 | bool mounted = false; | 406 | bool mounted = false; |
@@ -408,5 +411,5 @@ bool Qsmb::isMounted(const QString &mountPoint) { | |||
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 | } |
@@ -415,2 +418,20 @@ bool Qsmb::isMounted(const QString &mountPoint) { | |||
415 | return mounted; | 418 | return mounted; |
416 | } | 419 | } |
420 | |||
421 | QString 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 | } | ||
diff --git a/noncore/net/opie-smb/qsmb.h b/noncore/net/opie-smb/qsmb.h index fba94d0..abf27da 100644 --- a/noncore/net/opie-smb/qsmb.h +++ b/noncore/net/opie-smb/qsmb.h | |||
@@ -28,4 +28,5 @@ private: | |||
28 | bool scanning; | 28 | bool scanning; |
29 | bool isMounted(const QString &); | 29 | bool isMounted(const QString &); |
30 | QString getMount(const QString &); | ||
30 | 31 | ||
31 | public slots: | 32 | public slots: |