summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp43
-rw-r--r--core/apps/textedit/fileBrowser.h2
-rw-r--r--noncore/net/opieftp/inputDialog.cpp4
-rw-r--r--noncore/net/opieftp/inputDialog.h2
-rw-r--r--noncore/net/opieftp/opieftp.cpp4
5 files changed, 35 insertions, 20 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 8ea8067..652f830 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -1,613 +1,624 @@
1/**************************************************************************** 1/****************************************************************************
2** copyright 2001 ljp ljp@llornkcor.com 2** copyright 2001 ljp ljp@llornkcor.com
3** Created: Fri Dec 14 08:16:46 2001 3** Created: Fri Dec 14 08:16:46 2001
4** 4**
5** This file may be distributed and/or modified under the terms of the 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 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 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13****************************************************************************/ 13****************************************************************************/
14#define QTOPIA_INTERNAL_MIMEEXT 14//#define QTOPIA_INTERNAL_MIMEEXT
15#include "fileBrowser.h" 15#include "fileBrowser.h"
16//#include "inputDialog.h" 16//#include "inputDialog.h"
17 17
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/resource.h> 19#include <qpe/resource.h>
20#include <qpe/fileselector.h> 20#include <qpe/fileselector.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/menubutton.h> 22#include <qpe/menubutton.h>
23#include <qpe/mimetype.h> 23#include <qpe/mimetype.h>
24 24
25#include <qdict.h> 25#include <qdict.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qcombo.h> 28#include <qcombo.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <unistd.h> 33#include <unistd.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qlineedit.h> 35#include <qlineedit.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37 37
38#include <unistd.h> 38#include <unistd.h>
39#include <stdlib.h> 39#include <stdlib.h>
40 40
41static int u_id = 1; 41static int u_id = 1;
42static int get_unique_id() 42static int get_unique_id()
43{ 43{
44 return u_id++; 44 return u_id++;
45} 45}
46 46
47fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter ) 47fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter )
48 : QDialog( parent, name, modal, fl ) 48 : QDialog( parent, name, modal, fl )
49{ 49{
50 if ( !name ) 50 if ( !name )
51 setName( "fileBrowser" ); 51 setName( "fileBrowser" );
52 setCaption(tr( name ) ); 52 setCaption(tr( name ) );
53 mimeType = mimeFilter; 53// mimeType = mimeFilter;
54 MimeType mt( mimeType); 54// MimeType mt( mimeType);
55 if( mt.extension().isEmpty()) 55// if( mt.extension().isEmpty())
56 filterStr = "*"; 56 QStringList filterList;
57 else 57 filterList=QStringList::split(";",mimeFilter,FALSE);
58 filterStr = "*."+ mt.extension(); 58 for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) {
59 printf( "%s \n", (*it).latin1() );
60 }
61
62 filterStr = mimeFilter.right(mimeFilter.length()- mimeFilter.find("/",0,TRUE) - 1);// "*";
63 qDebug(filterStr);
64// else
65// filterStr = "*."+ mt.extension();
59// qDebug("description "+mt.description()); 66// qDebug("description "+mt.description());
60// qDebug( "id "+mt.id()); 67// qDebug( "id "+mt.id());
61// qDebug("extension "+mt.extension()); 68// qDebug("extension "+mt.extension());
62 69
63// channel = new QCopChannel( "QPE/fileDialog", this ); 70// channel = new QCopChannel( "QPE/fileDialog", this );
64// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 71// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
65// this, SLOT(receive(const QCString&, const QByteArray&)) ); 72// this, SLOT(receive(const QCString&, const QByteArray&)) );
66 73
67 QGridLayout *layout = new QGridLayout( this ); 74 QGridLayout *layout = new QGridLayout( this );
68 layout->setSpacing( 4 ); 75 layout->setSpacing( 4 );
69 layout->setMargin( 4 ); 76 layout->setMargin( 4 );
70 77
71 dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" ); 78 dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" );
72 dirPathCombo->setEditable(TRUE); 79 dirPathCombo->setEditable(TRUE);
73 80
74 connect( dirPathCombo, SIGNAL( activated( const QString & ) ), 81 connect( dirPathCombo, SIGNAL( activated( const QString & ) ),
75 this, SLOT( dirPathComboActivated( const QString & ) ) ); 82 this, SLOT( dirPathComboActivated( const QString & ) ) );
76 83
77 connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), 84 connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ),
78 this, SLOT( dirPathEditPressed( ) ) ); 85 this, SLOT( dirPathEditPressed( ) ) );
79 86
80 dirPathStringList << "/"; 87 dirPathStringList << "/";
81// we can get the storage here 88// we can get the storage here
82 89
83 layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); 90 layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 );
84 91
85 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); 92 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
86 cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); 93 cdUpButton ->setMinimumSize( QSize( 20, 20 ) );
87 cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); 94 cdUpButton ->setMaximumSize( QSize( 20, 20 ) );
88 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 95 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
89 cdUpButton ->setFlat(TRUE); 96 cdUpButton ->setFlat(TRUE);
90 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); 97 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 );
91 98
92 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 99 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
93 docButton->setMinimumSize( QSize( 20, 20 ) ); 100 docButton->setMinimumSize( QSize( 20, 20 ) );
94 docButton->setMaximumSize( QSize( 20, 20 ) ); 101 docButton->setMaximumSize( QSize( 20, 20 ) );
95 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 102 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
96 docButton->setFlat(TRUE); 103 docButton->setFlat(TRUE);
97 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); 104 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
98 105
99 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); 106 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
100 homeButton->setMinimumSize( QSize( 20, 20 ) ); 107 homeButton->setMinimumSize( QSize( 20, 20 ) );
101 homeButton->setMaximumSize( QSize( 20, 20 ) ); 108 homeButton->setMaximumSize( QSize( 20, 20 ) );
102 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 109 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
103 homeButton->setFlat(TRUE); 110 homeButton->setFlat(TRUE);
104 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); 111 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 );
105 112
106 FileStack = new QWidgetStack( this ); 113 FileStack = new QWidgetStack( this );
107 114
108 ListView = new QListView( this, "ListView" ); 115 ListView = new QListView( this, "ListView" );
109// ListView->setMinimumSize( QSize( 100, 25 ) ); 116// ListView->setMinimumSize( QSize( 100, 25 ) );
110 ListView->addColumn( tr( "Name" ) ); 117 ListView->addColumn( tr( "Name" ) );
111 ListView->setColumnWidth(0,120); 118 ListView->setColumnWidth(0,120);
112 ListView->setSorting( 2, FALSE); 119 ListView->setSorting( 2, FALSE);
113 ListView->addColumn( tr( "Size" ) ); 120 ListView->addColumn( tr( "Size" ) );
114 ListView->setColumnWidth(1,-1); 121 ListView->setColumnWidth(1,-1);
115 ListView->addColumn( "Date",-1); 122 ListView->addColumn( "Date",-1);
116 123
117 ListView->setColumnWidthMode(0,QListView::Manual); 124 ListView->setColumnWidthMode(0,QListView::Manual);
118 ListView->setColumnAlignment(1,QListView::AlignRight); 125 ListView->setColumnAlignment(1,QListView::AlignRight);
119 ListView->setColumnAlignment(2,QListView::AlignRight); 126 ListView->setColumnAlignment(2,QListView::AlignRight);
120 ListView->setAllColumnsShowFocus( TRUE ); 127 ListView->setAllColumnsShowFocus( TRUE );
121 128
122 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); 129 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold);
123 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 130 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
124 this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 131 this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
125 132
126 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 133 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
127 134
128 FileStack->addWidget( ListView, get_unique_id() ); 135 FileStack->addWidget( ListView, get_unique_id() );
129 136
130 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy 137 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
131// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 138// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
132// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 139// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
133 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); 140 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
141 this, SLOT( docOpen( const DocLnk & ) ) );
134 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); 142 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 );
135 143
136 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); 144 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" );
137 SelectionCombo->insertItem( tr( "Documents" ) ); 145 SelectionCombo->insertItem( tr( "Documents" ) );
138 SelectionCombo->insertItem( tr( "All files" ) ); 146 SelectionCombo->insertItem( tr( "All files" ) );
139 SelectionCombo->insertItem( tr( "Hidden files" ) ); 147 SelectionCombo->insertItem( tr( "Hidden files" ) );
140// SelectionCombo->setMaximumWidth(120); 148// SelectionCombo->setMaximumWidth(120);
141 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); 149 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 );
142 150
143 connect( SelectionCombo, SIGNAL( activated( const QString & ) ), 151 connect( SelectionCombo, SIGNAL( activated( const QString & ) ),
144 this, SLOT( selectionChanged( const QString & ) ) ); 152 this, SLOT( selectionChanged( const QString & ) ) );
145 153
146 typemb = new MenuButton(this); 154 typemb = new MenuButton(this);
147 typemb->setLabel(tr("Type: %1")); 155 typemb->setLabel(tr("Type: %1"));
148 typemb->setMinimumWidth(110); 156 typemb->setMinimumWidth(110);
149 typemb->setFixedHeight(22); 157 typemb->setFixedHeight(22);
150 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); 158 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 );
151 updateMimeTypeMenu() ; 159 updateMimeTypeMenu() ;
152 160
153 currentDir.setPath(QDir::currentDirPath()); 161 currentDir.setPath(QDir::currentDirPath());
154 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); 162 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
155 currentDir.setNameFilter(filterStr); 163 currentDir.setNameFilter(filterStr);
156 164
157 populateList(); 165 populateList();
158 move(0,15); 166 move(0,15);
159} 167}
160 168
161fileBrowser::~fileBrowser() 169fileBrowser::~fileBrowser()
162{ 170{
163} 171}
164 172
165void fileBrowser::setFileView( int selection ) 173void fileBrowser::setFileView( int selection )
166{ 174{
167 SelectionCombo->setCurrentItem( selection ); 175 SelectionCombo->setCurrentItem( selection );
168 selectionChanged( SelectionCombo->currentText() ); 176 selectionChanged( SelectionCombo->currentText() );
169} 177}
170 178
171void fileBrowser::populateList() 179void fileBrowser::populateList()
172{ 180{
173 ListView->clear(); 181 ListView->clear();
174 QListViewItem * item; 182 QListViewItem * item;
175 bool isDir=FALSE; 183 bool isDir=FALSE;
176//qDebug(currentDir.canonicalPath()); 184//qDebug(currentDir.canonicalPath());
177 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 185 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
178 currentDir.setMatchAllDirs(TRUE); 186 currentDir.setMatchAllDirs(TRUE);
179 187
180// currentDir.setNameFilter("*.txt;*.etx"); 188// currentDir.setNameFilter("*.txt;*.etx");
181 QString fileL, fileS, fileDate; 189 QString fileL, fileS, fileDate;
182 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 190 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
183 QFileInfoListIterator it(*list); 191 QFileInfoListIterator it(*list);
184 QFileInfo *fi; 192 QFileInfo *fi;
185 while ( (fi=it.current()) ) { 193 while ( (fi=it.current()) ) {
186 if (fi->isSymLink() ){ 194 if (fi->isSymLink() ){
187 QString symLink=fi->readLink(); 195 QString symLink=fi->readLink();
188// qDebug("Symlink detected "+symLink); 196// qDebug("Symlink detected "+symLink);
189 QFileInfo sym( symLink); 197 QFileInfo sym( symLink);
190 fileS.sprintf( "%10li", sym.size() ); 198 fileS.sprintf( "%10li", sym.size() );
191 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 199 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
192 fileDate = sym.lastModified().toString(); 200 fileDate = sym.lastModified().toString();
193 } else { 201 } else {
194// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 202// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
195 fileS.sprintf( "%10li", fi->size() ); 203 fileS.sprintf( "%10li", fi->size() );
196 fileL.sprintf( "%s",fi->fileName().data() ); 204 fileL.sprintf( "%s",fi->fileName().data() );
197 fileDate= fi->lastModified().toString(); 205 fileDate= fi->lastModified().toString();
198 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 206 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
199 fileL+="/"; 207 fileL+="/";
200 isDir=TRUE; 208 isDir=TRUE;
201// qDebug( fileL); 209// qDebug( fileL);
202 } 210 }
203 } 211 }
204 if(fileL !="./" && fi->exists()) { 212 if(fileL !="./" && fi->exists()) {
205 item= new QListViewItem( ListView,fileL,fileS , fileDate); 213 item= new QListViewItem( ListView,fileL,fileS , fileDate);
206 QPixmap pm; 214 QPixmap pm;
207 215
208 if(isDir || fileL.find("/",0,TRUE) != -1) { 216 if(isDir || fileL.find("/",0,TRUE) != -1) {
209 if( !QDir( fi->filePath() ).isReadable()) 217 if( !QDir( fi->filePath() ).isReadable())
210 pm = Resource::loadPixmap( "lockedfolder" ); 218 pm = Resource::loadPixmap( "lockedfolder" );
211 else 219 else
212 pm= Resource::loadPixmap( "folder" ); 220 pm= Resource::loadPixmap( "folder" );
213 item->setPixmap( 0,pm ); 221 item->setPixmap( 0,pm );
214 } else { 222 } else {
215 if( !fi->isReadable() ) 223 if( !fi->isReadable() )
216 pm = Resource::loadPixmap( "locked" ); 224 pm = Resource::loadPixmap( "locked" );
217 else { 225 else {
218 MimeType mt(fi->filePath()); 226 MimeType mt(fi->filePath());
219 pm=mt.pixmap(); 227 pm=mt.pixmap();// sets the pixmap for the mimetype
220 if(pm.isNull()) 228 if(pm.isNull())
221 pm = Resource::loadPixmap( "UnknownDocument-14" ); 229 pm = Resource::loadPixmap( "UnknownDocument-14" );
222 item->setPixmap( 0,pm); 230 item->setPixmap( 0,pm);
223 } 231 }
224 } 232 }
225 if( fileL.find("->",0,TRUE) != -1) { 233 if( fileL.find("->",0,TRUE) != -1) {
226 // overlay link image 234 // overlay link image
227 pm= Resource::loadPixmap( "folder" ); 235 pm= Resource::loadPixmap( "folder" );
228 QPixmap lnk = Resource::loadPixmap( "symlink" ); 236 QPixmap lnk = Resource::loadPixmap( "symlink" );
229 QPainter painter( &pm ); 237 QPainter painter( &pm );
230 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 238 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
231 pm.setMask( pm.createHeuristicMask( FALSE ) ); 239 pm.setMask( pm.createHeuristicMask( FALSE ) );
232 item->setPixmap( 0, pm); 240 item->setPixmap( 0, pm);
233 } 241 }
234 } 242 }
235 isDir=FALSE; 243 isDir=FALSE;
236 ++it; 244 ++it;
237// } 245// }
238 } 246 }
239 ListView->setSorting( 3, FALSE); 247 ListView->setSorting( 3, FALSE);
240 QString currentPath = currentDir.canonicalPath(); 248 QString currentPath = currentDir.canonicalPath();
241 249
242 fillCombo( (const QString &)currentPath); 250 fillCombo( (const QString &)currentPath);
243// dirPathCombo->lineEdit()->setText(currentPath); 251// dirPathCombo->lineEdit()->setText(currentPath);
244 252
245// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 253// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
246// dirPathCombo->clear(); 254// dirPathCombo->clear();
247// dirPathStringList.prepend(currentPath ); 255// dirPathStringList.prepend(currentPath );
248// dirPathCombo->insertStringList( dirPathStringList,-1); 256// dirPathCombo->insertStringList( dirPathStringList,-1);
249// } 257// }
250} 258}
251 259
252void fileBrowser::upDir() 260void fileBrowser::upDir()
253{ 261{
254 QString current = currentDir.canonicalPath(); 262 QString current = currentDir.canonicalPath();
255 QDir dir(current); 263 QDir dir(current);
256 dir.cdUp(); 264 dir.cdUp();
257 current = dir.canonicalPath(); 265 current = dir.canonicalPath();
258 chdir( current.latin1() ); 266 chdir( current.latin1() );
259 currentDir.cd( current, TRUE); 267 currentDir.cd( current, TRUE);
260 populateList(); 268 populateList();
261 update(); 269 update();
262} 270}
263 271
264// you may want to switch these 2 functions. I like single clicks 272// you may want to switch these 2 functions. I like single clicks
265void fileBrowser::listClicked(QListViewItem *selectedItem) 273void fileBrowser::listClicked(QListViewItem *selectedItem)
266{ 274{
267 if(selectedItem) { 275 if(selectedItem) {
268 QString strItem=selectedItem->text(0); 276 QString strItem=selectedItem->text(0);
269 QString strSize=selectedItem->text(1); 277 QString strSize=selectedItem->text(1);
270// qDebug("strItem is "+strItem); 278// qDebug("strItem is "+strItem);
271 strSize.stripWhiteSpace(); 279 strSize.stripWhiteSpace();
272// qDebug(strSize); 280// qDebug(strSize);
273 281
274 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 282 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
275 // is symlink 283 // is symlink
276 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 284 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
277// qDebug("strItem symlink is "+strItem2); 285// qDebug("strItem symlink is "+strItem2);
278 if(QDir(strItem2).exists() ) { 286 if(QDir(strItem2).exists() ) {
279 currentDir.cd(strItem2, TRUE); 287 currentDir.cd(strItem2, TRUE);
280 populateList(); 288 populateList();
281 } 289 }
282 } else { // not a symlink 290 } else { // not a symlink
283 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 291 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
284 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 292 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
285 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 293 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
286 currentDir.cd(strItem,FALSE); 294 currentDir.cd(strItem,FALSE);
287// qDebug("Path is "+strItem); 295// qDebug("Path is "+strItem);
288 populateList(); 296 populateList();
289 } else { 297 } else {
290 currentDir.cdUp(); 298 currentDir.cdUp();
291 populateList(); 299 populateList();
292 } 300 }
293 if(QDir(strItem).exists()){ 301 if(QDir(strItem).exists()){
294 currentDir.cd(strItem, TRUE); 302 currentDir.cd(strItem, TRUE);
295 populateList(); 303 populateList();
296 } 304 }
297 } else { 305 } else {
298 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 306 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
299 if( QFile::exists(strItem ) ) { 307 if( QFile::exists(strItem ) ) {
300//currentDir.canonicalPath() 308//currentDir.canonicalPath()
301 qDebug("We found our files!!"+strItem); 309 qDebug("We found our files!!"+strItem);
302 OnOK(); 310 OnOK();
303 } 311 }
304 } //end not symlink 312 } //end not symlink
305 chdir(strItem.latin1()); 313 chdir(strItem.latin1());
306 } 314 }
307 } 315 }
308} 316}
309 317
310void fileBrowser::OnOK() 318void fileBrowser::OnOK()
311{ 319{
312 QListViewItemIterator it1( ListView); 320 QListViewItemIterator it1( ListView);
313 for ( ; it1.current(); ++it1 ) { 321 for ( ; it1.current(); ++it1 ) {
314 if ( it1.current()->isSelected() ) { 322 if ( it1.current()->isSelected() ) {
315 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); 323 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
316 qDebug("selected filename is "+selectedFileName); 324 qDebug("selected filename is "+selectedFileName);
317 fileList.append( selectedFileName ); 325 fileList.append( selectedFileName );
318 } 326 }
319 } 327 }
320 accept(); 328 accept();
321} 329}
322 330
323void fileBrowser::homeButtonPushed() { 331void fileBrowser::homeButtonPushed() {
324 QString current = QDir::homeDirPath(); 332 QString current = QDir::homeDirPath();
325 chdir( current.latin1() ); 333 chdir( current.latin1() );
326 currentDir.cd( current, TRUE); 334 currentDir.cd( current, TRUE);
327 populateList(); 335 populateList();
328 update(); 336 update();
329} 337}
330 338
331void fileBrowser::docButtonPushed() { 339void fileBrowser::docButtonPushed() {
332 QString current = QPEApplication::documentDir(); 340 QString current = QPEApplication::documentDir();
333 chdir( current.latin1() ); 341 chdir( current.latin1() );
334 currentDir.cd( current, TRUE); 342 currentDir.cd( current, TRUE);
335 populateList(); 343 populateList();
336 update(); 344 update();
337 345
338} 346}
339 347
340void fileBrowser::selectionChanged( const QString &select ) 348void fileBrowser::selectionChanged( const QString &select )
341{ 349{
342 if ( select == "Documents") { 350 if ( select == "Documents") {
343 FileStack->raiseWidget( fileSelector ); 351 FileStack->raiseWidget( fileSelector );
344 dirPathCombo->hide(); 352 dirPathCombo->hide();
345 cdUpButton->hide(); 353 cdUpButton->hide();
346 docButton->hide(); 354 docButton->hide();
347 homeButton->hide(); 355 homeButton->hide();
348 } else { 356 } else {
349 if ( select == "All files" ) 357 if ( select == "All files" )
350 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); 358 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All);
351 else 359 else
352 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 360 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
353 361
354 populateList(); 362 populateList();
355 update(); 363 update();
356 dirPathCombo->show(); 364 dirPathCombo->show();
357 cdUpButton->show(); 365 cdUpButton->show();
358 docButton->show(); 366 docButton->show();
359 homeButton->show(); 367 homeButton->show();
360 FileStack->raiseWidget( ListView ); 368 FileStack->raiseWidget( ListView );
361 } 369 }
362} 370}
363 371
364void fileBrowser::docOpen( const DocLnk &doc ) 372void fileBrowser::docOpen( const DocLnk &doc )
365{ 373{
366 fileList.append( doc.file().latin1() ); 374 fileList.append( doc.file().latin1() );
367 accept(); 375 accept();
368} 376}
369 377
370void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 378void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
371{ 379{
372 switch (mouse) { 380 switch (mouse) {
373 case 1: 381 case 1:
374 break; 382 break;
375 case 2: 383 case 2:
376 showListMenu(item); 384 showListMenu(item);
377 break; 385 break;
378 }; 386 };
379} 387}
380 388
381void fileBrowser::showListMenu(QListViewItem *item) { 389void fileBrowser::showListMenu(QListViewItem *item) {
382 390
383 QPopupMenu m;// = new QPopupMenu( Local_View ); 391 QPopupMenu m;// = new QPopupMenu( Local_View );
384 if(item) { 392 if(item) {
385 if( item->text(0).find("/",0,TRUE)) 393 if( item->text(0).find("/",0,TRUE))
386 m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); 394 m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() ));
387 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); 395 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() ));
388 m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); 396 m.insertItem( tr( "Rescan" ), this, SLOT( populateList() ));
389 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 397 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
390 m.insertSeparator(); 398 m.insertSeparator();
391 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 399 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
392 } else { 400 } else {
393 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); 401 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() ));
394 m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); 402 m.insertItem( tr( "Rescan" ), this, SLOT( populateList() ));
395 403
396 } 404 }
397 m.exec( QCursor::pos() ); 405 m.exec( QCursor::pos() );
398} 406}
399 407
400void fileBrowser::doCd() { 408void fileBrowser::doCd() {
401 listClicked( ListView->currentItem()); 409 listClicked( ListView->currentItem());
402} 410}
403 411
404void fileBrowser::makDir() { 412void fileBrowser::makDir() {
405 InputDialog *fileDlg; 413 InputDialog *fileDlg;
406 fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); 414 fileDlg = new InputDialog(this,"Make Directory",TRUE, 0);
407 fileDlg->exec(); 415 fileDlg->exec();
408 if( fileDlg->result() == 1 ) { 416 if( fileDlg->result() == 1 ) {
409 QString filename = fileDlg->LineEdit1->text(); 417 QString filename = fileDlg->LineEdit1->text();
410 qDebug("Make dir"); 418 qDebug("Make dir");
411 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 419 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
412 } 420 }
413 populateList(); 421 populateList();
414} 422}
415 423
416void fileBrowser::localRename() { 424void fileBrowser::localRename() {
417 QString curFile = ListView->currentItem()->text(0); 425 QString curFile = ListView->currentItem()->text(0);
418 InputDialog *fileDlg; 426 InputDialog *fileDlg;
419 fileDlg = new InputDialog(this,"Rename",TRUE, 0); 427 fileDlg = new InputDialog(this,"Rename",TRUE, 0);
420 fileDlg->inputText = curFile; 428 fileDlg->setTextEdit((const QString &) curFile);
421 fileDlg->exec(); 429 fileDlg->exec();
422 if( fileDlg->result() == 1 ) { 430 if( fileDlg->result() == 1 ) {
423 QString oldname = currentDir.canonicalPath() + "/" + curFile; 431 QString oldname = currentDir.canonicalPath() + "/" + curFile;
424 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 432 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
425 if( rename(oldname.latin1(), newName.latin1())== -1) 433 if( rename(oldname.latin1(), newName.latin1())== -1)
426 QMessageBox::message("Note","Could not rename"); 434 QMessageBox::message("Note","Could not rename");
427 } 435 }
428 populateList(); 436 populateList();
429} 437}
430 438
431void fileBrowser::localDelete() { 439void fileBrowser::localDelete() {
432 QString f = ListView->currentItem()->text(0); 440 QString f = ListView->currentItem()->text(0);
433 if(QDir(f).exists() ) { 441 if(QDir(f).exists() ) {
434 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ 442 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+
435 " ?\nIt must be empty","Yes","No",0,0,1) ) { 443 " ?\nIt must be empty","Yes","No",0,0,1) ) {
436 case 0: { 444 case 0: {
437 f=currentDir.canonicalPath()+"/"+f; 445 f=currentDir.canonicalPath()+"/"+f;
438 QString cmd="rmdir "+f; 446 QString cmd="rmdir "+f;
439 system( cmd.latin1()); 447 system( cmd.latin1());
440 populateList(); 448 populateList();
441 } 449 }
442 break; 450 break;
443 case 1: 451 case 1:
444 // exit 452 // exit
445 break; 453 break;
446 }; 454 };
447 } else { 455 } else {
448 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f 456 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f
449 +" ?","Yes","No",0,0,1) ) { 457 +" ?","Yes","No",0,0,1) ) {
450 case 0: { 458 case 0: {
451 f=currentDir.canonicalPath()+"/"+f; 459 f=currentDir.canonicalPath()+"/"+f;
452 QString cmd="rm "+f; 460 QString cmd="rm "+f;
453 system( cmd.latin1()); 461 system( cmd.latin1());
454 populateList(); 462 populateList();
455 } 463 }
456 break; 464 break;
457 case 1: 465 case 1:
458 // exit 466 // exit
459 break; 467 break;
460 }; 468 };
461 } 469 }
462} 470}
463 471
464void fileBrowser::updateMimeTypeMenu() { 472void fileBrowser::updateMimeTypeMenu() {
465 473
466 disconnect( typemb, SIGNAL(selected(const QString&)), 474 disconnect( typemb, SIGNAL(selected(const QString&)),
467 this, SLOT(showType(const QString&)) ); 475 this, SLOT(showType(const QString&)) );
468 476
469 QString prev; 477 QString prev;
470 478
471 // Type filter 479 // Type filter
472 QStringList types; 480 QStringList types;
473 types << tr("All"); 481 types << tr("All");
474 types << "--"; 482 types << "--";
475 types += getMimeTypes(); 483 types += getMimeTypes();
476 prev = typemb->currentText(); 484 prev = typemb->currentText();
477 typemb->clear(); 485 typemb->clear();
478 typemb->insertItems(types); 486 typemb->insertItems(types);
479 // typemb->select(prev); 487 // typemb->select(prev);
480 488
481 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); 489 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&)));
482} 490}
483 491
484void fileBrowser::showType(const QString &t) { 492void fileBrowser::showType(const QString &t) {
485 493
486 qDebug(t); 494 qDebug(t);
487 if(t.find("All",0,TRUE) != -1) { 495 if(t.find("All",0,TRUE) != -1) {
488 filterStr = "*"; 496 filterStr = "*";
489 } else { 497 } else {
490 QStringList list = mimetypes.grep( t,TRUE); 498 QStringList list = mimetypes.grep( t,TRUE);
491 QString ext; 499 QString ext;
492 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 500 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
493 mimeType =(*it); 501 mimeType =(*it);
494 MimeType mt( mimeType); 502 MimeType mt( mimeType);
495 qDebug("mime "+mimeType); 503// qDebug("mime "+mimeType);
496// qDebug("description "+mt.description()); 504// qDebug("description "+mt.description());
497// qDebug( "id "+mt.id()); 505// qDebug( "id "+mt.id());
498 qDebug("extension "+mt.extension()); 506// qDebug("extension "+mt.extension());
499 if( mt.extension().isEmpty()) 507// if( mt.extension().isEmpty())
500 filterStr = "*"; 508 filterStr = "*";
501 else 509// else
502 filterStr = "*."+ mt.extension()+" "; 510// filterStr = "*."+ mt.extension()+" ";
503// printf( "%s \n", (*it).latin1() ); 511// printf( "%s \n", (*it).latin1() );
504 } 512 }
505 } 513 }
506 currentDir.setNameFilter(filterStr); 514 currentDir.setNameFilter(filterStr);
507 515
508 populateList(); 516 populateList();
509 update(); 517 update();
510// if(fileSelector) { 518// if(fileSelector) {
511// disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); 519// disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
512// delete fileSelector; 520// delete fileSelector;
513 // } 521 // }
514 // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy 522 // fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
515// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 523// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
516// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 524// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
517 // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); 525 // connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
518// fileSelector->reread(); 526// fileSelector->reread();
519// if ( t == tr("All") ) { 527// if ( t == tr("All") ) {
520// icons->setTypeFilter("",TRUE); 528// icons->setTypeFilter("",TRUE);
521// } else { 529// } else {
522// icons->setTypeFilter(t+"/*",TRUE); 530// icons->setTypeFilter(t+"/*",TRUE);
523// } 531// }
524 532
525} 533}
526 534
527QStringList fileBrowser::getMimeTypes() { 535QStringList fileBrowser::getMimeTypes() {
528 536
529 QStringList r; 537 QStringList r;
530 AppLnkSet apps( QPEApplication::qpeDir() + "apps" ); 538 AppLnkSet apps( QPEApplication::qpeDir() + "apps" );
531 QFile file( QPEApplication::qpeDir()+"etc/available.mime"); 539 QFile file( QPEApplication::qpeDir()+"etc/available.mime");
532 file.open( IO_WriteOnly|IO_Truncate);//) 540 file.open( IO_WriteOnly|IO_Truncate);//)
533 for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) { 541 for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) {
534 AppLnk* l; 542 AppLnk* l;
535 l = it.current(); 543 l = it.current();
536 QStringList maj = l->mimeTypes(); 544 QStringList maj = l->mimeTypes();
537 QStringList::ConstIterator f; 545 QStringList::ConstIterator f;
538 for ( f = maj.begin(); f != maj.end(); f++ ) { 546 for ( f = maj.begin(); f != maj.end(); f++ ) {
539 QString temp = *f; 547 QString temp = *f;
540 mimetypes << temp; 548 mimetypes << temp;
541 int sl = temp.find('/'); 549 int sl = temp.find('/');
542 if (sl >= 0) { 550 if (sl >= 0) {
543 QString k = temp.left(sl); 551 QString k = temp.left(sl);
544 if( r.grep(k,TRUE).isEmpty() ) { 552 if( r.grep(k,TRUE).isEmpty() ) {
545 r << k; 553 r << k;
546 k+="\n"; 554 k+="\n";
547 file.writeBlock( k.latin1(), k.length()); 555 file.writeBlock( k.latin1(), k.length());
548 } 556 }
549 } 557 }
550 } 558 }
551 } 559 }
552 r.sort(); 560 r.sort();
553 file.close(); 561 file.close();
554 return r; 562 return r;
555} 563}
556 564
557void fileBrowser::receive( const QCString &msg, const QByteArray &data ) { 565void fileBrowser::receive( const QCString &msg, const QByteArray &data ) {
558// QDataStream stream( data, IO_ReadOnly ); 566// QDataStream stream( data, IO_ReadOnly );
559// if (msg == "keyRegister(int key, QString channel, QString message)") 567// if (msg == "keyRegister(int key, QString channel, QString message)")
560// { 568// {
561// int k; 569// int k;
562// QString c, m; 570// QString c, m;
563// stream >> k; 571// stream >> k;
564// stream >> c; 572// stream >> c;
565// stream >> m; 573// stream >> m;
566} 574}
567 575
568void fileBrowser::dirPathComboActivated( const QString & current) { 576void fileBrowser::dirPathComboActivated( const QString & current) {
569 chdir( current.latin1() ); 577 chdir( current.latin1() );
570 currentDir.cd( current, TRUE); 578 currentDir.cd( current, TRUE);
571 populateList(); 579 populateList();
572 update(); 580 update();
573} 581}
574 582
575void fileBrowser::dirPathEditPressed() { 583void fileBrowser::dirPathEditPressed() {
576 QString current = dirPathCombo->lineEdit()->text(); 584 QString current = dirPathCombo->lineEdit()->text();
577 chdir( current.latin1() ); 585 chdir( current.latin1() );
578 currentDir.cd( current, TRUE); 586 currentDir.cd( current, TRUE);
579 populateList(); 587 populateList();
580 update(); 588 update();
581} 589}
582 590
583void fileBrowser::fillCombo(const QString &currentPath) { 591void fileBrowser::fillCombo(const QString &currentPath) {
584 592
585 dirPathCombo->lineEdit()->setText(currentPath); 593 dirPathCombo->lineEdit()->setText(currentPath);
586 594
587 if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 595 if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
588 dirPathCombo->clear(); 596 dirPathCombo->clear();
589 dirPathStringList.prepend(currentPath ); 597 dirPathStringList.prepend(currentPath );
590 dirPathCombo->insertStringList( dirPathStringList,-1); 598 dirPathCombo->insertStringList( dirPathStringList,-1);
591 } 599 }
592} 600}
593 601
594 602
595InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 603InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
596 : QDialog( parent, name, modal, fl ) 604 : QDialog( parent, name, modal, fl )
597{ 605{
598 if ( !name ) 606 if ( !name )
599 setName( "InputDialog" ); 607 setName( "InputDialog" );
600 resize( 234, 50 ); 608 resize( 234, 50 );
601 setMaximumSize( QSize( 240, 50 ) ); 609 setMaximumSize( QSize( 240, 50 ) );
602 setCaption( tr(name ) ); 610 setCaption( tr(name ) );
603 611
604 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 612 LineEdit1 = new QLineEdit( this, "LineEdit1" );
605 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 613 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
606} 614}
607 615
608InputDialog::~InputDialog() 616InputDialog::~InputDialog()
609{ 617{
610 inputText= LineEdit1->text(); 618 inputText= LineEdit1->text();
611 619
612} 620}
613 621
622void InputDialog::setTextEdit(const QString &string) {
623 LineEdit1->setText(string);
624}
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
index e76c7df..3db6a27 100644
--- a/core/apps/textedit/fileBrowser.h
+++ b/core/apps/textedit/fileBrowser.h
@@ -1,119 +1,119 @@
1/**************************************************************************** 1/****************************************************************************
2** 2**
3** Created: Fri Dec 14 08:16:02 2001 3** Created: Fri Dec 14 08:16:02 2001
4** 4**
5** This file may be distributed and/or modified under the terms of the 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 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 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com 13copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com
14****************************************************************************/ 14****************************************************************************/
15#ifndef FILEBROWSER_H 15#ifndef FILEBROWSER_H
16#define FILEBROWSER_H 16#define FILEBROWSER_H
17 17
18//#include <qvariant.h> 18//#include <qvariant.h>
19#include <qdialog.h> 19#include <qdialog.h>
20#include <qfile.h> 20#include <qfile.h>
21#include <qdir.h> 21#include <qdir.h>
22#include <qstringlist.h> 22#include <qstringlist.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qdict.h> 25#include <qdict.h>
26 26
27#include <qpe/filemanager.h> 27#include <qpe/filemanager.h>
28 28
29#include <qvariant.h> 29#include <qvariant.h>
30#include <qdialog.h> 30#include <qdialog.h>
31class QLineEdit; 31class QLineEdit;
32 32
33class QVBoxLayout; 33class QVBoxLayout;
34class QHBoxLayout; 34class QHBoxLayout;
35class QGridLayout; 35class QGridLayout;
36class QListView; 36class QListView;
37class QListViewItem; 37class QListViewItem;
38class QPushButton; 38class QPushButton;
39class QComboBox; 39class QComboBox;
40class QWidgetStack; 40class QWidgetStack;
41class FileSelector; 41class FileSelector;
42class QPoint; 42class QPoint;
43class MenuButton; 43class MenuButton;
44class QRegExp; 44class QRegExp;
45 45
46 46
47class fileBrowser : public QDialog 47class fileBrowser : public QDialog
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 50
51public: 51public:
52 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); 52 fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
53 ~fileBrowser(); 53 ~fileBrowser();
54 54
55 QString selectedFileName; 55 QString selectedFileName;
56 QFile file; 56 QFile file;
57 QStringList fileList; 57 QStringList fileList;
58 QComboBox *SelectionCombo; 58 QComboBox *SelectionCombo;
59public slots: 59public slots:
60 void setFileView( int ); 60 void setFileView( int );
61 61
62private: 62private:
63// QDict<void> mimes; 63// QDict<void> mimes;
64 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; 64 QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton;
65 QListView* ListView; 65 QListView* ListView;
66 QLabel *dirLabel; 66 QLabel *dirLabel;
67 QString filterStr, mimeType; 67 QString filterStr, mimeType;
68 QDir currentDir; 68 QDir currentDir;
69 QStringList dirPathStringList, mimetypes; 69 QStringList dirPathStringList, mimetypes;
70/* QListViewItem * item; */ 70/* QListViewItem * item; */
71 QComboBox *dirPathCombo; 71 QComboBox *dirPathCombo;
72 MenuButton *typemb; 72 MenuButton *typemb;
73 QWidgetStack *FileStack; 73 QWidgetStack *FileStack;
74 FileSelector *fileSelector; 74 FileSelector *fileSelector;
75 QRegExp tf; 75 QRegExp tf;
76 QStringList getMimeTypes(); 76 QStringList getMimeTypes();
77 void fillCombo( const QString&); 77 void fillCombo( const QString&);
78 78
79private slots: 79private slots:
80 void populateList(); 80 void populateList();
81 void homeButtonPushed(); 81 void homeButtonPushed();
82 void docButtonPushed(); 82 void docButtonPushed();
83 void ListPressed( int, QListViewItem *, const QPoint&, int); 83 void ListPressed( int, QListViewItem *, const QPoint&, int);
84 void showListMenu(QListViewItem*); 84 void showListMenu(QListViewItem*);
85 void doCd(); 85 void doCd();
86 void makDir(); 86 void makDir();
87 void localRename(); 87 void localRename();
88 void localDelete(); 88 void localDelete();
89 void receive( const QCString &msg, const QByteArray &data ); 89 void receive( const QCString &msg, const QByteArray &data );
90 void dirPathComboActivated( const QString & ); 90 void dirPathComboActivated( const QString & );
91 void upDir(); 91 void upDir();
92 void listClicked( QListViewItem * ); 92 void listClicked( QListViewItem * );
93 void selectionChanged( const QString & ); 93 void selectionChanged( const QString & );
94 void OnOK(); 94 void OnOK();
95 void docOpen( const DocLnk & ); 95 void docOpen( const DocLnk & );
96 void updateMimeTypeMenu(); 96 void updateMimeTypeMenu();
97 void showType(const QString &); 97 void showType(const QString &);
98 void dirPathEditPressed(); 98 void dirPathEditPressed();
99 99
100protected slots: 100protected slots:
101 101
102protected: 102protected:
103 103
104}; 104};
105 105
106 106
107class InputDialog : public QDialog 107class InputDialog : public QDialog
108{ 108{
109 Q_OBJECT 109 Q_OBJECT
110 110
111public: 111public:
112 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 112 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
113 ~InputDialog(); 113 ~InputDialog();
114 QString inputText; 114 QString inputText;
115 QLineEdit* LineEdit1; 115 QLineEdit* LineEdit1;
116 116 void setTextEdit(const QString &);
117}; 117};
118 118
119#endif // FILEBROWSER_H 119#endif // FILEBROWSER_H
diff --git a/noncore/net/opieftp/inputDialog.cpp b/noncore/net/opieftp/inputDialog.cpp
index 89b345e..373db3b 100644
--- a/noncore/net/opieftp/inputDialog.cpp
+++ b/noncore/net/opieftp/inputDialog.cpp
@@ -1,40 +1,44 @@
1/**************************************************************************** 1/****************************************************************************
2 inputDialog.cpp 2 inputDialog.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 12
13#include "inputDialog.h" 13#include "inputDialog.h"
14 14
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qlayout.h> 16#include <qlayout.h>
17#include <qvariant.h> 17#include <qvariant.h>
18#include <qtooltip.h> 18#include <qtooltip.h>
19#include <qwhatsthis.h> 19#include <qwhatsthis.h>
20 20
21 21
22InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 22InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
23 : QDialog( parent, name, modal, fl ) 23 : QDialog( parent, name, modal, fl )
24{ 24{
25 if ( !name ) 25 if ( !name )
26 setName( "InputDialog" ); 26 setName( "InputDialog" );
27 resize( 234, 50 ); 27 resize( 234, 50 );
28 setMaximumSize( QSize( 240, 50 ) ); 28 setMaximumSize( QSize( 240, 50 ) );
29 setCaption( tr(name ) ); 29 setCaption( tr(name ) );
30 30
31 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 31 LineEdit1 = new QLineEdit( this, "LineEdit1" );
32 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 32 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
33} 33}
34 34
35InputDialog::~InputDialog() 35InputDialog::~InputDialog()
36{ 36{
37 inputText= LineEdit1->text(); 37 inputText= LineEdit1->text();
38 38
39} 39}
40 40
41void InputDialog::setTextEdit(const QString &string)
42{
43 LineEdit1->setText(string);
44}
diff --git a/noncore/net/opieftp/inputDialog.h b/noncore/net/opieftp/inputDialog.h
index 2cd8285..dfe0e8a 100644
--- a/noncore/net/opieftp/inputDialog.h
+++ b/noncore/net/opieftp/inputDialog.h
@@ -1,34 +1,34 @@
1/*************************************************************************** 1/***************************************************************************
2 inputDialog.h 2 inputDialog.h
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#ifndef INPUTDIALOG_H 12#ifndef INPUTDIALOG_H
13#define INPUTDIALOG_H 13#define INPUTDIALOG_H
14 14
15#include <qvariant.h> 15#include <qvariant.h>
16#include <qdialog.h> 16#include <qdialog.h>
17class QVBoxLayout; 17class QVBoxLayout;
18class QHBoxLayout; 18class QHBoxLayout;
19class QGridLayout; 19class QGridLayout;
20class QLineEdit; 20class QLineEdit;
21 21
22class InputDialog : public QDialog 22class InputDialog : public QDialog
23{ 23{
24 Q_OBJECT 24 Q_OBJECT
25 25
26public: 26public:
27 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 27 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
28 ~InputDialog(); 28 ~InputDialog();
29 QString inputText; 29 QString inputText;
30 QLineEdit* LineEdit1; 30 QLineEdit* LineEdit1;
31 31 void setTextEdit(const QString &);
32}; 32};
33 33
34#endif // INPUTDIALOG_H 34#endif // INPUTDIALOG_H
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index e64fd73..b451925 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,1192 +1,1192 @@
1/*************************************************************************** 1/***************************************************************************
2 opieftp.cpp 2 opieftp.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//#define DEVELOPERS_VERSION 12//#define DEVELOPERS_VERSION
13 13
14#include "opieftp.h" 14#include "opieftp.h"
15#include "ftplib.h" 15#include "ftplib.h"
16#include "inputDialog.h" 16#include "inputDialog.h"
17 17
18#include <qpe/qpemenubar.h> 18#include <qpe/qpemenubar.h>
19#include <qpe/qpetoolbar.h> 19#include <qpe/qpetoolbar.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/mimetype.h> 24#include <qpe/mimetype.h>
25 25
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qlistview.h> 36#include <qlistview.h>
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qprogressbar.h> 39#include <qprogressbar.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41#include <qtabwidget.h> 41#include <qtabwidget.h>
42#include <qwidget.h> 42#include <qwidget.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qimage.h> 44#include <qimage.h>
45#include <qpixmap.h> 45#include <qpixmap.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qlineedit.h> 47#include <qlineedit.h>
48#include <qregexp.h> 48#include <qregexp.h>
49 49
50#include <unistd.h> 50#include <unistd.h>
51#include <stdlib.h> 51#include <stdlib.h>
52 52
53 53
54QProgressBar *ProgressBar; 54QProgressBar *ProgressBar;
55static netbuf *conn=NULL; 55static netbuf *conn=NULL;
56 56
57static int log_progress(netbuf *ctl, int xfered, void *arg) 57static int log_progress(netbuf *ctl, int xfered, void *arg)
58{ 58{
59 int fsz = *(int *)arg; 59 int fsz = *(int *)arg;
60 int pct = (xfered * 100) / fsz; 60 int pct = (xfered * 100) / fsz;
61// printf("%3d%%\r", pct); 61// printf("%3d%%\r", pct);
62// fflush(stdout); 62// fflush(stdout);
63 ProgressBar->setProgress(xfered); 63 ProgressBar->setProgress(xfered);
64 qApp->processEvents(); 64 qApp->processEvents();
65 return 1; 65 return 1;
66} 66}
67 67
68OpieFtp::OpieFtp( ) 68OpieFtp::OpieFtp( )
69 : QMainWindow( ) 69 : QMainWindow( )
70{ 70{
71 setCaption( tr( "OpieFtp" ) ); 71 setCaption( tr( "OpieFtp" ) );
72 72
73 QGridLayout *layout = new QGridLayout( this ); 73 QGridLayout *layout = new QGridLayout( this );
74 layout->setSpacing( 2); 74 layout->setSpacing( 2);
75 layout->setMargin( 2); 75 layout->setMargin( 2);
76 76
77 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 77 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
78 78
79 QPEMenuBar *menuBar = new QPEMenuBar(this); 79 QPEMenuBar *menuBar = new QPEMenuBar(this);
80 connectionMenu = new QPopupMenu( this ); 80 connectionMenu = new QPopupMenu( this );
81 localMenu = new QPopupMenu( this ); 81 localMenu = new QPopupMenu( this );
82 remoteMenu = new QPopupMenu( this ); 82 remoteMenu = new QPopupMenu( this );
83 tabMenu = new QPopupMenu( this ); 83 tabMenu = new QPopupMenu( this );
84 84
85 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 ); 85 layout->addMultiCellWidget( menuBar, 0, 0, 0, 3 );
86 86
87 menuBar->insertItem( tr( "Connection" ), connectionMenu); 87 menuBar->insertItem( tr( "Connection" ), connectionMenu);
88 menuBar->insertItem( tr( "Local" ), localMenu); 88 menuBar->insertItem( tr( "Local" ), localMenu);
89 menuBar->insertItem( tr( "Remote" ), remoteMenu); 89 menuBar->insertItem( tr( "Remote" ), remoteMenu);
90 menuBar->insertItem( tr( "View" ), tabMenu); 90 menuBar->insertItem( tr( "View" ), tabMenu);
91 91
92 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 92 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
93 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 93 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
94 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 94 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
95 95
96 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 96 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
97 localMenu->insertSeparator(); 97 localMenu->insertSeparator();
98 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 98 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
99 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 99 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
100 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 100 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
101 localMenu->insertSeparator(); 101 localMenu->insertSeparator();
102 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 102 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
103 localMenu->setCheckable(TRUE); 103 localMenu->setCheckable(TRUE);
104 104
105 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 105 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
106 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 106 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
107 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 107 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
108 remoteMenu->insertSeparator(); 108 remoteMenu->insertSeparator();
109 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 109 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
110 110
111 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 111 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
112 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 112 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
113 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 113 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
114 tabMenu->setCheckable(TRUE); 114 tabMenu->setCheckable(TRUE);
115 115
116 TabWidget = new QTabWidget( this, "TabWidget" ); 116 TabWidget = new QTabWidget( this, "TabWidget" );
117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 ); 117 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 3 );
118 118
119 TabWidget->setTabShape(QTabWidget::Triangular); 119 TabWidget->setTabShape(QTabWidget::Triangular);
120 120
121 tab = new QWidget( TabWidget, "tab" ); 121 tab = new QWidget( TabWidget, "tab" );
122 tabLayout = new QGridLayout( tab ); 122 tabLayout = new QGridLayout( tab );
123 tabLayout->setSpacing( 2); 123 tabLayout->setSpacing( 2);
124 tabLayout->setMargin( 2); 124 tabLayout->setMargin( 2);
125 125
126 Local_View = new QListView( tab, "Local_View" ); 126 Local_View = new QListView( tab, "Local_View" );
127// Local_View->setResizePolicy( QListView::AutoOneFit ); 127// Local_View->setResizePolicy( QListView::AutoOneFit );
128 Local_View->addColumn( tr("File"),150); 128 Local_View->addColumn( tr("File"),150);
129 Local_View->addColumn( tr("Size"),-1); 129 Local_View->addColumn( tr("Size"),-1);
130 Local_View->setColumnAlignment(1,QListView::AlignRight); 130 Local_View->setColumnAlignment(1,QListView::AlignRight);
131 Local_View->addColumn( tr("Date"),-1); 131 Local_View->addColumn( tr("Date"),-1);
132 Local_View->setColumnAlignment(2,QListView::AlignRight); 132 Local_View->setColumnAlignment(2,QListView::AlignRight);
133 Local_View->setAllColumnsShowFocus(TRUE); 133 Local_View->setAllColumnsShowFocus(TRUE);
134 Local_View->setMultiSelection( TRUE ); 134 Local_View->setMultiSelection( TRUE );
135 Local_View->setSelectionMode(QListView::Extended); 135 Local_View->setSelectionMode(QListView::Extended);
136 136
137 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 137 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
138 138
139 tabLayout->addWidget( Local_View, 0, 0 ); 139 tabLayout->addWidget( Local_View, 0, 0 );
140 140
141 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 141 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
142 this,SLOT( localListClicked(QListViewItem *)) ); 142 this,SLOT( localListClicked(QListViewItem *)) );
143// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 143// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
144// this,SLOT( localListClicked(QListViewItem *)) ); 144// this,SLOT( localListClicked(QListViewItem *)) );
145 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 145 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
146 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 146 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
147 147
148 TabWidget->insertTab( tab, tr( "Local" ) ); 148 TabWidget->insertTab( tab, tr( "Local" ) );
149 149
150 tab_2 = new QWidget( TabWidget, "tab_2" ); 150 tab_2 = new QWidget( TabWidget, "tab_2" );
151 tabLayout_2 = new QGridLayout( tab_2 ); 151 tabLayout_2 = new QGridLayout( tab_2 );
152 tabLayout_2->setSpacing( 2); 152 tabLayout_2->setSpacing( 2);
153 tabLayout_2->setMargin( 2); 153 tabLayout_2->setMargin( 2);
154 154
155 Remote_View = new QListView( tab_2, "Remote_View" ); 155 Remote_View = new QListView( tab_2, "Remote_View" );
156 Remote_View->addColumn( tr("File"),150); 156 Remote_View->addColumn( tr("File"),150);
157 Remote_View->addColumn( tr("Size"),-1); 157 Remote_View->addColumn( tr("Size"),-1);
158 Remote_View->setColumnAlignment(1,QListView::AlignRight); 158 Remote_View->setColumnAlignment(1,QListView::AlignRight);
159 Remote_View->addColumn( tr("Date"),-1); 159 Remote_View->addColumn( tr("Date"),-1);
160 Remote_View->setColumnAlignment(2,QListView::AlignRight); 160 Remote_View->setColumnAlignment(2,QListView::AlignRight);
161 Remote_View->addColumn( tr("Dir"),-1); 161 Remote_View->addColumn( tr("Dir"),-1);
162 Remote_View->setColumnAlignment(4,QListView::AlignRight); 162 Remote_View->setColumnAlignment(4,QListView::AlignRight);
163 Remote_View->setAllColumnsShowFocus(TRUE); 163 Remote_View->setAllColumnsShowFocus(TRUE);
164 Remote_View->setMultiSelection( TRUE ); 164 Remote_View->setMultiSelection( TRUE );
165 Remote_View->setSelectionMode(QListView::Extended); 165 Remote_View->setSelectionMode(QListView::Extended);
166 166
167 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 167 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
168 168
169 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 169 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
170 this,SLOT( remoteListClicked(QListViewItem *)) ); 170 this,SLOT( remoteListClicked(QListViewItem *)) );
171 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 171 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
172 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 172 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
173 173
174 tabLayout_2->addWidget( Remote_View, 0, 0 ); 174 tabLayout_2->addWidget( Remote_View, 0, 0 );
175 175
176 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 176 TabWidget->insertTab( tab_2, tr( "Remote" ) );
177 177
178 tab_3 = new QWidget( TabWidget, "tab_3" ); 178 tab_3 = new QWidget( TabWidget, "tab_3" );
179 tabLayout_3 = new QGridLayout( tab_3 ); 179 tabLayout_3 = new QGridLayout( tab_3 );
180 tabLayout_3->setSpacing( 2); 180 tabLayout_3->setSpacing( 2);
181 tabLayout_3->setMargin( 2); 181 tabLayout_3->setMargin( 2);
182 182
183 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 183 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
184 TextLabel1->setText( tr( "Username" ) ); 184 TextLabel1->setText( tr( "Username" ) );
185 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 185 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
186 186
187 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 187 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
188 UsernameComboBox->setEditable(TRUE); 188 UsernameComboBox->setEditable(TRUE);
189 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 189 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
190 190
191 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 191 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
192 TextLabel2->setText( tr( "Password" ) ); 192 TextLabel2->setText( tr( "Password" ) );
193 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 193 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
194 194
195 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 195 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
196 PasswordEdit->setEchoMode(QLineEdit::Password); 196 PasswordEdit->setEchoMode(QLineEdit::Password);
197 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 197 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
198 198
199 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 199 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
200 TextLabel3->setText( tr( "Remote server" ) ); 200 TextLabel3->setText( tr( "Remote server" ) );
201 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 201 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
202 202
203 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 203 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
204 ServerComboBox->setEditable(TRUE); 204 ServerComboBox->setEditable(TRUE);
205 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 205 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
206 206
207 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); 207 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
208 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); 208 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
209 209
210 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 210 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
211 TextLabel5->setText( tr( "Remote path" ) ); 211 TextLabel5->setText( tr( "Remote path" ) );
212 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 212 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
213 213
214 214
215 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 215 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
216 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 216 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
217 217
218 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 218 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
219 TextLabel4->setText( tr( "Port" ) ); 219 TextLabel4->setText( tr( "Port" ) );
220 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 220 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
221 221
222 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 222 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
223 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 223 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
224 PortSpinBox->setMaxValue(32786); 224 PortSpinBox->setMaxValue(32786);
225 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 225 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
226 226
227 QPushButton *deleteServerBtn; 227 QPushButton *deleteServerBtn;
228 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); 228 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
229 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); 229 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
230 230
231 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 231 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
232 232
233 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); 233 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
234 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 234 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
235 connectServerBtn->setToggleButton(TRUE); 235 connectServerBtn->setToggleButton(TRUE);
236 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 236 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
237 237
238 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 238 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
239 tabLayout_3->addItem( spacer, 5, 0 ); 239 tabLayout_3->addItem( spacer, 5, 0 );
240 240
241 TabWidget->insertTab( tab_3, tr( "Config" ) ); 241 TabWidget->insertTab( tab_3, tr( "Config" ) );
242 242
243 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 243 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
244 this,SLOT(tabChanged(QWidget*))); 244 this,SLOT(tabChanged(QWidget*)));
245 245
246 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 246 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
247 currentDir.setPath( QDir::currentDirPath()); 247 currentDir.setPath( QDir::currentDirPath());
248// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 248// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
249 249
250 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); 250 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
251 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 ); 251 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 3 );
252 currentPathCombo->setEditable(TRUE); 252 currentPathCombo->setEditable(TRUE);
253 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 253 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
254 254
255 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 255 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
256 this, SLOT( currentPathComboActivated( const QString & ) ) ); 256 this, SLOT( currentPathComboActivated( const QString & ) ) );
257 257
258 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 258 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
259 this,SLOT(currentPathComboChanged())); 259 this,SLOT(currentPathComboChanged()));
260 260
261 ProgressBar = new QProgressBar( this, "ProgressBar" ); 261 ProgressBar = new QProgressBar( this, "ProgressBar" );
262 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 262 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
263 263
264// fillCombos(); 264// fillCombos();
265 265
266 filterStr="*"; 266 filterStr="*";
267 b=FALSE; 267 b=FALSE;
268 populateLocalView(); 268 populateLocalView();
269 readConfig(); 269 readConfig();
270 ServerComboBox->setCurrentItem(currentServerConfig); 270 ServerComboBox->setCurrentItem(currentServerConfig);
271 TabWidget->setCurrentPage(2); 271 TabWidget->setCurrentPage(2);
272} 272}
273 273
274OpieFtp::~OpieFtp() 274OpieFtp::~OpieFtp()
275{ 275{
276} 276}
277 277
278void OpieFtp::cleanUp() 278void OpieFtp::cleanUp()
279{ 279{
280 if(conn) 280 if(conn)
281 FtpQuit(conn); 281 FtpQuit(conn);
282 QString sfile=QDir::homeDirPath(); 282 QString sfile=QDir::homeDirPath();
283 if(sfile.right(1) != "/") 283 if(sfile.right(1) != "/")
284 sfile+="/._temp"; 284 sfile+="/._temp";
285 else 285 else
286 sfile+="._temp"; 286 sfile+="._temp";
287 QFile file( sfile); 287 QFile file( sfile);
288 if(file.exists()) 288 if(file.exists())
289 file.remove(); 289 file.remove();
290 exit(0); 290 exit(0);
291} 291}
292 292
293void OpieFtp::tabChanged(QWidget *w) 293void OpieFtp::tabChanged(QWidget *w)
294{ 294{
295 if (TabWidget->currentPageIndex() == 0) { 295 if (TabWidget->currentPageIndex() == 0) {
296 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 296 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
297 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 297 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
298 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 298 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
299 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 299 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
300 } 300 }
301 if (TabWidget->currentPageIndex() == 1) { 301 if (TabWidget->currentPageIndex() == 1) {
302 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 302 currentPathCombo->lineEdit()->setText( currentRemoteDir );
303 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 303 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
304 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 304 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
305 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 305 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
306 } 306 }
307 if (TabWidget->currentPageIndex() == 2) { 307 if (TabWidget->currentPageIndex() == 2) {
308 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 308 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
309 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 309 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
310 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 310 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
311 } 311 }
312} 312}
313 313
314void OpieFtp::newConnection() 314void OpieFtp::newConnection()
315{ 315{
316 UsernameComboBox->lineEdit()->setText(""); 316 UsernameComboBox->lineEdit()->setText("");
317 PasswordEdit->setText( "" ); 317 PasswordEdit->setText( "" );
318 ServerComboBox->lineEdit()->setText( ""); 318 ServerComboBox->lineEdit()->setText( "");
319 remotePath->setText( currentRemoteDir = "/"); 319 remotePath->setText( currentRemoteDir = "/");
320 PortSpinBox->setValue( 21); 320 PortSpinBox->setValue( 21);
321 TabWidget->setCurrentPage(2); 321 TabWidget->setCurrentPage(2);
322} 322}
323 323
324void OpieFtp::serverComboEdited(const QString & edit) 324void OpieFtp::serverComboEdited(const QString & edit)
325{ 325{
326 if( !edit.isEmpty() ) { 326 if( !edit.isEmpty() ) {
327 currentServerConfig = -1; 327 currentServerConfig = -1;
328// qDebug("comboedited"); 328// qDebug("comboedited");
329 } 329 }
330} 330}
331 331
332void OpieFtp::connectorBtnToggled(bool On) 332void OpieFtp::connectorBtnToggled(bool On)
333{ 333{
334 if(On) { 334 if(On) {
335 connector(); 335 connector();
336 } else { 336 } else {
337 disConnector(); 337 disConnector();
338 } 338 }
339 339
340} 340}
341 341
342void OpieFtp::connector() 342void OpieFtp::connector()
343{ 343{
344 QCopEnvelope ( "QPE/System", "busy()" ); 344 QCopEnvelope ( "QPE/System", "busy()" );
345// qApp->processEvents(); 345// qApp->processEvents();
346 currentRemoteDir=remotePath->text(); 346 currentRemoteDir=remotePath->text();
347 if(ServerComboBox->currentText().isEmpty()) { 347 if(ServerComboBox->currentText().isEmpty()) {
348 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 348 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
349 TabWidget->setCurrentPage(2); 349 TabWidget->setCurrentPage(2);
350 ServerComboBox->setFocus(); 350 ServerComboBox->setFocus();
351 connectServerBtn->setOn(FALSE); 351 connectServerBtn->setOn(FALSE);
352 connectServerBtn->setText( tr("Connect")); 352 connectServerBtn->setText( tr("Connect"));
353 return; 353 return;
354 } 354 }
355 FtpInit(); 355 FtpInit();
356 TabWidget->setCurrentPage(1); 356 TabWidget->setCurrentPage(1);
357 QString ftp_host = ServerComboBox->currentText(); 357 QString ftp_host = ServerComboBox->currentText();
358 QString ftp_user = UsernameComboBox->currentText(); 358 QString ftp_user = UsernameComboBox->currentText();
359 QString ftp_pass = PasswordEdit->text(); 359 QString ftp_pass = PasswordEdit->text();
360 QString port=PortSpinBox->cleanText(); 360 QString port=PortSpinBox->cleanText();
361 port.stripWhiteSpace(); 361 port.stripWhiteSpace();
362 362
363 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 363 if(ftp_host.find("ftp://",0, TRUE) != -1 )
364 ftp_host=ftp_host.right(ftp_host.length()-6); 364 ftp_host=ftp_host.right(ftp_host.length()-6);
365 ftp_host+=":"+port; 365 ftp_host+=":"+port;
366 if (!FtpConnect( ftp_host.latin1(), &conn)) { 366 if (!FtpConnect( ftp_host.latin1(), &conn)) {
367 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 367 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
368 connectServerBtn->setOn(FALSE); 368 connectServerBtn->setOn(FALSE);
369 connectServerBtn->setText( tr("Connect")); 369 connectServerBtn->setText( tr("Connect"));
370 return ; 370 return ;
371 } 371 }
372 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 372 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
373 QString msg; 373 QString msg;
374 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 374 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
375 msg.replace(QRegExp(":"),"\n"); 375 msg.replace(QRegExp(":"),"\n");
376 QMessageBox::message(tr("Note"),msg); 376 QMessageBox::message(tr("Note"),msg);
377 if(conn) 377 if(conn)
378 FtpQuit(conn); 378 FtpQuit(conn);
379 connectServerBtn->setOn(FALSE); 379 connectServerBtn->setOn(FALSE);
380 connectServerBtn->setText( tr("Connect")); 380 connectServerBtn->setText( tr("Connect"));
381 return ; 381 return ;
382 } 382 }
383 remoteDirList("/") ; 383 remoteDirList("/") ;
384 setCaption(ftp_host); 384 setCaption(ftp_host);
385 writeConfig(); 385 writeConfig();
386 connectServerBtn->setText( tr("Disconnect")); 386 connectServerBtn->setText( tr("Disconnect"));
387 QCopEnvelope ( "QPE/System", "notBusy()" ); 387 QCopEnvelope ( "QPE/System", "notBusy()" );
388} 388}
389 389
390void OpieFtp::disConnector() 390void OpieFtp::disConnector()
391{ 391{
392 if(conn) 392 if(conn)
393 FtpQuit(conn); 393 FtpQuit(conn);
394 setCaption("OpieFtp"); 394 setCaption("OpieFtp");
395 currentRemoteDir="/"; 395 currentRemoteDir="/";
396 Remote_View->clear(); 396 Remote_View->clear();
397 connectServerBtn->setText( tr("Connect")); 397 connectServerBtn->setText( tr("Connect"));
398 connectServerBtn->setOn(FALSE); 398 connectServerBtn->setOn(FALSE);
399} 399}
400 400
401void OpieFtp::localUpload() 401void OpieFtp::localUpload()
402{ 402{
403 int fsz; 403 int fsz;
404 QCopEnvelope ( "QPE/System", "busy()" ); 404 QCopEnvelope ( "QPE/System", "busy()" );
405// qApp->processEvents(); 405// qApp->processEvents();
406 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 406 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
407 QListViewItemIterator it( Local_View ); 407 QListViewItemIterator it( Local_View );
408 for ( ; it.current(); ++it ) { 408 for ( ; it.current(); ++it ) {
409 if ( it.current()->isSelected() ) { 409 if ( it.current()->isSelected() ) {
410 QString strItem = it.current()->text(0); 410 QString strItem = it.current()->text(0);
411 QString localFile = currentDir.canonicalPath()+"/"+strItem; 411 QString localFile = currentDir.canonicalPath()+"/"+strItem;
412 QString remoteFile= currentRemoteDir+strItem; 412 QString remoteFile= currentRemoteDir+strItem;
413 QFileInfo fi(localFile); 413 QFileInfo fi(localFile);
414 if( !fi.isDir()) { 414 if( !fi.isDir()) {
415 fsz=fi.size(); 415 fsz=fi.size();
416 ProgressBar->setTotalSteps(fsz); 416 ProgressBar->setTotalSteps(fsz);
417 417
418 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 418 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
419 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 419 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
420 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 420 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
421 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 421 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
422 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 422 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
423 423
424 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 424 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
425 QString msg; 425 QString msg;
426 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 426 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
427 msg.replace(QRegExp(":"),"\n"); 427 msg.replace(QRegExp(":"),"\n");
428 QMessageBox::message(tr("Note"),msg); 428 QMessageBox::message(tr("Note"),msg);
429 } 429 }
430 } else { 430 } else {
431 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 431 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
432 } 432 }
433 ProgressBar->reset(); 433 ProgressBar->reset();
434 nullifyCallBack(); 434 nullifyCallBack();
435 } //end currentSelected 435 } //end currentSelected
436 it.current()->setSelected(FALSE); 436 it.current()->setSelected(FALSE);
437 } 437 }
438 TabWidget->setCurrentPage(1); 438 TabWidget->setCurrentPage(1);
439 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 439 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
440 QCopEnvelope ( "QPE/System", "notBusy()" ); 440 QCopEnvelope ( "QPE/System", "notBusy()" );
441} 441}
442 442
443void OpieFtp::nullifyCallBack() 443void OpieFtp::nullifyCallBack()
444{ 444{
445 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 445 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
446 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 446 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
447 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 447 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
448 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 448 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
449} 449}
450 450
451void OpieFtp::remoteDownload() 451void OpieFtp::remoteDownload()
452{ 452{
453// qApp->processEvents(); 453// qApp->processEvents();
454 int fsz; 454 int fsz;
455 QCopEnvelope ( "QPE/System", "busy()" ); 455 QCopEnvelope ( "QPE/System", "busy()" );
456 456
457 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 457 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
458 QListViewItemIterator it( Remote_View ); 458 QListViewItemIterator it( Remote_View );
459 for ( ; it.current(); ++it ) { 459 for ( ; it.current(); ++it ) {
460 if ( it.current()->isSelected() ) { 460 if ( it.current()->isSelected() ) {
461 QString strItem = it.current()->text(0); 461 QString strItem = it.current()->text(0);
462// strItem=strItem.right(strItem.length()-1); 462// strItem=strItem.right(strItem.length()-1);
463 QString localFile = currentDir.canonicalPath(); 463 QString localFile = currentDir.canonicalPath();
464 if(localFile.right(1).find("/",0,TRUE) == -1) 464 if(localFile.right(1).find("/",0,TRUE) == -1)
465 localFile += "/"; 465 localFile += "/";
466 localFile += strItem; 466 localFile += strItem;
467// QString localFile = currentDir.canonicalPath()+"/"+strItem; 467// QString localFile = currentDir.canonicalPath()+"/"+strItem;
468 QString remoteFile= currentRemoteDir+strItem; 468 QString remoteFile= currentRemoteDir+strItem;
469 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 469 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
470 fsz = 0; 470 fsz = 0;
471 QString temp; 471 QString temp;
472 temp.sprintf( remoteFile+" "+" %dkb", fsz); 472 temp.sprintf( remoteFile+" "+" %dkb", fsz);
473 473
474 ProgressBar->setTotalSteps(fsz); 474 ProgressBar->setTotalSteps(fsz);
475 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 475 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
476 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 476 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
477 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 477 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
478 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 478 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
479 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 479 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
480 480
481 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 481 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
482 QString msg; 482 QString msg;
483 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 483 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
484 msg.replace(QRegExp(":"),"\n"); 484 msg.replace(QRegExp(":"),"\n");
485 QMessageBox::message(tr("Note"),msg); 485 QMessageBox::message(tr("Note"),msg);
486 } 486 }
487 ProgressBar->reset(); 487 ProgressBar->reset();
488 nullifyCallBack(); 488 nullifyCallBack();
489 } 489 }
490 it.current()->setSelected(FALSE); 490 it.current()->setSelected(FALSE);
491 } 491 }
492 TabWidget->setCurrentPage(0); 492 TabWidget->setCurrentPage(0);
493 populateLocalView(); 493 populateLocalView();
494 QCopEnvelope ( "QPE/System", "notBusy()" ); 494 QCopEnvelope ( "QPE/System", "notBusy()" );
495} 495}
496 496
497bool OpieFtp::remoteDirList(const QString &dir) 497bool OpieFtp::remoteDirList(const QString &dir)
498{ 498{
499 QString tmp = QDir::homeDirPath(); 499 QString tmp = QDir::homeDirPath();
500 if(tmp.right(1) != "/") 500 if(tmp.right(1) != "/")
501 tmp+="/._temp"; 501 tmp+="/._temp";
502 else 502 else
503 tmp+="._temp"; 503 tmp+="._temp";
504// qDebug("Listing remote dir "+tmp); 504// qDebug("Listing remote dir "+tmp);
505 QCopEnvelope ( "QPE/System", "busy()" ); 505 QCopEnvelope ( "QPE/System", "busy()" );
506 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 506 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
507 QString msg; 507 QString msg;
508 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 508 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
509 msg.replace(QRegExp(":"),"\n"); 509 msg.replace(QRegExp(":"),"\n");
510 QMessageBox::message(tr("Note"),msg); 510 QMessageBox::message(tr("Note"),msg);
511 return false; 511 return false;
512 } 512 }
513 populateRemoteView() ; 513 populateRemoteView() ;
514 QCopEnvelope ( "QPE/System", "notBusy()" ); 514 QCopEnvelope ( "QPE/System", "notBusy()" );
515 return true; 515 return true;
516} 516}
517 517
518bool OpieFtp::remoteChDir(const QString &dir) 518bool OpieFtp::remoteChDir(const QString &dir)
519{ 519{
520 QCopEnvelope ( "QPE/System", "busy()" ); 520 QCopEnvelope ( "QPE/System", "busy()" );
521 if (!FtpChdir( dir.latin1(), conn )) { 521 if (!FtpChdir( dir.latin1(), conn )) {
522 QString msg; 522 QString msg;
523 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 523 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
524 msg.replace(QRegExp(":"),"\n"); 524 msg.replace(QRegExp(":"),"\n");
525 QMessageBox::message(tr("Note"),msg); 525 QMessageBox::message(tr("Note"),msg);
526 qDebug(msg); 526 qDebug(msg);
527 QCopEnvelope ( "QPE/System", "notBusy()" ); 527 QCopEnvelope ( "QPE/System", "notBusy()" );
528 return FALSE; 528 return FALSE;
529 } 529 }
530 QCopEnvelope ( "QPE/System", "notBusy()" ); 530 QCopEnvelope ( "QPE/System", "notBusy()" );
531 return TRUE; 531 return TRUE;
532} 532}
533 533
534void OpieFtp::populateLocalView() 534void OpieFtp::populateLocalView()
535{ 535{
536 Local_View->clear(); 536 Local_View->clear();
537 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 537 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
538 currentDir.setMatchAllDirs(TRUE); 538 currentDir.setMatchAllDirs(TRUE);
539 currentDir.setNameFilter(filterStr); 539 currentDir.setNameFilter(filterStr);
540 QString fileL, fileS, fileDate; 540 QString fileL, fileS, fileDate;
541 bool isDir=FALSE; 541 bool isDir=FALSE;
542 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 542 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
543 QFileInfoListIterator it(*list); 543 QFileInfoListIterator it(*list);
544 QFileInfo *fi; 544 QFileInfo *fi;
545 while ( (fi=it.current()) ) { 545 while ( (fi=it.current()) ) {
546 if (fi->isSymLink() ){ 546 if (fi->isSymLink() ){
547 QString symLink=fi->readLink(); 547 QString symLink=fi->readLink();
548// qDebug("Symlink detected "+symLink); 548// qDebug("Symlink detected "+symLink);
549 QFileInfo sym( symLink); 549 QFileInfo sym( symLink);
550 fileS.sprintf( "%10li", sym.size() ); 550 fileS.sprintf( "%10li", sym.size() );
551 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 551 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
552 fileDate = sym.lastModified().toString(); 552 fileDate = sym.lastModified().toString();
553 } else { 553 } else {
554// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 554// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
555 fileS.sprintf( "%10li", fi->size() ); 555 fileS.sprintf( "%10li", fi->size() );
556 fileL.sprintf( "%s",fi->fileName().data() ); 556 fileL.sprintf( "%s",fi->fileName().data() );
557 fileDate= fi->lastModified().toString(); 557 fileDate= fi->lastModified().toString();
558 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 558 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
559 fileL+="/"; 559 fileL+="/";
560 isDir=TRUE; 560 isDir=TRUE;
561// qDebug( fileL); 561// qDebug( fileL);
562 } 562 }
563 } 563 }
564 if(fileL !="./" && fi->exists()) { 564 if(fileL !="./" && fi->exists()) {
565 item= new QListViewItem( Local_View,fileL,fileS , fileDate); 565 item= new QListViewItem( Local_View,fileL,fileS , fileDate);
566 QPixmap pm; 566 QPixmap pm;
567 567
568 if(isDir || fileL.find("/",0,TRUE) != -1) { 568 if(isDir || fileL.find("/",0,TRUE) != -1) {
569 if( !QDir( fi->filePath() ).isReadable()) 569 if( !QDir( fi->filePath() ).isReadable())
570 pm = Resource::loadPixmap( "lockedfolder" ); 570 pm = Resource::loadPixmap( "lockedfolder" );
571 else 571 else
572 pm= Resource::loadPixmap( "folder" ); 572 pm= Resource::loadPixmap( "folder" );
573 item->setPixmap( 0,pm ); 573 item->setPixmap( 0,pm );
574 } else { 574 } else {
575 if( !fi->isReadable() ) 575 if( !fi->isReadable() )
576 pm = Resource::loadPixmap( "locked" ); 576 pm = Resource::loadPixmap( "locked" );
577 else { 577 else {
578 MimeType mt(fi->filePath()); 578 MimeType mt(fi->filePath());
579 pm=mt.pixmap(); //sets the correct pixmap for mimetype 579 pm=mt.pixmap(); //sets the correct pixmap for mimetype
580 if(pm.isNull()) 580 if(pm.isNull())
581 pm = Resource::loadPixmap( "UnknownDocument-14" ); 581 pm = Resource::loadPixmap( "UnknownDocument-14" );
582 item->setPixmap( 0,pm); 582 item->setPixmap( 0,pm);
583 } 583 }
584 } 584 }
585 if( fileL.find("->",0,TRUE) != -1) { 585 if( fileL.find("->",0,TRUE) != -1) {
586 // overlay link image 586 // overlay link image
587 pm= Resource::loadPixmap( "folder" ); 587 pm= Resource::loadPixmap( "folder" );
588 QPixmap lnk = Resource::loadPixmap( "symlink" ); 588 QPixmap lnk = Resource::loadPixmap( "symlink" );
589 QPainter painter( &pm ); 589 QPainter painter( &pm );
590 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 590 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
591 pm.setMask( pm.createHeuristicMask( FALSE ) ); 591 pm.setMask( pm.createHeuristicMask( FALSE ) );
592 item->setPixmap( 0, pm); 592 item->setPixmap( 0, pm);
593 } 593 }
594 } 594 }
595 isDir=FALSE; 595 isDir=FALSE;
596 ++it; 596 ++it;
597 } 597 }
598 Local_View->setSorting( 3,FALSE); 598 Local_View->setSorting( 3,FALSE);
599 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 599 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
600 fillCombo( (const QString &)currentDir); 600 fillCombo( (const QString &)currentDir);
601} 601}
602 602
603bool OpieFtp::populateRemoteView( ) 603bool OpieFtp::populateRemoteView( )
604{ 604{
605// qDebug("populate remoteview"); 605// qDebug("populate remoteview");
606 QString sfile=QDir::homeDirPath(); 606 QString sfile=QDir::homeDirPath();
607 if(sfile.right(1) != "/") 607 if(sfile.right(1) != "/")
608 sfile+="/._temp"; 608 sfile+="/._temp";
609 else 609 else
610 sfile+="._temp"; 610 sfile+="._temp";
611 QFile file( sfile); 611 QFile file( sfile);
612 Remote_View->clear(); 612 Remote_View->clear();
613 QString s, File_Name; 613 QString s, File_Name;
614 QListViewItem *itemDir=NULL, *itemFile=NULL; 614 QListViewItem *itemDir=NULL, *itemFile=NULL;
615 QString fileL, fileS, fileDate; 615 QString fileL, fileS, fileDate;
616 if ( file.open(IO_ReadOnly)) { 616 if ( file.open(IO_ReadOnly)) {
617 QTextStream t( &file ); // use a text stream 617 QTextStream t( &file ); // use a text stream
618 while ( !t.eof()) { 618 while ( !t.eof()) {
619 s = t.readLine(); 619 s = t.readLine();
620 fileL = s.right(s.length()-55); 620 fileL = s.right(s.length()-55);
621 fileL = fileL.stripWhiteSpace(); 621 fileL = fileL.stripWhiteSpace();
622 if(s.left(1) == "d") 622 if(s.left(1) == "d")
623 fileL = fileL+"/"; 623 fileL = fileL+"/";
624// fileL = "/"+fileL+"/"; 624// fileL = "/"+fileL+"/";
625 fileS = s.mid( 30, 42-30); 625 fileS = s.mid( 30, 42-30);
626 fileS = fileS.stripWhiteSpace(); 626 fileS = fileS.stripWhiteSpace();
627 fileDate = s.mid( 42, 55-42); 627 fileDate = s.mid( 42, 55-42);
628 fileDate = fileDate.stripWhiteSpace(); 628 fileDate = fileDate.stripWhiteSpace();
629 if(fileL.find("total",0,TRUE) == -1) { 629 if(fileL.find("total",0,TRUE) == -1) {
630 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 630 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
631 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); 631 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d");
632 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 632 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
633// if(itemDir) 633// if(itemDir)
634 item->moveItem(itemDir); 634 item->moveItem(itemDir);
635 itemDir=item; 635 itemDir=item;
636 } else { 636 } else {
637 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); 637 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f");
638 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 638 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
639// if(itemFile) 639// if(itemFile)
640 item->moveItem(itemDir); 640 item->moveItem(itemDir);
641 item->moveItem(itemFile); 641 item->moveItem(itemFile);
642 itemFile=item; 642 itemFile=item;
643 } 643 }
644 } 644 }
645 } 645 }
646 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 646 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
647 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 647 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
648 file.close(); 648 file.close();
649 if( file.exists()) 649 if( file.exists())
650 file. remove(); 650 file. remove();
651 } else 651 } else
652 qDebug("temp file not opened successfullly "+sfile); 652 qDebug("temp file not opened successfullly "+sfile);
653 Remote_View->setSorting( 4,TRUE); 653 Remote_View->setSorting( 4,TRUE);
654 return true; 654 return true;
655} 655}
656 656
657void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 657void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
658{ 658{
659 if( selectedItem) { 659 if( selectedItem) {
660// QCopEnvelope ( "QPE/System", "busy()" ); 660// QCopEnvelope ( "QPE/System", "busy()" );
661 QString oldRemoteCurrentDir = currentRemoteDir; 661 QString oldRemoteCurrentDir = currentRemoteDir;
662 QString strItem=selectedItem->text(0); 662 QString strItem=selectedItem->text(0);
663 strItem=strItem.simplifyWhiteSpace(); 663 strItem=strItem.simplifyWhiteSpace();
664 if(strItem == "../") { // the user wants to go ^ 664 if(strItem == "../") { // the user wants to go ^
665 if( FtpCDUp( conn) == 0) { 665 if( FtpCDUp( conn) == 0) {
666 QString msg; 666 QString msg;
667 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 667 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
668 msg.replace(QRegExp(":"),"\n"); 668 msg.replace(QRegExp(":"),"\n");
669 QMessageBox::message(tr("Note"),msg); 669 QMessageBox::message(tr("Note"),msg);
670 qDebug(msg); 670 qDebug(msg);
671 } 671 }
672 char path[256]; 672 char path[256];
673 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 673 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
674 QString msg; 674 QString msg;
675 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 675 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
676 msg.replace(QRegExp(":"),"\n"); 676 msg.replace(QRegExp(":"),"\n");
677 QMessageBox::message(tr("Note"),msg); 677 QMessageBox::message(tr("Note"),msg);
678 qDebug(msg); 678 qDebug(msg);
679 } 679 }
680 currentRemoteDir=path; 680 currentRemoteDir=path;
681 } else { 681 } else {
682 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 682 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
683 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 683 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
684 strItem = strItem.stripWhiteSpace(); 684 strItem = strItem.stripWhiteSpace();
685 currentRemoteDir = strItem; 685 currentRemoteDir = strItem;
686 if( !remoteChDir( (const QString &)strItem)) { 686 if( !remoteChDir( (const QString &)strItem)) {
687 currentRemoteDir = oldRemoteCurrentDir; 687 currentRemoteDir = oldRemoteCurrentDir;
688 strItem=""; 688 strItem="";
689// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 689// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
690 } 690 }
691 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 691 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
692 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 692 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
693 currentRemoteDir = oldRemoteCurrentDir; 693 currentRemoteDir = oldRemoteCurrentDir;
694 strItem=""; 694 strItem="";
695// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 695// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
696 696
697 } else { 697 } else {
698 currentRemoteDir = currentRemoteDir+strItem; 698 currentRemoteDir = currentRemoteDir+strItem;
699 } 699 }
700 } else { 700 } else {
701 QCopEnvelope ( "QPE/System", "notBusy()" ); 701 QCopEnvelope ( "QPE/System", "notBusy()" );
702 return; 702 return;
703 } 703 }
704 } 704 }
705 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 705 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
706 if(currentRemoteDir.right(1) !="/") 706 if(currentRemoteDir.right(1) !="/")
707 currentRemoteDir +="/"; 707 currentRemoteDir +="/";
708 currentPathCombo->lineEdit()->setText( currentRemoteDir); 708 currentPathCombo->lineEdit()->setText( currentRemoteDir);
709 fillRemoteCombo( (const QString &)currentRemoteDir); 709 fillRemoteCombo( (const QString &)currentRemoteDir);
710// QCopEnvelope ( "QPE/System", "notBusy()" ); 710// QCopEnvelope ( "QPE/System", "notBusy()" );
711 } 711 }
712} 712}
713 713
714void OpieFtp::localListClicked(QListViewItem *selectedItem) 714void OpieFtp::localListClicked(QListViewItem *selectedItem)
715{ 715{
716 if(selectedItem!= NULL) { 716 if(selectedItem!= NULL) {
717 717
718 QString strItem=selectedItem->text(0); 718 QString strItem=selectedItem->text(0);
719 QString strSize=selectedItem->text(1); 719 QString strSize=selectedItem->text(1);
720 strSize=strSize.stripWhiteSpace(); 720 strSize=strSize.stripWhiteSpace();
721 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 721 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
722 // is symlink 722 // is symlink
723 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 723 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
724 if(QDir(strItem2).exists() ) { 724 if(QDir(strItem2).exists() ) {
725 currentDir.cd(strItem2, TRUE); 725 currentDir.cd(strItem2, TRUE);
726 populateLocalView(); 726 populateLocalView();
727 } 727 }
728 } else { // not a symlink 728 } else { // not a symlink
729 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 729 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
730 730
731 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 731 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
732 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 732 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
733 currentDir.cd(strItem,FALSE); 733 currentDir.cd(strItem,FALSE);
734 populateLocalView(); 734 populateLocalView();
735 } else { 735 } else {
736 currentDir.cdUp(); 736 currentDir.cdUp();
737 populateLocalView(); 737 populateLocalView();
738 } 738 }
739 if(QDir(strItem).exists()){ 739 if(QDir(strItem).exists()){
740 currentDir.cd(strItem, TRUE); 740 currentDir.cd(strItem, TRUE);
741 populateLocalView(); 741 populateLocalView();
742 } 742 }
743 } else { 743 } else {
744 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 744 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
745 if( QFile::exists(strItem ) ) { 745 if( QFile::exists(strItem ) ) {
746 // qDebug("upload "+strItem); 746 // qDebug("upload "+strItem);
747 return; 747 return;
748 } 748 }
749 } //end not symlink 749 } //end not symlink
750 chdir(strItem.latin1()); 750 chdir(strItem.latin1());
751 } 751 }
752 } 752 }
753} 753}
754 754
755void OpieFtp::doLocalCd() 755void OpieFtp::doLocalCd()
756{ 756{
757 localListClicked( Local_View->currentItem()); 757 localListClicked( Local_View->currentItem());
758} 758}
759 759
760void OpieFtp:: doRemoteCd() 760void OpieFtp:: doRemoteCd()
761{ 761{
762 remoteListClicked( Remote_View->currentItem()); 762 remoteListClicked( Remote_View->currentItem());
763 763
764} 764}
765 765
766void OpieFtp::showHidden() 766void OpieFtp::showHidden()
767{ 767{
768 if (!b) { 768 if (!b) {
769 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 769 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
770 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 770 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
771// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 771// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
772 b=TRUE; 772 b=TRUE;
773 773
774 } else { 774 } else {
775 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 775 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
776 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 776 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
777// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 777// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
778 b=FALSE; 778 b=FALSE;
779 } 779 }
780 populateLocalView(); 780 populateLocalView();
781} 781}
782 782
783void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 783void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
784{ 784{
785// if(item) 785// if(item)
786 if (mouse == 2) { 786 if (mouse == 2) {
787 showLocalMenu(item); 787 showLocalMenu(item);
788 } 788 }
789} 789}
790 790
791void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 791void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
792{ 792{
793 if(mouse == 2) { 793 if(mouse == 2) {
794 showRemoteMenu(item); 794 showRemoteMenu(item);
795 } 795 }
796} 796}
797 797
798void OpieFtp::showRemoteMenu(QListViewItem * item) 798void OpieFtp::showRemoteMenu(QListViewItem * item)
799{ 799{
800 QPopupMenu m;// = new QPopupMenu( Local_View ); 800 QPopupMenu m;// = new QPopupMenu( Local_View );
801 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 801 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
802 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 802 m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
803 else 803 else
804 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 804 m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
805 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 805 m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
806 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 806 m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
807 m.insertSeparator(); 807 m.insertSeparator();
808 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 808 m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
809 m.exec( QCursor::pos() ); 809 m.exec( QCursor::pos() );
810} 810}
811 811
812void OpieFtp::showLocalMenu(QListViewItem * item) 812void OpieFtp::showLocalMenu(QListViewItem * item)
813{ 813{
814 814
815 QPopupMenu m; 815 QPopupMenu m;
816 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 816 m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
817 m.insertSeparator(); 817 m.insertSeparator();
818 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 818 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
819 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 819 m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
820 else 820 else
821 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 821 m.insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
822 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 822 m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
823 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 823 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
824 m.insertSeparator(); 824 m.insertSeparator();
825 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 825 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
826 m.setCheckable(TRUE); 826 m.setCheckable(TRUE);
827 if (b) 827 if (b)
828 m.setItemChecked(m.idAt(0),TRUE); 828 m.setItemChecked(m.idAt(0),TRUE);
829 else 829 else
830 m.setItemChecked(m.idAt(0),FALSE); 830 m.setItemChecked(m.idAt(0),FALSE);
831 831
832 m.exec( QCursor::pos() ); 832 m.exec( QCursor::pos() );
833} 833}
834 834
835void OpieFtp::localMakDir() 835void OpieFtp::localMakDir()
836{ 836{
837 InputDialog *fileDlg; 837 InputDialog *fileDlg;
838 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 838 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
839 fileDlg->exec(); 839 fileDlg->exec();
840 if( fileDlg->result() == 1 ) { 840 if( fileDlg->result() == 1 ) {
841 QString filename = fileDlg->LineEdit1->text(); 841 QString filename = fileDlg->LineEdit1->text();
842 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 842 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
843 } 843 }
844 populateLocalView(); 844 populateLocalView();
845} 845}
846 846
847void OpieFtp::localDelete() 847void OpieFtp::localDelete()
848{ 848{
849 QString f = Local_View->currentItem()->text(0); 849 QString f = Local_View->currentItem()->text(0);
850 if(QDir(f).exists() ) { 850 if(QDir(f).exists() ) {
851 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 851 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
852 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 852 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
853 case 0: { 853 case 0: {
854 f=currentDir.canonicalPath()+"/"+f; 854 f=currentDir.canonicalPath()+"/"+f;
855 QString cmd="rmdir "+f; 855 QString cmd="rmdir "+f;
856 system( cmd.latin1()); 856 system( cmd.latin1());
857 populateLocalView(); 857 populateLocalView();
858 } 858 }
859 break; 859 break;
860 case 1: 860 case 1:
861 // exit 861 // exit
862 break; 862 break;
863 }; 863 };
864 864
865 } else { 865 } else {
866 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 866 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
867 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 867 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
868 case 0: { 868 case 0: {
869 f=currentDir.canonicalPath()+"/"+f; 869 f=currentDir.canonicalPath()+"/"+f;
870 QString cmd="rm "+f; 870 QString cmd="rm "+f;
871 system( cmd.latin1()); 871 system( cmd.latin1());
872 populateLocalView(); 872 populateLocalView();
873 } 873 }
874 break; 874 break;
875 case 1: 875 case 1:
876 // exit 876 // exit
877 break; 877 break;
878 }; 878 };
879 } 879 }
880} 880}
881 881
882void OpieFtp::remoteMakDir() 882void OpieFtp::remoteMakDir()
883{ 883{
884 InputDialog *fileDlg; 884 InputDialog *fileDlg;
885 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 885 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
886 fileDlg->exec(); 886 fileDlg->exec();
887 if( fileDlg->result() == 1 ) { 887 if( fileDlg->result() == 1 ) {
888 QString filename = fileDlg->LineEdit1->text();//+".playlist"; 888 QString filename = fileDlg->LineEdit1->text();//+".playlist";
889 QString tmp=currentRemoteDir+filename; 889 QString tmp=currentRemoteDir+filename;
890 QCopEnvelope ( "QPE/System", "busy()" ); 890 QCopEnvelope ( "QPE/System", "busy()" );
891 if(FtpMkdir( tmp.latin1(), conn) == 0) { 891 if(FtpMkdir( tmp.latin1(), conn) == 0) {
892 QString msg; 892 QString msg;
893 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); 893 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn));
894 msg.replace(QRegExp(":"),"\n"); 894 msg.replace(QRegExp(":"),"\n");
895 QMessageBox::message(tr("Note"),msg); 895 QMessageBox::message(tr("Note"),msg);
896 } 896 }
897 QCopEnvelope ( "QPE/System", "notBusy()" ); 897 QCopEnvelope ( "QPE/System", "notBusy()" );
898 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 898 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
899 } 899 }
900} 900}
901 901
902void OpieFtp::remoteDelete() 902void OpieFtp::remoteDelete()
903{ 903{
904 QString f = Remote_View->currentItem()->text(0); 904 QString f = Remote_View->currentItem()->text(0);
905 QCopEnvelope ( "QPE/System", "busy()" ); 905 QCopEnvelope ( "QPE/System", "busy()" );
906 if( f.right(1) =="/") { 906 if( f.right(1) =="/") {
907 QString path= currentRemoteDir+f; 907 QString path= currentRemoteDir+f;
908 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 908 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
909 ,tr("Yes"),tr("No"),0,0,1) ) { 909 ,tr("Yes"),tr("No"),0,0,1) ) {
910 case 0: { 910 case 0: {
911 f=currentDir.canonicalPath()+"/"+f; 911 f=currentDir.canonicalPath()+"/"+f;
912 if(FtpRmdir( path.latin1(), conn) ==0) { 912 if(FtpRmdir( path.latin1(), conn) ==0) {
913 QString msg; 913 QString msg;
914 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 914 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
915 msg.replace(QRegExp(":"),"\n"); 915 msg.replace(QRegExp(":"),"\n");
916 QMessageBox::message(tr("Note"),msg); 916 QMessageBox::message(tr("Note"),msg);
917 } 917 }
918 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 918 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
919 } 919 }
920 break; 920 break;
921 }; 921 };
922 } else { 922 } else {
923 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 923 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
924 ,tr("Yes"),tr("No"),0,0,1) ) { 924 ,tr("Yes"),tr("No"),0,0,1) ) {
925 case 0: { 925 case 0: {
926 QString path= currentRemoteDir+f; 926 QString path= currentRemoteDir+f;
927 if(FtpDelete( path.latin1(), conn)==0) { 927 if(FtpDelete( path.latin1(), conn)==0) {
928 QString msg; 928 QString msg;
929 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 929 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
930 msg.replace(QRegExp(":"),"\n"); 930 msg.replace(QRegExp(":"),"\n");
931 QMessageBox::message(tr("Note"),msg); 931 QMessageBox::message(tr("Note"),msg);
932 } 932 }
933 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 933 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
934 } 934 }
935 break; 935 break;
936 }; 936 };
937 } 937 }
938 QCopEnvelope ( "QPE/System", "notBusy()" ); 938 QCopEnvelope ( "QPE/System", "notBusy()" );
939} 939}
940 940
941void OpieFtp::remoteRename() 941void OpieFtp::remoteRename()
942{ 942{
943 QString curFile = Remote_View->currentItem()->text(0); 943 QString curFile = Remote_View->currentItem()->text(0);
944 InputDialog *fileDlg; 944 InputDialog *fileDlg;
945 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 945 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
946 fileDlg->inputText = curFile; 946 fileDlg->setTextEdit((const QString &)curFile);
947 fileDlg->exec(); 947 fileDlg->exec();
948 if( fileDlg->result() == 1 ) { 948 if( fileDlg->result() == 1 ) {
949 QString oldName = currentRemoteDir +"/"+ curFile; 949 QString oldName = currentRemoteDir +"/"+ curFile;
950 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 950 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
951 QCopEnvelope ( "QPE/System", "busy()" ); 951 QCopEnvelope ( "QPE/System", "busy()" );
952 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 952 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
953 QString msg; 953 QString msg;
954 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 954 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
955 msg.replace(QRegExp(":"),"\n"); 955 msg.replace(QRegExp(":"),"\n");
956 QMessageBox::message(tr("Note"),msg); 956 QMessageBox::message(tr("Note"),msg);
957 } 957 }
958 QCopEnvelope ( "QPE/System", "notBusy()" ); 958 QCopEnvelope ( "QPE/System", "notBusy()" );
959 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 959 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
960 } 960 }
961} 961}
962 962
963void OpieFtp::localRename() 963void OpieFtp::localRename()
964{ 964{
965 QString curFile = Local_View->currentItem()->text(0); 965 QString curFile = Local_View->currentItem()->text(0);
966 InputDialog *fileDlg; 966 InputDialog *fileDlg;
967 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 967 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
968 fileDlg->inputText = curFile; 968 fileDlg->setTextEdit((const QString &)curFile);
969 fileDlg->exec(); 969 fileDlg->exec();
970 if( fileDlg->result() == 1 ) { 970 if( fileDlg->result() == 1 ) {
971 QString oldname = currentDir.canonicalPath() + "/" + curFile; 971 QString oldname = currentDir.canonicalPath() + "/" + curFile;
972 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 972 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
973 if( rename(oldname.latin1(), newName.latin1())== -1) 973 if( rename(oldname.latin1(), newName.latin1())== -1)
974 QMessageBox::message(tr("Note"),tr("Could not rename")); 974 QMessageBox::message(tr("Note"),tr("Could not rename"));
975 } 975 }
976 populateLocalView(); 976 populateLocalView();
977} 977}
978 978
979void OpieFtp::currentPathComboActivated(const QString & currentPath) { 979void OpieFtp::currentPathComboActivated(const QString & currentPath) {
980 if (TabWidget->currentPageIndex() == 0) { 980 if (TabWidget->currentPageIndex() == 0) {
981 chdir( currentPath.latin1() ); 981 chdir( currentPath.latin1() );
982 currentDir.cd( currentPath, TRUE); 982 currentDir.cd( currentPath, TRUE);
983 populateLocalView(); 983 populateLocalView();
984 update(); 984 update();
985 } else { 985 } else {
986// chdir( currentPath.latin1() ); 986// chdir( currentPath.latin1() );
987// currentDir.cd( currentPath, TRUE); 987// currentDir.cd( currentPath, TRUE);
988// populateList(); 988// populateList();
989// update(); 989// update();
990 990
991 } 991 }
992} 992}
993 993
994void OpieFtp::fillCombo(const QString &currentPath) { 994void OpieFtp::fillCombo(const QString &currentPath) {
995 995
996 currentPathCombo->lineEdit()->setText(currentPath); 996 currentPathCombo->lineEdit()->setText(currentPath);
997 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 997 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
998 currentPathCombo->clear(); 998 currentPathCombo->clear();
999 localDirPathStringList.prepend(currentPath ); 999 localDirPathStringList.prepend(currentPath );
1000 currentPathCombo->insertStringList( localDirPathStringList,-1); 1000 currentPathCombo->insertStringList( localDirPathStringList,-1);
1001 } 1001 }
1002 currentPathCombo->lineEdit()->setText(currentPath); 1002 currentPathCombo->lineEdit()->setText(currentPath);
1003 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1003 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1004 currentPathCombo->clear(); 1004 currentPathCombo->clear();
1005 remoteDirPathStringList.prepend(currentPath ); 1005 remoteDirPathStringList.prepend(currentPath );
1006 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1006 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1007 } 1007 }
1008} 1008}
1009 1009
1010void OpieFtp::fillRemoteCombo(const QString &currentPath) { 1010void OpieFtp::fillRemoteCombo(const QString &currentPath) {
1011 1011
1012 currentPathCombo->lineEdit()->setText(currentPath); 1012 currentPathCombo->lineEdit()->setText(currentPath);
1013 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1013 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1014 currentPathCombo->clear(); 1014 currentPathCombo->clear();
1015 remoteDirPathStringList.prepend(currentPath ); 1015 remoteDirPathStringList.prepend(currentPath );
1016 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1016 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1017 } 1017 }
1018} 1018}
1019 1019
1020void OpieFtp::currentPathComboChanged() 1020void OpieFtp::currentPathComboChanged()
1021{ 1021{
1022 QString oldRemoteCurrentDir = currentRemoteDir; 1022 QString oldRemoteCurrentDir = currentRemoteDir;
1023// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); 1023// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
1024 if (TabWidget->currentPageIndex() == 0) { 1024 if (TabWidget->currentPageIndex() == 0) {
1025 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 1025 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
1026 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 1026 currentDir.setPath( currentPathCombo->lineEdit()->text() );
1027 populateLocalView(); 1027 populateLocalView();
1028 } else { 1028 } else {
1029 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 1029 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
1030 } 1030 }
1031 } 1031 }
1032 if (TabWidget->currentPageIndex() == 1) { 1032 if (TabWidget->currentPageIndex() == 1) {
1033 currentRemoteDir = currentPathCombo->lineEdit()->text(); 1033 currentRemoteDir = currentPathCombo->lineEdit()->text();
1034 if(currentRemoteDir.right(1) !="/") { 1034 if(currentRemoteDir.right(1) !="/") {
1035 currentRemoteDir = currentRemoteDir +"/"; 1035 currentRemoteDir = currentRemoteDir +"/";
1036 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 1036 currentPathCombo->lineEdit()->setText( currentRemoteDir );
1037 } 1037 }
1038 if( !remoteChDir( (const QString &)currentRemoteDir) ) { 1038 if( !remoteChDir( (const QString &)currentRemoteDir) ) {
1039 currentRemoteDir = oldRemoteCurrentDir; 1039 currentRemoteDir = oldRemoteCurrentDir;
1040 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 1040 currentPathCombo->lineEdit()->setText( currentRemoteDir );
1041 } 1041 }
1042 1042
1043 remoteDirList( (const QString &)currentRemoteDir); 1043 remoteDirList( (const QString &)currentRemoteDir);
1044 } 1044 }
1045} 1045}
1046 1046
1047void OpieFtp::switchToLocalTab() 1047void OpieFtp::switchToLocalTab()
1048{ 1048{
1049 TabWidget->setCurrentPage(0); 1049 TabWidget->setCurrentPage(0);
1050} 1050}
1051 1051
1052void OpieFtp::switchToRemoteTab() 1052void OpieFtp::switchToRemoteTab()
1053{ 1053{
1054 TabWidget->setCurrentPage(1); 1054 TabWidget->setCurrentPage(1);
1055} 1055}
1056 1056
1057void OpieFtp::switchToConfigTab() 1057void OpieFtp::switchToConfigTab()
1058{ 1058{
1059 TabWidget->setCurrentPage(2); 1059 TabWidget->setCurrentPage(2);
1060} 1060}
1061 1061
1062void OpieFtp::readConfig() 1062void OpieFtp::readConfig()
1063{ 1063{
1064 fillCombos(); 1064 fillCombos();
1065 Config cfg("opieftp"); 1065 Config cfg("opieftp");
1066 cfg.setGroup("Server"); 1066 cfg.setGroup("Server");
1067 currentServerConfig = cfg.readNumEntry("currentServer", -1); 1067 currentServerConfig = cfg.readNumEntry("currentServer", -1);
1068 serverComboSelected( currentServerConfig); 1068 serverComboSelected( currentServerConfig);
1069} 1069}
1070 1070
1071void OpieFtp::writeConfig() 1071void OpieFtp::writeConfig()
1072{ 1072{
1073 Config cfg("opieftp"); 1073 Config cfg("opieftp");
1074 cfg.setGroup("Server"); 1074 cfg.setGroup("Server");
1075 QString username, remoteServerStr, remotePathStr, password, port, temp; 1075 QString username, remoteServerStr, remotePathStr, password, port, temp;
1076 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1076 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1077 if( currentServerConfig == -1) { 1077 if( currentServerConfig == -1) {
1078 for (int i = 1; i <= numberOfEntries; i++) { 1078 for (int i = 1; i <= numberOfEntries; i++) {
1079 temp.setNum(i); 1079 temp.setNum(i);
1080 cfg.setGroup("Server"); 1080 cfg.setGroup("Server");
1081 QString tempStr = cfg.readEntry( temp,""); 1081 QString tempStr = cfg.readEntry( temp,"");
1082 } 1082 }
1083 1083
1084 temp.setNum( numberOfEntries + 1); 1084 temp.setNum( numberOfEntries + 1);
1085 cfg.setGroup("Server"); 1085 cfg.setGroup("Server");
1086 remoteServerStr = cfg.readEntry( temp,""); 1086 remoteServerStr = cfg.readEntry( temp,"");
1087 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1087 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1088 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1088 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1089 1089
1090 temp.setNum(numberOfEntries+1); 1090 temp.setNum(numberOfEntries+1);
1091 cfg.setGroup("Server"); 1091 cfg.setGroup("Server");
1092 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); 1092 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
1093 cfg.setGroup(temp); 1093 cfg.setGroup(temp);
1094 cfg.writeEntry("RemotePath", remotePath->text()); 1094 cfg.writeEntry("RemotePath", remotePath->text());
1095 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1095 cfg.writeEntry("Username", UsernameComboBox->currentText());
1096 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); 1096 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
1097 cfg.setGroup("Server"); 1097 cfg.setGroup("Server");
1098 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); 1098 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
1099 } 1099 }
1100} 1100}
1101 1101
1102void OpieFtp::fillCombos() 1102void OpieFtp::fillCombos()
1103{ 1103{
1104 Config cfg("opieftp"); 1104 Config cfg("opieftp");
1105 cfg.setGroup("Server"); 1105 cfg.setGroup("Server");
1106 QString username, remoteServerStr, remotePathStr, password, port, temp; 1106 QString username, remoteServerStr, remotePathStr, password, port, temp;
1107 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1107 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1108 for (int i = 1; i <= numberOfEntries; i++) { 1108 for (int i = 1; i <= numberOfEntries; i++) {
1109 temp.setNum(i); 1109 temp.setNum(i);
1110 cfg.setGroup("Server"); 1110 cfg.setGroup("Server");
1111 remoteServerStr = cfg.readEntry( temp,""); 1111 remoteServerStr = cfg.readEntry( temp,"");
1112 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1112 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1113 port = remoteServerStr.right( divider - 1); 1113 port = remoteServerStr.right( divider - 1);
1114 bool ok; 1114 bool ok;
1115 PortSpinBox->setValue( port.toInt(&ok,10)); 1115 PortSpinBox->setValue( port.toInt(&ok,10));
1116 1116
1117 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1117 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1118 ServerComboBox->insertItem( remoteServerStr ); 1118 ServerComboBox->insertItem( remoteServerStr );
1119// cfg.setGroup(temp); 1119// cfg.setGroup(temp);
1120 1120
1121// remotePathStr = cfg.readEntry(remoteServer,""); 1121// remotePathStr = cfg.readEntry(remoteServer,"");
1122// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); 1122// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
1123// port = remoteServer.right( divider+1); 1123// port = remoteServer.right( divider+1);
1124// PortSpinBox->setValue( port); 1124// PortSpinBox->setValue( port);
1125 1125
1126// remoteServer = remoteServer.left(divider - 1); 1126// remoteServer = remoteServer.left(divider - 1);
1127// remotePath->setText( remotePathStr); 1127// remotePath->setText( remotePathStr);
1128 1128
1129// username = cfg.readEntry(temp); 1129// username = cfg.readEntry(temp);
1130// UsernameComboBox->insertItem(username); 1130// UsernameComboBox->insertItem(username);
1131// password = cfg.readEntryCrypt(username,""); 1131// password = cfg.readEntryCrypt(username,"");
1132// PasswordEdit->setText(password); 1132// PasswordEdit->setText(password);
1133 } 1133 }
1134} 1134}
1135 1135
1136 1136
1137void OpieFtp::serverComboSelected(int index) 1137void OpieFtp::serverComboSelected(int index)
1138{ 1138{
1139 currentServerConfig = index; 1139 currentServerConfig = index;
1140 QString username, remoteServerStr, remotePathStr, password, port, temp; 1140 QString username, remoteServerStr, remotePathStr, password, port, temp;
1141// remoteServerStr = ServerComboBox->text(index); 1141// remoteServerStr = ServerComboBox->text(index);
1142 Config cfg("opieftp"); 1142 Config cfg("opieftp");
1143 cfg.setGroup("Server"); 1143 cfg.setGroup("Server");
1144 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1144 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1145 1145
1146 temp.setNum(index+1); 1146 temp.setNum(index+1);
1147 remoteServerStr = cfg.readEntry( temp,""); 1147 remoteServerStr = cfg.readEntry( temp,"");
1148 cfg.setGroup(temp); 1148 cfg.setGroup(temp);
1149// qDebug(temp); 1149// qDebug(temp);
1150 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1150 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1151 port = remoteServerStr.right( divider - 1); 1151 port = remoteServerStr.right( divider - 1);
1152 bool ok; 1152 bool ok;
1153 int portInt = port.toInt(&ok,10); 1153 int portInt = port.toInt(&ok,10);
1154 if( portInt == 0) portInt = 21; 1154 if( portInt == 0) portInt = 21;
1155 1155
1156 PortSpinBox->setValue( portInt); 1156 PortSpinBox->setValue( portInt);
1157 1157
1158 remotePath->setText(cfg.readEntry("RemotePath", "/")); 1158 remotePath->setText(cfg.readEntry("RemotePath", "/"));
1159 1159
1160 username = cfg.readEntry("Username", "anonymous"); 1160 username = cfg.readEntry("Username", "anonymous");
1161 UsernameComboBox->lineEdit()->setText(username); 1161 UsernameComboBox->lineEdit()->setText(username);
1162 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); 1162 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org"));
1163 1163
1164 cfg.setGroup("Server"); 1164 cfg.setGroup("Server");
1165 temp.sprintf("%d",currentServerConfig); 1165 temp.sprintf("%d",currentServerConfig);
1166 cfg.writeEntry("currentServer", temp); 1166 cfg.writeEntry("currentServer", temp);
1167 update(); 1167 update();
1168} 1168}
1169// UsernameComboBox->lineEdit()->setText("root"); 1169// UsernameComboBox->lineEdit()->setText("root");
1170// PasswordEdit->setText( tr( "" ) ); 1170// PasswordEdit->setText( tr( "" ) );
1171// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 1171// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
1172// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); 1172// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
1173// PortSpinBox->setValue( 4242); 1173// PortSpinBox->setValue( 4242);
1174 1174
1175void OpieFtp::deleteServer() 1175void OpieFtp::deleteServer()
1176{ 1176{
1177 QString username, remoteServerStr, remotePathStr, password, port, temp; 1177 QString username, remoteServerStr, remotePathStr, password, port, temp;
1178 remoteServerStr = ServerComboBox->currentText( ); 1178 remoteServerStr = ServerComboBox->currentText( );
1179 username = UsernameComboBox->currentText(); 1179 username = UsernameComboBox->currentText();
1180 Config cfg("opieftp"); 1180 Config cfg("opieftp");
1181 cfg.setGroup("Server"); 1181 cfg.setGroup("Server");
1182 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1182 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1183 for (int i = 0; i <= numberOfEntries; i++) { 1183 for (int i = 0; i <= numberOfEntries; i++) {
1184 temp.setNum(i+1); 1184 temp.setNum(i+1);
1185 cfg.setGroup("Server"); 1185 cfg.setGroup("Server");
1186 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 1186 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1
1187 && cfg.readEntry(temp).find(username,0,TRUE) != -1 1187 && cfg.readEntry(temp).find(username,0,TRUE) != -1
1188 && !remoteServerStr.isEmpty()) { 1188 && !remoteServerStr.isEmpty()) {
1189 qDebug(temp); 1189 qDebug(temp);
1190 } 1190 }
1191 } 1191 }
1192} 1192}