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