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