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