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