summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opie-smb/qsmb.cpp77
1 files changed, 39 insertions, 38 deletions
diff --git a/noncore/net/opie-smb/qsmb.cpp b/noncore/net/opie-smb/qsmb.cpp
index 8aa4987..d6d1b23 100644
--- a/noncore/net/opie-smb/qsmb.cpp
+++ b/noncore/net/opie-smb/qsmb.cpp
@@ -6,2 +6,3 @@
6#include <qstring.h> 6#include <qstring.h>
7#include <qstringlist.h>
7#include <qdir.h> 8#include <qdir.h>
@@ -24,2 +25,8 @@
24 25
26#include <netinet/in.h>
27#include <arpa/inet.h>
28
29#include <rpc/clnt.h>
30
31
25#include <opie2/odebug.h> 32#include <opie2/odebug.h>
@@ -94,3 +101,4 @@ void Qsmb::scan()
94 101
95 char match[512], lmhosts[512]; 102 QString match;
103 char lmhosts[512];
96 QString cmd; 104 QString cmd;
@@ -103,18 +111,9 @@ void Qsmb::scan()
103 111
104 cmd = "ifconfig |grep 'addr:'|awk '{print $2}'|awk 'BEGIN{FS=\":\"}{print $2}'|sed 's/\\.[0-9]*$//'|head -n1"; 112 sockaddr_in my_addr;
113 get_myaddress( &my_addr);
105 114
106 owarn << "cmd: " << cmd << oendl; 115 QString ip = inet_ntoa( my_addr.sin_addr);
116 owarn << "IP Address : " << ip<< oendl;
107 117
108 /* run findsmb & read output */ 118 match = ip.left(5);
109 if ((pipe = popen(cmd.latin1(), "r")) == NULL) {
110 snprintf(result, 256, "Error: Can't run %s", cmd.latin1());
111 TextViewOutput->append(result);
112 return;
113 }
114 while(fgets(result, 256, pipe) != NULL) {
115 strcpy( match, result);
116 match[5]='\0';
117 break;
118 }
119 owarn << "match: " << match << oendl;
120 119
@@ -145,3 +144,3 @@ void Qsmb::scan()
145 144
146 if( strstr(result, match) != NULL ) { 145 if( strstr(result, match.latin1()) != NULL ) {
147 char ip_addr[256], host[256], *ptr1; 146 char ip_addr[256], host[256], *ptr1;
@@ -285,2 +284,3 @@ void Qsmb::DoIt()
285 int i; 284 int i;
285 bool err = false;
286 286
@@ -300,15 +300,22 @@ void Qsmb::DoIt()
300 if(! QFileInfo(text).exists()) { 300 if(! QFileInfo(text).exists()) {
301 cmd = "mkdir -p "+ text; 301// /* make sure mount exists! */
302 owarn<<"cmd: "<< cmd << oendl; 302
303 /* make sure mount exists! */ 303// cmd = "mkdir -p "+ text;
304 if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { 304// owarn<<"cmd: "<< cmd << oendl;
305 snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); 305// if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) {
306 // result = "Error: Can't run " + cmd; 306// snprintf(result, 256, "Error: Can't run %s", cmd.latin1());
307 TextViewOutput->append(result); 307// TextViewOutput->append(result);
308 return; 308// return;
309 } 309// }
310 while(fgets(result, 256, pipe2) != NULL) { 310// while(fgets(result, 256, pipe2) != NULL) {
311 /* put result into TextViewOutput */ 311// /* put result into TextViewOutput */
312 TextViewOutput->append(result); 312// TextViewOutput->append(result);
313 } 313// }
314 QStringList ccmd;
315 ccmd << "mkdir";
316 ccmd << "-p";
317 ccmd << text;
318
319 owarn<<"cmd: "<< ccmd << oendl;
320 runCommand(ccmd);
314 } 321 }
@@ -334,9 +341,5 @@ void Qsmb::DoIt()
334 cmd2 = "echo '" + cmd + "'>/opt/QtPalmtop/etc/samba.env"; 341 cmd2 = "echo '" + cmd + "'>/opt/QtPalmtop/etc/samba.env";
335
336 /* run command & read output */ 342 /* run command & read output */
337 if ((pipe = popen(cmd2.latin1(), "r")) == NULL) { 343 if ((pipe = popen(cmd2.latin1(), "r")) == NULL) {
338
339 snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); 344 snprintf(result, 256, "Error: Can't run %s", cmd.latin1());
340// result = "Error: Can't run "+ cmd;
341 //TextViewOutput->append(result);
342 return; 345 return;
@@ -345,4 +348,2 @@ void Qsmb::DoIt()
345 while(fgets(result, 256, pipe) != NULL) { 348 while(fgets(result, 256, pipe) != NULL) {
346 /* put result into TextViewOutput */
347 //TextViewOutput->append(result);
348 } 349 }
@@ -350,8 +351,6 @@ void Qsmb::DoIt()
350 351
352
351 /* run command & read output */ 353 /* run command & read output */
352 if ((pipe = popen(cmd.latin1(), "r")) == NULL) { 354 if ((pipe = popen(cmd.latin1(), "r")) == NULL) {
353
354// result = "Error: Can't run "+ cmd;
355 snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); 355 snprintf(result, 256, "Error: Can't run %s", cmd.latin1());
356
357 TextViewOutput->append(result); 356 TextViewOutput->append(result);
@@ -365,2 +364,4 @@ void Qsmb::DoIt()
365 } 364 }
365
366
366 TextViewOutput->append("\n\n================CheckMounts==================\n"); 367 TextViewOutput->append("\n\n================CheckMounts==================\n");