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