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