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