summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-10-18 00:07:20 (UTC)
committer llornkcor <llornkcor>2002-10-18 00:07:20 (UTC)
commite7e36afd3685c7fab146ebd0078d7f1a60f8c5e6 (patch) (unidiff)
tree4c8e6cec21577de93127658b730d3685d5f62b90
parente688f02fa2d750eca01c92435d8793ba17aa050a (diff)
downloadopie-e7e36afd3685c7fab146ebd0078d7f1a60f8c5e6.zip
opie-e7e36afd3685c7fab146ebd0078d7f1a60f8c5e6.tar.gz
opie-e7e36afd3685c7fab146ebd0078d7f1a60f8c5e6.tar.bz2
patch by Ben Jackson, and changed listview alignment
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 4e14946..3d97ecb 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -1,451 +1,452 @@
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#include <qlistbox.h> 54#include <qlistbox.h>
55 55
56#include <unistd.h> 56#include <unistd.h>
57#include <stdlib.h> 57#include <stdlib.h>
58 58
59 59
60QProgressBar *ProgressBar; 60QProgressBar *ProgressBar;
61static netbuf *conn=NULL; 61static netbuf *conn=NULL;
62 62
63static int log_progress(netbuf *, int xfered, void *) 63static int log_progress(netbuf *, int xfered, void *)
64{ 64{
65// int fsz = *(int *)arg; 65// int fsz = *(int *)arg;
66// int pct = (xfered * 100) / fsz; 66// int pct = (xfered * 100) / fsz;
67// printf("%3d%%\r", pct); 67// printf("%3d%%\r", pct);
68// fflush(stdout); 68// fflush(stdout);
69 ProgressBar->setProgress(xfered); 69 ProgressBar->setProgress(xfered);
70 qApp->processEvents(); 70 qApp->processEvents();
71 return 1; 71 return 1;
72} 72}
73 73
74OpieFtp::OpieFtp( ) 74OpieFtp::OpieFtp( )
75 : QMainWindow( ) 75 : QMainWindow( )
76{ 76{
77 setCaption( tr( "OpieFtp" ) ); 77 setCaption( tr( "OpieFtp" ) );
78 fuckeduphack=FALSE; 78 fuckeduphack=FALSE;
79 QGridLayout *layout = new QGridLayout( this ); 79 QGridLayout *layout = new QGridLayout( this );
80 layout->setSpacing( 2); 80 layout->setSpacing( 2);
81 layout->setMargin( 2); 81 layout->setMargin( 2);
82 82
83 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 83 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
84 84
85 QPEMenuBar *menuBar = new QPEMenuBar(this); 85 QPEMenuBar *menuBar = new QPEMenuBar(this);
86// QPEToolBar *menuBar = new QPEToolBar(this); 86// QPEToolBar *menuBar = new QPEToolBar(this);
87// menuBar->setHorizontalStretchable( TRUE ); 87// menuBar->setHorizontalStretchable( TRUE );
88 88
89 connectionMenu = new QPopupMenu( this ); 89 connectionMenu = new QPopupMenu( this );
90 localMenu = new QPopupMenu( this ); 90 localMenu = new QPopupMenu( this );
91 remoteMenu = new QPopupMenu( this ); 91 remoteMenu = new QPopupMenu( this );
92 tabMenu = new QPopupMenu( this ); 92 tabMenu = new QPopupMenu( this );
93 93
94 layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); 94 layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 );
95 95
96 menuBar->insertItem( tr( "Connection" ), connectionMenu); 96 menuBar->insertItem( tr( "Connection" ), connectionMenu);
97 menuBar->insertItem( tr( "Local" ), localMenu); 97 menuBar->insertItem( tr( "Local" ), localMenu);
98 menuBar->insertItem( tr( "Remote" ), remoteMenu); 98 menuBar->insertItem( tr( "Remote" ), remoteMenu);
99 menuBar->insertItem( tr( "View" ), tabMenu); 99 menuBar->insertItem( tr( "View" ), tabMenu);
100 100
101 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() )); 101 connectionMenu->insertItem( tr( "New" ), this, SLOT( newConnection() ));
102 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() )); 102 connectionMenu->insertItem( tr( "Connect" ), this, SLOT( connector() ));
103 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() )); 103 connectionMenu->insertItem( tr( "Disconnect" ), this, SLOT( disConnector() ));
104 104
105 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 105 localMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
106 localMenu->insertSeparator(); 106 localMenu->insertSeparator();
107 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 107 localMenu->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
108 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 108 localMenu->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
109 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 109 localMenu->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
110 localMenu->insertSeparator(); 110 localMenu->insertSeparator();
111 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 111 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
112 localMenu->setCheckable(TRUE); 112 localMenu->setCheckable(TRUE);
113 113
114 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 114 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
115 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 115 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
116 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 116 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
117 remoteMenu->insertSeparator(); 117 remoteMenu->insertSeparator();
118 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 118 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
119 119
120 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 120 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
121 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 121 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
122 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 122 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
123 tabMenu->insertSeparator(); 123 tabMenu->insertSeparator();
124 tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); 124 tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
125 tabMenu->setCheckable(TRUE); 125 tabMenu->setCheckable(TRUE);
126 126
127 127
128 128
129 cdUpButton = new QToolButton( this,"cdUpButton"); 129 cdUpButton = new QToolButton( this,"cdUpButton");
130 cdUpButton->setPixmap(Resource::loadPixmap("up")); 130 cdUpButton->setPixmap(Resource::loadPixmap("up"));
131 cdUpButton ->setFixedSize( QSize( 20, 20 ) ); 131 cdUpButton ->setFixedSize( QSize( 20, 20 ) );
132 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 132 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
133 layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); 133 layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 );
134 cdUpButton->hide(); 134 cdUpButton->hide();
135 135
136// docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 136// docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
137// docButton->setFixedSize( QSize( 20, 20 ) ); 137// docButton->setFixedSize( QSize( 20, 20 ) );
138// connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 138// connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
139// docButton->setFlat(TRUE); 139// docButton->setFlat(TRUE);
140// layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); 140// layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
141 141
142 homeButton = new QToolButton(this,"homeButton"); 142 homeButton = new QToolButton(this,"homeButton");
143 homeButton->setPixmap( Resource::loadPixmap("home")); 143 homeButton->setPixmap( Resource::loadPixmap("home"));
144 homeButton->setFixedSize( QSize( 20, 20 ) ); 144 homeButton->setFixedSize( QSize( 20, 20 ) );
145 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 145 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
146 layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); 146 layout->addMultiCellWidget( homeButton, 0, 0, 4, 4);
147 homeButton->hide(); 147 homeButton->hide();
148 148
149 TabWidget = new QTabWidget( this, "TabWidget" ); 149 TabWidget = new QTabWidget( this, "TabWidget" );
150 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); 150 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 );
151 151
152// TabWidget->setTabShape(QTabWidget::Triangular); 152// TabWidget->setTabShape(QTabWidget::Triangular);
153 153
154 tab = new QWidget( TabWidget, "tab" ); 154 tab = new QWidget( TabWidget, "tab" );
155 tabLayout = new QGridLayout( tab ); 155 tabLayout = new QGridLayout( tab );
156 tabLayout->setSpacing( 2); 156 tabLayout->setSpacing( 2);
157 tabLayout->setMargin( 2); 157 tabLayout->setMargin( 2);
158 158
159 Local_View = new QListView( tab, "Local_View" ); 159 Local_View = new QListView( tab, "Local_View" );
160// Local_View->setResizePolicy( QListView::AutoOneFit ); 160// Local_View->setResizePolicy( QListView::AutoOneFit );
161 Local_View->addColumn( tr("File"),150); 161 Local_View->addColumn( tr("File"),150);
162 Local_View->addColumn( tr("Date"),-1); 162 Local_View->addColumn( tr("Date"),-1);
163 Local_View->setColumnAlignment(1,QListView::AlignRight); 163 Local_View->setColumnAlignment(1,QListView::AlignRight);
164 Local_View->addColumn( tr("Size"),-1); 164 Local_View->addColumn( tr("Size"),-1);
165 Local_View->setColumnAlignment(2,QListView::AlignRight); 165 Local_View->setColumnAlignment(2,QListView::AlignRight);
166 Local_View->setAllColumnsShowFocus(TRUE); 166 Local_View->setAllColumnsShowFocus(TRUE);
167 167
168 Local_View->setMultiSelection( TRUE); 168 Local_View->setMultiSelection( TRUE);
169 Local_View->setSelectionMode(QListView::Extended); 169 Local_View->setSelectionMode(QListView::Extended);
170 Local_View->setFocusPolicy(QWidget::ClickFocus); 170 Local_View->setFocusPolicy(QWidget::ClickFocus);
171 171
172 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 172 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
173 173
174 tabLayout->addWidget( Local_View, 0, 0 ); 174 tabLayout->addWidget( Local_View, 0, 0 );
175 175
176 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 176 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
177 this,SLOT( localListClicked(QListViewItem *)) ); 177 this,SLOT( localListClicked(QListViewItem *)) );
178// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 178// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
179// this,SLOT( localListClicked(QListViewItem *)) ); 179// this,SLOT( localListClicked(QListViewItem *)) );
180 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 180 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
181 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 181 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
182 182
183 TabWidget->insertTab( tab, tr( "Local" ) ); 183 TabWidget->insertTab( tab, tr( "Local" ) );
184 184
185 tab_2 = new QWidget( TabWidget, "tab_2" ); 185 tab_2 = new QWidget( TabWidget, "tab_2" );
186 tabLayout_2 = new QGridLayout( tab_2 ); 186 tabLayout_2 = new QGridLayout( tab_2 );
187 tabLayout_2->setSpacing( 2); 187 tabLayout_2->setSpacing( 2);
188 tabLayout_2->setMargin( 2); 188 tabLayout_2->setMargin( 2);
189 189
190 Remote_View = new QListView( tab_2, "Remote_View" ); 190 Remote_View = new QListView( tab_2, "Remote_View" );
191 Remote_View->addColumn( tr("File"),150); 191 Remote_View->addColumn( tr("File"),150);
192 Remote_View->addColumn( tr("Date"),-1); 192 Remote_View->addColumn( tr("Date"),-1);
193 Remote_View->setColumnAlignment(1,QListView::AlignRight); 193// Remote_View->setColumnAlignment(1,QListView::AlignRight);
194 Remote_View->addColumn( tr("Size"),-1); 194 Remote_View->addColumn( tr("Size"),-1);
195 Remote_View->setColumnAlignment(2,QListView::AlignRight); 195 Remote_View->setColumnAlignment(2,QListView::AlignRight);
196 Remote_View->setColumnAlignment(3,QListView::AlignCenter);
196 Remote_View->addColumn( tr("Dir"),-1); 197 Remote_View->addColumn( tr("Dir"),-1);
197 Remote_View->setColumnAlignment(4,QListView::AlignRight); 198 Remote_View->setColumnAlignment(4,QListView::AlignRight);
198 Remote_View->setAllColumnsShowFocus(TRUE); 199 Remote_View->setAllColumnsShowFocus(TRUE);
199 200
200 Remote_View->setMultiSelection( FALSE); 201 Remote_View->setMultiSelection( FALSE);
201 Remote_View->setSelectionMode(QListView::Extended); 202 Remote_View->setSelectionMode(QListView::Extended);
202 Remote_View->setFocusPolicy(QWidget::ClickFocus); 203 Remote_View->setFocusPolicy(QWidget::ClickFocus);
203 204
204 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 205 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
205 206
206 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 207 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
207 this,SLOT( remoteListClicked(QListViewItem *)) ); 208 this,SLOT( remoteListClicked(QListViewItem *)) );
208 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 209 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
209 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 210 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
210 211
211 tabLayout_2->addWidget( Remote_View, 0, 0 ); 212 tabLayout_2->addWidget( Remote_View, 0, 0 );
212 213
213 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 214 TabWidget->insertTab( tab_2, tr( "Remote" ) );
214 215
215 tab_3 = new QWidget( TabWidget, "tab_3" ); 216 tab_3 = new QWidget( TabWidget, "tab_3" );
216 tabLayout_3 = new QGridLayout( tab_3 ); 217 tabLayout_3 = new QGridLayout( tab_3 );
217 tabLayout_3->setSpacing( 2); 218 tabLayout_3->setSpacing( 2);
218 tabLayout_3->setMargin( 2); 219 tabLayout_3->setMargin( 2);
219 220
220 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 221 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
221 TextLabel1->setText( tr( "Username" ) ); 222 TextLabel1->setText( tr( "Username" ) );
222 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 223 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
223 224
224 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 225 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
225 UsernameComboBox->setEditable(TRUE); 226 UsernameComboBox->setEditable(TRUE);
226 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 227 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
227 228
228 connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this, 229 connect( UsernameComboBox,SIGNAL(textChanged(const QString &)),this,
229 SLOT( UsernameComboBoxEdited(const QString & ) )); 230 SLOT( UsernameComboBoxEdited(const QString & ) ));
230 231
231 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 232 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
232 TextLabel2->setText( tr( "Password" ) ); 233 TextLabel2->setText( tr( "Password" ) );
233 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 234 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
234 235
235 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 236 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
236 PasswordEdit->setEchoMode(QLineEdit::Password); 237 PasswordEdit->setEchoMode(QLineEdit::Password);
237 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 238 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
238 239
239 connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this, 240 connect( PasswordEdit,SIGNAL(textChanged(const QString &)),this,
240 SLOT( PasswordEditEdited(const QString & ) )); 241 SLOT( PasswordEditEdited(const QString & ) ));
241 242
242//PasswordEdit->setFixedWidth(85); 243//PasswordEdit->setFixedWidth(85);
243 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 244 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
244 TextLabel3->setText( tr( "Remote server" ) ); 245 TextLabel3->setText( tr( "Remote server" ) );
245 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 246 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
246 247
247 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 248 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
248 ServerComboBox->setEditable(TRUE); 249 ServerComboBox->setEditable(TRUE);
249 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 250 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
250 251
251 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); 252 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
252 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this, 253 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,
253 SLOT(serverComboEdited(const QString & ) )); 254 SLOT(serverComboEdited(const QString & ) ));
254 255
255 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 256 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
256 TextLabel5->setText( tr( "Remote path" ) ); 257 TextLabel5->setText( tr( "Remote path" ) );
257 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 258 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
258 259
259 260
260 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 261 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
261 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 262 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
262 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 263 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
263 TextLabel4->setText( tr( "Port" ) ); 264 TextLabel4->setText( tr( "Port" ) );
264 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 265 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
265 266
266 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 267 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
267 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 268 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
268 PortSpinBox->setMaxValue(32786); 269 PortSpinBox->setMaxValue(32786);
269 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 270 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
270 271
271 serverListView = new QListBox( tab_3, "ServerListView" ); 272 serverListView = new QListBox( tab_3, "ServerListView" );
272 tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5); 273 tabLayout_3->addMultiCellWidget( serverListView , 5, 5, 0, 5);
273 274
274 connect( serverListView, SIGNAL( highlighted( const QString &)), 275 connect( serverListView, SIGNAL( highlighted( const QString &)),
275 this,SLOT( serverListClicked( const QString &) ) ); 276 this,SLOT( serverListClicked( const QString &) ) );
276 277
277 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); 278 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
278 tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); 279 tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1);
279 connectServerBtn->setToggleButton(TRUE); 280 connectServerBtn->setToggleButton(TRUE);
280 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 281 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
281 282
282 newServerButton= new QPushButton( "Add", tab_3 , "NewServerButton" ); 283 newServerButton= new QPushButton( "Add", tab_3 , "NewServerButton" );
283 tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); 284 tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2);
284 connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); 285 connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() ));
285 286
286 QPushButton *deleteServerBtn; 287 QPushButton *deleteServerBtn;
287 deleteServerBtn = new QPushButton( "Delete", tab_3 , "OpenButton" ); 288 deleteServerBtn = new QPushButton( "Delete", tab_3 , "OpenButton" );
288 tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); 289 tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3);
289 290
290 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 291 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
291 292
292 293
293 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 294 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
294 tabLayout_3->addItem( spacer, 5, 0 ); 295 tabLayout_3->addItem( spacer, 5, 0 );
295 296
296 TabWidget->insertTab( tab_3, tr( "Config" ) ); 297 TabWidget->insertTab( tab_3, tr( "Config" ) );
297 298
298 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 299 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
299 this,SLOT(tabChanged(QWidget*))); 300 this,SLOT(tabChanged(QWidget*)));
300 301
301 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 302 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
302 currentDir.setPath( QDir::currentDirPath()); 303 currentDir.setPath( QDir::currentDirPath());
303// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 304// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
304 305
305 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); 306 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
306 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); 307 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4);
307 currentPathCombo ->setFixedWidth(220); 308 currentPathCombo ->setFixedWidth(220);
308 currentPathCombo->setEditable(TRUE); 309 currentPathCombo->setEditable(TRUE);
309 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 310 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
310 311
311 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 312 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
312 this, SLOT( currentPathComboActivated( const QString & ) ) ); 313 this, SLOT( currentPathComboActivated( const QString & ) ) );
313 314
314 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 315 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
315 this,SLOT(currentPathComboChanged())); 316 this,SLOT(currentPathComboChanged()));
316 317
317 ProgressBar = new QProgressBar( this, "ProgressBar" ); 318 ProgressBar = new QProgressBar( this, "ProgressBar" );
318 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); 319 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4);
319 ProgressBar->setMaximumHeight(10); 320 ProgressBar->setMaximumHeight(10);
320 filterStr="*"; 321 filterStr="*";
321 b=FALSE; 322 b=FALSE;
322 populateLocalView(); 323 populateLocalView();
323 readConfig(); 324 readConfig();
324 325
325// ServerComboBox->setCurrentItem(currentServerConfig); 326// ServerComboBox->setCurrentItem(currentServerConfig);
326 327
327 TabWidget->setCurrentPage(2); 328 TabWidget->setCurrentPage(2);
328} 329}
329 330
330OpieFtp::~OpieFtp() 331OpieFtp::~OpieFtp()
331{ 332{
332} 333}
333 334
334void OpieFtp::cleanUp() 335void OpieFtp::cleanUp()
335{ 336{
336 if(conn) 337 if(conn)
337 FtpQuit(conn); 338 FtpQuit(conn);
338 QString sfile=QDir::homeDirPath(); 339 QString sfile=QDir::homeDirPath();
339 if(sfile.right(1) != "/") 340 if(sfile.right(1) != "/")
340 sfile+="/._temp"; 341 sfile+="/._temp";
341 else 342 else
342 sfile+="._temp"; 343 sfile+="._temp";
343 QFile file( sfile); 344 QFile file( sfile);
344 if(file.exists()) 345 if(file.exists())
345 file.remove(); 346 file.remove();
346 Config cfg("opieftp"); 347 Config cfg("opieftp");
347 cfg.setGroup("Server"); 348 cfg.setGroup("Server");
348 cfg.writeEntry("currentServer", currentServerConfig); 349 cfg.writeEntry("currentServer", currentServerConfig);
349 350
350 exit(0); 351 exit(0);
351} 352}
352 353
353void OpieFtp::tabChanged(QWidget *) 354void OpieFtp::tabChanged(QWidget *)
354{ 355{
355 if (TabWidget->currentPageIndex() == 0) { 356 if (TabWidget->currentPageIndex() == 0) {
356 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 357 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
357 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 358 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
358 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 359 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
359 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 360 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
360 if(cdUpButton->isHidden()) 361 if(cdUpButton->isHidden())
361 cdUpButton->show(); 362 cdUpButton->show();
362 if(homeButton->isHidden()) 363 if(homeButton->isHidden())
363 homeButton->show(); 364 homeButton->show();
364 365
365 } 366 }
366 if (TabWidget->currentPageIndex() == 1) { 367 if (TabWidget->currentPageIndex() == 1) {
367 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 368 currentPathCombo->lineEdit()->setText( currentRemoteDir );
368 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 369 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
369 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 370 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
370 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 371 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
371 if(cdUpButton->isHidden()) 372 if(cdUpButton->isHidden())
372 cdUpButton->show(); 373 cdUpButton->show();
373 homeButton->hide(); 374 homeButton->hide();
374 375
375 } 376 }
376 if (TabWidget->currentPageIndex() == 2) { 377 if (TabWidget->currentPageIndex() == 2) {
377 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 378 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
378 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 379 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
379 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 380 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
380 cdUpButton->hide(); 381 cdUpButton->hide();
381 homeButton->hide(); 382 homeButton->hide();
382 } 383 }
383} 384}
384 385
385void OpieFtp::newConnection() 386void OpieFtp::newConnection()
386{ 387{
387 UsernameComboBox->lineEdit()->setText(""); 388 UsernameComboBox->lineEdit()->setText("");
388 PasswordEdit->setText( "" ); 389 PasswordEdit->setText( "" );
389 ServerComboBox->lineEdit()->setText( ""); 390 ServerComboBox->lineEdit()->setText( "");
390 remotePath->setText( currentRemoteDir = "/"); 391 remotePath->setText( currentRemoteDir = "/");
391 PortSpinBox->setValue( 21); 392 PortSpinBox->setValue( 21);
392 TabWidget->setCurrentPage(2); 393 TabWidget->setCurrentPage(2);
393} 394}
394 395
395void OpieFtp::serverComboEdited(const QString & ) 396void OpieFtp::serverComboEdited(const QString & )
396{ 397{
397// if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { 398// if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) {
398// qDebug("ServerComboEdited"); 399// qDebug("ServerComboEdited");
399// // currentServerConfig = -1; 400// // currentServerConfig = -1;
400// } 401// }
401} 402}
402 403
403void OpieFtp::UsernameComboBoxEdited(const QString &) { 404void OpieFtp::UsernameComboBoxEdited(const QString &) {
404// currentServerConfig = -1; 405// currentServerConfig = -1;
405} 406}
406 407
407void OpieFtp::PasswordEditEdited(const QString & ) { 408void OpieFtp::PasswordEditEdited(const QString & ) {
408// currentServerConfig = -1; 409// currentServerConfig = -1;
409} 410}
410 411
411void OpieFtp::connectorBtnToggled(bool On) 412void OpieFtp::connectorBtnToggled(bool On)
412{ 413{
413 if(On) { 414 if(On) {
414 connector(); 415 connector();
415 } else { 416 } else {
416 disConnector(); 417 disConnector();
417 } 418 }
418 419
419} 420}
420 421
421void OpieFtp::connector() 422void OpieFtp::connector()
422{ 423{
423// QCopEnvelope ( "QPE/System", "busy()" ); 424// QCopEnvelope ( "QPE/System", "busy()" );
424// qApp->processEvents(); 425// qApp->processEvents();
425 currentRemoteDir=remotePath->text(); 426 currentRemoteDir=remotePath->text();
426 427
427 if( ServerComboBox->currentText().isEmpty()) { 428 if( ServerComboBox->currentText().isEmpty()) {
428 429
429 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 430 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
430 TabWidget->setCurrentPage(2); 431 TabWidget->setCurrentPage(2);
431 ServerComboBox->setFocus(); 432 ServerComboBox->setFocus();
432 connectServerBtn->setOn(FALSE); 433 connectServerBtn->setOn(FALSE);
433 connectServerBtn->setText( tr("Connect")); 434 connectServerBtn->setText( tr("Connect"));
434 return; 435 return;
435 } 436 }
436 437
437 FtpInit(); 438 FtpInit();
438 439
439 TabWidget->setCurrentPage(1); 440 TabWidget->setCurrentPage(1);
440 QString ftp_host = ServerComboBox->currentText(); 441 QString ftp_host = ServerComboBox->currentText();
441 QString ftp_user = UsernameComboBox->currentText(); 442 QString ftp_user = UsernameComboBox->currentText();
442 QString ftp_pass = PasswordEdit->text(); 443 QString ftp_pass = PasswordEdit->text();
443 QString port=PortSpinBox->cleanText(); 444 QString port=PortSpinBox->cleanText();
444 port.stripWhiteSpace(); 445 port.stripWhiteSpace();
445 446
446 Config cfg("opieftp"); 447 Config cfg("opieftp");
447 cfg.setGroup("Server"); 448 cfg.setGroup("Server");
448// int current=cfg.readNumEntry("currentServer", 1); 449// int current=cfg.readNumEntry("currentServer", 1);
449 450
450// if(ftp_host!= cfg.readEntry(QString::number( current))) 451// if(ftp_host!= cfg.readEntry(QString::number( current)))
451// currentServerConfig=-1; 452// currentServerConfig=-1;
@@ -468,542 +469,544 @@ void OpieFtp::connector()
468 } 469 }
469 470
470 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 471 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
471 QString msg; 472 QString msg;
472 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 473 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
473 msg.replace(QRegExp(":"),"\n"); 474 msg.replace(QRegExp(":"),"\n");
474 QMessageBox::message(tr("Note"),msg); 475 QMessageBox::message(tr("Note"),msg);
475 if(conn) 476 if(conn)
476 FtpQuit(conn); 477 FtpQuit(conn);
477 connectServerBtn->setOn(FALSE); 478 connectServerBtn->setOn(FALSE);
478 connectServerBtn->setText( tr("Connect")); 479 connectServerBtn->setText( tr("Connect"));
479 return ; 480 return ;
480 } 481 }
481 482
482 remoteDirList("/") ; 483 remoteDirList("/") ;
483 setCaption(ftp_host); 484 setCaption(ftp_host);
484 if( currentServerConfig == -1) 485 if( currentServerConfig == -1)
485 writeConfig(); 486 writeConfig();
486 connectServerBtn->setText( tr("Disconnect")); 487 connectServerBtn->setText( tr("Disconnect"));
487// QCopEnvelope ( "QPE/System", "notBusy()" ); 488// QCopEnvelope ( "QPE/System", "notBusy()" );
488} 489}
489 490
490void OpieFtp::disConnector() 491void OpieFtp::disConnector()
491{ 492{
492 if(conn) 493 if(conn)
493 FtpQuit(conn); 494 FtpQuit(conn);
494 setCaption("OpieFtp"); 495 setCaption("OpieFtp");
495 currentRemoteDir="/"; 496 currentRemoteDir="/";
496 Remote_View->clear(); 497 Remote_View->clear();
497 connectServerBtn->setText( tr("Connect")); 498 connectServerBtn->setText( tr("Connect"));
498 connectServerBtn->setOn(FALSE); 499 connectServerBtn->setOn(FALSE);
499 setCaption("OpieFtp"); 500 setCaption("OpieFtp");
500} 501}
501 502
502void OpieFtp::localUpload() 503void OpieFtp::localUpload()
503{ 504{
504 int fsz; 505 int fsz;
505// QCopEnvelope ( "QPE/System", "busy()" ); 506// QCopEnvelope ( "QPE/System", "busy()" );
506// qApp->processEvents(); 507// qApp->processEvents();
507 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 508 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
508 QListViewItemIterator it( Local_View ); 509 QListViewItemIterator it( Local_View );
509 for ( ; it.current(); ++it ) { 510 for ( ; it.current(); ++it ) {
510 if ( it.current()->isSelected() ) { 511 if ( it.current()->isSelected() ) {
511 QString strItem = it.current()->text(0); 512 QString strItem = it.current()->text(0);
512 QString localFile = currentDir.canonicalPath()+"/"+strItem; 513 QString localFile = currentDir.canonicalPath()+"/"+strItem;
513 QString remoteFile= currentRemoteDir+strItem; 514 QString remoteFile= currentRemoteDir+strItem;
514 QFileInfo fi(localFile); 515 QFileInfo fi(localFile);
515 if( !fi.isDir()) { 516 if( !fi.isDir()) {
516 fsz=fi.size(); 517 fsz=fi.size();
517 ProgressBar->setTotalSteps(fsz); 518 ProgressBar->setTotalSteps(fsz);
518 519
519 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 520 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
520 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 521 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
521 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 522 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
522 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 523 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
523 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 524 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
524 525
525 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 526 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
526 QString msg; 527 QString msg;
527 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 528 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
528 msg.replace(QRegExp(":"),"\n"); 529 msg.replace(QRegExp(":"),"\n");
529 QMessageBox::message(tr("Note"),msg); 530 QMessageBox::message(tr("Note"),msg);
530 } 531 }
531 } else { 532 } else {
532 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 533 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
533 } 534 }
534 ProgressBar->reset(); 535 ProgressBar->reset();
535 nullifyCallBack(); 536 nullifyCallBack();
536 it.current()->setSelected(FALSE); 537 it.current()->setSelected(FALSE);
537 } //end currentSelected 538 } //end currentSelected
538 } 539 }
539 for ( ; it.current(); ++it ) { 540 for ( ; it.current(); ++it ) {
540 Local_View->clearSelection(); 541 Local_View->clearSelection();
541 } 542 }
542 Local_View->clearFocus(); 543 Local_View->clearFocus();
543 TabWidget->setCurrentPage(1); 544 TabWidget->setCurrentPage(1);
544 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 545 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
545// QCopEnvelope ( "QPE/System", "notBusy()" ); 546// QCopEnvelope ( "QPE/System", "notBusy()" );
546} 547}
547 548
548void OpieFtp::nullifyCallBack() 549void OpieFtp::nullifyCallBack()
549{ 550{
550 FtpOptions(FTPLIB_CALLBACK, 0, conn); 551 FtpOptions(FTPLIB_CALLBACK, 0, conn);
551 FtpOptions(FTPLIB_IDLETIME, 0, conn); 552 FtpOptions(FTPLIB_IDLETIME, 0, conn);
552 FtpOptions(FTPLIB_CALLBACKARG, 0, conn); 553 FtpOptions(FTPLIB_CALLBACKARG, 0, conn);
553 FtpOptions(FTPLIB_CALLBACKBYTES, 0, conn); 554 FtpOptions(FTPLIB_CALLBACKBYTES, 0, conn);
554} 555}
555 556
556void OpieFtp::remoteDownload() 557void OpieFtp::remoteDownload()
557{ 558{
558// qApp->processEvents(); 559// qApp->processEvents();
559 int fsz; 560 int fsz;
560// QCopEnvelope ( "QPE/System", "busy()" ); 561// QCopEnvelope ( "QPE/System", "busy()" );
561 562
562 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 563 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
563 QListViewItemIterator it( Remote_View ); 564 QListViewItemIterator it( Remote_View );
564 for ( ; it.current(); ++it ) { 565 for ( ; it.current(); ++it ) {
565 if ( it.current()->isSelected() ) { 566 if ( it.current()->isSelected() ) {
566 QString strItem = it.current()->text(0); 567 QString strItem = it.current()->text(0);
567// strItem=strItem.right(strItem.length()-1); 568// strItem=strItem.right(strItem.length()-1);
568 QString localFile = currentDir.canonicalPath(); 569 QString localFile = currentDir.canonicalPath();
569 if(localFile.right(1).find("/",0,TRUE) == -1) 570 if(localFile.right(1).find("/",0,TRUE) == -1)
570 localFile += "/"; 571 localFile += "/";
571 localFile += strItem; 572 localFile += strItem;
572// QString localFile = currentDir.canonicalPath()+"/"+strItem; 573// QString localFile = currentDir.canonicalPath()+"/"+strItem;
573 QString remoteFile= currentRemoteDir+strItem; 574 QString remoteFile= currentRemoteDir+strItem;
574 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 575 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
575 fsz = 0; 576 fsz = 0;
576 QString temp; 577 QString temp;
577 temp.sprintf( remoteFile+" "+" %dkb", fsz); 578 temp.sprintf( remoteFile+" "+" %dkb", fsz);
578 579
579 ProgressBar->setTotalSteps(fsz); 580 ProgressBar->setTotalSteps(fsz);
580 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 581 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
581 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 582 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
582 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 583 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
583 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 584 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
584 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 585 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
585 586
586 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 587 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
587 QString msg; 588 QString msg;
588 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 589 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
589 msg.replace(QRegExp(":"),"\n"); 590 msg.replace(QRegExp(":"),"\n");
590 QMessageBox::message(tr("Note"),msg); 591 QMessageBox::message(tr("Note"),msg);
591 } 592 }
592 ProgressBar->reset(); 593 ProgressBar->reset();
593 nullifyCallBack(); 594 nullifyCallBack();
594 it.current()->setSelected(FALSE); 595 it.current()->setSelected(FALSE);
595 } 596 }
596 } 597 }
597 for ( ; it.current(); ++it ) { 598 for ( ; it.current(); ++it ) {
598 Remote_View->clearSelection(); 599 Remote_View->clearSelection();
599 } 600 }
600 Remote_View->setFocus(); 601 Remote_View->setFocus();
601 TabWidget->setCurrentPage(0); 602 TabWidget->setCurrentPage(0);
602 populateLocalView(); 603 populateLocalView();
603// QCopEnvelope ( "QPE/System", "notBusy()" ); 604// QCopEnvelope ( "QPE/System", "notBusy()" );
604} 605}
605 606
606bool OpieFtp::remoteDirList(const QString &dir) 607bool OpieFtp::remoteDirList(const QString &dir)
607{ 608{
608 QString tmp = QDir::homeDirPath(); 609 QString tmp = QDir::homeDirPath();
609 if(tmp.right(1) != "/") 610 if(tmp.right(1) != "/")
610 tmp+="/._temp"; 611 tmp+="/._temp";
611 else 612 else
612 tmp+="._temp"; 613 tmp+="._temp";
613// qDebug("Listing remote dir "+tmp); 614// qDebug("Listing remote dir "+tmp);
614// QCopEnvelope ( "QPE/System", "busy()" ); 615// QCopEnvelope ( "QPE/System", "busy()" );
615 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 616 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
616 QString msg; 617 QString msg;
617 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 618 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
618 msg.replace(QRegExp(":"),"\n"); 619 msg.replace(QRegExp(":"),"\n");
619 QMessageBox::message(tr("Note"),msg); 620 QMessageBox::message(tr("Note"),msg);
620 return false; 621 return false;
621 } 622 }
622 populateRemoteView() ; 623 populateRemoteView() ;
623// QCopEnvelope ( "QPE/System", "notBusy()" ); 624// QCopEnvelope ( "QPE/System", "notBusy()" );
624 return true; 625 return true;
625} 626}
626 627
627bool OpieFtp::remoteChDir(const QString &dir) 628bool OpieFtp::remoteChDir(const QString &dir)
628{ 629{
629// QCopEnvelope ( "QPE/System", "busy()" ); 630// QCopEnvelope ( "QPE/System", "busy()" );
630 if (!FtpChdir( dir.latin1(), conn )) { 631 if (!FtpChdir( dir.latin1(), conn )) {
631 QString msg; 632 QString msg;
632 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 633 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
633 msg.replace(QRegExp(":"),"\n"); 634 msg.replace(QRegExp(":"),"\n");
634 QMessageBox::message(tr("Note"),msg); 635 QMessageBox::message(tr("Note"),msg);
635// qDebug(msg); 636// qDebug(msg);
636// QCopEnvelope ( "QPE/System", "notBusy()" ); 637// QCopEnvelope ( "QPE/System", "notBusy()" );
637 return FALSE; 638 return FALSE;
638 } 639 }
639// QCopEnvelope ( "QPE/System", "notBusy()" ); 640// QCopEnvelope ( "QPE/System", "notBusy()" );
640 return TRUE; 641 return TRUE;
641} 642}
642 643
643void OpieFtp::populateLocalView() 644void OpieFtp::populateLocalView()
644{ 645{
645 Local_View->clear(); 646 Local_View->clear();
646 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 647 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
647 currentDir.setMatchAllDirs(TRUE); 648 currentDir.setMatchAllDirs(TRUE);
648 currentDir.setNameFilter(filterStr); 649 currentDir.setNameFilter(filterStr);
649 QString fileL, fileS, fileDate; 650 QString fileL, fileS, fileDate;
650 bool isDir=FALSE; 651 bool isDir=FALSE;
651 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 652 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
652 QFileInfoListIterator it(*list); 653 QFileInfoListIterator it(*list);
653 QFileInfo *fi; 654 QFileInfo *fi;
654 while ( (fi=it.current()) ) { 655 while ( (fi=it.current()) ) {
655 if (fi->isSymLink() ){ 656 if (fi->isSymLink() ){
656 QString symLink=fi->readLink(); 657 QString symLink=fi->readLink();
657// qDebug("Symlink detected "+symLink); 658// qDebug("Symlink detected "+symLink);
658 QFileInfo sym( symLink); 659 QFileInfo sym( symLink);
659 fileS.sprintf( "%10i", sym.size() ); 660 fileS.sprintf( "%10i", sym.size() );
660 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 661 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
661 fileDate = sym.lastModified().toString(); 662 fileDate = sym.lastModified().toString();
662 } else { 663 } else {
663// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 664// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
664 fileS.sprintf( "%10i", fi->size() ); 665 fileS.sprintf( "%10i", fi->size() );
665 fileL.sprintf( "%s",fi->fileName().data() ); 666 fileL.sprintf( "%s",fi->fileName().data() );
666 fileDate= fi->lastModified().toString(); 667 fileDate= fi->lastModified().toString();
667 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 668 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
668 fileL+="/"; 669 fileL+="/";
669 isDir=TRUE; 670 isDir=TRUE;
670// qDebug( fileL); 671// qDebug( fileL);
671 } 672 }
672 } 673 }
673 if(fileL !="./" && fi->exists()) { 674 if(fileL !="./" && fi->exists()) {
674 item = new QListViewItem( Local_View,fileL, fileDate, fileS ); 675 item = new QListViewItem( Local_View,fileL, fileDate, fileS );
675 QPixmap pm; 676 QPixmap pm;
676 677
677 if(isDir || fileL.find("/",0,TRUE) != -1) { 678 if(isDir || fileL.find("/",0,TRUE) != -1) {
678 if( !QDir( fi->filePath() ).isReadable()) 679 if( !QDir( fi->filePath() ).isReadable())
679 pm = Resource::loadPixmap( "lockedfolder" ); 680 pm = Resource::loadPixmap( "lockedfolder" );
680 else 681 else
681 pm= Resource::loadPixmap( "folder" ); 682 pm= Resource::loadPixmap( "folder" );
682 item->setPixmap( 0,pm ); 683 item->setPixmap( 0,pm );
683 } else { 684 } else {
684 if( !fi->isReadable() ) 685 if( !fi->isReadable() )
685 pm = Resource::loadPixmap( "locked" ); 686 pm = Resource::loadPixmap( "locked" );
686 else { 687 else {
687 MimeType mt(fi->filePath()); 688 MimeType mt(fi->filePath());
688 pm=mt.pixmap(); //sets the correct pixmap for mimetype 689 pm=mt.pixmap(); //sets the correct pixmap for mimetype
689 if(pm.isNull()) 690 if(pm.isNull())
690 pm = Resource::loadPixmap( "UnknownDocument-14" ); 691 pm = Resource::loadPixmap( "UnknownDocument-14" );
691 item->setPixmap( 0,pm); 692 item->setPixmap( 0,pm);
692 } 693 }
693 } 694 }
694 if( fileL.find("->",0,TRUE) != -1) { 695 if( fileL.find("->",0,TRUE) != -1) {
695 // overlay link image 696 // overlay link image
696 pm= Resource::loadPixmap( "folder" ); 697 pm= Resource::loadPixmap( "folder" );
697 QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); 698 QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
698 QPainter painter( &pm ); 699 QPainter painter( &pm );
699 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 700 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
700 pm.setMask( pm.createHeuristicMask( FALSE ) ); 701 pm.setMask( pm.createHeuristicMask( FALSE ) );
701 item->setPixmap( 0, pm); 702 item->setPixmap( 0, pm);
702 } 703 }
703 } 704 }
704 isDir=FALSE; 705 isDir=FALSE;
705 ++it; 706 ++it;
706 } 707 }
707 Local_View->setSorting( 3,FALSE); 708 Local_View->setSorting( 3,FALSE);
708 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); 709 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() );
709 fillCombo( (const QString &)currentDir); 710 fillCombo( (const QString &)currentDir);
710} 711}
711 712
712bool OpieFtp::populateRemoteView( ) 713bool OpieFtp::populateRemoteView( )
713{ 714{
714// qDebug("populate remoteview"); 715// qDebug("populate remoteview");
715 QString sfile=QDir::homeDirPath(); 716 QString sfile=QDir::homeDirPath();
716 if(sfile.right(1) != "/") 717 if(sfile.right(1) != "/")
717 sfile+="/._temp"; 718 sfile+="/._temp";
718 else 719 else
719 sfile+="._temp"; 720 sfile+="._temp";
720 QFile file( sfile); 721 QFile file( sfile);
721 Remote_View->clear(); 722 Remote_View->clear();
722 QString s, File_Name; 723 QString s, File_Name;
723 QListViewItem *itemDir=NULL, *itemFile=NULL; 724 QListViewItem *itemDir=NULL, *itemFile=NULL;
725 QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] ");
724 QString fileL, fileS, fileDate; 726 QString fileL, fileS, fileDate;
725 if ( file.open(IO_ReadOnly)) { 727 if ( file.open(IO_ReadOnly)) {
726 QTextStream t( &file ); // use a text stream 728 QTextStream t( &file ); // use a text stream
727 while ( !t.eof()) { 729 while ( !t.eof()) {
728 s = t.readLine(); 730 s = t.readLine();
729 fileL = s.right(s.length()-55); 731
730 fileL = fileL.stripWhiteSpace(); 732 if(s.find("total",0,TRUE) == 0)
733 continue;
734
735 int len, month = monthRe.match(s, 0, &len);
736 fileDate = s.mid(month + 1, len - 2); // minus spaces
737 fileL = s.right(s.length() - month - len);
731 if(s.left(1) == "d") 738 if(s.left(1) == "d")
732 fileL = fileL+"/"; 739 fileL = fileL+"/";
733// fileL = "/"+fileL+"/"; 740 fileS = s.mid(month - 8, 8); // FIXME
734 fileS = s.mid( 30, 42-30);
735 fileS = fileS.stripWhiteSpace(); 741 fileS = fileS.stripWhiteSpace();
736 fileDate = s.mid( 42, 55-42); 742
737 fileDate = fileDate.stripWhiteSpace(); 743 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
738 if(fileL.find("total",0,TRUE) == -1) { 744 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d");
739 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 745 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
740 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d");
741 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
742// if(itemDir) 746// if(itemDir)
743 item->moveItem(itemDir); 747 item->moveItem(itemDir);
744 itemDir=item; 748 itemDir=item;
745 } else { 749 } else {
746 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); 750 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f");
747 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 751 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
748// if(itemFile) 752// if(itemFile)
749 item->moveItem(itemDir); 753 item->moveItem(itemDir);
750 item->moveItem(itemFile); 754 item->moveItem(itemFile);
751 itemFile=item; 755 itemFile=item;
752 } 756 }
753 }
754 } 757 }
755 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 758 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
756 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 759 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
757 file.close(); 760 file.close();
758 if( file.exists()) 761 if( file.exists())
759 file. remove(); 762 file. remove();
760 } else 763 } else
761 qDebug("temp file not opened successfullly "+sfile); 764 qDebug("temp file not opened successfullly "+sfile);
762 Remote_View->setSorting( 4,TRUE); 765 Remote_View->setSorting( 4,TRUE);
763 return true; 766 return true;
764} 767}
765 768
766void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 769void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
767{ 770{
768 if( selectedItem) { 771 if( selectedItem) {
769// QCopEnvelope ( "QPE/System", "busy()" ); 772// QCopEnvelope ( "QPE/System", "busy()" );
770 QString oldRemoteCurrentDir = currentRemoteDir; 773 QString oldRemoteCurrentDir = currentRemoteDir;
771 QString strItem=selectedItem->text(0); 774 QString strItem=selectedItem->text(0);
772 strItem=strItem.simplifyWhiteSpace(); 775 strItem=strItem.simplifyWhiteSpace();
773 if(strItem == "../") { // the user wants to go ^ 776 if(strItem == "../") { // the user wants to go ^
774 if( FtpCDUp( conn) == 0) { 777 if( FtpCDUp( conn) == 0) {
775 QString msg; 778 QString msg;
776 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 779 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
777 msg.replace(QRegExp(":"),"\n"); 780 msg.replace(QRegExp(":"),"\n");
778 QMessageBox::message(tr("Note"),msg); 781 QMessageBox::message(tr("Note"),msg);
779// qDebug(msg); 782// qDebug(msg);
780 } 783 }
781 char path[256]; 784 char path[256];
782 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 785 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
783 QString msg; 786 QString msg;
784 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 787 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
785 msg.replace(QRegExp(":"),"\n"); 788 msg.replace(QRegExp(":"),"\n");
786 QMessageBox::message(tr("Note"),msg); 789 QMessageBox::message(tr("Note"),msg);
787// qDebug(msg); 790// qDebug(msg);
788 } 791 }
789 currentRemoteDir=path; 792 currentRemoteDir=path;
790 } else { 793 } else {
791 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers 794 if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
792 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); 795 strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
793 strItem = strItem.stripWhiteSpace(); 796 strItem = strItem.stripWhiteSpace();
794 currentRemoteDir = strItem; 797 currentRemoteDir = strItem;
795 if( !remoteChDir( (const QString &)strItem)) { 798 if( !remoteChDir( (const QString &)strItem)) {
796 currentRemoteDir = oldRemoteCurrentDir; 799 currentRemoteDir = oldRemoteCurrentDir;
797 strItem=""; 800 strItem="";
798// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 801// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
799 } 802 }
800 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory 803 } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
801 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { 804 if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
802 currentRemoteDir = oldRemoteCurrentDir; 805 currentRemoteDir = oldRemoteCurrentDir;
803 strItem=""; 806 strItem="";
804// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); 807// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
805 808
806 } else { 809 } else {
807 currentRemoteDir = currentRemoteDir+strItem; 810 currentRemoteDir = currentRemoteDir+strItem;
808 } 811 }
809 } else { 812 } else {
810// QCopEnvelope ( "QPE/System", "notBusy()" ); 813// QCopEnvelope ( "QPE/System", "notBusy()" );
811 return; 814 return;
812 } 815 }
813 } 816 }
814 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 817 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
815 if(currentRemoteDir.right(1) !="/") 818 if(currentRemoteDir.right(1) !="/")
816 currentRemoteDir +="/"; 819 currentRemoteDir +="/";
817 currentPathCombo->lineEdit()->setText( currentRemoteDir); 820 currentPathCombo->lineEdit()->setText( currentRemoteDir);
818 fillRemoteCombo( (const QString &)currentRemoteDir); 821 fillRemoteCombo( (const QString &)currentRemoteDir);
819// QCopEnvelope ( "QPE/System", "notBusy()" ); 822// QCopEnvelope ( "QPE/System", "notBusy()" );
820 Remote_View->ensureItemVisible(Remote_View->firstChild()); 823 Remote_View->ensureItemVisible(Remote_View->firstChild());
821 824
822 } 825 }
823} 826}
824 827
825void OpieFtp::localListClicked(QListViewItem *selectedItem) 828void OpieFtp::localListClicked(QListViewItem *selectedItem)
826{ 829{
827 if(selectedItem!= NULL) { 830 if(selectedItem!= NULL) {
828 831
829 QString strItem=selectedItem->text(0); 832 QString strItem=selectedItem->text(0);
830 QString strSize=selectedItem->text(1); 833 QString strSize=selectedItem->text(1);
831 strSize=strSize.stripWhiteSpace(); 834 strSize=strSize.stripWhiteSpace();
832 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 835 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
833 // is symlink 836 // is symlink
834 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); 837 QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
835 if(QDir(strItem2).exists() ) { 838 if(QDir(strItem2).exists() ) {
836 currentDir.cd(strItem2, TRUE); 839 currentDir.cd(strItem2, TRUE);
837 populateLocalView(); 840 populateLocalView();
838 } 841 }
839 } else { // not a symlink 842 } else { // not a symlink
840 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 843 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
841 844
842 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 845 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
843 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 846 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
844 currentDir.cd(strItem,FALSE); 847 currentDir.cd(strItem,FALSE);
845 populateLocalView(); 848 populateLocalView();
846 } else { 849 } else {
847 currentDir.cdUp(); 850 currentDir.cdUp();
848 populateLocalView(); 851 populateLocalView();
849 } 852 }
850 if(QDir(strItem).exists()){ 853 if(QDir(strItem).exists()){
851 currentDir.cd(strItem, TRUE); 854 currentDir.cd(strItem, TRUE);
852 populateLocalView(); 855 populateLocalView();
853 } 856 }
854 } else { 857 } else {
855 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 858 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
856 if( QFile::exists(strItem ) ) { 859 if( QFile::exists(strItem ) ) {
857 // qDebug("upload "+strItem); 860 // qDebug("upload "+strItem);
858 return; 861 return;
859 } 862 }
860 } //end not symlink 863 } //end not symlink
861 chdir(strItem.latin1()); 864 chdir(strItem.latin1());
862 } 865 }
863 Local_View->ensureItemVisible(Local_View->firstChild()); 866 Local_View->ensureItemVisible(Local_View->firstChild());
864 } 867 }
865} 868}
866 869
867void OpieFtp::doLocalCd() 870void OpieFtp::doLocalCd()
868{ 871{
869 localListClicked( Local_View->currentItem()); 872 localListClicked( Local_View->currentItem());
870} 873}
871 874
872void OpieFtp:: doRemoteCd() 875void OpieFtp:: doRemoteCd()
873{ 876{
874 remoteListClicked( Remote_View->currentItem()); 877 remoteListClicked( Remote_View->currentItem());
875 878
876} 879}
877 880
878void OpieFtp::showHidden() 881void OpieFtp::showHidden()
879{ 882{
880 if (!b) { 883 if (!b) {
881 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 884 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
882 localMenu->setItemChecked(localMenu->idAt(0),TRUE); 885 localMenu->setItemChecked(localMenu->idAt(0),TRUE);
883// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 886// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
884 b=TRUE; 887 b=TRUE;
885 888
886 } else { 889 } else {
887 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 890 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
888 localMenu->setItemChecked(localMenu->idAt(0),FALSE); 891 localMenu->setItemChecked(localMenu->idAt(0),FALSE);
889// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 892// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
890 b=FALSE; 893 b=FALSE;
891 } 894 }
892 populateLocalView(); 895 populateLocalView();
893} 896}
894 897
895void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int) 898void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &, int)
896{ 899{
897// if(item) 900// if(item)
898 if (mouse == 2) { 901 if (mouse == 2) {
899 showLocalMenu(item); 902 showLocalMenu(item);
900 } 903 }
901} 904}
902 905
903void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int ) 906void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &, int )
904{ 907{
905 if(mouse == 2) { 908 if(mouse == 2) {
906 showRemoteMenu(item); 909 showRemoteMenu(item);
907 } 910 }
908} 911}
909 912
910void OpieFtp::showRemoteMenu(QListViewItem * item) 913void OpieFtp::showRemoteMenu(QListViewItem * item)
911{ 914{
912 QPopupMenu * m;// = new QPopupMenu( Local_View ); 915 QPopupMenu * m;// = new QPopupMenu( Local_View );
913 m = new QPopupMenu(this); 916 m = new QPopupMenu(this);
914 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) 917 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1)
915 m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); 918 m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() ));
916 else 919 else
917 m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 920 m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
918 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 921 m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
919 m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); 922 m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() ));
920 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 923 m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
921 m->insertSeparator(); 924 m->insertSeparator();
922 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 925 m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
923 m->exec( QCursor::pos() ); 926 m->exec( QCursor::pos() );
924 delete m; 927 delete m;
925} 928}
926 929
927void OpieFtp::showLocalMenu(QListViewItem * item) 930void OpieFtp::showLocalMenu(QListViewItem * item)
928{ 931{
929 932
930 QPopupMenu *m; 933 QPopupMenu *m;
931 m = new QPopupMenu( this); 934 m = new QPopupMenu( this);
932 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); 935 m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() ));
933 m->insertSeparator(); 936 m->insertSeparator();
934 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) 937 if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1)
935 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); 938 m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() ));
936 else 939 else
937 m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); 940 m->insertItem( tr( "Upload" ), this, SLOT( localUpload() ));
938 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); 941 m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() ));
939 m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); 942 m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() ));
940 m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); 943 m->insertItem( tr( "Rename" ), this, SLOT( localRename() ));
941 m->insertSeparator(); 944 m->insertSeparator();
942 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 945 m->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
943 m->setCheckable(TRUE); 946 m->setCheckable(TRUE);
944 if (b) 947 if (b)
945 m->setItemChecked(m->idAt(0),TRUE); 948 m->setItemChecked(m->idAt(0),TRUE);
946 else 949 else
947 m->setItemChecked(m->idAt(0),FALSE); 950 m->setItemChecked(m->idAt(0),FALSE);
948 951
949 m->exec( QCursor::pos() ); 952 m->exec( QCursor::pos() );
950 delete m; 953 delete m;
951} 954}
952 955
953void OpieFtp::localMakDir() 956void OpieFtp::localMakDir()
954{ 957{
955 InputDialog *fileDlg; 958 InputDialog *fileDlg;
956 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 959 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
957 fileDlg->exec(); 960 fileDlg->exec();
958 if( fileDlg->result() == 1 ) { 961 if( fileDlg->result() == 1 ) {
959 QString filename = fileDlg->LineEdit1->text(); 962 QString filename = fileDlg->LineEdit1->text();
960 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 963 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
961 } 964 }
962 populateLocalView(); 965 populateLocalView();
963} 966}
964 967
965void OpieFtp::localDelete() 968void OpieFtp::localDelete()
966{ 969{
967 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 970 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
968 QListViewItemIterator it( Local_View ); 971 QListViewItemIterator it( Local_View );
969 for ( ; it.current(); ++it ) { 972 for ( ; it.current(); ++it ) {
970 if ( it.current()->isSelected() ) { 973 if ( it.current()->isSelected() ) {
971 QString f = it.current()->text(0); 974 QString f = it.current()->text(0);
972 it.current()->setSelected(FALSE); 975 it.current()->setSelected(FALSE);
973 976
974// QString f = Local_View->currentItem()->text(0); 977// QString f = Local_View->currentItem()->text(0);
975 if(QDir(f).exists() ) { 978 if(QDir(f).exists() ) {
976 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ 979 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+
977 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { 980 tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) {
978 case 0: { 981 case 0: {
979 f=currentDir.canonicalPath()+"/"+f; 982 f=currentDir.canonicalPath()+"/"+f;
980 QString cmd="rmdir "+f; 983 QString cmd="rmdir "+f;
981 system( cmd.latin1()); 984 system( cmd.latin1());
982 } 985 }
983 break; 986 break;
984 case 1: 987 case 1:
985 // exit 988 // exit
986 break; 989 break;
987 }; 990 };
988 991
989 } else { 992 } else {
990 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f 993 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f
991 +" ?",tr("Yes"),tr("No"),0,0,1) ) { 994 +" ?",tr("Yes"),tr("No"),0,0,1) ) {
992 case 0: { 995 case 0: {
993 f=currentDir.canonicalPath()+"/"+f; 996 f=currentDir.canonicalPath()+"/"+f;
994 QString cmd="rm "+f; 997 QString cmd="rm "+f;
995 system( cmd.latin1()); 998 system( cmd.latin1());
996 } 999 }
997 break; 1000 break;
998 case 1: 1001 case 1:
999 // exit 1002 // exit
1000 break; 1003 break;
1001 }; 1004 };
1002 } 1005 }
1003 } 1006 }
1004 } 1007 }
1005 populateLocalView(); 1008 populateLocalView();
1006 1009
1007} 1010}
1008 1011
1009void OpieFtp::remoteMakDir() 1012void OpieFtp::remoteMakDir()