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