summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-18 03:02:37 (UTC)
committer llornkcor <llornkcor>2002-04-18 03:02:37 (UTC)
commit65748a36a621a19078789cc277a89c8a1f341351 (patch) (unidiff)
treeb512d4b7ce7521c1d5d475ad3b3f5827f5bdffe7
parent276f934cd66542d8cc403bb74e9cb661264ddd2f (diff)
downloadopie-65748a36a621a19078789cc277a89c8a1f341351.zip
opie-65748a36a621a19078789cc277a89c8a1f341351.tar.gz
opie-65748a36a621a19078789cc277a89c8a1f341351.tar.bz2
initial offering
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--apps/Applications/advancedfm.desktop7
-rw-r--r--noncore/apps/advancedfm/Makefile159
-rw-r--r--noncore/apps/advancedfm/advancedFm.control10
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp1263
-rw-r--r--noncore/apps/advancedfm/advancedfm.h118
-rw-r--r--noncore/apps/advancedfm/advancedfm.pro11
-rw-r--r--noncore/apps/advancedfm/filePermissions.cpp274
-rw-r--r--noncore/apps/advancedfm/filePermissions.h56
-rw-r--r--noncore/apps/advancedfm/inputDialog.cpp44
-rw-r--r--noncore/apps/advancedfm/inputDialog.h35
-rw-r--r--noncore/apps/advancedfm/main.cpp31
-rw-r--r--noncore/apps/advancedfm/output.cpp38
-rw-r--r--noncore/apps/advancedfm/output.h33
13 files changed, 2079 insertions, 0 deletions
diff --git a/apps/Applications/advancedfm.desktop b/apps/Applications/advancedfm.desktop
new file mode 100644
index 0000000..f0284f3
--- a/dev/null
+++ b/apps/Applications/advancedfm.desktop
@@ -0,0 +1,7 @@
1[Desktop Entry]
2Comment = An advanced file manager program
3Exec = advancedfm
4File = advancedfm
5Icon = FileBrowser
6Name = AdvancedFM
7Type = Application
diff --git a/noncore/apps/advancedfm/Makefile b/noncore/apps/advancedfm/Makefile
new file mode 100644
index 0000000..4622c6e
--- a/dev/null
+++ b/noncore/apps/advancedfm/Makefile
@@ -0,0 +1,159 @@
1#############################################################################
2# Makefile for building $(OPIEDIR)/bin/advancedfm
3# Generated by tmake at 18:31, 2002/04/15
4# Project: advancedfm
5# Template: app
6#############################################################################
7
8####### Compiler, tools and options
9
10 CC =gcc
11 CXX =g++
12 CFLAGS =-pipe -Wall -W -O2 -fno-default-inline -DNO_DEBUG
13 CXXFLAGS=-pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fno-default-inline -DNO_DEBUG
14 INCPATH =-I$(OPIEDIR)/include -I$(QTDIR)/include
15 LINK =g++
16 LFLAGS =
17 LIBS =$(SUBLIBS) -L$(QTDIR)/lib -lqpe -lqte
18 MOC =$(QTDIR)/bin/moc
19 UIC =$(QTDIR)/bin/uic
20
21 TAR =tar -cf
22 GZIP =gzip -9f
23
24####### Files
25
26 HEADERS =advancedfm.h \
27 inputDialog.h \
28 filePermissions.h \
29 output.h
30 SOURCES =advancedfm.cpp \
31 inputDialog.cpp \
32 filePermissions.cpp \
33 output.cpp \
34 main.cpp
35 OBJECTS =advancedfm.o \
36 inputDialog.o \
37 filePermissions.o \
38 output.o \
39 main.o
40 INTERFACES =
41 UICDECLS =
42 UICIMPLS =
43 SRCMOC =moc_advancedfm.cpp \
44 moc_inputDialog.cpp \
45 moc_filePermissions.cpp \
46 moc_output.cpp
47 OBJMOC =moc_advancedfm.o \
48 moc_inputDialog.o \
49 moc_filePermissions.o \
50 moc_output.o
51 DIST =
52 TARGET =$(OPIEDIR)/bin/advancedfm
53INTERFACE_DECL_PATH = .
54
55####### Implicit rules
56
57.SUFFIXES: .cpp .cxx .cc .C .c
58
59.cpp.o:
60 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
61
62.cxx.o:
63 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
64
65.cc.o:
66 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
67
68.C.o:
69 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
70
71.c.o:
72 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
73
74####### Build rules
75
76
77all: $(TARGET)
78
79$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
80 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS)
81
82moc: $(SRCMOC)
83
84tmake: Makefile
85
86Makefile: advancedfm.pro
87 tmake advancedfm.pro -o Makefile
88
89dist:
90 $(TAR) advancedfm.tar advancedfm.pro $(SOURCES) $(HEADERS) $(INTERFACES) $(DIST)
91 $(GZIP) advancedfm.tar
92
93clean:
94 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) $(TARGET)
95 -rm -f *~ core
96
97####### Sub-libraries
98
99
100###### Combined headers
101
102
103####### Compile
104
105advancedfm.o: advancedfm.cpp \
106 advancedfm.h \
107 inputDialog.h \
108 filePermissions.h \
109 output.h \
110 /usr/src/oldsrc/Opie/opie/include/qpe/lnkproperties.h \
111 /usr/src/oldsrc/Opie/opie/include/qpe/filemanager.h \
112 /usr/src/oldsrc/Opie/opie/include/qpe/qcopenvelope_qws.h \
113 /usr/src/oldsrc/Opie/opie/include/qpe/qpemenubar.h \
114 /usr/src/oldsrc/Opie/opie/include/qpe/qpetoolbar.h \
115 /usr/src/oldsrc/Opie/opie/include/qpe/qpeapplication.h \
116 /usr/src/oldsrc/Opie/opie/include/qpe/resource.h \
117 /usr/src/oldsrc/Opie/opie/include/qpe/config.h \
118 /usr/src/oldsrc/Opie/opie/include/qpe/mimetype.h \
119 /usr/src/oldsrc/Opie/opie/include/qpe/applnk.h
120
121inputDialog.o: inputDialog.cpp \
122 inputDialog.h
123
124filePermissions.o: filePermissions.cpp \
125 filePermissions.h
126
127output.o: output.cpp \
128 output.h
129
130main.o: main.cpp \
131 /usr/src/oldsrc/Opie/opie/include/qpe/qpeapplication.h \
132 /usr/src/oldsrc/Opie/opie/include/qpe/qcopenvelope_qws.h \
133 /usr/src/oldsrc/Opie/opie/include/qpe/config.h \
134 advancedfm.h
135
136moc_advancedfm.o: moc_advancedfm.cpp \
137 advancedfm.h
138
139moc_inputDialog.o: moc_inputDialog.cpp \
140 inputDialog.h
141
142moc_filePermissions.o: moc_filePermissions.cpp \
143 filePermissions.h
144
145moc_output.o: moc_output.cpp \
146 output.h
147
148moc_advancedfm.cpp: advancedfm.h
149 $(MOC) advancedfm.h -o moc_advancedfm.cpp
150
151moc_inputDialog.cpp: inputDialog.h
152 $(MOC) inputDialog.h -o moc_inputDialog.cpp
153
154moc_filePermissions.cpp: filePermissions.h
155 $(MOC) filePermissions.h -o moc_filePermissions.cpp
156
157moc_output.cpp: output.h
158 $(MOC) output.h -o moc_output.cpp
159
diff --git a/noncore/apps/advancedfm/advancedFm.control b/noncore/apps/advancedfm/advancedFm.control
new file mode 100644
index 0000000..40102ba
--- a/dev/null
+++ b/noncore/apps/advancedfm/advancedFm.control
@@ -0,0 +1,10 @@
1Files: bin/advancedfm pics/opie/symlink.png apps/Applications/advanced.desktop
2Priority: optional
3Package: advancedFm
4Section: opie/applications
5Maintainer: L.J. Potter <ljp@llornkcor.com>
6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: opie-base ($QPE_VERSION)
9Description: AdvancedFm
10 The advanced file manager for the Opie environment.
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp
new file mode 100644
index 0000000..a4ec714
--- a/dev/null
+++ b/noncore/apps/advancedfm/advancedfm.cpp
@@ -0,0 +1,1263 @@
1/***************************************************************************
2 AdvancedFm.cpp
3 -------------------
4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com
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 *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 ***************************************************************************/
12#define DEVELOPERS_VERSION
13#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties
14
15#include "advancedfm.h"
16#include "inputDialog.h"
17#include "filePermissions.h"
18#include "output.h"
19
20#include <qpe/lnkproperties.h>
21#include <qpe/filemanager.h>
22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpemenubar.h>
24#include <qpe/qpetoolbar.h>
25#include <qpe/qpeapplication.h>
26#include <qpe/resource.h>
27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/config.h>
29#include <qpe/mimetype.h>
30#include <qpe/applnk.h>
31
32//#include <opie/ofileselector.h>
33#include <qmultilineedit.h>
34
35#include <qtextstream.h>
36#include <qpushbutton.h>
37#include <qtoolbutton.h>
38#include <qdatetime.h>
39#include <qdir.h>
40#include <qfile.h>
41#include <qstring.h>
42#include <qcombobox.h>
43#include <qpopupmenu.h>
44#include <qlistview.h>
45#include <qmainwindow.h>
46#include <qlabel.h>
47#include <qprogressbar.h>
48#include <qspinbox.h>
49#include <qtabwidget.h>
50#include <qwidget.h>
51#include <qlayout.h>
52#include <qimage.h>
53#include <qpixmap.h>
54#include <qmessagebox.h>
55#include <qlineedit.h>
56#include <qregexp.h>
57
58#include <unistd.h>
59#include <stdlib.h>
60#include <sys/stat.h>
61#include <dirent.h>
62#include <stdio.h>
63#include <time.h>
64#include <fcntl.h>
65
66AdvancedFm::AdvancedFm( )
67 : QMainWindow( )
68{
69 setCaption( tr( "AdvancedFm" ) );
70
71 QGridLayout *layout = new QGridLayout( this );
72 layout->setSpacing( 2);
73 layout->setMargin( 2);
74
75 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
76
77 QPEMenuBar *menuBar = new QPEMenuBar(this);
78// fileMenu = new QPopupMenu( this );
79 fileMenu = new QPopupMenu( this );
80 viewMenu = new QPopupMenu( this );
81
82 layout->addMultiCellWidget( menuBar, 0, 0, 0, 1 );
83
84 menuBar->insertItem( tr( "File" ), fileMenu);
85 menuBar->insertItem( tr( "View" ), viewMenu);
86
87 cfButton = new QPushButton(Resource::loadIconSet("cardmon/pcmcia"),"",this,"CFButton");
88 cfButton ->setFixedSize( QSize( 20, 20 ) );
89 connect( cfButton ,SIGNAL(released()),this,SLOT( CFButtonPushed()) );
90 cfButton->setFlat(TRUE);
91 layout->addMultiCellWidget( cfButton , 0, 0, 2, 2);
92
93 sdButton = new QPushButton(Resource::loadIconSet("sdmon/sdcard"),"",this,"SDButton");
94 sdButton->setFixedSize( QSize( 20, 20 ) );
95 connect( sdButton ,SIGNAL(released()),this,SLOT( SDButtonPushed()) );
96 sdButton->setFlat(TRUE);
97 layout->addMultiCellWidget( sdButton , 0, 0, 3, 3);
98
99 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
100 cdUpButton ->setFixedSize( QSize( 20, 20 ) );
101 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
102 cdUpButton ->setFlat(TRUE);
103 layout->addMultiCellWidget( cdUpButton , 0, 0, 4, 4);
104
105 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
106 docButton->setFixedSize( QSize( 20, 20 ) );
107 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
108 docButton->setFlat(TRUE);
109 layout->addMultiCellWidget( docButton, 0, 0, 5, 5);
110
111 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
112 homeButton->setFixedSize( QSize( 20, 20 ) );
113 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
114 homeButton->setFlat(TRUE);
115 layout->addMultiCellWidget( homeButton, 0, 0, 6, 6);
116// fileMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
117// fileMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
118// fileMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
119
120 fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
121 fileMenu->insertSeparator();
122 fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
123 fileMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
124 fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() ));
125 fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() ));
126 fileMenu->insertSeparator();
127 fileMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
128 fileMenu->setCheckable(TRUE);
129
130 viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
131 viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
132 viewMenu->setCheckable(TRUE);
133
134 TabWidget = new QTabWidget( this, "TabWidget" );
135 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 6);
136
137 tab = new QWidget( TabWidget, "tab" );
138 tabLayout = new QGridLayout( tab );
139 tabLayout->setSpacing( 2);
140 tabLayout->setMargin( 2);
141
142 Local_View = new QListView( tab, "Local_View" );
143// Local_View->setResizePolicy( QListView::AutoOneFit );
144 Local_View->addColumn( tr("File"),140);
145 Local_View->addColumn( tr("Size"),-1);
146 Local_View->setColumnAlignment(1,QListView::AlignRight);
147 Local_View->addColumn( tr("Date"),-1);
148 Local_View->setColumnAlignment(2,QListView::AlignRight);
149 Local_View->setAllColumnsShowFocus(TRUE);
150// Local_View->setMultiSelection( TRUE );
151// Local_View->setSelectionMode(QListView::Extended);
152 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
153
154 tabLayout->addWidget( Local_View, 0, 0 );
155
156 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
157 this,SLOT( localListClicked(QListViewItem *)) );
158 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
159 this,SLOT( localListPressed(int, QListViewItem *, const QPoint&, int)) );
160
161 TabWidget->insertTab( tab, tr("1"));
162
163 tab_2 = new QWidget( TabWidget, "tab_2" );
164 tabLayout_2 = new QGridLayout( tab_2 );
165 tabLayout_2->setSpacing( 2);
166 tabLayout_2->setMargin( 2);
167
168 Remote_View = new QListView( tab_2, "Remote_View" );
169 Remote_View->addColumn( tr("File"),140);
170 Remote_View->addColumn( tr("Size"),-1);
171 Remote_View->setColumnAlignment(1,QListView::AlignRight);
172 Remote_View->addColumn( tr("Date"),-1);
173 Remote_View->setColumnAlignment(2,QListView::AlignRight);
174 Remote_View->setAllColumnsShowFocus(TRUE);
175// Remote_View->setMultiSelection( TRUE );
176// Remote_View->setSelectionMode(QListView::Extended);
177 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
178
179 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
180 this,SLOT( remoteListClicked(QListViewItem *)) );
181 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
182 this,SLOT( remoteListPressed(int, QListViewItem *, const QPoint&, int)) );
183
184 tabLayout_2->addWidget( Remote_View, 0, 0 );
185
186 TabWidget->insertTab( tab_2, tr( "2"));
187
188 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
189 this,SLOT(tabChanged(QWidget*)));
190
191// tab_3 = new QWidget( TabWidget, "tab_3" );
192// tabLayout_3 = new QGridLayout( tab_3 );
193// tabLayout_3->setSpacing( 2);
194// tabLayout_3->setMargin( 2);
195
196// OFileSelector *fileSelector;
197// fileSelector = new OFileSelector(tab_3,0,0,"/","","*");
198// tabLayout_3->addMultiCellWidget( fileSelector, 0, 0, 0, 3 );
199
200// TabWidget->insertTab( tab_3, tr( "Files" ) );
201
202 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
203 currentDir.setPath( QDir::currentDirPath());
204
205 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
206 currentRemoteDir.setPath( QDir::currentDirPath());
207
208 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
209 currentPathCombo->setEditable(TRUE);
210 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 6);
211 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
212
213 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
214 this, SLOT( currentPathComboActivated( const QString & ) ) );
215
216 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
217 this,SLOT(currentPathComboChanged()));
218
219 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
220
221 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 6);
222
223 filterStr="*";
224 b=FALSE;
225 populateLocalView();
226 populateRemoteView();
227}
228
229AdvancedFm::~AdvancedFm()
230{
231}
232
233void AdvancedFm::cleanUp()
234{
235 QString sfile=QDir::homeDirPath();
236 if(sfile.right(1) != "/")
237 sfile+="/._temp";
238 else
239 sfile+="._temp";
240 QFile file( sfile);
241 if(file.exists())
242 file.remove();
243}
244
245void AdvancedFm::tabChanged(QWidget *w)
246{
247 if (TabWidget->currentPageIndex() == 0) {
248 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
249 viewMenu->setItemChecked(viewMenu->idAt(0),TRUE);
250 viewMenu->setItemChecked(viewMenu->idAt(1),FALSE);
251 }
252 if (TabWidget->currentPageIndex() == 1) {
253 currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath());
254 viewMenu->setItemChecked(viewMenu->idAt(1),TRUE);
255 viewMenu->setItemChecked(viewMenu->idAt(0),FALSE);
256 }
257}
258
259
260void AdvancedFm::populateLocalView()
261{
262// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
263// QListViewItemIterator it( Local_View );
264// for ( ; it.current(); ++it ) {
265// if ( it.current()->isSelected() ) {
266// QString strItem = it.current()->text(0);
267// QString localFile = currentDir.canonicalPath()+"/"+strItem;
268// QFileInfo fi(localFile);
269// }
270// }
271 QPixmap pm;
272 Local_View->clear();
273 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
274 currentDir.setMatchAllDirs(TRUE);
275 currentDir.setNameFilter(filterStr);
276 QString fileL, fileS, fileDate;
277// qDebug(currentDir.canonicalPath());
278
279 bool isDir=FALSE;
280 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
281 QFileInfoListIterator it(*list);
282 QFileInfo *fi;
283 while ( (fi=it.current()) ) {
284 if (fi->isSymLink() ) {
285 QString symLink=fi->readLink();
286// qDebug("Symlink detected "+symLink);
287 QFileInfo sym( symLink);
288 fileS.sprintf( "%10li", sym.size() );
289 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
290 fileDate = sym.lastModified().toString();
291 } else {
292 fileS.sprintf( "%10li", fi->size() );
293 fileL.sprintf( "%s",fi->fileName().data() );
294 fileDate= fi->lastModified().toString();
295 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
296 fileL+="/";
297 isDir=TRUE;
298// qDebug( fileL);
299 }
300 }
301 if(fileL !="./" && fi->exists()) {
302 item= new QListViewItem( Local_View, fileL, fileS , fileDate);
303
304 if(isDir || fileL.find("/",0,TRUE) != -1) {
305 if( !QDir( fi->filePath() ).isReadable())
306 pm = Resource::loadPixmap( "lockedfolder" );
307 else
308 pm= Resource::loadPixmap( "folder" );
309 item->setPixmap( 0,pm );
310 } else {
311 if( !fi->isReadable() )
312 pm = Resource::loadPixmap( "locked" );
313 else {
314 MimeType mt(fi->filePath());
315 pm=mt.pixmap(); //sets the correct pixmap for mimetype
316 if(pm.isNull())
317 pm = Resource::loadPixmap( "UnknownDocument-14" );
318 item->setPixmap( 0,pm);
319 }
320 }
321 if( fileL.find("->",0,TRUE) != -1) {
322 // overlay link image
323 pm= Resource::loadPixmap( "folder" );
324 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
325 QPainter painter( &pm );
326 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
327 pm.setMask( pm.createHeuristicMask( FALSE ) );
328 item->setPixmap( 0, pm);
329 }
330 } isDir=FALSE;
331 ++it;
332 }
333
334 if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) {
335 struct stat buf;
336 struct stat st;
337 dev_t devT;
338 mode_t mode;
339 DIR *dir;
340 int fd = 0;
341 struct dirent *mydirent;
342 int i = 1;
343 if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL)
344 while ((mydirent = readdir(dir)) != NULL) {
345 lstat( mydirent->d_name, &buf);
346 qDebug(mydirent->d_name);
347// mode = buf.st_mode;
348 fileL.sprintf("%s", mydirent->d_name);
349// fileS.sprintf("%d, %d", ); //this isn't correct
350 devT = buf.st_dev;
351 fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF);
352// fileS.sprintf("%d,%d", devT, devT);
353 fileDate.sprintf("%s", ctime( &buf.st_mtime));
354 if( fileL.find(".") == -1 ){
355 item= new QListViewItem( Local_View, fileL, fileS, fileDate);
356 pm = Resource::loadPixmap( "UnknownDocument-14" );
357 item->setPixmap( 0,pm);
358 }
359 }
360
361 closedir(dir);
362 }
363
364 Local_View->setSorting( 3,FALSE);
365 fillCombo( (const QString &) currentDir.canonicalPath());
366}
367
368void AdvancedFm::populateRemoteView()
369{
370// QList<QListViewItem> * getSelectedItems( QListView * Local_View );
371// QListViewItemIterator it( Remote_View );
372// for ( ; it.current(); ++it ) {
373// if ( it.current()->isSelected() ) {
374// QString strItem = it.current()->text(0);
375// QString localFile = currentRemoteDir.canonicalPath()+"/"+strItem;
376// QFileInfo fi(localFile);
377// }
378// }
379 QPixmap pm;
380 Remote_View->clear();
381 currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
382 currentRemoteDir.setMatchAllDirs(TRUE);
383 currentRemoteDir.setNameFilter(filterStr);
384 QString fileL, fileS, fileDate;
385 bool isDir=FALSE;
386 const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
387 QFileInfoListIterator it(*list);
388 QFileInfo *fi;
389 while ( (fi=it.current()) ) {
390 if (fi->isSymLink() ){
391 QString symLink=fi->readLink();
392// qDebug("Symlink detected "+symLink);
393 QFileInfo sym( symLink);
394 fileS.sprintf( "%10li", sym.size() );
395 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
396 fileDate = sym.lastModified().toString();
397 } else {
398// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
399 fileS.sprintf( "%10li", fi->size() );
400 fileL.sprintf( "%s",fi->fileName().data() );
401 fileDate= fi->lastModified().toString();
402 if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) {
403 fileL+="/";
404 isDir=TRUE;
405// qDebug( fileL);
406 }
407 }
408 if(fileL !="./" && fi->exists()) {
409 item= new QListViewItem( Remote_View,fileL,fileS , fileDate);
410 QPixmap pm;
411
412 if(isDir || fileL.find("/",0,TRUE) != -1) {
413 if( !QDir( fi->filePath() ).isReadable())
414 pm = Resource::loadPixmap( "lockedfolder" );
415 else
416 pm= Resource::loadPixmap( "folder" );
417 item->setPixmap( 0,pm );
418 } else {
419 if( !fi->isReadable() )
420 pm = Resource::loadPixmap( "locked" );
421 else {
422 MimeType mt(fi->filePath());
423 pm=mt.pixmap(); //sets the correct pixmap for mimetype
424 if(pm.isNull())
425 pm = Resource::loadPixmap( "UnknownDocument-14" );
426 item->setPixmap( 0,pm);
427 }
428 }
429 if( fileL.find("->",0,TRUE) != -1) {
430 // overlay link image
431 pm= Resource::loadPixmap( "folder" );
432 QPixmap lnk = Resource::loadPixmap( "symlink" );
433 QPainter painter( &pm );
434 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
435 pm.setMask( pm.createHeuristicMask( FALSE ) );
436 item->setPixmap( 0, pm);
437 }
438 } isDir=FALSE;
439 ++it;
440 }
441
442 if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) {
443 struct stat buf;
444 struct stat st;
445 mode_t mode;
446 DIR *dir;
447 int fd = 0;
448 struct dirent *mydirent;
449 int i = 1;
450 if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL)
451 while ((mydirent = readdir(dir)) != NULL) {
452 lstat( mydirent->d_name, &buf);
453 qDebug(mydirent->d_name);
454// mode = buf.st_mode;
455 fileL.sprintf("%s", mydirent->d_name);
456// fileS.sprintf("%d, %d", ); //this isn't correct
457 fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF);
458 fileDate.sprintf("%s", ctime( &buf.st_mtime));
459 if( fileL.find(".") == -1 ){
460 item= new QListViewItem( Remote_View, fileL, fileS, fileDate);
461 pm = Resource::loadPixmap( "UnknownDocument-14" );
462 item->setPixmap( 0,pm);
463 }
464 }
465
466 closedir(dir);
467 }
468
469 Remote_View->setSorting( 3,FALSE);
470 fillCombo( (const QString &) currentRemoteDir.canonicalPath() );
471}
472
473void AdvancedFm::localListClicked(QListViewItem *selectedItem)
474{
475 if(selectedItem) {
476 QString strItem=selectedItem->text(0);
477 QString strSize=selectedItem->text(1);
478 strSize=strSize.stripWhiteSpace();
479 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
480 // is symlink
481 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
482 if(QDir(strItem2).exists() ) {
483 currentDir.cd(strItem2, TRUE);
484 populateLocalView();
485 }
486 } else { // not a symlink
487 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
488 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
489 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
490 currentDir.cd(strItem,FALSE);
491 populateLocalView();
492 } else {
493 currentDir.cdUp();
494 populateLocalView();
495 }
496 if(QDir(strItem).exists()){
497 currentDir.cd(strItem, TRUE);
498 populateLocalView();
499 }
500 } else {
501 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
502 if( QFile::exists(strItem ) ) {
503// qDebug("upload "+strItem);
504 }
505 } //end not symlink
506 chdir(strItem.latin1());
507 }
508 }
509}
510
511void AdvancedFm::remoteListClicked(QListViewItem *selectedItem)
512{
513 if(selectedItem) {
514 QString strItem=selectedItem->text(0);
515 QString strSize=selectedItem->text(1);
516 strSize=strSize.stripWhiteSpace();
517 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
518 // is symlink
519 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
520 if(QDir(strItem2).exists() ) {
521 currentRemoteDir.cd(strItem2, TRUE);
522 populateRemoteView();
523 }
524 } else { // not a symlink
525 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
526 if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) {
527 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
528 currentRemoteDir.cd(strItem,FALSE);
529 populateRemoteView();
530 } else {
531 currentRemoteDir.cdUp();
532 populateRemoteView();
533 }
534 if(QDir(strItem).exists()){
535 currentRemoteDir.cd(strItem, TRUE);
536 populateRemoteView();
537 }
538 } else {
539 strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem);
540 if( QFile::exists(strItem ) ) {
541// qDebug("upload "+strItem);
542 }
543 } //end not symlink
544 chdir(strItem.latin1());
545 }
546 }
547}
548
549void AdvancedFm::doLocalCd()
550{
551 localListClicked( Local_View->currentItem());
552}
553
554void AdvancedFm::doRemoteCd()
555{
556 localListClicked( Remote_View->currentItem());
557}
558
559void AdvancedFm::showHidden()
560{
561 if (!b) {
562 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
563// localMenu->setItemChecked(localMenu->idAt(0),TRUE);
564// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
565 b=TRUE;
566
567 } else {
568 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
569// localMenu->setItemChecked(localMenu->idAt(0),FALSE);
570// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
571 b=FALSE;
572 }
573 populateLocalView();
574}
575
576void AdvancedFm::showRemoteHidden()
577{
578 if (!b) {
579 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
580// viewMenu->setItemChecked(localMenu->idAt(0),TRUE);
581// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
582 b=TRUE;
583
584 } else {
585 currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
586// localMenu->setItemChecked(localMenu->idAt(0),FALSE);
587// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
588 b=FALSE;
589 }
590 populateRemoteView();
591}
592
593void AdvancedFm::localListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
594{
595 switch (mouse) {
596 case 1:
597 break;
598 case 2:
599 showLocalMenu(item);
600 Local_View->clearSelection();
601 break;
602 };
603}
604
605void AdvancedFm::remoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
606{
607 switch (mouse) {
608 case 1:
609 break;
610 case 2:
611 showRemoteMenu(item);
612 Remote_View->clearSelection();
613 break;
614 };
615}
616
617void AdvancedFm::showLocalMenu(QListViewItem * item)
618{
619 if(item) {
620 QPopupMenu m;
621 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
622 m.insertSeparator();
623 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
624 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
625 else
626 m.insertItem( tr( "Open" ), this, SLOT( runThis() ));
627 m.insertItem( tr( "Open as Text" ), this, SLOT( runText() ));
628 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
629 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
630 m.insertItem( tr( "Copy" ), this, SLOT( copy() ));
631 m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
632 m.insertItem( tr( "Move" ), this, SLOT( move() ));
633 m.insertSeparator();
634 m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
635 m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
636 m.insertSeparator();
637 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
638 m.insertSeparator();
639 m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
640 m.insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
641 m.setCheckable(TRUE);
642 if (b)
643 m.setItemChecked(m.idAt(0),TRUE);
644 else
645 m.setItemChecked(m.idAt(0),FALSE);
646 m.exec( QCursor::pos() );
647 }
648}
649
650void AdvancedFm::showRemoteMenu(QListViewItem * item)
651{
652 if(item) {
653 QPopupMenu m;
654 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() ));
655 m.insertSeparator();
656 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
657 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
658 else
659 m.insertItem( tr( "Open" ), this, SLOT( runThis() ));
660 m.insertItem( tr( "Open as Text" ), this, SLOT( runText() ));
661 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
662 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
663 m.insertItem( tr( "Copy" ), this, SLOT( copy() ));
664 m.insertItem( tr( "Copy As" ), this, SLOT( copyAs() ));
665 m.insertItem( tr( "Move" ), this, SLOT( move() ));
666 m.insertSeparator();
667 m.insertItem( tr( "Run Command" ), this, SLOT( runCommand() ));
668 m.insertItem( tr( "File Info" ), this, SLOT( fileStatus() ));
669 m.insertSeparator();
670 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
671 m.insertSeparator();
672 m.insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() ));
673 m.insertItem( tr( "Properties" ), this, SLOT( doProperties() ));
674 m.setCheckable(TRUE);
675 if (b)
676 m.setItemChecked(m.idAt(0),TRUE);
677 else
678 m.setItemChecked(m.idAt(0),FALSE);
679 m.exec( QCursor::pos() );
680 }
681}
682
683void AdvancedFm::runThis() {
684// QFileInfo *fi;
685 if (TabWidget->currentPageIndex() == 0) {
686 QString curFile = Local_View->currentItem()->text(0);
687 curFile = currentDir.canonicalPath()+"/"+curFile;
688 DocLnk nf(curFile);
689 QString execStr = nf.exec();
690 qDebug( execStr);
691 if( execStr.isEmpty() ) {
692 } else {
693 nf.execute();
694 }
695// MimeType mt( curFile);
696 } else {
697 QString curFile = Remote_View->currentItem()->text(0);
698 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
699 DocLnk nf(curFile);
700 QString execStr = nf.exec();
701 qDebug(execStr);
702 if( execStr.isEmpty() ) {
703 } else {
704 nf.execute();
705 }
706// MimeType mt( curFile);
707 }
708}
709
710void AdvancedFm::runText() {
711 if (TabWidget->currentPageIndex() == 0) {
712 QString curFile = Local_View->currentItem()->text(0);
713 curFile = currentDir.canonicalPath()+"/"+curFile;
714 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
715 e << curFile;
716 } else {
717 QString curFile = Remote_View->currentItem()->text(0);
718 curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
719 DocLnk nf(curFile);
720 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
721 e << curFile;
722 }
723}
724
725void AdvancedFm::localMakDir()
726{
727 InputDialog *fileDlg;
728 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
729 fileDlg->exec();
730 if( fileDlg->result() == 1 ) {
731 QString filename = fileDlg->LineEdit1->text();
732 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
733 }
734 populateLocalView();
735}
736
737void AdvancedFm::remoteMakDir()
738{
739 InputDialog *fileDlg;
740 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
741 fileDlg->exec();
742 if( fileDlg->result() == 1 ) {
743 QString filename = fileDlg->LineEdit1->text();
744 currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
745 }
746 populateRemoteView();
747}
748
749void AdvancedFm::localDelete()
750{
751 QString f = Local_View->currentItem()->text(0);
752 if(QDir(f).exists() ) {
753 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
754 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
755 case 0: {
756 f=currentDir.canonicalPath()+"/"+f;
757 QString cmd="rmdir "+f;
758 system( cmd.latin1());
759 populateLocalView();
760 }
761 break;
762 case 1:
763 // exit
764 break;
765 };
766
767 } else {
768 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
769 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
770 case 0: {
771 f=currentDir.canonicalPath()+"/"+f;
772 QString cmd="rm "+f;
773 system( cmd.latin1());
774 populateLocalView();
775 }
776 break;
777 case 1:
778 // exit
779 break;
780 };
781 }
782}
783
784void AdvancedFm::remoteDelete()
785{
786 QString f = Remote_View->currentItem()->text(0);
787 if(QDir(f).exists() ) {
788 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
789 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
790 case 0: {
791 f = currentRemoteDir.canonicalPath()+"/"+f;
792 QString cmd="rmdir "+f;
793 system( cmd.latin1());
794 populateRemoteView();
795 }
796 break;
797 case 1:
798 // exit
799 break;
800 };
801
802 } else {
803 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
804 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
805 case 0: {
806 f = currentRemoteDir.canonicalPath()+"/"+f;
807 QString cmd="rm "+f;
808 system( cmd.latin1());
809 populateRemoteView();
810 }
811 break;
812 case 1:
813 // exit
814 break;
815 };
816 }
817}
818
819void AdvancedFm::localRename()
820{
821 QString curFile = Local_View->currentItem()->text(0);
822 InputDialog *fileDlg;
823 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
824 fileDlg->setInputText((const QString &)curFile);
825 fileDlg->exec();
826 if( fileDlg->result() == 1 ) {
827 QString oldname = currentDir.canonicalPath() + "/" + curFile;
828 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
829 if( rename(oldname.latin1(), newName.latin1())== -1)
830 QMessageBox::message(tr("Note"),tr("Could not rename"));
831 }
832 populateLocalView();
833}
834
835void AdvancedFm::remoteRename()
836{
837 QString curFile = Local_View->currentItem()->text(0);
838 InputDialog *fileDlg;
839 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
840 fileDlg->setInputText((const QString &)curFile);
841 fileDlg->exec();
842 if( fileDlg->result() == 1 ) {
843 QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
844 QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
845 if( rename(oldname.latin1(), newName.latin1())== -1)
846 QMessageBox::message(tr("Note"),tr("Could not rename"));
847 }
848 populateRemoteView();
849}
850
851void AdvancedFm::switchToLocalTab()
852{
853 TabWidget->setCurrentPage(0);
854}
855
856void AdvancedFm::switchToRemoteTab()
857{
858 TabWidget->setCurrentPage(1);
859}
860
861void AdvancedFm::readConfig()
862{
863 Config cfg("AdvancedFm");
864}
865
866void AdvancedFm::writeConfig()
867{
868 Config cfg("AdvancedFm");
869}
870
871void AdvancedFm::currentPathComboChanged()
872{
873 if (TabWidget->currentPageIndex() == 0) {
874 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
875 currentDir.setPath( currentPathCombo->lineEdit()->text() );
876 populateLocalView();
877 } else {
878 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
879 }
880 }
881 if (TabWidget->currentPageIndex() == 0) {
882 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
883 currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() );
884 populateRemoteView();
885 } else {
886 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
887 }
888 }
889}
890
891void AdvancedFm::fillCombo(const QString &currentPath) {
892
893 if (TabWidget->currentPageIndex() == 0) {
894 currentPathCombo->lineEdit()->setText( currentPath);
895 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
896 currentPathCombo->clear();
897 localDirPathStringList.prepend( currentPath );
898 currentPathCombo->insertStringList( localDirPathStringList,-1);
899 }
900 } else {
901 currentPathCombo->lineEdit()->setText( currentPath);
902 if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) {
903 currentPathCombo->clear();
904 remoteDirPathStringList.prepend( currentPath );
905 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
906 }
907 }
908}
909
910void AdvancedFm::currentPathComboActivated(const QString & currentPath) {
911 if (TabWidget->currentPageIndex() == 0) {
912 chdir( currentPath.latin1() );
913 currentDir.cd( currentPath, TRUE);
914 populateLocalView();
915 update();
916 } else {
917 chdir( currentPath.latin1() );
918 currentRemoteDir.cd( currentPath, TRUE);
919 populateRemoteView();
920 update();
921 }
922}
923
924void AdvancedFm::filePerms() {
925 QString curFile = getPath();
926 filePermissions *filePerm;
927 filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(curFile));
928 filePerm->showMaximized();
929 filePerm->exec();
930 if( filePerm)
931 delete filePerm;
932}
933
934void AdvancedFm::doProperties() {
935
936 DocLnk lnk( getPath());
937 LnkProperties prop( &lnk );
938// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
939 prop.showMaximized();
940 prop.exec();
941}
942
943QString AdvancedFm::getPath() {
944 if (TabWidget->currentPageIndex() == 0) {
945 return currentDir.canonicalPath()+"/"+ Local_View->currentItem()->text(0);
946 } else {
947 return currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
948 }
949}
950
951void AdvancedFm::homeButtonPushed() {
952 QString current = QDir::homeDirPath();
953 chdir( current.latin1() );
954 if (TabWidget->currentPageIndex() == 0) {
955 currentDir.cd( current, TRUE);
956 populateLocalView();
957 } else {
958 currentRemoteDir.cd( current, TRUE);
959 populateRemoteView();
960 }
961 update();
962}
963
964void AdvancedFm::docButtonPushed() {
965 QString current = QPEApplication::documentDir();
966 chdir( current.latin1() );
967 if (TabWidget->currentPageIndex() == 0) {
968 currentDir.cd( current, TRUE);
969 populateLocalView();
970 } else {
971 currentRemoteDir.cd( current, TRUE);
972 populateRemoteView();
973 }
974 update();
975}
976
977void AdvancedFm::SDButtonPushed() {
978 QString current = "/mnt/card";
979 chdir( current.latin1() );
980 if (TabWidget->currentPageIndex() == 0) {
981 currentDir.cd( current, TRUE);
982 populateLocalView();
983 } else {
984 currentRemoteDir.cd( current, TRUE);
985 populateRemoteView();
986 }
987 update();
988
989}
990
991void AdvancedFm::CFButtonPushed() {
992 QString current = "/mnt/cf";
993 chdir( current.latin1() );
994 if (TabWidget->currentPageIndex() == 0) {
995 currentDir.cd( current, TRUE);
996 populateLocalView();
997 } else {
998 currentRemoteDir.cd( current, TRUE);
999 populateRemoteView();
1000 }
1001 update();
1002
1003}
1004
1005
1006void AdvancedFm::upDir()
1007{
1008 if (TabWidget->currentPageIndex() == 0) {
1009 QString current = currentDir.canonicalPath();
1010 QDir dir(current);
1011 dir.cdUp();
1012 current = dir.canonicalPath();
1013 chdir( current.latin1() );
1014 currentDir.cd( current, TRUE);
1015 populateLocalView();
1016 update();
1017 } else {
1018 QString current = currentRemoteDir.canonicalPath();
1019 QDir dir(current);
1020 dir.cdUp();
1021 current = dir.canonicalPath();
1022 chdir( current.latin1() );
1023 currentRemoteDir.cd( current, TRUE);
1024 populateRemoteView();
1025 update();
1026 }
1027}
1028
1029void AdvancedFm::copy()
1030{
1031 QString curFile = getPath();
1032 if (TabWidget->currentPageIndex() == 0) {
1033 QString destFile = currentRemoteDir.canonicalPath()+"/"+Local_View->currentItem()->text(0);
1034 QFile f(destFile);
1035 if( f.exists())
1036 f.remove();
1037 if(!copyFile(destFile, curFile) )
1038 qWarning("nothin doing");
1039 populateRemoteView();
1040 TabWidget->setCurrentPage(1);
1041 } else {
1042 QString destFile = currentDir.canonicalPath()+"/"+Remote_View->currentItem()->text(0);
1043 QFile f(destFile);
1044 if( f.exists())
1045 f.remove();
1046 if(!copyFile(destFile, curFile) )
1047 qWarning("nothin doing");
1048 populateLocalView();
1049 TabWidget->setCurrentPage(0);
1050 }
1051}
1052
1053void AdvancedFm::copyAs()
1054{
1055 QString curFile = getPath();
1056 if (TabWidget->currentPageIndex() == 0) {
1057 QString destFile = Local_View->currentItem()->text(0);
1058 InputDialog *fileDlg;
1059 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1060 fileDlg->setInputText((const QString &) destFile );
1061 fileDlg->exec();
1062 if( fileDlg->result() == 1 ) {
1063 QString filename = fileDlg->LineEdit1->text();
1064 destFile = currentRemoteDir.canonicalPath()+"/"+destFile;
1065
1066 QFile f(destFile);
1067 if( f.exists())
1068 f.remove();
1069 if(!copyFile(destFile, curFile) )
1070 qWarning("nothin doing");
1071 }
1072 populateRemoteView();
1073 TabWidget->setCurrentPage(1);
1074 } else {
1075 QString destFile = Remote_View->currentItem()->text(0);
1076 InputDialog *fileDlg;
1077 fileDlg = new InputDialog(this,tr("Copy As"),TRUE, 0);
1078 fileDlg->setInputText((const QString &) destFile);
1079 fileDlg->exec();
1080 if( fileDlg->result() == 1 ) {
1081 QString filename = fileDlg->LineEdit1->text();
1082 destFile = currentDir.canonicalPath()+"/"+destFile;
1083
1084 QFile f(destFile);
1085 if( f.exists())
1086 f.remove();
1087 if(!copyFile(destFile, curFile) )
1088 qWarning("nothin doing");
1089 }
1090 populateLocalView();
1091 TabWidget->setCurrentPage(0);
1092 }
1093}
1094
1095void AdvancedFm::move() {
1096 QString curFile = getPath();
1097// qDebug(curFile);
1098 QString destFile;
1099 if (TabWidget->currentPageIndex() == 0) {
1100 QString destFile = currentRemoteDir.canonicalPath()+Local_View->currentItem()->text(0);
1101// qDebug(destFile);
1102
1103 QFile f(destFile);
1104 if( f.exists())
1105 f.remove();
1106 if(!copyFile( destFile, curFile) ) {
1107 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile));
1108 return;
1109 }
1110 QFile::remove(curFile);
1111 TabWidget->setCurrentPage(1);
1112 } else {
1113 QString destFile = currentDir.canonicalPath()+destFile + Remote_View->currentItem()->text(0);
1114// qDebug(destFile);
1115
1116 QFile f(destFile);
1117 if( f.exists())
1118 f.remove();
1119 if(!copyFile(destFile, curFile) ) {
1120 QMessageBox::message(tr("Note"),tr("Could not move\n"+curFile));
1121 return;
1122 }
1123 QFile::remove(curFile);
1124 TabWidget->setCurrentPage(0);
1125 }
1126 populateRemoteView();
1127 populateLocalView();
1128}
1129
1130bool AdvancedFm::copyFile( const QString & dest, const QString & src )
1131{
1132 char bf[ 50000 ];
1133 int bytesRead;
1134 bool success = TRUE;
1135 struct stat status;
1136
1137 QFile s( src );
1138 QFile d( dest );
1139
1140 if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
1141 while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
1142 if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
1143 success = FALSE;
1144 break;
1145 }
1146 }
1147 if( success && (bytesRead > 0) ){
1148 d.writeBlock( bf, bytesRead );
1149 }
1150 } else {
1151 success = FALSE;
1152 }
1153
1154 // Set file permissions
1155 if( stat( (const char *) src, &status ) == 0 ){
1156 chmod( (const char *) dest, status.st_mode );
1157 }
1158
1159 return success;
1160}
1161
1162void AdvancedFm::runCommand() {
1163 QString curFile;
1164 if (TabWidget->currentPageIndex() == 0) {
1165 if( Local_View->currentItem())
1166 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0);
1167 } else {
1168 if(Remote_View->currentItem())
1169 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0);
1170 }
1171
1172 InputDialog *fileDlg;
1173 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1174 fileDlg->setInputText(curFile);
1175 fileDlg->exec();
1176 QString command;
1177 if( fileDlg->result() == 1 ) {
1178 command = fileDlg->LineEdit1->text();
1179
1180 int err=0;
1181 Output *outDlg;
1182 outDlg = new Output(this, tr("Formatter Output"),FALSE);
1183 outDlg->showMaximized();
1184 outDlg->show();
1185 qApp->processEvents();
1186 FILE *fp;
1187 char line[130];
1188 sleep(1);
1189// if(command.find("2>",0,TRUE) != -1)
1190 command +=" 2>&1";
1191 fp = popen( (const char *) command, "r");
1192 if ( !fp ) {
1193 qDebug("Could not execute '" + command + "'! err=%d", fp);
1194 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") );
1195 pclose(fp);
1196 return;
1197 } else {
1198 while ( fgets( line, sizeof line, fp)) {
1199 outDlg->OutputEdit->append(line);
1200 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1201
1202 }
1203
1204 }
1205
1206 }
1207
1208}
1209
1210void AdvancedFm::runCommandStd() {
1211 QString curFile;
1212 if (TabWidget->currentPageIndex() == 0) {
1213 if( Local_View->currentItem())
1214 curFile = currentDir.canonicalPath() + Local_View->currentItem()->text(0);
1215 } else {
1216 if(Remote_View->currentItem())
1217 curFile = currentRemoteDir.canonicalPath() + Remote_View->currentItem()->text(0);
1218 }
1219
1220 InputDialog *fileDlg;
1221 fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
1222 fileDlg->setInputText(curFile);
1223 fileDlg->exec();
1224 QString command;
1225 if( fileDlg->result() == 1 ) {
1226 qApp->processEvents();
1227 command = fileDlg->LineEdit1->text() + " &";
1228 system(command.latin1());
1229 }
1230}
1231
1232void AdvancedFm::fileStatus() {
1233 QString curFile;
1234 if (TabWidget->currentPageIndex() == 0) {
1235 curFile = Local_View->currentItem()->text(0);
1236 } else {
1237 curFile = Remote_View->currentItem()->text(0);
1238 }
1239 QString command = " stat -l "+ curFile +" 2>&1";
1240 int err=0;
1241 Output *outDlg;
1242 outDlg = new Output(this, tr("Formatter Output"),FALSE);
1243 outDlg->showMaximized();
1244 outDlg->show();
1245 qApp->processEvents();
1246 FILE *fp;
1247 char line[130];
1248 sleep(1);
1249 fp = popen( (const char *) command, "r");
1250 if ( !fp ) {
1251 qDebug("Could not execute '" + command + "'! err=%d", fp);
1252 QMessageBox::warning( this, tr("AdvancedFm"), tr("command failed!"), tr("&OK") );
1253 pclose(fp);
1254 return;
1255 } else {
1256 while ( fgets( line, sizeof line, fp)) {
1257 outDlg->OutputEdit->append(line);
1258 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
1259
1260 }
1261
1262 }
1263}
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
new file mode 100644
index 0000000..2ca45b1
--- a/dev/null
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -0,0 +1,118 @@
1/***************************************************************************
2 opieftp.h
3 -------------------
4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com
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 *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 ***************************************************************************/
12#ifndef ADVANCEDFM_H
13#define ADVANCEDFM_H
14
15#include <qvariant.h>
16#include <qdialog.h>
17#include <qmainwindow.h>
18#include <qdir.h>
19#include <qstring.h>
20#include <qpoint.h>
21
22class QVBoxLayout;
23class QHBoxLayout;
24class QGridLayout;
25class QComboBox;
26class QListView;
27class QListviewItem;
28class QLabel;
29class QProgressBar;
30class QSpinBox;
31class QTabWidget;
32class QWidget;
33class QPEToolBar;
34class QPEMenuBar;
35class QPopupMenu;
36class QFile;
37class QListViewItem;
38class QLineEdit;
39class QPushButton;
40
41class AdvancedFm : public QMainWindow
42{
43 Q_OBJECT
44public:
45 AdvancedFm();
46 ~AdvancedFm();
47
48 QTabWidget *TabWidget;
49 QWidget *tab, *tab_2, *tab_3;
50 QListView *Local_View, *Remote_View;
51
52 QLineEdit *currentPathEdit;
53 QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu;
54 QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton;
55 QDir currentDir, currentRemoteDir;
56 QComboBox *currentPathCombo;
57 QString filterStr;
58 QListViewItem * item;
59 bool b;
60 int currentServerConfig;
61protected slots:
62 void showLocalMenu( QListViewItem *);
63 void showRemoteMenu( QListViewItem *);
64 void doLocalCd();
65 void doRemoteCd();
66// void copy();
67
68 void populateLocalView();
69 void populateRemoteView();
70 void showHidden();
71 void showRemoteHidden();
72 void writeConfig();
73 void readConfig();
74 void localListClicked(QListViewItem *);
75 void remoteListClicked(QListViewItem *);
76 void localListPressed( int, QListViewItem *, const QPoint&, int);
77 void remoteListPressed( int, QListViewItem *, const QPoint&, int);
78 void localMakDir();
79 void localDelete();
80 void remoteMakDir();
81 void remoteDelete();
82/* bool remoteDirList(const QString &); */
83/* bool remoteChDir(const QString &); */
84 void tabChanged(QWidget*);
85 void cleanUp();
86 void remoteRename();
87 void localRename();
88 void runThis();
89 void runText();
90 void filePerms();
91 void doProperties();
92 void runCommand();
93 void runCommandStd();
94 QString getPath();
95 void switchToLocalTab();
96 void switchToRemoteTab();
97
98protected:
99 QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
100 QStringList remoteDirPathStringList, localDirPathStringList;
101
102protected slots:
103 void homeButtonPushed();
104 void docButtonPushed();
105 void SDButtonPushed();
106 void CFButtonPushed();
107 void upDir();
108 void currentPathComboChanged();
109 void copy();
110 void copyAs();
111 void currentPathComboActivated(const QString &);
112 void fillCombo(const QString &);
113 bool copyFile( const QString & , const QString & );
114 void move();
115 void fileStatus();
116};
117
118#endif // ADVANCEDFM_H
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro
new file mode 100644
index 0000000..25fb782
--- a/dev/null
+++ b/noncore/apps/advancedfm/advancedfm.pro
@@ -0,0 +1,11 @@
1TEMPLATE = app
2CONFIG += qt warn_on release
3HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h
4SOURCES = advancedfm.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp
5TARGET = advancedfm
6REQUIRES=medium-config
7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include
9DESTDIR = $(OPIEDIR)/bin
10LIBS += -lqpe
11
diff --git a/noncore/apps/advancedfm/filePermissions.cpp b/noncore/apps/advancedfm/filePermissions.cpp
new file mode 100644
index 0000000..c06f14f
--- a/dev/null
+++ b/noncore/apps/advancedfm/filePermissions.cpp
@@ -0,0 +1,274 @@
1/****************************************************************************
2** copyright 2002 ljp ljp@llornkcor.com
3** Created: Sat Feb 23 19:44:40 2002 L.J. Potter
4**
5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12**
13****************************************************************************/
14#include "filePermissions.h"
15
16#include <qfile.h>
17#include <qfileinfo.h>
18
19#include <qcheckbox.h>
20#include <qlabel.h>
21#include <qlineedit.h>
22#include <qlayout.h>
23#include <qvariant.h>
24#include <qtooltip.h>
25#include <qmessagebox.h>
26
27#include <unistd.h>
28#include <sys/stat.h>
29#include <stdlib.h>
30#include <sys/types.h>
31#include <pwd.h>
32#include <grp.h>
33
34filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName )
35 : QDialog( parent, name, modal, fl )
36{
37 if ( !name )
38 setName( "filePermissions" );
39// qDebug("FilePermissions "+fileName);
40/* resize( 236, 210 );
41 setMaximumSize( QSize( 236, 210 ) );
42*/ setCaption( tr( "Set File Permissions" ) );
43
44 TextLabel1 = new QLabel( this, "TextLabel1" );
45 TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) );
46 TextLabel1->setText( tr( "Set file permissions for:" ) );
47
48 LineEdit1 = new QLineEdit( this, "LineEdit1" );
49 LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) );
50 LineEdit1->setReadOnly(true);
51
52 TextLabel4 = new QLabel( this, "TextLabel4" );
53 TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) );
54 TextLabel4->setText( tr( "owner" ) );
55
56 TextLabel4_2 = new QLabel( this, "TextLabel4_2" );
57 TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) );
58 TextLabel4_2->setText( tr( "group" ) );
59
60 TextLabel4_3 = new QLabel( this, "TextLabel4_3" );
61 TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) );
62 TextLabel4_3->setText( tr( "others" ) );
63
64 CheckBox1 = new QCheckBox( this, "CheckBox1" );
65 CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) );
66 connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck()));
67
68 CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" );
69 CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) );
70 connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck()));
71
72 CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" );
73 CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) );
74 connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck()));
75
76 CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" );
77 CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) );
78 connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck()));
79
80 CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" );
81 CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) );
82 connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck()));
83
84 CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" );
85 CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) );
86 connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck()));
87
88 CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" );
89 CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) );
90 connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck()));
91
92 CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" );
93 CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) );
94 connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck()));
95
96 CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" );
97 CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) );
98 connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck()));
99
100 GroupLineEdit = new QLineEdit( this, "GroupLineEdit" );
101 GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) );
102
103 OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" );
104 OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) );
105
106 TextLabel5 = new QLabel( this, "TextLabel5" );
107 TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) );
108 TextLabel5->setText( tr( "Owner" ) );
109
110 TextLabel5_2 = new QLabel( this, "TextLabel5_2" );
111 TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) );
112 TextLabel5_2->setText( tr( "Group" ) );
113
114 ModeLine = new QLineEdit( this, "TextLabelMode" );
115 ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) );
116
117 TextLabel3_2 = new QLabel( this, "TextLabel3_2" );
118 TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) );
119 TextLabel3_2->setText( tr( "read" ) );
120 TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
121
122 TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" );
123 TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) );
124 TextLabel3_2_2->setText( tr( "write" ) );
125 TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
126
127 TextLabel3 = new QLabel( this, "TextLabel3" );
128 TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) );
129 TextLabel3->setText( tr( "execute" ) );
130 TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) );
131
132 struct stat buf;
133 mode_t mode;
134 file = fileName;
135 QFileInfo fi(file);
136
137 LineEdit1->setText( file);
138 OwnerLineEdit->setText( fi.owner());
139 GroupLineEdit->setText( fi.group());
140
141 if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); }
142 if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); }
143 if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); }
144
145 if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); }
146 if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); }
147 if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); }
148
149 if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); }
150 if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); }
151 if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); }
152
153 stat(file.latin1(), &buf);
154 mode = buf.st_mode;
155 modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) );
156 ModeLine->setText(modeStr);
157 bool ok;
158 i_mode = modeStr.toInt(&ok,10);
159
160}
161
162/*
163 * Destroys the object and frees any allocated resources
164 */
165filePermissions::~filePermissions()
166{
167}
168
169
170// might this be better as a callback routine???
171void filePermissions::ownReadCheck() {
172 if(CheckBox1->isChecked()) { i_mode +=400; }
173 else i_mode -=400;
174 modeStr.sprintf("0%d",i_mode);
175 ModeLine->setText( modeStr);
176// 0400
177}
178
179void filePermissions::ownWriteCheck() {
180 if(CheckBox1_2->isChecked()) { i_mode +=200; }
181 else i_mode -=200;
182 modeStr.sprintf("0%d",i_mode);
183 ModeLine->setText(modeStr);
184// 0200
185}
186
187void filePermissions::ownExeCheck() {
188 if(CheckBox1_3->isChecked()) { i_mode +=100; }
189 else i_mode -=100;
190 modeStr.sprintf("0%d",i_mode);
191 ModeLine->setText(modeStr);
192// 0100
193}
194
195void filePermissions::grpReadCheck() {
196 if(CheckBox1_4->isChecked()) { i_mode +=40; }
197 else i_mode -=40;
198 modeStr.sprintf("0%d",i_mode);
199 ModeLine->setText(modeStr);
200// 0040
201}
202
203void filePermissions::grpWriteCheck() {
204 if(CheckBox1_5->isChecked()) { i_mode +=20; }
205 else i_mode -=20;
206 modeStr.sprintf("0%d",i_mode);
207 ModeLine->setText(modeStr);
208// 0020
209}
210
211void filePermissions::grpExeCheck() {
212 if(CheckBox1_6->isChecked()) { i_mode +=10; }
213 else i_mode -=10;
214 modeStr.sprintf("0%d",i_mode);
215 ModeLine->setText(modeStr);
216// 0010
217}
218
219void filePermissions::wrldReadCheck() {
220 if(CheckBox1_7->isChecked()) { i_mode +=4; }
221 else i_mode -=4;
222 modeStr.sprintf("0%d",i_mode);
223 ModeLine->setText(modeStr);
224// 0004
225}
226
227void filePermissions::wrldWriteCheck() {
228 if(CheckBox1_8->isChecked()) { i_mode +=2; }
229 else i_mode -=2;
230 modeStr.sprintf("0%d",i_mode);
231 ModeLine->setText(modeStr);
232// 0002
233}
234
235void filePermissions::wrldExeCheck() {
236 if(CheckBox1_8_2->isChecked()) { i_mode +=1; }
237 else i_mode -=1;
238 modeStr.sprintf("0%d",i_mode);
239 ModeLine->setText(modeStr);
240// 0001
241}
242
243void filePermissions::accept() {
244
245 QFileInfo fi(file);
246 struct passwd *pwd=0;
247 struct group *grp=0;
248 pwd = getpwnam(OwnerLineEdit->text().latin1() );
249 if(pwd == NULL) {
250 perror("getpwnam");
251 QMessageBox::warning(this,"Warning","Error- no user");
252 return;
253 } else {
254 grp = getgrnam(GroupLineEdit->text().latin1());
255 if(grp==NULL) {
256 perror("getgrnam");
257 QMessageBox::warning(this,"Warning","Error- no group");
258 return;
259 }
260 if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) {
261 perror("chown");
262 QMessageBox::warning(this,"Warning","Error setting ownership or group");
263 return;
264 }
265 bool ok;
266 uint moder = modeStr.toUInt(&ok,8);
267 if( chmod( file.latin1(), moder) < 0) {
268 perror("chmod");
269 QMessageBox::warning(this,"Warning","Error setting mode");
270 return;
271 }
272 }
273 close();
274}
diff --git a/noncore/apps/advancedfm/filePermissions.h b/noncore/apps/advancedfm/filePermissions.h
new file mode 100644
index 0000000..880304f
--- a/dev/null
+++ b/noncore/apps/advancedfm/filePermissions.h
@@ -0,0 +1,56 @@
1/****************************************************************************
2** copyright 2002 ljp ljp@llornkcor.com
3** Created: Sat Feb 23 19:44:17 2002
4**
5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12**
13****************************************************************************/
14#ifndef FILEPERMISSIONS_H
15#define FILEPERMISSIONS_H
16
17#include <qvariant.h>
18#include <qdialog.h>
19class QVBoxLayout;
20class QHBoxLayout;
21class QGridLayout;
22class QCheckBox;
23class QLabel;
24class QLineEdit;
25class QString;
26
27class filePermissions : public QDialog
28{
29 Q_OBJECT
30
31public:
32 filePermissions( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 , const QString & fileName ="");
33 ~filePermissions();
34
35 QLineEdit *LineEdit1, *ModeLine;
36 QLabel *TextLabel1, *TextLabel4, *TextLabel4_2, *TextLabel4_3, *TextLabel3_2_2, *TextLabel3_2, *TextLabel3, *TextLabel5_2, *TextLabel5;
37 QCheckBox*CheckBox1, *CheckBox1_3, *CheckBox1_2, *CheckBox1_4, *CheckBox1_5, *CheckBox1_6, *CheckBox1_7, *CheckBox1_8, *CheckBox1_8_2;
38 QLineEdit*GroupLineEdit, *OwnerLineEdit;
39 QString modeStr, file;
40 int i_mode;
41private slots:
42 void ownReadCheck();
43 void ownWriteCheck();
44 void ownExeCheck();
45
46 void grpReadCheck();
47 void grpWriteCheck();
48 void grpExeCheck();
49
50 void wrldReadCheck();
51 void wrldWriteCheck();
52 void wrldExeCheck();
53 void accept();
54};
55
56#endif // FILEPERMISSIONS_H
diff --git a/noncore/apps/advancedfm/inputDialog.cpp b/noncore/apps/advancedfm/inputDialog.cpp
new file mode 100644
index 0000000..5af0f72
--- a/dev/null
+++ b/noncore/apps/advancedfm/inputDialog.cpp
@@ -0,0 +1,44 @@
1/****************************************************************************
2 inputDialog.cpp
3 -------------------
4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com
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 *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 ***************************************************************************/
12
13#include "inputDialog.h"
14
15#include <qlineedit.h>
16#include <qlayout.h>
17#include <qvariant.h>
18#include <qtooltip.h>
19#include <qwhatsthis.h>
20
21
22InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
23 : QDialog( parent, name, modal, fl )
24{
25 if ( !name )
26 setName( "InputDialog" );
27 resize( 234, 50 );
28 setMaximumSize( QSize( 240, 50 ) );
29 setCaption( tr(name ) );
30
31 LineEdit1 = new QLineEdit( this, "LineEdit1" );
32 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
33}
34
35InputDialog::~InputDialog()
36{
37 inputText = LineEdit1->text();
38
39}
40
41void InputDialog::setInputText(const QString &string)
42{
43LineEdit1->setText( string);
44}
diff --git a/noncore/apps/advancedfm/inputDialog.h b/noncore/apps/advancedfm/inputDialog.h
new file mode 100644
index 0000000..114a3a8
--- a/dev/null
+++ b/noncore/apps/advancedfm/inputDialog.h
@@ -0,0 +1,35 @@
1/***************************************************************************
2 inputDialog.h
3 -------------------
4** Created: Sat Mar 9 23:33:09 2002
5 copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com
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 *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 ***************************************************************************/
12#ifndef INPUTDIALOG_H
13#define INPUTDIALOG_H
14
15#include <qvariant.h>
16#include <qdialog.h>
17class QVBoxLayout;
18class QHBoxLayout;
19class QGridLayout;
20class QLineEdit;
21
22class InputDialog : public QDialog
23{
24 Q_OBJECT
25
26public:
27 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
28 ~InputDialog();
29 QString inputText;
30 QLineEdit* LineEdit1;
31 void setInputText(const QString &);
32
33};
34
35#endif // INPUTDIALOG_H
diff --git a/noncore/apps/advancedfm/main.cpp b/noncore/apps/advancedfm/main.cpp
new file mode 100644
index 0000000..a0401e8
--- a/dev/null
+++ b/noncore/apps/advancedfm/main.cpp
@@ -0,0 +1,31 @@
1
2/***************************************************************************
3 main.cpp - description
4 -------------------
5 begin : March 10, 2002
6 copyright : (C) 2002 by llornkcor
7 email : ljp@llornkcor.com
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 ***************************************************************************/
13#include <qpe/qpeapplication.h>
14#include <qpe/qcopenvelope_qws.h>
15#include <qpe/config.h>
16#include <qstring.h>
17#include <qstringlist.h>
18
19
20
21#include "advancedfm.h"
22
23int main(int argc, char *argv[])
24{
25 QPEApplication a(argc, argv);
26
27 AdvancedFm advencedFm;
28 a.showMainWidget( &advencedFm);
29 return a.exec();
30}
31
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
new file mode 100644
index 0000000..6970f58
--- a/dev/null
+++ b/noncore/apps/advancedfm/output.cpp
@@ -0,0 +1,38 @@
1/****************************************************************************
2** outputEdit.cpp
3**
4** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com>
5****************************************************************************/
6#include "output.h"
7
8#include <qmultilineedit.h>
9#include <qpushbutton.h>
10#include <qlayout.h>
11#include <qvariant.h>
12#include <qtooltip.h>
13#include <qwhatsthis.h>
14
15Output::Output( QWidget* parent, const char* name, bool modal, WFlags fl )
16 : QDialog( parent, name, modal, fl )
17{
18 if ( !name )
19 setName( "Output" );
20 resize( 196, 269 );
21 setCaption( name );
22 OutputLayout = new QGridLayout( this );
23 OutputLayout->setSpacing( 6 );
24 OutputLayout->setMargin( 11 );
25
26 OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
27
28 OutputLayout->addWidget( OutputEdit, 0, 0 );
29}
30
31/*
32 * Destroys the object and frees any allocated resources
33 */
34Output::~Output()
35{
36 // no need to delete child widgets, Qt does it all for us
37}
38
diff --git a/noncore/apps/advancedfm/output.h b/noncore/apps/advancedfm/output.h
new file mode 100644
index 0000000..84adccd
--- a/dev/null
+++ b/noncore/apps/advancedfm/output.h
@@ -0,0 +1,33 @@
1/****************************************************************************
2** Form interface generated from reading ui file 'outputEdit.ui'
3**
4** Created: Fri Apr 12 15:12:44 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef OUTPUT_H
10#define OUTPUT_H
11
12#include <qvariant.h>
13#include <qdialog.h>
14class QVBoxLayout;
15class QHBoxLayout;
16class QGridLayout;
17class QMultiLineEdit;
18
19class Output : public QDialog
20{
21 Q_OBJECT
22
23public:
24 Output( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
25 ~Output();
26
27 QMultiLineEdit* OutputEdit;
28
29protected:
30 QGridLayout* OutputLayout;
31};
32
33#endif // OUTPUT_H