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