author | llornkcor <llornkcor> | 2005-08-14 21:45:59 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-08-14 21:45:59 (UTC) |
commit | 1dc2675c1bf557ba0032781535faf033809bae48 (patch) (unidiff) | |
tree | a949c816bc2fcc3213b38f4b5aed54254f7bd7c0 | |
parent | ab6f37a50ef2a0d95f25eff4a749bfcf39057d65 (diff) | |
download | opie-1dc2675c1bf557ba0032781535faf033809bae48.zip opie-1dc2675c1bf557ba0032781535faf033809bae48.tar.gz opie-1dc2675c1bf557ba0032781535faf033809bae48.tar.bz2 |
use shell script smbfind and not perl script findsmb
-rw-r--r-- | noncore/net/opie-smb/opie-smb.control | 2 | ||||
-rw-r--r-- | noncore/net/opie-smb/qsmb.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/opie-smb/opie-smb.control b/noncore/net/opie-smb/opie-smb.control index 98a23b4..fc8c316 100644 --- a/noncore/net/opie-smb/opie-smb.control +++ b/noncore/net/opie-smb/opie-smb.control | |||
@@ -1,11 +1,11 @@ | |||
1 | Package: opie-smb | 1 | Package: opie-smb |
2 | Files: plugins/application/libopie-smb.so* bin/opie-smb pics/opie-smb apps/Applications/opie-smb.desktop | 2 | Files: plugins/application/libopie-smb.so* bin/opie-smb bin/smbfind pics/opie-smb apps/Applications/opie-smb.desktop |
3 | Version: $QPE_VERSION$EXTRAVERSION | 3 | Version: $QPE_VERSION$EXTRAVERSION |
4 | Architecture: arm | 4 | Architecture: arm |
5 | Arch: arm | 5 | Arch: arm |
6 | Maintainer: Kurt Korbatits (support@midget.net.au) | 6 | Maintainer: Kurt Korbatits (support@midget.net.au) |
7 | Section: Network | 7 | Section: Network |
8 | Priority: optional | 8 | Priority: optional |
9 | Description: Gui front end for samba utilities. | 9 | Description: Gui front end for samba utilities. |
10 | Source: | 10 | Source: |
11 | Depends: smbclient | 11 | Depends: smbclient |
diff --git a/noncore/net/opie-smb/qsmb.cpp b/noncore/net/opie-smb/qsmb.cpp index 527ab38..880573b 100644 --- a/noncore/net/opie-smb/qsmb.cpp +++ b/noncore/net/opie-smb/qsmb.cpp | |||
@@ -1,402 +1,402 @@ | |||
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 <qdir.h> | 7 | #include <qdir.h> |
8 | #include <qfileinfo.h> | 8 | #include <qfileinfo.h> |
9 | 9 | ||
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include <qlineedit.h> | 11 | #include <qlineedit.h> |
12 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
13 | #include <qstringlist.h> | 13 | #include <qstringlist.h> |
14 | #include <qcheckbox.h> | 14 | #include <qcheckbox.h> |
15 | #include <qtextview.h> | 15 | #include <qtextview.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | 17 | ||
18 | 18 | ||
19 | #include <pthread.h> | 19 | #include <pthread.h> |
20 | #include <signal.h> | 20 | #include <signal.h> |
21 | #include <ctype.h> | 21 | #include <ctype.h> |
22 | 22 | ||
23 | 23 | ||
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | using namespace Opie::Core; | 25 | using namespace Opie::Core; |
26 | 26 | ||
27 | 27 | ||
28 | Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) | 28 | Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) |
29 | : FormQPESMBBase( parent, name, fl ) | 29 | : FormQPESMBBase( parent, name, fl ) |
30 | { | 30 | { |
31 | connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); | 31 | connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); |
32 | connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); | 32 | connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); |
33 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); | 33 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); |
34 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); | 34 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); |
35 | 35 | ||
36 | //TODO configurable mount points | 36 | //TODO configurable mount points |
37 | if(!QFileInfo("/mnt/samba1").exists()) system("mkdir /mnt/samba1"); | 37 | if(!QFileInfo("/mnt/samba1").exists()) system("mkdir /mnt/samba1"); |
38 | if(!QFileInfo("/mnt/samba2").exists()) system("mkdir /mnt/samba2"); | 38 | if(!QFileInfo("/mnt/samba2").exists()) system("mkdir /mnt/samba2"); |
39 | if(!QFileInfo("/mnt/samba2").exists()) system("mkdir /mnt/samba3"); | 39 | if(!QFileInfo("/mnt/samba2").exists()) system("mkdir /mnt/samba3"); |
40 | 40 | ||
41 | mountpt->insertItem("/mnt/samba1",-1); | 41 | mountpt->insertItem("/mnt/samba1",-1); |
42 | mountpt->insertItem("/mnt/samba2",-1); | 42 | mountpt->insertItem("/mnt/samba2",-1); |
43 | mountpt->insertItem("/mnt/samba3",-1); | 43 | mountpt->insertItem("/mnt/samba3",-1); |
44 | 44 | ||
45 | top_element = NULL; | 45 | top_element = NULL; |
46 | scanning = false; | 46 | scanning = false; |
47 | } | 47 | } |
48 | 48 | ||
49 | Qsmb::~Qsmb() | 49 | Qsmb::~Qsmb() |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | void Qsmb::clear() | 53 | void Qsmb::clear() |
54 | { | 54 | { |
55 | if (scanning) return; | 55 | if (scanning) return; |
56 | ListViewScan->clear(); | 56 | ListViewScan->clear(); |
57 | TextViewOutput->setText(""); | 57 | TextViewOutput->setText(""); |
58 | top_element = NULL; | 58 | top_element = NULL; |
59 | } | 59 | } |
60 | 60 | ||
61 | void Qsmb::scanClicked() | 61 | void Qsmb::scanClicked() |
62 | { | 62 | { |
63 | if (scanning) return; | 63 | if (scanning) return; |
64 | pthread_create(&tpid, NULL, runit, (void *)this); | 64 | pthread_create(&tpid, NULL, runit, (void *)this); |
65 | } | 65 | } |
66 | 66 | ||
67 | void Qsmb::DoItClicked() | 67 | void Qsmb::DoItClicked() |
68 | { | 68 | { |
69 | 69 | ||
70 | if(! ListViewScan->selectedItem()) { | 70 | if(! ListViewScan->selectedItem()) { |
71 | QMessageBox::warning(this, tr("Error"),tr("<p>No share selected!</p>")); | 71 | QMessageBox::warning(this, tr("Error"),tr("<p>No share selected!</p>")); |
72 | return; | 72 | return; |
73 | } | 73 | } |
74 | if (scanning) return; | 74 | if (scanning) return; |
75 | pthread_create(&tpid, NULL, runitm, (void *)this); | 75 | pthread_create(&tpid, NULL, runitm, (void *)this); |
76 | } | 76 | } |
77 | 77 | ||
78 | void* runit(void* arg) | 78 | void* runit(void* arg) |
79 | { | 79 | { |
80 | Qsmb* caller = (Qsmb*)arg; | 80 | Qsmb* caller = (Qsmb*)arg; |
81 | caller->scan(); | 81 | caller->scan(); |
82 | return(0); | 82 | return(0); |
83 | } | 83 | } |
84 | 84 | ||
85 | void* runitm(void* arg) | 85 | void* runitm(void* arg) |
86 | { | 86 | { |
87 | Qsmb* caller = (Qsmb*)arg; | 87 | Qsmb* caller = (Qsmb*)arg; |
88 | caller->DoIt(); | 88 | caller->DoIt(); |
89 | return(0); | 89 | return(0); |
90 | } | 90 | } |
91 | 91 | ||
92 | void Qsmb::scan() | 92 | void Qsmb::scan() |
93 | { | 93 | { |
94 | int i; | 94 | int i; |
95 | 95 | ||
96 | if (scanning) return; | 96 | if (scanning) return; |
97 | scanning = true; | 97 | scanning = true; |
98 | 98 | ||
99 | char match[512], lmhosts[512]; | 99 | char match[512], lmhosts[512]; |
100 | QString cmd; | 100 | QString cmd; |
101 | char result[256]; | 101 | char result[256]; |
102 | 102 | ||
103 | FILE *pipe, *pipe2; | 103 | FILE *pipe, *pipe2; |
104 | 104 | ||
105 | LScan->setText("Scanning..."); | 105 | LScan->setText("Scanning..."); |
106 | qApp->processEvents(); | 106 | qApp->processEvents(); |
107 | 107 | ||
108 | cmd = "ifconfig |grep 'addr:'|awk '{print $2}'|awk 'BEGIN{FS=\":\"}{print $2}'|sed 's/\\.[0-9]*$//'|head -n1"; | 108 | cmd = "ifconfig |grep 'addr:'|awk '{print $2}'|awk 'BEGIN{FS=\":\"}{print $2}'|sed 's/\\.[0-9]*$//'|head -n1"; |
109 | 109 | ||
110 | owarn << "cmd: " << cmd << oendl; | 110 | owarn << "cmd: " << cmd << oendl; |
111 | 111 | ||
112 | /* run findsmb & read output */ | 112 | /* run findsmb & read output */ |
113 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { | 113 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { |
114 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 114 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
115 | TextViewOutput->append(result); | 115 | TextViewOutput->append(result); |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | while(fgets(result, 256, pipe) != NULL) { | 118 | while(fgets(result, 256, pipe) != NULL) { |
119 | strcpy( match, result); | 119 | strcpy( match, result); |
120 | match[5]='\0'; | 120 | match[5]='\0'; |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | owarn << "match: " << match << oendl; | 123 | owarn << "match: " << match << oendl; |
124 | 124 | ||
125 | cmd = "/usr/bin/findsmb"; | 125 | cmd = "smbfind"; |
126 | owarn <<"cmd: " << cmd << oendl; | 126 | owarn <<"cmd: " << cmd << oendl; |
127 | 127 | ||
128 | TextViewOutput->append(cmd); | 128 | TextViewOutput->append(cmd); |
129 | 129 | ||
130 | snprintf(lmhosts, 512, "echo '127.0.0.1 localhost'>/etc/samba/lmhosts"); | 130 | snprintf(lmhosts, 512, "echo '127.0.0.1 localhost'>/etc/samba/lmhosts"); |
131 | 131 | ||
132 | if ((pipe2 = popen(lmhosts, "r")) == NULL) { | 132 | if ((pipe2 = popen(lmhosts, "r")) == NULL) { |
133 | snprintf(result, 256, "Error: Can't run %s", lmhosts); | 133 | snprintf(result, 256, "Error: Can't run %s", lmhosts); |
134 | //TextViewOutput->append(result); | 134 | //TextViewOutput->append(result); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | 137 | ||
138 | /* run command & read output */ | 138 | /* run command & read output */ |
139 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { | 139 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { |
140 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 140 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
141 | TextViewOutput->append(result); | 141 | TextViewOutput->append(result); |
142 | return; | 142 | return; |
143 | } | 143 | } |
144 | 144 | ||
145 | /* parse output and display in ListViewScan */ | 145 | /* parse output and display in ListViewScan */ |
146 | while(fgets(result, 256, pipe) != NULL) { | 146 | while(fgets(result, 256, pipe) != NULL) { |
147 | /* put result into TextViewOutput */ | 147 | /* put result into TextViewOutput */ |
148 | TextViewOutput->append(result); | 148 | TextViewOutput->append(result); |
149 | 149 | ||
150 | if( strstr(result, match) != NULL ) { | 150 | if( strstr(result, match) != NULL ) { |
151 | char ip_addr[256], host[256], *ptr1; | 151 | char ip_addr[256], host[256], *ptr1; |
152 | 152 | ||
153 | strcpy( ip_addr, result); | 153 | strcpy( ip_addr, result); |
154 | ptr1 = strchr(ip_addr,' '); | 154 | ptr1 = strchr(ip_addr,' '); |
155 | strcpy( host, ptr1); | 155 | strcpy( host, ptr1); |
156 | ip_addr[ptr1 - ip_addr]='\0'; | 156 | ip_addr[ptr1 - ip_addr]='\0'; |
157 | 157 | ||
158 | for(i = 0; i < 256; i++) { | 158 | for(i = 0; i < 256; i++) { |
159 | if(host[i]!=' ') { | 159 | if(host[i]!=' ') { |
160 | strcpy( host, host + i); | 160 | strcpy( host, host + i); |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | ptr1 = strchr(host,' '); | 164 | ptr1 = strchr(host,' '); |
165 | host[ptr1 - host] = '\0'; | 165 | host[ptr1 - host] = '\0'; |
166 | 166 | ||
167 | owarn << "add host: " << host << oendl; | 167 | owarn << "add host: " << host << oendl; |
168 | 168 | ||
169 | CBHost->insertItem( host, -1); | 169 | CBHost->insertItem( host, -1); |
170 | snprintf( lmhosts, 512, "echo '%s %s'>>/etc/samba/lmhosts", ip_addr,host); | 170 | snprintf( lmhosts, 512, "echo '%s %s'>>/etc/samba/lmhosts", ip_addr,host); |
171 | 171 | ||
172 | owarn << "lmhosts: " << lmhosts << oendl; | 172 | owarn << "lmhosts: " << lmhosts << oendl; |
173 | 173 | ||
174 | if ((pipe2 = popen(lmhosts, "r")) == NULL) { | 174 | if ((pipe2 = popen(lmhosts, "r")) == NULL) { |
175 | snprintf(result, 256, "Error: Can't run %s", lmhosts); | 175 | snprintf(result, 256, "Error: Can't run %s", lmhosts); |
176 | return; | 176 | return; |
177 | } | 177 | } |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | TextViewOutput->append("\n\n============================================\n"); | 181 | TextViewOutput->append("\n\n============================================\n"); |
182 | LScan->setText(""); | 182 | LScan->setText(""); |
183 | scanning = false; | 183 | scanning = false; |
184 | } | 184 | } |
185 | 185 | ||
186 | void Qsmb::hostSelected(int index) | 186 | void Qsmb::hostSelected(int index) |
187 | { | 187 | { |
188 | owarn << "hostSelected" << oendl; | 188 | owarn << "hostSelected" << oendl; |
189 | int i; | 189 | int i; |
190 | 190 | ||
191 | QListViewItem *element; | 191 | QListViewItem *element; |
192 | QListViewItem *parent; | 192 | QListViewItem *parent; |
193 | 193 | ||
194 | QString text = CBHost->currentText(); | 194 | QString text = CBHost->currentText(); |
195 | 195 | ||
196 | if (scanning) return; | 196 | if (scanning) return; |
197 | scanning = true; | 197 | scanning = true; |
198 | 198 | ||
199 | QString cmd; | 199 | QString cmd; |
200 | char result[256]; | 200 | char result[256]; |
201 | 201 | ||
202 | FILE *pipe; | 202 | FILE *pipe; |
203 | 203 | ||
204 | LScan->setText("Scanning..."); | 204 | LScan->setText("Scanning..."); |
205 | 205 | ||
206 | if((const char *)username->text() == '\0') | 206 | if((const char *)username->text() == '\0') |
207 | cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N 2>&1 |grep Disk"; | 207 | cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N 2>&1 |grep Disk"; |
208 | else | 208 | else |
209 | cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N -U"+username->text()+":"+password->text()+" 2>&1 |grep Disk"; | 209 | cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N -U"+username->text()+":"+password->text()+" 2>&1 |grep Disk"; |
210 | 210 | ||
211 | for(i = 0; i < 512; i++) { | 211 | for(i = 0; i < 512; i++) { |
212 | if(cmd[i]==':') { | 212 | if(cmd[i]==':') { |
213 | cmd[i]='%'; | 213 | cmd[i]='%'; |
214 | break; | 214 | break; |
215 | } | 215 | } |
216 | if(cmd[i]=='\0') | 216 | if(cmd[i]=='\0') |
217 | break; | 217 | break; |
218 | } | 218 | } |
219 | 219 | ||
220 | owarn << "i="<< index << "cmd:" << cmd << oendl; | 220 | owarn << "i="<< index << "cmd:" << cmd << oendl; |
221 | 221 | ||
222 | TextViewOutput->append(cmd); | 222 | TextViewOutput->append(cmd); |
223 | 223 | ||
224 | /* run smbclient & read output */ | 224 | /* run smbclient & read output */ |
225 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { | 225 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { |
226 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 226 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
227 | // cmd = "Error: Can't run "+cmd; | 227 | // cmd = "Error: Can't run "+cmd; |
228 | TextViewOutput->append(result); | 228 | TextViewOutput->append(result); |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | 231 | ||
232 | /* parse output and display in ListViewScan */ | 232 | /* parse output and display in ListViewScan */ |
233 | while(fgets(result, 256, pipe) != NULL) { | 233 | while(fgets(result, 256, pipe) != NULL) { |
234 | /* put result into TextViewOutput */ | 234 | /* put result into TextViewOutput */ |
235 | TextViewOutput->append(result); | 235 | TextViewOutput->append(result); |
236 | 236 | ||
237 | if( strchr(result, '$') == NULL ) { | 237 | if( strchr(result, '$') == NULL ) { |
238 | char share[256], *ptr1; | 238 | char share[256], *ptr1; |
239 | 239 | ||
240 | strcpy(share,result); | 240 | strcpy(share,result); |
241 | ptr1 = strchr(share,' '); | 241 | ptr1 = strchr(share,' '); |
242 | share[ptr1 - share]='\0'; | 242 | share[ptr1 - share]='\0'; |
243 | 243 | ||
244 | owarn<< "add share: " << share << oendl; | 244 | owarn<< "add share: " << share << oendl; |
245 | 245 | ||
246 | if(top_element != NULL) { | 246 | if(top_element != NULL) { |
247 | bool found = false; | 247 | bool found = false; |
248 | element = top_element; | 248 | element = top_element; |
249 | 249 | ||
250 | while(element != NULL && !found) { | 250 | while(element != NULL && !found) { |
251 | if(strcmp( element->text(0).ascii(), share)==0) { | 251 | if(strcmp( element->text(0).ascii(), share)==0) { |
252 | parent = element; | 252 | parent = element; |
253 | found = true; | 253 | found = true; |
254 | } | 254 | } |
255 | element = element->nextSibling(); | 255 | element = element->nextSibling(); |
256 | } | 256 | } |
257 | 257 | ||
258 | if(!found) { | 258 | if(!found) { |
259 | element = new QListViewItem(ListViewScan,share); | 259 | element = new QListViewItem(ListViewScan,share); |
260 | element->setOpen(true); | 260 | element->setOpen(true); |
261 | parent=element; | 261 | parent=element; |
262 | } | 262 | } |
263 | } else { | 263 | } else { |
264 | element = new QListViewItem(ListViewScan,share); | 264 | element = new QListViewItem(ListViewScan,share); |
265 | element->setOpen(true); | 265 | element->setOpen(true); |
266 | top_element = element; | 266 | top_element = element; |
267 | parent = element; | 267 | parent = element; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | TextViewOutput->append("\n\n============================================\n"); | 272 | TextViewOutput->append("\n\n============================================\n"); |
273 | LScan->setText(""); | 273 | LScan->setText(""); |
274 | scanning = false; | 274 | scanning = false; |
275 | } | 275 | } |
276 | 276 | ||
277 | void Qsmb::DoIt() | 277 | void Qsmb::DoIt() |
278 | { | 278 | { |
279 | QListViewItem *element; | 279 | QListViewItem *element; |
280 | element = ListViewScan->selectedItem(); | 280 | element = ListViewScan->selectedItem(); |
281 | if(!element) { | 281 | if(!element) { |
282 | QMessageBox::warning(this, tr("Error!!"),tr("<p><b>No</b> share selected!!</p>")); | 282 | QMessageBox::warning(this, tr("Error!!"),tr("<p><b>No</b> share selected!!</p>")); |
283 | return; | 283 | return; |
284 | } | 284 | } |
285 | 285 | ||
286 | if (scanning) return; | 286 | if (scanning) return; |
287 | scanning = true; | 287 | scanning = true; |
288 | 288 | ||
289 | int i; | 289 | int i; |
290 | 290 | ||
291 | char share[512]; | 291 | char share[512]; |
292 | QString cmd; | 292 | QString cmd; |
293 | QString cmd2; | 293 | QString cmd2; |
294 | char result[256]; | 294 | char result[256]; |
295 | // QString result; | 295 | // QString result; |
296 | QString text = mountpt->currentText(); | 296 | QString text = mountpt->currentText(); |
297 | 297 | ||
298 | FILE *pipe,*pipe2; | 298 | FILE *pipe,*pipe2; |
299 | 299 | ||
300 | LScan->setText("Mounting..."); | 300 | LScan->setText("Mounting..."); |
301 | qApp->processEvents(); | 301 | qApp->processEvents(); |
302 | 302 | ||
303 | cmd = "mkdir -p "+ text; | 303 | cmd = "mkdir -p "+ text; |
304 | 304 | ||
305 | owarn<<"cmd: "<< cmd << oendl; | 305 | owarn<<"cmd: "<< cmd << oendl; |
306 | 306 | ||
307 | /* make sure mount exists! */ | 307 | /* make sure mount exists! */ |
308 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { | 308 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { |
309 | 309 | ||
310 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 310 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
311 | // result = "Error: Can't run " + cmd; | 311 | // result = "Error: Can't run " + cmd; |
312 | TextViewOutput->append(result); | 312 | TextViewOutput->append(result); |
313 | return; | 313 | return; |
314 | } | 314 | } |
315 | 315 | ||
316 | while(fgets(result, 256, pipe2) != NULL) { | 316 | while(fgets(result, 256, pipe2) != NULL) { |
317 | /* put result into TextViewOutput */ | 317 | /* put result into TextViewOutput */ |
318 | TextViewOutput->append(result); | 318 | TextViewOutput->append(result); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | strcpy(share,(const char *)element->text(0)); | 322 | strcpy(share,(const char *)element->text(0)); |
323 | 323 | ||
324 | for(i = 0; i < 256; i++) { | 324 | for(i = 0; i < 256; i++) { |
325 | if(isalpha( share[i])) { | 325 | if(isalpha( share[i])) { |
326 | strcpy( share, share + i); | 326 | strcpy( share, share + i); |
327 | break; | 327 | break; |
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | cmd = "/usr/bin/smbmount //"+CBHost->currentText()+"/"+share+" "+mountpt->currentText()+" -U"+username->text()+":"+password->text(); | 331 | cmd = "/usr/bin/smbmount //"+CBHost->currentText()+"/"+share+" "+mountpt->currentText()+" -U"+username->text()+":"+password->text(); |
332 | 332 | ||
333 | for(i = 0; i < 512; i++) { | 333 | for(i = 0; i < 512; i++) { |
334 | if(cmd[i]==':') { | 334 | if(cmd[i]==':') { |
335 | cmd[i]='%'; | 335 | cmd[i]='%'; |
336 | break; | 336 | break; |
337 | } | 337 | } |
338 | if(cmd[i]=='\0') | 338 | if(cmd[i]=='\0') |
339 | break; | 339 | break; |
340 | } | 340 | } |
341 | 341 | ||
342 | owarn << "cmd: " << cmd << oendl; | 342 | owarn << "cmd: " << cmd << oendl; |
343 | TextViewOutput->append(cmd.latin1()); | 343 | TextViewOutput->append(cmd.latin1()); |
344 | 344 | ||
345 | 345 | ||
346 | if(onbootBtn->isChecked()) { | 346 | if(onbootBtn->isChecked()) { |
347 | owarn << "Saving Setting permanently..." << oendl; | 347 | owarn << "Saving Setting permanently..." << oendl; |
348 | cmd2 = "echo '" + cmd + "'>/opt/QtPalmtop/etc/samba.env"; | 348 | cmd2 = "echo '" + cmd + "'>/opt/QtPalmtop/etc/samba.env"; |
349 | 349 | ||
350 | /* run command & read output */ | 350 | /* run command & read output */ |
351 | if ((pipe = popen(cmd2.latin1(), "r")) == NULL) { | 351 | if ((pipe = popen(cmd2.latin1(), "r")) == NULL) { |
352 | 352 | ||
353 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 353 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
354 | // result = "Error: Can't run "+ cmd; | 354 | // result = "Error: Can't run "+ cmd; |
355 | //TextViewOutput->append(result); | 355 | //TextViewOutput->append(result); |
356 | return; | 356 | return; |
357 | } | 357 | } |
358 | /* parse output and display in ListViewScan */ | 358 | /* parse output and display in ListViewScan */ |
359 | while(fgets(result, 256, pipe) != NULL) { | 359 | while(fgets(result, 256, pipe) != NULL) { |
360 | /* put result into TextViewOutput */ | 360 | /* put result into TextViewOutput */ |
361 | //TextViewOutput->append(result); | 361 | //TextViewOutput->append(result); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | /* run command & read output */ | 365 | /* run command & read output */ |
366 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { | 366 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { |
367 | 367 | ||
368 | // result = "Error: Can't run "+ cmd; | 368 | // result = "Error: Can't run "+ cmd; |
369 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 369 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
370 | 370 | ||
371 | TextViewOutput->append(result); | 371 | TextViewOutput->append(result); |
372 | return; | 372 | return; |
373 | } | 373 | } |
374 | 374 | ||
375 | /* parse output and display in ListViewScan */ | 375 | /* parse output and display in ListViewScan */ |
376 | while(fgets(result, 256, pipe) != NULL) { | 376 | while(fgets(result, 256, pipe) != NULL) { |
377 | /* put result into TextViewOutput */ | 377 | /* put result into TextViewOutput */ |
378 | TextViewOutput->append(result); | 378 | TextViewOutput->append(result); |
379 | } | 379 | } |
380 | TextViewOutput->append("\n\n================CheckMounts==================\n"); | 380 | TextViewOutput->append("\n\n================CheckMounts==================\n"); |
381 | LScan->setText(""); | 381 | LScan->setText(""); |
382 | 382 | ||
383 | cmd = "/bin/mount 2>&1"; | 383 | cmd = "/bin/mount 2>&1"; |
384 | owarn << "cmd: " << cmd << oendl; | 384 | owarn << "cmd: " << cmd << oendl; |
385 | 385 | ||
386 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { | 386 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { |
387 | 387 | ||
388 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 388 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
389 | // result = "Error: Can't run "+ cmd; | 389 | // result = "Error: Can't run "+ cmd; |
390 | 390 | ||
391 | TextViewOutput->append(result); | 391 | TextViewOutput->append(result); |
392 | return; | 392 | return; |
393 | } | 393 | } |
394 | /* parse output and display in ListViewScan */ | 394 | /* parse output and display in ListViewScan */ |
395 | while(fgets(result, 256, pipe2) != NULL) { | 395 | while(fgets(result, 256, pipe2) != NULL) { |
396 | /* put result into TextViewOutput */ | 396 | /* put result into TextViewOutput */ |
397 | TextViewOutput->append(result); | 397 | TextViewOutput->append(result); |
398 | } | 398 | } |
399 | 399 | ||
400 | TextViewOutput->append("\n\n============================================\n"); | 400 | TextViewOutput->append("\n\n============================================\n"); |
401 | scanning = false; | 401 | scanning = false; |
402 | } | 402 | } |