summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp77
1 files changed, 51 insertions, 26 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp
index 93203cd..eae86a4 100644
--- a/noncore/apps/advancedfm/advancedfmMenu.cpp
+++ b/noncore/apps/advancedfm/advancedfmMenu.cpp
@@ -1,740 +1,765 @@
1/*************************************************************************** 1/***************************************************************************
2 AdvancedFm.cpp 2 AdvancedFm.cpp
3 ------------------- 3 -------------------
4 ** Created: Sat Mar 9 23:33:09 2002 4 ** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp 5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12#include "advancedfm.h" 12#include "advancedfm.h"
13#include "output.h" 13#include "output.h"
14#include "filePermissions.h" 14#include "filePermissions.h"
15 15
16#include <opie/otabwidget.h> 16#include <opie/otabwidget.h>
17#include <opie/oprocess.h> 17#include <opie/oprocess.h>
18 18
19#include <qpe/lnkproperties.h> 19#include <qpe/lnkproperties.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/qpemenubar.h> 21#include <qpe/qpemenubar.h>
22#include <qpe/qpetoolbar.h> 22#include <qpe/qpetoolbar.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25#include <qpe/applnk.h> 25#include <qpe/applnk.h>
26#include <qpe/ir.h> 26#include <qpe/ir.h>
27 27
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qmultilineedit.h> 29#include <qmultilineedit.h>
30 30
31#include <qstring.h> 31#include <qstring.h>
32 32
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35#include <qcombobox.h> 35#include <qcombobox.h>
36#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37#include <qtabwidget.h> 37#include <qtabwidget.h>
38#include <qtoolbutton.h> 38#include <qtoolbutton.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qlineedit.h> 40#include <qlineedit.h>
41#include <qlistview.h> 41#include <qlistview.h>
42 42
43#include <stdlib.h> 43#include <stdlib.h>
44#include <unistd.h> 44#include <unistd.h>
45#include <sys/stat.h> 45#include <sys/stat.h>
46#include <dirent.h> 46#include <dirent.h>
47 47#include <sys/sendfile.h>
48#include <fcntl.h>
48 49
49void AdvancedFm::doDirChange() 50void AdvancedFm::doDirChange()
50{ 51{
51 ListClicked( CurrentView()->currentItem()); 52 ListClicked( CurrentView()->currentItem());
52} 53}
53 54
54void AdvancedFm::showMenuHidden() 55void AdvancedFm::showMenuHidden()
55{ 56{
56 if (b) 57 if (b)
57 { 58 {
58 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 59 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
59 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 60 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
60 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 61 fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
61// b=FALSE; 62// b=FALSE;
62 63
63 } 64 }
64 else 65 else
65 { 66 {
66 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 67 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
67 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 68 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
68 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 69 fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
69// b=TRUE; 70// b=TRUE;
70 } 71 }
71 rePopulate(); 72 rePopulate();
72// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); 73// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
73 if(b) b = false; else b = true; 74 if(b) b = false; else b = true;
74} 75}
75 76
76void AdvancedFm::showHidden() 77void AdvancedFm::showHidden()
77{ 78{
78 if (b) 79 if (b)
79 { 80 {
80 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 81 CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
81 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 82 OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
82// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); 83// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
83// b=FALSE; 84// b=FALSE;
84 85
85 } 86 }
86 else 87 else
87 { 88 {
88 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 89 CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
89 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 90 OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
90// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); 91// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
91// b=TRUE; 92// b=TRUE;
92 } 93 }
93 rePopulate(); 94 rePopulate();
94} 95}
95 96
96QString AdvancedFm::dealWithSymName(const QString &fileName) 97QString AdvancedFm::dealWithSymName(const QString &fileName)
97{ 98{
98 QString strItem = fileName; 99 QString strItem = fileName;
99 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 100 return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
100} 101}
101 102
102void AdvancedFm::runThis() 103void AdvancedFm::runThis()
103{ 104{
104 QString fs; 105 QString fs;
105 QDir *thisDir = CurrentDir(); 106 QDir *thisDir = CurrentDir();
106 107
107 QString curFile = CurrentView()->currentItem()->text(0); 108 QString curFile = CurrentView()->currentItem()->text(0);
108 QString path = thisDir->canonicalPath(); 109 QString path = thisDir->canonicalPath();
109 110
110 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 111 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
111 112
112 curFile = dealWithSymName((const QString&)curFile); 113 curFile = dealWithSymName((const QString&)curFile);
113 114
114 if(curFile != "../") 115 if(curFile != "../")
115 { 116 {
116 117
117 fs = getFileSystemType((const QString &) path); 118 fs = getFileSystemType((const QString &) path);
118 QFileInfo fileInfo( path + "/" + curFile); 119 QFileInfo fileInfo( path + "/" + curFile);
119 qDebug( fileInfo.owner()); 120 qDebug( fileInfo.owner());
120 121
121 if( (fileInfo.permission( QFileInfo::ExeUser) 122 if( (fileInfo.permission( QFileInfo::ExeUser)
122 | fileInfo.permission( QFileInfo::ExeGroup) 123 | fileInfo.permission( QFileInfo::ExeGroup)
123 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { 124 | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
124 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { 125 | fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
125 QCopEnvelope e("QPE/System", "execute(QString)" ); 126 QCopEnvelope e("QPE/System", "execute(QString)" );
126 e << curFile; 127 e << curFile;
127 } 128 }
128 else 129 else
129 { 130 {
130 curFile = path + "/" + curFile; 131 curFile = path + "/" + curFile;
131 DocLnk nf(curFile); 132 DocLnk nf(curFile);
132 QString execStr = nf.exec(); 133 QString execStr = nf.exec();
133 qDebug( execStr); 134 qDebug( execStr);
134 if( execStr.isEmpty() ) 135 if( execStr.isEmpty() )
135 { 136 {
136 } 137 }
137 else 138 else
138 { 139 {
139 nf.execute(); 140 nf.execute();
140 } 141 }
141 } 142 }
142 } 143 }
143} 144}
144 145
145void AdvancedFm::runText() 146void AdvancedFm::runText()
146{ 147{
147 QString curFile = CurrentView()->currentItem()->text(0); 148 QString curFile = CurrentView()->currentItem()->text(0);
148 if(curFile != "../") 149 if(curFile != "../")
149 { 150 {
150 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 151 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
151 curFile = dealWithSymName((const QString&)curFile); 152 curFile = dealWithSymName((const QString&)curFile);
152 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 153 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
153 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 154 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
154 e << curFile; 155 e << curFile;
155 } 156 }
156} 157}
157 158
158void AdvancedFm::makeDir() 159void AdvancedFm::makeDir()
159{ 160{
160 InputDialog *fileDlg; 161 InputDialog *fileDlg;
161 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 162 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
162 fileDlg->exec(); 163 fileDlg->exec();
163 if( fileDlg->result() == 1 ) 164 if( fileDlg->result() == 1 )
164 { 165 {
165 QDir *thisDir = CurrentDir(); 166 QDir *thisDir = CurrentDir();
166 QString filename = fileDlg->LineEdit1->text(); 167 QString filename = fileDlg->LineEdit1->text();
167 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); 168 thisDir->mkdir( thisDir->canonicalPath()+"/"+filename);
168 } 169 }
169 populateView(); 170 populateView();
170} 171}
171 172
172void AdvancedFm::doDelete() 173void AdvancedFm::doDelete()
173{ 174{
174 175
175 QStringList curFileList = getPath(); 176 QStringList curFileList = getPath();
176 bool doMsg=true; 177 bool doMsg=true;
177 int count = curFileList.count(); 178 int count = curFileList.count();
178 if( count > 0) 179 if( count > 0)
179 { 180 {
180 if(count > 1 ) 181 if(count > 1 )
181 { 182 {
182 QString msg; 183 QString msg;
183 msg=tr("Really delete\n%1 files?").arg(count); 184 msg=tr("Really delete\n%1 files?").arg(count);
184 switch ( QMessageBox::warning(this,tr("Delete"),msg 185 switch ( QMessageBox::warning(this,tr("Delete"),msg
185 ,tr("Yes"),tr("No"),0,0,1) ) 186 ,tr("Yes"),tr("No"),0,0,1) )
186 { 187 {
187 case 0: 188 case 0:
188 doMsg=false; 189 doMsg=false;
189 break; 190 break;
190 case 1: 191 case 1:
191 return; 192 return;
192 break; 193 break;
193 }; 194 };
194 } 195 }
195 196
196 QString myFile; 197 QString myFile;
197 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 198 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
198 { 199 {
199 myFile = (*it); 200 myFile = (*it);
200 if( myFile.find(" -> ",0,TRUE) != -1) 201 if( myFile.find(" -> ",0,TRUE) != -1)
201 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 202 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
202 203
203 QString f = CurrentDir()->canonicalPath(); 204 QString f = CurrentDir()->canonicalPath();
204 if(f.right(1).find("/",0,TRUE) == -1) 205 if(f.right(1).find("/",0,TRUE) == -1)
205 f += "/"; 206 f += "/";
206 f += myFile; 207 f += myFile;
207 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) 208 if(QDir(f).exists() && !QFileInfo(f).isSymLink() )
208 { 209 {
209 switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + 210 switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f +
210 "\nand all it's contents ?" 211 "\nand all it's contents ?"
211 ,tr("Yes"),tr("No"),0,0,1) ) 212 ,tr("Yes"),tr("No"),0,0,1) )
212 { 213 {
213 case 0: 214 case 0:
214 { 215 {
215 f=f.left(f.length()-1); 216 f=f.left(f.length()-1);
216 QString cmd="rm -rf "+f; 217 QString cmd="rm -rf "+f;
217 startProcess( (const QString)cmd.latin1() ); 218 startProcess( (const QString)cmd.latin1() );
218 populateView(); 219 populateView();
219 } 220 }
220 break; 221 break;
221 case 1: 222 case 1:
222 // exit 223 // exit
223 break; 224 break;
224 }; 225 };
225 226
226 } else { 227 } else {
227 if(doMsg) { 228 if(doMsg) {
228 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f 229 switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
229 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 230 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
230 case 1: 231 case 1:
231 return; 232 return;
232 break; 233 break;
233 }; 234 };
234 } 235 }
235 QString cmd="rm "+f; 236 QString cmd="rm "+f;
236 QFile file(f); 237 QFile file(f);
237 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) 238 if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
238 file.remove(); 239 file.remove();
239 } 240 }
240 } 241 }
241 } 242 }
242 populateView(); 243 populateView();
243} 244}
244 245
245void AdvancedFm::filePerms() 246void AdvancedFm::filePerms()
246{ 247{
247 QStringList curFileList = getPath(); 248 QStringList curFileList = getPath();
248 QString filePath; 249 QString filePath;
249 250
250 filePath = CurrentDir()->canonicalPath()+"/"; 251 filePath = CurrentDir()->canonicalPath()+"/";
251 252
252 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 253 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
253 { 254 {
254 filePermissions *filePerm; 255 filePermissions *filePerm;
255 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); 256 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
256 filePerm->showMaximized(); 257 filePerm->showMaximized();
257 filePerm->exec(); 258 filePerm->exec();
258 if( filePerm) 259 if( filePerm)
259 delete filePerm; 260 delete filePerm;
260 } 261 }
261 populateView(); 262 populateView();
262} 263}
263 264
264void AdvancedFm::doProperties() 265void AdvancedFm::doProperties()
265{ 266{
266#if defined(QT_QWS_OPIE) 267#if defined(QT_QWS_OPIE)
267 268
268 QStringList curFileList = getPath(); 269 QStringList curFileList = getPath();
269 270
270 QString filePath; 271 QString filePath;
271 filePath = CurrentDir()->canonicalPath()+"/"; 272 filePath = CurrentDir()->canonicalPath()+"/";
272 273
273 qDebug("%d",curFileList.count()); 274 qDebug("%d",curFileList.count());
274 275
275 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 276 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
276 { 277 {
277 qDebug((filePath+*it)); 278 qDebug((filePath+*it));
278 DocLnk lnk( (filePath+*it)); 279 DocLnk lnk( (filePath+*it));
279 LnkProperties prop( &lnk ); 280 LnkProperties prop( &lnk );
280 prop.showMaximized(); 281 prop.showMaximized();
281 prop.exec(); 282 prop.exec();
282 } 283 }
283#endif 284#endif
284 285
285} 286}
286 287
287void AdvancedFm::upDir() 288void AdvancedFm::upDir()
288{ 289{
289 QDir *thisDir = CurrentDir(); 290 QDir *thisDir = CurrentDir();
290 QString current = thisDir->canonicalPath(); 291 QString current = thisDir->canonicalPath();
291 QDir dir(current); 292 QDir dir(current);
292 dir.cdUp(); 293 dir.cdUp();
293 current = dir.canonicalPath(); 294 current = dir.canonicalPath();
294 chdir( current.latin1() ); 295 chdir( current.latin1() );
295 thisDir->cd( current, TRUE); 296 thisDir->cd( current, TRUE);
296 297
297 populateView(); 298 populateView();
298 update(); 299 update();
299} 300}
300 301
301void AdvancedFm::copy() 302void AdvancedFm::copy()
302{ 303{
303 qApp->processEvents(); 304 qApp->processEvents();
304 QStringList curFileList = getPath(); 305 QStringList curFileList = getPath();
305 306
306 QDir *thisDir = CurrentDir(); 307 QDir *thisDir = CurrentDir();
307 QDir *thatDir = OtherDir(); 308 QDir *thatDir = OtherDir();
308 309
309 bool doMsg=true; 310 bool doMsg=true;
310 int count=curFileList.count(); 311 int count=curFileList.count();
311 if( count > 0) { 312 if( count > 0) {
312 if(count > 1 ){ 313 if(count > 1 ){
313 QString msg; 314 QString msg;
314 msg=tr("Really copy\n%1 files?").arg(count); 315 msg=tr("Really copy\n%1 files?").arg(count);
315 switch ( QMessageBox::warning(this,tr("Delete"),msg 316 switch ( QMessageBox::warning(this,tr("Copy"),msg
316 ,tr("Yes"),tr("No"),0,0,1) ) 317 ,tr("Yes"),tr("No"),0,0,1) )
317 { 318 {
318 case 0: 319 case 0:
319 doMsg=false; 320 doMsg=false;
320 break; 321 break;
321 case 1: 322 case 1:
322 return; 323 return;
323 break; 324 break;
324 }; 325 };
325 } 326 }
326 327
327 QString curFile, item, destFile; 328 QString curFile, item, destFile;
328 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 329 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
329 { 330 {
330 item=(*it); 331 item=(*it);
331 if(item.find("->",0,TRUE)) //symlink 332 if(item.find("->",0,TRUE)) //symlink
332 item = item.left(item.find("->",0,TRUE)); 333 item = item.left(item.find("->",0,TRUE));
333 334
334 curFile = thisDir->canonicalPath()+"/"+ item; 335 curFile = thisDir->canonicalPath()+"/"+ item;
335 destFile = thatDir->canonicalPath()+"/"+ item; 336 destFile = thatDir->canonicalPath()+"/"+ item;
336 337
337 qDebug("Destination file is "+destFile); 338 qDebug("Destination file is "+destFile);
338 qDebug("CurrentFile file is " + curFile); 339 qDebug("CurrentFile file is " + curFile);
339 340
340 QFile f(destFile); 341 QFile f(destFile);
341 if( f.exists()) 342 if( f.exists())
342 { 343 {
343 if(doMsg) 344 if(doMsg)
344 { 345 {
345 switch ( QMessageBox::warning(this,tr("File Exists!"), 346 switch ( QMessageBox::warning(this,tr("File Exists!"),
346 tr("%1 exists. Ok to overwrite?").arg( item ), 347 tr("%1 exists. Ok to overwrite?").arg( item ),
347 tr("Yes"),tr("No"),0,0,1) ) 348 tr("Yes"),tr("No"),0,0,1) )
348 { 349 {
349 case 1: 350 case 1:
350 return; 351 return;
351 break; 352 break;
352 }; 353 };
353 } 354 }
354 f.remove(); 355 f.remove();
355 } 356 }
356 357
357 if( !copyFile( curFile, destFile) ) 358 if( !copyFile( curFile, destFile) )
358 { 359 {
359 QMessageBox::message("AdvancedFm", 360 QMessageBox::message("AdvancedFm",
360 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); 361 tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
361 return; 362 return;
362 } 363 }
363 } 364 }
364 setOtherTabCurrent(); 365 setOtherTabCurrent();
365 populateView(); 366 populateView();
366 } 367 }
367} 368}
368 369
369void AdvancedFm::copyAs() 370void AdvancedFm::copyAs()
370{ 371{
371 qApp->processEvents(); 372 qApp->processEvents();
372 373
373 QStringList curFileList = getPath(); 374 QStringList curFileList = getPath();
374 QString curFile, item; 375 QString curFile, item;
375 InputDialog *fileDlg; 376 InputDialog *fileDlg;
376 377
377 QDir *thisDir = CurrentDir(); 378 QDir *thisDir = CurrentDir();
378 QDir *thatDir = OtherDir(); 379 QDir *thatDir = OtherDir();
379 380
380 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 381 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
381 { 382 {
382 QString destFile; 383 QString destFile;
383 item=(*it); 384 item=(*it);
384 curFile = thisDir->canonicalPath()+"/"+(*it); 385 curFile = thisDir->canonicalPath()+"/"+(*it);
385 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); 386 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
386 387
387 fileDlg->setInputText((const QString &) destFile ); 388 fileDlg->setInputText((const QString &) destFile );
388 fileDlg->exec(); 389 fileDlg->exec();
389 390
390 if( fileDlg->result() == 1 ) 391 if( fileDlg->result() == 1 )
391 { 392 {
392 QString filename = fileDlg->LineEdit1->text(); 393 QString filename = fileDlg->LineEdit1->text();
393 destFile = thatDir->canonicalPath()+"/"+filename; 394 destFile = thatDir->canonicalPath()+"/"+filename;
394 395
395 QFile f( destFile); 396 QFile f( destFile);
396 if( f.exists()) 397 if( f.exists())
397 { 398 {
398 switch (QMessageBox::warning(this,tr("File Exists!"), 399 switch (QMessageBox::warning(this,tr("File Exists!"),
399 item+tr("\nexists. Ok to overwrite?"), 400 item+tr("\nexists. Ok to overwrite?"),
400 tr("Yes"),tr("No"),0,0,1) ) 401 tr("Yes"),tr("No"),0,0,1) )
401 { 402 {
402 case 0: 403 case 0:
403 f.remove(); 404 f.remove();
404 break; 405 break;
405 case 1: 406 case 1:
406 return; 407 return;
407 break; 408 break;
408 }; 409 };
409 } 410 }
410 if( !copyFile( curFile, destFile) ) 411 if( !copyFile( curFile, destFile) )
411 { 412 {
412 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 413 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
413 +curFile +tr("to\n")+destFile); 414 +curFile +tr("to\n")+destFile);
414 return; 415 return;
415 } 416 }
416 } 417 }
417 delete fileDlg; 418 delete fileDlg;
418 419
419 } 420 }
420 setOtherTabCurrent(); 421 setOtherTabCurrent();
421 populateView(); 422 populateView();
422} 423}
423 424
424void AdvancedFm::copySameDir() 425void AdvancedFm::copySameDir()
425{ 426{
426 qApp->processEvents(); 427 qApp->processEvents();
427 QStringList curFileList = getPath(); 428 QStringList curFileList = getPath();
428 QString curFile, item, destFile; 429 QString curFile, item, destFile;
429 InputDialog *fileDlg; 430 InputDialog *fileDlg;
430 431
431 QDir *thisDir = CurrentDir(); 432 QDir *thisDir = CurrentDir();
432 433
433 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 434 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
434 { 435 {
435 item=(*it); 436 item=(*it);
436 curFile = thisDir->canonicalPath()+"/"+ item; 437 curFile = thisDir->canonicalPath()+"/"+ item;
437 438
438 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 439 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
439 fileDlg->setInputText((const QString &) destFile ); 440 fileDlg->setInputText((const QString &) destFile );
440 fileDlg->exec(); 441 fileDlg->exec();
441 442
442 if( fileDlg->result() == 1 ) 443 if( fileDlg->result() == 1 )
443 { 444 {
444 445
445 QString filename = fileDlg->LineEdit1->text(); 446 QString filename = fileDlg->LineEdit1->text();
446 destFile = thisDir->canonicalPath()+"/"+filename; 447 destFile = thisDir->canonicalPath()+"/"+filename;
447 448
448 QFile f(destFile); 449 QFile f(destFile);
449 if( f.exists()) 450 if( f.exists())
450 { 451 {
451 switch (QMessageBox::warning(this,tr("Delete"), 452 switch (QMessageBox::warning(this,tr("Delete"),
452 destFile+tr(" already exists.\nDo you really want to delete it?"), 453 destFile+tr(" already exists.\nDo you really want to delete it?"),
453 tr("Yes"),tr("No"),0,0,1) ) { 454 tr("Yes"),tr("No"),0,0,1) ) {
454 case 0: 455 case 0:
455 456
456 f.remove(); 457 f.remove();
457 break; 458 break;
458 case 1: 459 case 1:
459 return; 460 return;
460 break; 461 break;
461 }; 462 };
462 } 463 }
463 if(!copyFile( curFile,destFile) ) 464 if(!copyFile( curFile,destFile) )
464 { 465 {
465 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 466 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
466 +curFile +tr("to\n")+destFile); 467 +curFile +tr("to\n")+destFile);
467 return; 468 return;
468 } 469 }
469 470
470 qDebug("copy "+curFile+" as "+destFile); 471 qDebug("copy "+curFile+" as "+destFile);
471 } 472 }
472 delete fileDlg; 473 delete fileDlg;
473 } 474 }
474 populateView(); 475 populateView();
475} 476}
476 477
477void AdvancedFm::move() 478void AdvancedFm::move()
478{ 479{
479 qApp->processEvents(); 480 qApp->processEvents();
480 481
481 QStringList curFileList = getPath(); 482 QStringList curFileList = getPath();
482 if( curFileList.count() > 0) 483 if( curFileList.count() > 0)
483 { 484 {
484 QString curFile, destFile, item; 485 QString curFile, destFile, item;
485 486
486 QDir *thisDir = CurrentDir(); 487 QDir *thisDir = CurrentDir();
487 QDir *thatDir = OtherDir(); 488 QDir *thatDir = OtherDir();
488 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 489 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
489 { 490 {
490 item=(*it); 491 item=(*it);
491 QString destFile = thatDir->canonicalPath(); 492 QString destFile = thatDir->canonicalPath();
492 493
493 if(destFile.right(1).find("/",0,TRUE) == -1) 494 if(destFile.right(1).find("/",0,TRUE) == -1)
494 destFile+="/"; 495 destFile+="/";
495 destFile += item; 496 destFile += item;
496 qDebug("Destination file is "+destFile); 497 qDebug("Destination file is "+destFile);
497 498
498 curFile = thisDir->canonicalPath(); 499 curFile = thisDir->canonicalPath();
499 if(curFile.right(1).find("/",0,TRUE) == -1) 500 if(curFile.right(1).find("/",0,TRUE) == -1)
500 curFile +="/"; 501 curFile +="/";
501 curFile+= item; 502 curFile+= item;
502 qDebug("CurrentFile file is " + curFile); 503 qDebug("CurrentFile file is " + curFile);
503 504
504 QFile f( curFile); 505 QFile f( curFile);
505 if( f.exists()) { 506 if( f.exists()) {
506 if( !copyFile( curFile, destFile) ) 507 if( !copyFile( curFile, destFile) )
507 { 508 {
508 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); 509 QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
509 return; 510 return;
510 } else 511 } else
511 QFile::remove(curFile); 512 QFile::remove(curFile);
512 } 513 }
513 } 514 }
514 515
515 } 516 }
516 setOtherTabCurrent(); 517 setOtherTabCurrent();
517 populateView(); 518 populateView();
518// populateLocalView(); 519// populateLocalView();
519} 520}
520 521
521bool AdvancedFm::copyFile( const QString & src, const QString & dest ) 522bool AdvancedFm::copyFile( const QString & src, const QString & dest )
522{ 523{
523 char bf[ 50000 ]; 524// char bf[ 50000 ];
524 int bytesRead; 525// int bytesRead;
525 bool success = TRUE; 526 bool success = true;
526 struct stat status; 527 struct stat status;
528
529// QFile s( src );
530// QFile d( dest );
531
532 int read_fd=0;
533 int write_fd=0;
534 struct stat stat_buf;
535 off_t offset = 0;
536 read_fd = ::open(src.latin1(), O_RDONLY);
537 if(read_fd != -1) {
538 fstat (read_fd, &stat_buf);
539 write_fd = ::open(dest.latin1(), O_WRONLY | O_CREAT, stat_buf.st_mode);
540 if(write_fd != -1) {
541 if(sendfile(write_fd, read_fd, &offset, stat_buf.st_size) == -1) {
542 success = false;
543 }
544 } else {
545 success = false;
546 }
547 } else {
548 success = false;
549 }
527 550
528 QFile s( src ); 551 ::close (read_fd);
529 QFile d( dest ); 552 ::close (write_fd);
530 553
531 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) 554
532 { 555// if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) )
533 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) 556// {
534 { 557// while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) )
535 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ 558// {
536 success = FALSE; 559// if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
537 break; 560// success = FALSE;
538 } 561// break;
539 } 562// }
540 if( success && (bytesRead > 0) ) 563// }
541 { 564// if( success && (bytesRead > 0) )
542 d.writeBlock( bf, bytesRead ); 565// {
543 } 566// d.writeBlock( bf, bytesRead );
544 } 567// }
545 else 568
546 { 569// }
547 success = FALSE; 570// else
548 } 571// {
572// success = FALSE;
573// }
549 574
550 // Set file permissions 575 // Set file permissions
551 if( stat( (const char *) src, &status ) == 0 ) 576 if( stat( (const char *) src, &status ) == 0 )
552 { 577 {
553 chmod( (const char *) dest, status.st_mode ); 578 chmod( (const char *) dest, status.st_mode );
554 } 579 }
555 580
556 return success; 581 return success;
557} 582}
558 583
559void AdvancedFm::runCommand() 584void AdvancedFm::runCommand()
560{ 585{
561 QDir *thisDir = CurrentDir(); 586 QDir *thisDir = CurrentDir();
562 587
563 QString curFile; 588 QString curFile;
564 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); 589 curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
565 590
566 InputDialog *fileDlg; 591 InputDialog *fileDlg;
567 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 592 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
568 fileDlg->setInputText(curFile); 593 fileDlg->setInputText(curFile);
569 fileDlg->exec(); 594 fileDlg->exec();
570 //QString command; 595 //QString command;
571 596
572 if( fileDlg->result() == 1 ) 597 if( fileDlg->result() == 1 )
573 { 598 {
574 qDebug(fileDlg->LineEdit1->text()); 599 qDebug(fileDlg->LineEdit1->text());
575 QStringList command; 600 QStringList command;
576 601
577 command << "/bin/sh"; 602 command << "/bin/sh";
578 command << "-c"; 603 command << "-c";
579 command << fileDlg->LineEdit1->text(); 604 command << fileDlg->LineEdit1->text();
580 Output *outDlg; 605 Output *outDlg;
581 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 606 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
582 outDlg->showMaximized(); 607 outDlg->showMaximized();
583 outDlg->exec(); 608 outDlg->exec();
584 qApp->processEvents(); 609 qApp->processEvents();
585 610
586 } 611 }
587} 612}
588 613
589void AdvancedFm::runCommandStd() 614void AdvancedFm::runCommandStd()
590{ 615{
591 QString curFile; 616 QString curFile;
592 QDir *thisDir = CurrentDir(); 617 QDir *thisDir = CurrentDir();
593 QListView *thisView = CurrentView(); 618 QListView *thisView = CurrentView();
594 if( thisView->currentItem()) 619 if( thisView->currentItem())
595 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); 620 curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
596 621
597 InputDialog *fileDlg; 622 InputDialog *fileDlg;
598 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); 623 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
599 fileDlg->setInputText(curFile); 624 fileDlg->setInputText(curFile);
600 fileDlg->exec(); 625 fileDlg->exec();
601 626
602 if( fileDlg->result() == 1 ) 627 if( fileDlg->result() == 1 )
603 { 628 {
604 qApp->processEvents(); 629 qApp->processEvents();
605 startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); 630 startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
606 } 631 }
607} 632}
608 633
609void AdvancedFm::fileStatus() 634void AdvancedFm::fileStatus()
610{ 635{
611 QString curFile; 636 QString curFile;
612 curFile = CurrentView()->currentItem()->text(0); 637 curFile = CurrentView()->currentItem()->text(0);
613 638
614 QStringList command; 639 QStringList command;
615 command << "/bin/sh"; 640 command << "/bin/sh";
616 command << "-c"; 641 command << "-c";
617 command << "stat -l "+ curFile; 642 command << "stat -l "+ curFile;
618 643
619 Output *outDlg; 644 Output *outDlg;
620 outDlg = new Output( command, this, tr("AdvancedFm Output"), true); 645 outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
621 outDlg->showMaximized(); 646 outDlg->showMaximized();
622 outDlg->exec(); 647 outDlg->exec();
623 qApp->processEvents(); 648 qApp->processEvents();
624} 649}
625 650
626 651
627void AdvancedFm::mkDir() 652void AdvancedFm::mkDir()
628{ 653{
629 makeDir(); 654 makeDir();
630} 655}
631 656
632void AdvancedFm::rn() 657void AdvancedFm::rn()
633{ 658{
634 renameIt(); 659 renameIt();
635} 660}
636 661
637void AdvancedFm::del() 662void AdvancedFm::del()
638{ 663{
639 doDelete(); 664 doDelete();
640} 665}
641 666
642void AdvancedFm::mkSym() 667void AdvancedFm::mkSym()
643{ 668{
644 QString cmd; 669 QString cmd;
645 QStringList curFileList = getPath(); 670 QStringList curFileList = getPath();
646 if( curFileList.count() > 0) 671 if( curFileList.count() > 0)
647 { 672 {
648 QDir *thisDir = CurrentDir(); 673 QDir *thisDir = CurrentDir();
649 QDir * thatDir = OtherDir(); 674 QDir * thatDir = OtherDir();
650 675
651 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 676 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
652 { 677 {
653 678
654 QString destName = thatDir->canonicalPath()+"/"+(*it); 679 QString destName = thatDir->canonicalPath()+"/"+(*it);
655 if(destName.right(1) == "/") 680 if(destName.right(1) == "/")
656 { 681 {
657 destName = destName.left( destName.length() -1); 682 destName = destName.left( destName.length() -1);
658 } 683 }
659 684
660 QString curFile = thisDir->canonicalPath()+"/"+(*it); 685 QString curFile = thisDir->canonicalPath()+"/"+(*it);
661 686
662 if( curFile.right(1) == "/") 687 if( curFile.right(1) == "/")
663 { 688 {
664 curFile = curFile.left( curFile.length() -1); 689 curFile = curFile.left( curFile.length() -1);
665 } 690 }
666 691
667 cmd = "ln -s "+curFile+" "+destName; 692 cmd = "ln -s "+curFile+" "+destName;
668 qDebug(cmd); 693 qDebug(cmd);
669 startProcess( (const QString)cmd ); 694 startProcess( (const QString)cmd );
670 } 695 }
671 setOtherTabCurrent(); 696 setOtherTabCurrent();
672 populateView(); 697 populateView();
673 } 698 }
674} 699}
675 700
676void AdvancedFm::doBeam() 701void AdvancedFm::doBeam()
677{ 702{
678 Ir ir; 703 Ir ir;
679 if(!ir.supported()) 704 if(!ir.supported())
680 { 705 {
681 } 706 }
682 else 707 else
683 { 708 {
684 QStringList curFileList = getPath(); 709 QStringList curFileList = getPath();
685 if( curFileList.count() > 0) 710 if( curFileList.count() > 0)
686 { 711 {
687 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) 712 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it )
688 { 713 {
689 714
690 QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); 715 QString curFile = CurrentDir()->canonicalPath()+"/"+(*it);
691 if( curFile.right(1) == "/") 716 if( curFile.right(1) == "/")
692 { 717 {
693 curFile = curFile.left( curFile.length() -1); 718 curFile = curFile.left( curFile.length() -1);
694 } 719 }
695 Ir *file = new Ir(this, "IR"); 720 Ir *file = new Ir(this, "IR");
696 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 721 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
697 file->send( curFile, curFile ); 722 file->send( curFile, curFile );
698 } 723 }
699 } 724 }
700 } 725 }
701 726
702} 727}
703 728
704void AdvancedFm::fileBeamFinished( Ir *) 729void AdvancedFm::fileBeamFinished( Ir *)
705{ 730{
706 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 731 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
707} 732}
708 733
709void AdvancedFm::selectAll() 734void AdvancedFm::selectAll()
710{ 735{
711// if (TabWidget->currentTab() == 0) { 736// if (TabWidget->currentTab() == 0) {
712 QListView *thisView = CurrentView(); 737 QListView *thisView = CurrentView();
713 thisView->selectAll(true); 738 thisView->selectAll(true);
714 thisView->setSelected( thisView->firstChild(),false); 739 thisView->setSelected( thisView->firstChild(),false);
715// } else { 740// } else {
716// Remote_View->selectAll(true); 741// Remote_View->selectAll(true);
717// Remote_View->setSelected( Remote_View->firstChild(),false); 742// Remote_View->setSelected( Remote_View->firstChild(),false);
718// } 743// }
719} 744}
720 745
721void AdvancedFm::startProcess(const QString & cmd) 746void AdvancedFm::startProcess(const QString & cmd)
722{ 747{
723 QStringList command; 748 QStringList command;
724 OProcess *process; 749 OProcess *process;
725 process = new OProcess(); 750 process = new OProcess();
726 connect(process, SIGNAL(processExited(OProcess *)), 751 connect(process, SIGNAL(processExited(OProcess *)),
727 this, SLOT( processEnded(OProcess *))); 752 this, SLOT( processEnded(OProcess *)));
728 753
729 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), 754 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)),
730 this, SLOT( oprocessStderr(OProcess *, char *, int))); 755 this, SLOT( oprocessStderr(OProcess *, char *, int)));
731 756
732 command << "/bin/sh"; 757 command << "/bin/sh";
733 command << "-c"; 758 command << "-c";
734 command << cmd.latin1(); 759 command << cmd.latin1();
735 *process << command; 760 *process << command;
736 if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) 761 if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
737 qDebug("could not start process"); 762 qDebug("could not start process");
738} 763}
739 764
740void AdvancedFm::processEnded(OProcess *) 765void AdvancedFm::processEnded(OProcess *)