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