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