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