summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-05-16 16:29:14 (UTC)
committer llornkcor <llornkcor>2002-05-16 16:29:14 (UTC)
commit62c1424c5421e926173133ab4acd7346c590612e (patch) (unidiff)
treef9df1716b94df11330bb7cb466e26d2e3d1f8add
parentb94bd6003bf7c2024b0f254805f54ff4e52ead6e (diff)
downloadopie-62c1424c5421e926173133ab4acd7346c590612e.zip
opie-62c1424c5421e926173133ab4acd7346c590612e.tar.gz
opie-62c1424c5421e926173133ab4acd7346c590612e.tar.bz2
fixed not loading ftp configs correctly..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 7ca3fff..293c391 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -109,518 +109,521 @@ OpieFtp::OpieFtp( )
109 localMenu->insertSeparator(); 109 localMenu->insertSeparator();
110 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 110 localMenu->insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
111 localMenu->setCheckable(TRUE); 111 localMenu->setCheckable(TRUE);
112 112
113 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); 113 remoteMenu->insertItem( tr( "Download" ), this, SLOT( remoteDownload() ));
114 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); 114 remoteMenu->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() ));
115 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); 115 remoteMenu->insertItem( tr( "Rename" ), this, SLOT( remoteRename() ));
116 remoteMenu->insertSeparator(); 116 remoteMenu->insertSeparator();
117 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); 117 remoteMenu->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() ));
118 118
119 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); 119 tabMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() ));
120 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); 120 tabMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() ));
121 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() )); 121 tabMenu->insertItem( tr( "Switch to Config" ), this, SLOT( switchToConfigTab() ));
122 tabMenu->insertSeparator(); 122 tabMenu->insertSeparator();
123 tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); 123 tabMenu->insertItem( tr( "About" ), this, SLOT( doAbout() ));
124 tabMenu->setCheckable(TRUE); 124 tabMenu->setCheckable(TRUE);
125 125
126 126
127 127
128 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); 128 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
129 cdUpButton ->setFixedSize( QSize( 20, 20 ) ); 129 cdUpButton ->setFixedSize( QSize( 20, 20 ) );
130 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 130 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
131 cdUpButton ->setFlat(TRUE); 131 cdUpButton ->setFlat(TRUE);
132 layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 ); 132 layout->addMultiCellWidget( cdUpButton, 0, 0, 3, 3 );
133 cdUpButton->hide(); 133 cdUpButton->hide();
134 134
135// docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 135// docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
136// docButton->setFixedSize( QSize( 20, 20 ) ); 136// docButton->setFixedSize( QSize( 20, 20 ) );
137// connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 137// connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
138// docButton->setFlat(TRUE); 138// docButton->setFlat(TRUE);
139// layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); 139// layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
140 140
141 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); 141 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
142 homeButton->setFixedSize( QSize( 20, 20 ) ); 142 homeButton->setFixedSize( QSize( 20, 20 ) );
143 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 143 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
144 homeButton->setFlat(TRUE); 144 homeButton->setFlat(TRUE);
145 layout->addMultiCellWidget( homeButton, 0, 0, 4, 4); 145 layout->addMultiCellWidget( homeButton, 0, 0, 4, 4);
146 homeButton->hide(); 146 homeButton->hide();
147 147
148 TabWidget = new QTabWidget( this, "TabWidget" ); 148 TabWidget = new QTabWidget( this, "TabWidget" );
149 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 ); 149 layout->addMultiCellWidget( TabWidget, 1, 1, 0, 4 );
150 150
151// TabWidget->setTabShape(QTabWidget::Triangular); 151// TabWidget->setTabShape(QTabWidget::Triangular);
152 152
153 tab = new QWidget( TabWidget, "tab" ); 153 tab = new QWidget( TabWidget, "tab" );
154 tabLayout = new QGridLayout( tab ); 154 tabLayout = new QGridLayout( tab );
155 tabLayout->setSpacing( 2); 155 tabLayout->setSpacing( 2);
156 tabLayout->setMargin( 2); 156 tabLayout->setMargin( 2);
157 157
158 Local_View = new QListView( tab, "Local_View" ); 158 Local_View = new QListView( tab, "Local_View" );
159// Local_View->setResizePolicy( QListView::AutoOneFit ); 159// Local_View->setResizePolicy( QListView::AutoOneFit );
160 Local_View->addColumn( tr("File"),150); 160 Local_View->addColumn( tr("File"),150);
161 Local_View->addColumn( tr("Date"),-1); 161 Local_View->addColumn( tr("Date"),-1);
162 Local_View->setColumnAlignment(1,QListView::AlignRight); 162 Local_View->setColumnAlignment(1,QListView::AlignRight);
163 Local_View->addColumn( tr("Size"),-1); 163 Local_View->addColumn( tr("Size"),-1);
164 Local_View->setColumnAlignment(2,QListView::AlignRight); 164 Local_View->setColumnAlignment(2,QListView::AlignRight);
165 Local_View->setAllColumnsShowFocus(TRUE); 165 Local_View->setAllColumnsShowFocus(TRUE);
166 166
167 Local_View->setMultiSelection( TRUE); 167 Local_View->setMultiSelection( TRUE);
168 Local_View->setSelectionMode(QListView::Extended); 168 Local_View->setSelectionMode(QListView::Extended);
169 Local_View->setFocusPolicy(QWidget::ClickFocus); 169 Local_View->setFocusPolicy(QWidget::ClickFocus);
170 170
171 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); 171 QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold);
172 172
173 tabLayout->addWidget( Local_View, 0, 0 ); 173 tabLayout->addWidget( Local_View, 0, 0 );
174 174
175 connect( Local_View, SIGNAL( clicked( QListViewItem*)), 175 connect( Local_View, SIGNAL( clicked( QListViewItem*)),
176 this,SLOT( localListClicked(QListViewItem *)) ); 176 this,SLOT( localListClicked(QListViewItem *)) );
177// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)), 177// connect( Local_View, SIGNAL( doubleClicked( QListViewItem*)),
178// this,SLOT( localListClicked(QListViewItem *)) ); 178// this,SLOT( localListClicked(QListViewItem *)) );
179 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 179 connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
180 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 180 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
181 181
182 TabWidget->insertTab( tab, tr( "Local" ) ); 182 TabWidget->insertTab( tab, tr( "Local" ) );
183 183
184 tab_2 = new QWidget( TabWidget, "tab_2" ); 184 tab_2 = new QWidget( TabWidget, "tab_2" );
185 tabLayout_2 = new QGridLayout( tab_2 ); 185 tabLayout_2 = new QGridLayout( tab_2 );
186 tabLayout_2->setSpacing( 2); 186 tabLayout_2->setSpacing( 2);
187 tabLayout_2->setMargin( 2); 187 tabLayout_2->setMargin( 2);
188 188
189 Remote_View = new QListView( tab_2, "Remote_View" ); 189 Remote_View = new QListView( tab_2, "Remote_View" );
190 Remote_View->addColumn( tr("File"),150); 190 Remote_View->addColumn( tr("File"),150);
191 Remote_View->addColumn( tr("Date"),-1); 191 Remote_View->addColumn( tr("Date"),-1);
192 Remote_View->setColumnAlignment(1,QListView::AlignRight); 192 Remote_View->setColumnAlignment(1,QListView::AlignRight);
193 Remote_View->addColumn( tr("Size"),-1); 193 Remote_View->addColumn( tr("Size"),-1);
194 Remote_View->setColumnAlignment(2,QListView::AlignRight); 194 Remote_View->setColumnAlignment(2,QListView::AlignRight);
195 Remote_View->addColumn( tr("Dir"),-1); 195 Remote_View->addColumn( tr("Dir"),-1);
196 Remote_View->setColumnAlignment(4,QListView::AlignRight); 196 Remote_View->setColumnAlignment(4,QListView::AlignRight);
197 Remote_View->setAllColumnsShowFocus(TRUE); 197 Remote_View->setAllColumnsShowFocus(TRUE);
198 198
199 Remote_View->setMultiSelection( FALSE); 199 Remote_View->setMultiSelection( FALSE);
200 Remote_View->setSelectionMode(QListView::Extended); 200 Remote_View->setSelectionMode(QListView::Extended);
201 Remote_View->setFocusPolicy(QWidget::ClickFocus); 201 Remote_View->setFocusPolicy(QWidget::ClickFocus);
202 202
203 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 203 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
204 204
205 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 205 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
206 this,SLOT( remoteListClicked(QListViewItem *)) ); 206 this,SLOT( remoteListClicked(QListViewItem *)) );
207 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 207 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
208 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 208 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
209 209
210 tabLayout_2->addWidget( Remote_View, 0, 0 ); 210 tabLayout_2->addWidget( Remote_View, 0, 0 );
211 211
212 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 212 TabWidget->insertTab( tab_2, tr( "Remote" ) );
213 213
214 tab_3 = new QWidget( TabWidget, "tab_3" ); 214 tab_3 = new QWidget( TabWidget, "tab_3" );
215 tabLayout_3 = new QGridLayout( tab_3 ); 215 tabLayout_3 = new QGridLayout( tab_3 );
216 tabLayout_3->setSpacing( 2); 216 tabLayout_3->setSpacing( 2);
217 tabLayout_3->setMargin( 2); 217 tabLayout_3->setMargin( 2);
218 218
219 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 219 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
220 TextLabel1->setText( tr( "Username" ) ); 220 TextLabel1->setText( tr( "Username" ) );
221 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 221 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
222 222
223 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 223 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
224 UsernameComboBox->setEditable(TRUE); 224 UsernameComboBox->setEditable(TRUE);
225 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 225 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
226 226
227 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 227 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
228 TextLabel2->setText( tr( "Password" ) ); 228 TextLabel2->setText( tr( "Password" ) );
229 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 229 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
230 230
231 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 231 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
232 PasswordEdit->setEchoMode(QLineEdit::Password); 232 PasswordEdit->setEchoMode(QLineEdit::Password);
233 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 233 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
234 234
235 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 235 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
236 TextLabel3->setText( tr( "Remote server" ) ); 236 TextLabel3->setText( tr( "Remote server" ) );
237 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 237 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
238 238
239 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 239 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
240 ServerComboBox->setEditable(TRUE); 240 ServerComboBox->setEditable(TRUE);
241 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 241 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
242 242
243 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) )); 243 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
244 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) )); 244 connect(ServerComboBox,SIGNAL(textChanged(const QString &)),this,SLOT(serverComboEdited(const QString & ) ));
245 245
246 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 246 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
247 TextLabel5->setText( tr( "Remote path" ) ); 247 TextLabel5->setText( tr( "Remote path" ) );
248 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 248 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
249 249
250 250
251 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 251 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
252 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 252 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
253 253
254 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 254 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
255 TextLabel4->setText( tr( "Port" ) ); 255 TextLabel4->setText( tr( "Port" ) );
256 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 256 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
257 257
258 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 258 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
259 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 259 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
260 PortSpinBox->setMaxValue(32786); 260 PortSpinBox->setMaxValue(32786);
261 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 261 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
262 262
263 QPushButton *deleteServerBtn; 263 QPushButton *deleteServerBtn;
264 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" ); 264 deleteServerBtn = new QPushButton( "Delete Server", tab_3 , "OpenButton" );
265 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3); 265 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
266 266
267 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); 267 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
268 268
269 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); 269 connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" );
270 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1); 270 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
271 connectServerBtn->setToggleButton(TRUE); 271 connectServerBtn->setToggleButton(TRUE);
272 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); 272 connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) ));
273 273
274 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 274 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
275 tabLayout_3->addItem( spacer, 5, 0 ); 275 tabLayout_3->addItem( spacer, 5, 0 );
276 276
277 TabWidget->insertTab( tab_3, tr( "Config" ) ); 277 TabWidget->insertTab( tab_3, tr( "Config" ) );
278 278
279 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 279 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
280 this,SLOT(tabChanged(QWidget*))); 280 this,SLOT(tabChanged(QWidget*)));
281 281
282 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 282 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
283 currentDir.setPath( QDir::currentDirPath()); 283 currentDir.setPath( QDir::currentDirPath());
284// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 284// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
285 285
286 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); 286 currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" );
287 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4); 287 layout->addMultiCellWidget( currentPathCombo, 3, 3, 0, 4);
288 288
289 currentPathCombo->setEditable(TRUE); 289 currentPathCombo->setEditable(TRUE);
290 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 290 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
291 291
292 connect( currentPathCombo, SIGNAL( activated( const QString & ) ), 292 connect( currentPathCombo, SIGNAL( activated( const QString & ) ),
293 this, SLOT( currentPathComboActivated( const QString & ) ) ); 293 this, SLOT( currentPathComboActivated( const QString & ) ) );
294 294
295 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), 295 connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()),
296 this,SLOT(currentPathComboChanged())); 296 this,SLOT(currentPathComboChanged()));
297 297
298 ProgressBar = new QProgressBar( this, "ProgressBar" ); 298 ProgressBar = new QProgressBar( this, "ProgressBar" );
299 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); 299 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4);
300 300
301// fillCombos(); 301 fillCombos();
302 302
303 filterStr="*"; 303 filterStr="*";
304 b=FALSE; 304 b=FALSE;
305 populateLocalView(); 305 populateLocalView();
306 readConfig(); 306qDebug("read COnfig");
307 readConfig();
308 qDebug("Set current item");
307 ServerComboBox->setCurrentItem(currentServerConfig); 309 ServerComboBox->setCurrentItem(currentServerConfig);
308 310
309 TabWidget->setCurrentPage(2); 311 TabWidget->setCurrentPage(2);
310} 312}
311 313
312OpieFtp::~OpieFtp() 314OpieFtp::~OpieFtp()
313{ 315{
314} 316}
315 317
316void OpieFtp::cleanUp() 318void OpieFtp::cleanUp()
317{ 319{
318 if(conn) 320 if(conn)
319 FtpQuit(conn); 321 FtpQuit(conn);
320 QString sfile=QDir::homeDirPath(); 322 QString sfile=QDir::homeDirPath();
321 if(sfile.right(1) != "/") 323 if(sfile.right(1) != "/")
322 sfile+="/._temp"; 324 sfile+="/._temp";
323 else 325 else
324 sfile+="._temp"; 326 sfile+="._temp";
325 QFile file( sfile); 327 QFile file( sfile);
326 if(file.exists()) 328 if(file.exists())
327 file.remove(); 329 file.remove();
328 exit(0); 330 exit(0);
329} 331}
330 332
331void OpieFtp::tabChanged(QWidget *w) 333void OpieFtp::tabChanged(QWidget *w)
332{ 334{
333 if (TabWidget->currentPageIndex() == 0) { 335 if (TabWidget->currentPageIndex() == 0) {
334 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); 336 currentPathCombo->lineEdit()->setText( currentDir.canonicalPath());
335 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); 337 tabMenu->setItemChecked(tabMenu->idAt(0),TRUE);
336 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 338 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
337 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 339 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
338 if(cdUpButton->isHidden()) 340 if(cdUpButton->isHidden())
339 cdUpButton->show(); 341 cdUpButton->show();
340 if(homeButton->isHidden()) 342 if(homeButton->isHidden())
341 homeButton->show(); 343 homeButton->show();
342 344
343 } 345 }
344 if (TabWidget->currentPageIndex() == 1) { 346 if (TabWidget->currentPageIndex() == 1) {
345 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 347 currentPathCombo->lineEdit()->setText( currentRemoteDir );
346 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); 348 tabMenu->setItemChecked(tabMenu->idAt(1),TRUE);
347 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 349 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
348 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); 350 tabMenu->setItemChecked(tabMenu->idAt(2),FALSE);
349 if(cdUpButton->isHidden()) 351 if(cdUpButton->isHidden())
350 cdUpButton->show(); 352 cdUpButton->show();
351 homeButton->hide(); 353 homeButton->hide();
352 354
353 } 355 }
354 if (TabWidget->currentPageIndex() == 2) { 356 if (TabWidget->currentPageIndex() == 2) {
355 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); 357 tabMenu->setItemChecked(tabMenu->idAt(2),TRUE);
356 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); 358 tabMenu->setItemChecked(tabMenu->idAt(0),FALSE);
357 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); 359 tabMenu->setItemChecked(tabMenu->idAt(1),FALSE);
358 cdUpButton->hide(); 360 cdUpButton->hide();
359 homeButton->hide(); 361 homeButton->hide();
360 } 362 }
361} 363}
362 364
363void OpieFtp::newConnection() 365void OpieFtp::newConnection()
364{ 366{
365 UsernameComboBox->lineEdit()->setText(""); 367 UsernameComboBox->lineEdit()->setText("");
366 PasswordEdit->setText( "" ); 368 PasswordEdit->setText( "" );
367 ServerComboBox->lineEdit()->setText( ""); 369 ServerComboBox->lineEdit()->setText( "");
368 remotePath->setText( currentRemoteDir = "/"); 370 remotePath->setText( currentRemoteDir = "/");
369 PortSpinBox->setValue( 21); 371 PortSpinBox->setValue( 21);
370 TabWidget->setCurrentPage(2); 372 TabWidget->setCurrentPage(2);
371} 373}
372 374
373void OpieFtp::serverComboEdited(const QString & edit) 375void OpieFtp::serverComboEdited(const QString & edit)
374{ 376{
375 if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { 377 if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) {
376 qDebug("ServerComboEdited"); 378 qDebug("ServerComboEdited");
377 currentServerConfig = -1; 379 currentServerConfig = -1;
378 } 380 }
379} 381}
380 382
381void OpieFtp::connectorBtnToggled(bool On) 383void OpieFtp::connectorBtnToggled(bool On)
382{ 384{
383 if(On) { 385 if(On) {
384 connector(); 386 connector();
385 } else { 387 } else {
386 disConnector(); 388 disConnector();
387 } 389 }
388 390
389} 391}
390 392
391void OpieFtp::connector() 393void OpieFtp::connector()
392{ 394{
393// QCopEnvelope ( "QPE/System", "busy()" ); 395// QCopEnvelope ( "QPE/System", "busy()" );
394// qApp->processEvents(); 396// qApp->processEvents();
395 currentRemoteDir=remotePath->text(); 397 currentRemoteDir=remotePath->text();
396 if(ServerComboBox->currentText().isEmpty()) { 398 if(ServerComboBox->currentText().isEmpty()) {
397 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); 399 QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
398 TabWidget->setCurrentPage(2); 400 TabWidget->setCurrentPage(2);
399 ServerComboBox->setFocus(); 401 ServerComboBox->setFocus();
400 connectServerBtn->setOn(FALSE); 402 connectServerBtn->setOn(FALSE);
401 connectServerBtn->setText( tr("Connect")); 403 connectServerBtn->setText( tr("Connect"));
402 return; 404 return;
403 } 405 }
404 FtpInit(); 406 FtpInit();
405 TabWidget->setCurrentPage(1); 407 TabWidget->setCurrentPage(1);
406 QString ftp_host = ServerComboBox->currentText(); 408 QString ftp_host = ServerComboBox->currentText();
407 QString ftp_user = UsernameComboBox->currentText(); 409 QString ftp_user = UsernameComboBox->currentText();
408 QString ftp_pass = PasswordEdit->text(); 410 QString ftp_pass = PasswordEdit->text();
409 QString port=PortSpinBox->cleanText(); 411 QString port=PortSpinBox->cleanText();
410 port.stripWhiteSpace(); 412 port.stripWhiteSpace();
411 413
412 if(ftp_host.find("ftp://",0, TRUE) != -1 ) 414 if(ftp_host.find("ftp://",0, TRUE) != -1 )
413 ftp_host=ftp_host.right(ftp_host.length()-6); 415 ftp_host=ftp_host.right(ftp_host.length()-6);
414 ftp_host+=":"+port; 416 ftp_host+=":"+port;
415 if (!FtpConnect( ftp_host.latin1(), &conn)) { 417 if (!FtpConnect( ftp_host.latin1(), &conn)) {
416 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); 418 QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
417 connectServerBtn->setOn(FALSE); 419 connectServerBtn->setOn(FALSE);
418 connectServerBtn->setText( tr("Connect")); 420 connectServerBtn->setText( tr("Connect"));
419 return ; 421 return ;
420 } 422 }
421 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { 423 if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
422 QString msg; 424 QString msg;
423 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); 425 msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
424 msg.replace(QRegExp(":"),"\n"); 426 msg.replace(QRegExp(":"),"\n");
425 QMessageBox::message(tr("Note"),msg); 427 QMessageBox::message(tr("Note"),msg);
426 if(conn) 428 if(conn)
427 FtpQuit(conn); 429 FtpQuit(conn);
428 connectServerBtn->setOn(FALSE); 430 connectServerBtn->setOn(FALSE);
429 connectServerBtn->setText( tr("Connect")); 431 connectServerBtn->setText( tr("Connect"));
430 return ; 432 return ;
431 } 433 }
432 remoteDirList("/") ; 434 remoteDirList("/") ;
433 setCaption(ftp_host); 435 setCaption(ftp_host);
434 writeConfig(); 436 if( currentServerConfig == -1)
437 writeConfig();
435 connectServerBtn->setText( tr("Disconnect")); 438 connectServerBtn->setText( tr("Disconnect"));
436// QCopEnvelope ( "QPE/System", "notBusy()" ); 439// QCopEnvelope ( "QPE/System", "notBusy()" );
437} 440}
438 441
439void OpieFtp::disConnector() 442void OpieFtp::disConnector()
440{ 443{
441 if(conn) 444 if(conn)
442 FtpQuit(conn); 445 FtpQuit(conn);
443 setCaption("OpieFtp"); 446 setCaption("OpieFtp");
444 currentRemoteDir="/"; 447 currentRemoteDir="/";
445 Remote_View->clear(); 448 Remote_View->clear();
446 connectServerBtn->setText( tr("Connect")); 449 connectServerBtn->setText( tr("Connect"));
447 connectServerBtn->setOn(FALSE); 450 connectServerBtn->setOn(FALSE);
448 setCaption("OpieFtp"); 451 setCaption("OpieFtp");
449} 452}
450 453
451void OpieFtp::localUpload() 454void OpieFtp::localUpload()
452{ 455{
453 int fsz; 456 int fsz;
454// QCopEnvelope ( "QPE/System", "busy()" ); 457// QCopEnvelope ( "QPE/System", "busy()" );
455// qApp->processEvents(); 458// qApp->processEvents();
456 QList<QListViewItem> * getSelectedItems( QListView * Local_View ); 459 QList<QListViewItem> * getSelectedItems( QListView * Local_View );
457 QListViewItemIterator it( Local_View ); 460 QListViewItemIterator it( Local_View );
458 for ( ; it.current(); ++it ) { 461 for ( ; it.current(); ++it ) {
459 if ( it.current()->isSelected() ) { 462 if ( it.current()->isSelected() ) {
460 QString strItem = it.current()->text(0); 463 QString strItem = it.current()->text(0);
461 QString localFile = currentDir.canonicalPath()+"/"+strItem; 464 QString localFile = currentDir.canonicalPath()+"/"+strItem;
462 QString remoteFile= currentRemoteDir+strItem; 465 QString remoteFile= currentRemoteDir+strItem;
463 QFileInfo fi(localFile); 466 QFileInfo fi(localFile);
464 if( !fi.isDir()) { 467 if( !fi.isDir()) {
465 fsz=fi.size(); 468 fsz=fi.size();
466 ProgressBar->setTotalSteps(fsz); 469 ProgressBar->setTotalSteps(fsz);
467 470
468 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 471 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
469 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 472 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
470 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 473 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
471 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 474 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
472 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); 475 qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
473 476
474 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 477 if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
475 QString msg; 478 QString msg;
476 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); 479 msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
477 msg.replace(QRegExp(":"),"\n"); 480 msg.replace(QRegExp(":"),"\n");
478 QMessageBox::message(tr("Note"),msg); 481 QMessageBox::message(tr("Note"),msg);
479 } 482 }
480 } else { 483 } else {
481 QMessageBox::message(tr("Note"),tr("Cannot upload directories")); 484 QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
482 } 485 }
483 ProgressBar->reset(); 486 ProgressBar->reset();
484 nullifyCallBack(); 487 nullifyCallBack();
485 it.current()->setSelected(FALSE); 488 it.current()->setSelected(FALSE);
486 } //end currentSelected 489 } //end currentSelected
487 } 490 }
488 for ( ; it.current(); ++it ) { 491 for ( ; it.current(); ++it ) {
489 Local_View->clearSelection(); 492 Local_View->clearSelection();
490 } 493 }
491 Local_View->clearFocus(); 494 Local_View->clearFocus();
492 TabWidget->setCurrentPage(1); 495 TabWidget->setCurrentPage(1);
493 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 496 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
494// QCopEnvelope ( "QPE/System", "notBusy()" ); 497// QCopEnvelope ( "QPE/System", "notBusy()" );
495} 498}
496 499
497void OpieFtp::nullifyCallBack() 500void OpieFtp::nullifyCallBack()
498{ 501{
499 FtpOptions(FTPLIB_CALLBACK, NULL, conn); 502 FtpOptions(FTPLIB_CALLBACK, NULL, conn);
500 FtpOptions(FTPLIB_IDLETIME, NULL, conn); 503 FtpOptions(FTPLIB_IDLETIME, NULL, conn);
501 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); 504 FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
502 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); 505 FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
503} 506}
504 507
505void OpieFtp::remoteDownload() 508void OpieFtp::remoteDownload()
506{ 509{
507// qApp->processEvents(); 510// qApp->processEvents();
508 int fsz; 511 int fsz;
509// QCopEnvelope ( "QPE/System", "busy()" ); 512// QCopEnvelope ( "QPE/System", "busy()" );
510 513
511 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 514 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
512 QListViewItemIterator it( Remote_View ); 515 QListViewItemIterator it( Remote_View );
513 for ( ; it.current(); ++it ) { 516 for ( ; it.current(); ++it ) {
514 if ( it.current()->isSelected() ) { 517 if ( it.current()->isSelected() ) {
515 QString strItem = it.current()->text(0); 518 QString strItem = it.current()->text(0);
516// strItem=strItem.right(strItem.length()-1); 519// strItem=strItem.right(strItem.length()-1);
517 QString localFile = currentDir.canonicalPath(); 520 QString localFile = currentDir.canonicalPath();
518 if(localFile.right(1).find("/",0,TRUE) == -1) 521 if(localFile.right(1).find("/",0,TRUE) == -1)
519 localFile += "/"; 522 localFile += "/";
520 localFile += strItem; 523 localFile += strItem;
521// QString localFile = currentDir.canonicalPath()+"/"+strItem; 524// QString localFile = currentDir.canonicalPath()+"/"+strItem;
522 QString remoteFile= currentRemoteDir+strItem; 525 QString remoteFile= currentRemoteDir+strItem;
523 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) 526 if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
524 fsz = 0; 527 fsz = 0;
525 QString temp; 528 QString temp;
526 temp.sprintf( remoteFile+" "+" %dkb", fsz); 529 temp.sprintf( remoteFile+" "+" %dkb", fsz);
527 530
528 ProgressBar->setTotalSteps(fsz); 531 ProgressBar->setTotalSteps(fsz);
529 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); 532 FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
530 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); 533 FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
531 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); 534 FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
532 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); 535 FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
533 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); 536 qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
534 537
535 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { 538 if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
536 QString msg; 539 QString msg;
537 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); 540 msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
538 msg.replace(QRegExp(":"),"\n"); 541 msg.replace(QRegExp(":"),"\n");
539 QMessageBox::message(tr("Note"),msg); 542 QMessageBox::message(tr("Note"),msg);
540 } 543 }
541 ProgressBar->reset(); 544 ProgressBar->reset();
542 nullifyCallBack(); 545 nullifyCallBack();
543 it.current()->setSelected(FALSE); 546 it.current()->setSelected(FALSE);
544 } 547 }
545 } 548 }
546 for ( ; it.current(); ++it ) { 549 for ( ; it.current(); ++it ) {
547 Remote_View->clearSelection(); 550 Remote_View->clearSelection();
548 } 551 }
549 Remote_View->setFocus(); 552 Remote_View->setFocus();
550 TabWidget->setCurrentPage(0); 553 TabWidget->setCurrentPage(0);
551 populateLocalView(); 554 populateLocalView();
552// QCopEnvelope ( "QPE/System", "notBusy()" ); 555// QCopEnvelope ( "QPE/System", "notBusy()" );
553} 556}
554 557
555bool OpieFtp::remoteDirList(const QString &dir) 558bool OpieFtp::remoteDirList(const QString &dir)
556{ 559{
557 QString tmp = QDir::homeDirPath(); 560 QString tmp = QDir::homeDirPath();
558 if(tmp.right(1) != "/") 561 if(tmp.right(1) != "/")
559 tmp+="/._temp"; 562 tmp+="/._temp";
560 else 563 else
561 tmp+="._temp"; 564 tmp+="._temp";
562// qDebug("Listing remote dir "+tmp); 565// qDebug("Listing remote dir "+tmp);
563// QCopEnvelope ( "QPE/System", "busy()" ); 566// QCopEnvelope ( "QPE/System", "busy()" );
564 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { 567 if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
565 QString msg; 568 QString msg;
566 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); 569 msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
567 msg.replace(QRegExp(":"),"\n"); 570 msg.replace(QRegExp(":"),"\n");
568 QMessageBox::message(tr("Note"),msg); 571 QMessageBox::message(tr("Note"),msg);
569 return false; 572 return false;
570 } 573 }
571 populateRemoteView() ; 574 populateRemoteView() ;
572// QCopEnvelope ( "QPE/System", "notBusy()" ); 575// QCopEnvelope ( "QPE/System", "notBusy()" );
573 return true; 576 return true;
574} 577}
575 578
576bool OpieFtp::remoteChDir(const QString &dir) 579bool OpieFtp::remoteChDir(const QString &dir)
577{ 580{
578// QCopEnvelope ( "QPE/System", "busy()" ); 581// QCopEnvelope ( "QPE/System", "busy()" );
579 if (!FtpChdir( dir.latin1(), conn )) { 582 if (!FtpChdir( dir.latin1(), conn )) {
580 QString msg; 583 QString msg;
581 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); 584 msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
582 msg.replace(QRegExp(":"),"\n"); 585 msg.replace(QRegExp(":"),"\n");
583 QMessageBox::message(tr("Note"),msg); 586 QMessageBox::message(tr("Note"),msg);
584// qDebug(msg); 587// qDebug(msg);
585// QCopEnvelope ( "QPE/System", "notBusy()" ); 588// QCopEnvelope ( "QPE/System", "notBusy()" );
586 return FALSE; 589 return FALSE;
587 } 590 }
588// QCopEnvelope ( "QPE/System", "notBusy()" ); 591// QCopEnvelope ( "QPE/System", "notBusy()" );
589 return TRUE; 592 return TRUE;
590} 593}
591 594
592void OpieFtp::populateLocalView() 595void OpieFtp::populateLocalView()
593{ 596{
594 Local_View->clear(); 597 Local_View->clear();
595 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 598 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
596 currentDir.setMatchAllDirs(TRUE); 599 currentDir.setMatchAllDirs(TRUE);
597 currentDir.setNameFilter(filterStr); 600 currentDir.setNameFilter(filterStr);
598 QString fileL, fileS, fileDate; 601 QString fileL, fileS, fileDate;
599 bool isDir=FALSE; 602 bool isDir=FALSE;
600 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 603 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
601 QFileInfoListIterator it(*list); 604 QFileInfoListIterator it(*list);
602 QFileInfo *fi; 605 QFileInfo *fi;
603 while ( (fi=it.current()) ) { 606 while ( (fi=it.current()) ) {
604 if (fi->isSymLink() ){ 607 if (fi->isSymLink() ){
605 QString symLink=fi->readLink(); 608 QString symLink=fi->readLink();
606// qDebug("Symlink detected "+symLink); 609// qDebug("Symlink detected "+symLink);
607 QFileInfo sym( symLink); 610 QFileInfo sym( symLink);
608 fileS.sprintf( "%10li", sym.size() ); 611 fileS.sprintf( "%10li", sym.size() );
609 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); 612 fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() );
610 fileDate = sym.lastModified().toString(); 613 fileDate = sym.lastModified().toString();
611 } else { 614 } else {
612// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 615// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
613 fileS.sprintf( "%10li", fi->size() ); 616 fileS.sprintf( "%10li", fi->size() );
614 fileL.sprintf( "%s",fi->fileName().data() ); 617 fileL.sprintf( "%s",fi->fileName().data() );
615 fileDate= fi->lastModified().toString(); 618 fileDate= fi->lastModified().toString();
616 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 619 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
617 fileL+="/"; 620 fileL+="/";
618 isDir=TRUE; 621 isDir=TRUE;
619// qDebug( fileL); 622// qDebug( fileL);
620 } 623 }
621 } 624 }
622 if(fileL !="./" && fi->exists()) { 625 if(fileL !="./" && fi->exists()) {
623 item= new QListViewItem( Local_View,fileL, fileDate, fileS ); 626 item= new QListViewItem( Local_View,fileL, fileDate, fileS );
624 QPixmap pm; 627 QPixmap pm;
625 628
626 if(isDir || fileL.find("/",0,TRUE) != -1) { 629 if(isDir || fileL.find("/",0,TRUE) != -1) {
@@ -956,381 +959,390 @@ void OpieFtp::remoteMakDir()
956{ 959{
957 InputDialog *fileDlg; 960 InputDialog *fileDlg;
958 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); 961 fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
959 fileDlg->exec(); 962 fileDlg->exec();
960 if( fileDlg->result() == 1 ) { 963 if( fileDlg->result() == 1 ) {
961 QString filename = fileDlg->LineEdit1->text();//+".playlist"; 964 QString filename = fileDlg->LineEdit1->text();//+".playlist";
962 QString tmp=currentRemoteDir+filename; 965 QString tmp=currentRemoteDir+filename;
963// QCopEnvelope ( "QPE/System", "busy()" ); 966// QCopEnvelope ( "QPE/System", "busy()" );
964 if(FtpMkdir( tmp.latin1(), conn) == 0) { 967 if(FtpMkdir( tmp.latin1(), conn) == 0) {
965 QString msg; 968 QString msg;
966 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); 969 msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn));
967 msg.replace(QRegExp(":"),"\n"); 970 msg.replace(QRegExp(":"),"\n");
968 QMessageBox::message(tr("Note"),msg); 971 QMessageBox::message(tr("Note"),msg);
969 } 972 }
970// QCopEnvelope ( "QPE/System", "notBusy()" ); 973// QCopEnvelope ( "QPE/System", "notBusy()" );
971 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 974 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
972 } 975 }
973} 976}
974 977
975void OpieFtp::remoteDelete() 978void OpieFtp::remoteDelete()
976{ 979{
977 QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); 980 QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
978 QListViewItemIterator it( Remote_View ); 981 QListViewItemIterator it( Remote_View );
979 for ( ; it.current(); ++it ) { 982 for ( ; it.current(); ++it ) {
980 if ( it.current()->isSelected() ) { 983 if ( it.current()->isSelected() ) {
981 QString f = it.current()->text(0); 984 QString f = it.current()->text(0);
982// QString f = Remote_View->currentItem()->text(0); 985// QString f = Remote_View->currentItem()->text(0);
983// QCopEnvelope ( "QPE/System", "busy()" ); 986// QCopEnvelope ( "QPE/System", "busy()" );
984 if( f.right(1) =="/") { 987 if( f.right(1) =="/") {
985 QString path= currentRemoteDir+f; 988 QString path= currentRemoteDir+f;
986 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 989 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
987 ,tr("Yes"),tr("No"),0,0,1) ) { 990 ,tr("Yes"),tr("No"),0,0,1) ) {
988 case 0: { 991 case 0: {
989 f=currentDir.canonicalPath()+"/"+f; 992 f=currentDir.canonicalPath()+"/"+f;
990 if(FtpRmdir( path.latin1(), conn) ==0) { 993 if(FtpRmdir( path.latin1(), conn) ==0) {
991 QString msg; 994 QString msg;
992 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); 995 msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
993 msg.replace(QRegExp(":"),"\n"); 996 msg.replace(QRegExp(":"),"\n");
994 QMessageBox::message(tr("Note"),msg); 997 QMessageBox::message(tr("Note"),msg);
995 } 998 }
996 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 999 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
997 } 1000 }
998 break; 1001 break;
999 }; 1002 };
1000 } else { 1003 } else {
1001 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" 1004 switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
1002 ,tr("Yes"),tr("No"),0,0,1) ) { 1005 ,tr("Yes"),tr("No"),0,0,1) ) {
1003 case 0: { 1006 case 0: {
1004 QString path= currentRemoteDir+f; 1007 QString path= currentRemoteDir+f;
1005 if(FtpDelete( path.latin1(), conn)==0) { 1008 if(FtpDelete( path.latin1(), conn)==0) {
1006 QString msg; 1009 QString msg;
1007 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); 1010 msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
1008 msg.replace(QRegExp(":"),"\n"); 1011 msg.replace(QRegExp(":"),"\n");
1009 QMessageBox::message(tr("Note"),msg); 1012 QMessageBox::message(tr("Note"),msg);
1010 } 1013 }
1011 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1014 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1012 } 1015 }
1013 break; 1016 break;
1014 }; 1017 };
1015 } 1018 }
1016 } 1019 }
1017 } 1020 }
1018// QCopEnvelope ( "QPE/System", "notBusy()" ); 1021// QCopEnvelope ( "QPE/System", "notBusy()" );
1019} 1022}
1020 1023
1021void OpieFtp::remoteRename() 1024void OpieFtp::remoteRename()
1022{ 1025{
1023 QString curFile = Remote_View->currentItem()->text(0); 1026 QString curFile = Remote_View->currentItem()->text(0);
1024 InputDialog *fileDlg; 1027 InputDialog *fileDlg;
1025 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 1028 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
1026 fileDlg->setTextEdit((const QString &)curFile); 1029 fileDlg->setTextEdit((const QString &)curFile);
1027 fileDlg->exec(); 1030 fileDlg->exec();
1028 if( fileDlg->result() == 1 ) { 1031 if( fileDlg->result() == 1 ) {
1029 QString oldName = currentRemoteDir +"/"+ curFile; 1032 QString oldName = currentRemoteDir +"/"+ curFile;
1030 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; 1033 QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
1031// QCopEnvelope ( "QPE/System", "busy()" ); 1034// QCopEnvelope ( "QPE/System", "busy()" );
1032 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { 1035 if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
1033 QString msg; 1036 QString msg;
1034 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); 1037 msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
1035 msg.replace(QRegExp(":"),"\n"); 1038 msg.replace(QRegExp(":"),"\n");
1036 QMessageBox::message(tr("Note"),msg); 1039 QMessageBox::message(tr("Note"),msg);
1037 } 1040 }
1038// QCopEnvelope ( "QPE/System", "notBusy()" ); 1041// QCopEnvelope ( "QPE/System", "notBusy()" );
1039 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1042 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1040 } 1043 }
1041} 1044}
1042 1045
1043void OpieFtp::localRename() 1046void OpieFtp::localRename()
1044{ 1047{
1045 QString curFile = Local_View->currentItem()->text(0); 1048 QString curFile = Local_View->currentItem()->text(0);
1046 InputDialog *fileDlg; 1049 InputDialog *fileDlg;
1047 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); 1050 fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
1048 fileDlg->setTextEdit((const QString &)curFile); 1051 fileDlg->setTextEdit((const QString &)curFile);
1049 fileDlg->exec(); 1052 fileDlg->exec();
1050 if( fileDlg->result() == 1 ) { 1053 if( fileDlg->result() == 1 ) {
1051 QString oldname = currentDir.canonicalPath() + "/" + curFile; 1054 QString oldname = currentDir.canonicalPath() + "/" + curFile;
1052 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 1055 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
1053 if( rename(oldname.latin1(), newName.latin1())== -1) 1056 if( rename(oldname.latin1(), newName.latin1())== -1)
1054 QMessageBox::message(tr("Note"),tr("Could not rename")); 1057 QMessageBox::message(tr("Note"),tr("Could not rename"));
1055 } 1058 }
1056 populateLocalView(); 1059 populateLocalView();
1057} 1060}
1058 1061
1059void OpieFtp::currentPathComboActivated(const QString & currentPath) { 1062void OpieFtp::currentPathComboActivated(const QString & currentPath) {
1060 if (TabWidget->currentPageIndex() == 0) { 1063 if (TabWidget->currentPageIndex() == 0) {
1061 chdir( currentPath.latin1() ); 1064 chdir( currentPath.latin1() );
1062 currentDir.cd( currentPath, TRUE); 1065 currentDir.cd( currentPath, TRUE);
1063 populateLocalView(); 1066 populateLocalView();
1064 update(); 1067 update();
1065 } else { 1068 } else {
1066// chdir( currentPath.latin1() ); 1069// chdir( currentPath.latin1() );
1067// currentDir.cd( currentPath, TRUE); 1070// currentDir.cd( currentPath, TRUE);
1068// populateList(); 1071// populateList();
1069// update(); 1072// update();
1070 1073
1071 } 1074 }
1072} 1075}
1073 1076
1074void OpieFtp::fillCombo(const QString &currentPath) { 1077void OpieFtp::fillCombo(const QString &currentPath) {
1075 1078
1076 currentPathCombo->lineEdit()->setText(currentPath); 1079 currentPathCombo->lineEdit()->setText(currentPath);
1077 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1080 if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1078 currentPathCombo->clear(); 1081 currentPathCombo->clear();
1079 localDirPathStringList.prepend(currentPath ); 1082 localDirPathStringList.prepend(currentPath );
1080 currentPathCombo->insertStringList( localDirPathStringList,-1); 1083 currentPathCombo->insertStringList( localDirPathStringList,-1);
1081 } 1084 }
1082 currentPathCombo->lineEdit()->setText(currentPath); 1085 currentPathCombo->lineEdit()->setText(currentPath);
1083 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1086 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1084 currentPathCombo->clear(); 1087 currentPathCombo->clear();
1085 remoteDirPathStringList.prepend(currentPath ); 1088 remoteDirPathStringList.prepend(currentPath );
1086 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1089 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1087 } 1090 }
1088} 1091}
1089 1092
1090void OpieFtp::fillRemoteCombo(const QString &currentPath) { 1093void OpieFtp::fillRemoteCombo(const QString &currentPath) {
1091 1094
1092 currentPathCombo->lineEdit()->setText(currentPath); 1095 currentPathCombo->lineEdit()->setText(currentPath);
1093 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 1096 if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
1094 currentPathCombo->clear(); 1097 currentPathCombo->clear();
1095 remoteDirPathStringList.prepend(currentPath ); 1098 remoteDirPathStringList.prepend(currentPath );
1096 currentPathCombo->insertStringList( remoteDirPathStringList,-1); 1099 currentPathCombo->insertStringList( remoteDirPathStringList,-1);
1097 } 1100 }
1098} 1101}
1099 1102
1100void OpieFtp::currentPathComboChanged() 1103void OpieFtp::currentPathComboChanged()
1101{ 1104{
1102 QString oldRemoteCurrentDir = currentRemoteDir; 1105 QString oldRemoteCurrentDir = currentRemoteDir;
1103// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); 1106// qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir);
1104 if (TabWidget->currentPageIndex() == 0) { 1107 if (TabWidget->currentPageIndex() == 0) {
1105 if(QDir( currentPathCombo->lineEdit()->text()).exists()) { 1108 if(QDir( currentPathCombo->lineEdit()->text()).exists()) {
1106 currentDir.setPath( currentPathCombo->lineEdit()->text() ); 1109 currentDir.setPath( currentPathCombo->lineEdit()->text() );
1107 populateLocalView(); 1110 populateLocalView();
1108 } else { 1111 } else {
1109 QMessageBox::message(tr("Note"),tr("That directory does not exist")); 1112 QMessageBox::message(tr("Note"),tr("That directory does not exist"));
1110 } 1113 }
1111 } 1114 }
1112 if (TabWidget->currentPageIndex() == 1) { 1115 if (TabWidget->currentPageIndex() == 1) {
1113 currentRemoteDir = currentPathCombo->lineEdit()->text(); 1116 currentRemoteDir = currentPathCombo->lineEdit()->text();
1114 if(currentRemoteDir.right(1) !="/") { 1117 if(currentRemoteDir.right(1) !="/") {
1115 currentRemoteDir = currentRemoteDir +"/"; 1118 currentRemoteDir = currentRemoteDir +"/";
1116 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 1119 currentPathCombo->lineEdit()->setText( currentRemoteDir );
1117 } 1120 }
1118 if( !remoteChDir( (const QString &)currentRemoteDir) ) { 1121 if( !remoteChDir( (const QString &)currentRemoteDir) ) {
1119 currentRemoteDir = oldRemoteCurrentDir; 1122 currentRemoteDir = oldRemoteCurrentDir;
1120 currentPathCombo->lineEdit()->setText( currentRemoteDir ); 1123 currentPathCombo->lineEdit()->setText( currentRemoteDir );
1121 } 1124 }
1122 1125
1123 remoteDirList( (const QString &)currentRemoteDir); 1126 remoteDirList( (const QString &)currentRemoteDir);
1124 } 1127 }
1125} 1128}
1126 1129
1127void OpieFtp::switchToLocalTab() 1130void OpieFtp::switchToLocalTab()
1128{ 1131{
1129 TabWidget->setCurrentPage(0); 1132 TabWidget->setCurrentPage(0);
1130} 1133}
1131 1134
1132void OpieFtp::switchToRemoteTab() 1135void OpieFtp::switchToRemoteTab()
1133{ 1136{
1134 TabWidget->setCurrentPage(1); 1137 TabWidget->setCurrentPage(1);
1135} 1138}
1136 1139
1137void OpieFtp::switchToConfigTab() 1140void OpieFtp::switchToConfigTab()
1138{ 1141{
1139 TabWidget->setCurrentPage(2); 1142 TabWidget->setCurrentPage(2);
1140} 1143}
1141 1144
1142void OpieFtp::readConfig() 1145void OpieFtp::readConfig()
1143{ 1146{
1144 fillCombos(); 1147 fillCombos();
1145 Config cfg("opieftp"); 1148 Config cfg("opieftp");
1146 cfg.setGroup("Server"); 1149 cfg.setGroup("Server");
1147 currentServerConfig = cfg.readNumEntry("currentServer", -1); 1150 currentServerConfig = cfg.readNumEntry("currentServer", -1);
1151
1148// qDebug("Reading %d", currentServerConfig); 1152// qDebug("Reading %d", currentServerConfig);
1149 serverComboSelected( currentServerConfig); 1153 serverComboSelected( currentServerConfig);
1150} 1154}
1151 1155
1152void OpieFtp::writeConfig() 1156void OpieFtp::writeConfig()
1153{ 1157{
1154 Config cfg("opieftp"); 1158 Config cfg("opieftp");
1155 cfg.setGroup("Server"); 1159 cfg.setGroup("Server");
1156 QString username, remoteServerStr, remotePathStr, password, port, temp; 1160 QString username, remoteServerStr, remotePathStr, password, port, temp;
1157 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1161 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1158 if( currentServerConfig == -1) { 1162 if( currentServerConfig == -1) {
1159 for (int i = 1; i <= numberOfEntries; i++) { 1163 for (int i = 1; i <= numberOfEntries; i++) {
1160 temp.setNum(i); 1164 temp.setNum(i);
1161 cfg.setGroup("Server"); 1165 cfg.setGroup("Server");
1162 QString tempStr = cfg.readEntry( temp,""); 1166 QString tempStr = cfg.readEntry( temp,"");
1163 } 1167 }
1164 temp.setNum( numberOfEntries + 1); 1168 temp.setNum( numberOfEntries + 1);
1165 cfg.setGroup("Server"); 1169 cfg.setGroup("Server");
1166 remoteServerStr = cfg.readEntry( temp,""); 1170 remoteServerStr = cfg.readEntry( temp,"");
1167 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1171 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1168 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1172 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1169 1173
1170 temp.setNum(numberOfEntries+1); 1174 temp.setNum(numberOfEntries+1);
1171 cfg.setGroup("Server"); 1175 cfg.setGroup("Server");
1172 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); 1176 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
1177 cfg.writeEntry("currentServer", numberOfEntries+1);
1173 cfg.setGroup(temp); 1178 cfg.setGroup(temp);
1174 cfg.writeEntry("RemotePath", remotePath->text()); 1179 cfg.writeEntry("RemotePath", remotePath->text());
1175 cfg.writeEntry("Username", UsernameComboBox->currentText()); 1180 cfg.writeEntry("Username", UsernameComboBox->currentText());
1176 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); 1181 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
1177 cfg.setGroup("Server"); 1182 cfg.setGroup("Server");
1178 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); 1183 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
1184
1179 } 1185 }
1180} 1186}
1181 1187
1182void OpieFtp::fillCombos() 1188void OpieFtp::fillCombos()
1183{ 1189{
1184 Config cfg("opieftp"); 1190 Config cfg("opieftp");
1185 cfg.setGroup("Server"); 1191 cfg.setGroup("Server");
1186 QString username, remoteServerStr, remotePathStr, password, port, temp; 1192 QString username, remoteServerStr, remotePathStr, password, port, temp;
1187 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1193 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1188 for (int i = 1; i <= numberOfEntries; i++) { 1194 for (int i = 1; i <= numberOfEntries; i++) {
1189 temp.setNum(i); 1195 temp.setNum(i);
1196 qDebug(temp);
1190 cfg.setGroup("Server"); 1197 cfg.setGroup("Server");
1191 remoteServerStr = cfg.readEntry( temp,""); 1198 remoteServerStr = cfg.readEntry( temp,"");
1199 qDebug( remoteServerStr);
1192 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1200 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1193 port = remoteServerStr.right( divider - 1); 1201 port = remoteServerStr.right( divider - 1);
1194 bool ok; 1202 bool ok;
1195 PortSpinBox->setValue( port.toInt(&ok,10)); 1203 PortSpinBox->setValue( port.toInt(&ok,10));
1196 1204
1197 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); 1205 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1206 qDebug( remoteServerStr);
1198 ServerComboBox->insertItem( remoteServerStr ); 1207 ServerComboBox->insertItem( remoteServerStr );
1199// cfg.setGroup(temp); 1208// cfg.setGroup(temp);
1200 1209
1201// remotePathStr = cfg.readEntry(remoteServer,""); 1210// remotePathStr = cfg.readEntry(remoteServer,"");
1202// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); 1211// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
1203// port = remoteServer.right( divider+1); 1212// port = remoteServer.right( divider+1);
1204// PortSpinBox->setValue( port); 1213// PortSpinBox->setValue( port);
1205 1214
1206// remoteServer = remoteServer.left(divider - 1); 1215// remoteServer = remoteServer.left(divider - 1);
1207// remotePath->setText( remotePathStr); 1216// remotePath->setText( remotePathStr);
1208 1217
1209// username = cfg.readEntry(temp); 1218// username = cfg.readEntry(temp);
1210// UsernameComboBox->insertItem(username); 1219// UsernameComboBox->insertItem(username);
1211// password = cfg.readEntryCrypt(username,""); 1220// password = cfg.readEntryCrypt(username,"");
1212// PasswordEdit->setText(password); 1221// PasswordEdit->setText(password);
1213 } 1222 }
1214} 1223}
1215 1224
1216 1225
1217void OpieFtp::serverComboSelected(int index) 1226void OpieFtp::serverComboSelected(int index)
1218{ 1227{
1219 currentServerConfig = index; 1228 currentServerConfig = index;
1220 QString username, remoteServerStr, remotePathStr, password, port, temp; 1229 QString username, remoteServerStr, remotePathStr, password, port, temp;
1221// remoteServerStr = ServerComboBox->text(index); 1230// remoteServerStr = ServerComboBox->text(index);
1222 Config cfg("opieftp"); 1231 Config cfg("opieftp");
1223 cfg.setGroup("Server"); 1232 cfg.setGroup("Server");
1224 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1233 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1225 1234
1226 temp.setNum(index+1); 1235 temp.setNum(index);
1227 remoteServerStr = cfg.readEntry( temp,""); 1236 remoteServerStr = cfg.readEntry( temp,"");
1237 qDebug("Group" +temp);
1228 cfg.setGroup(temp); 1238 cfg.setGroup(temp);
1229// qDebug(temp); 1239// qDebug(temp);
1230 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); 1240 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1231 port = remoteServerStr.right( divider - 1); 1241 port = remoteServerStr.right( divider - 1);
1232 bool ok; 1242 bool ok;
1233 int portInt = port.toInt(&ok,10); 1243 int portInt = port.toInt(&ok,10);
1234 if( portInt == 0) portInt = 21; 1244 if( portInt == 0) portInt = 21;
1235 1245
1236 PortSpinBox->setValue( portInt); 1246 PortSpinBox->setValue( portInt);
1237 1247
1238 remotePath->setText(cfg.readEntry("RemotePath", "/")); 1248 remotePath->setText(cfg.readEntry("RemotePath", "/"));
1239 1249
1240 username = cfg.readEntry("Username", "anonymous"); 1250 username = cfg.readEntry("Username", "anonymous");
1241 UsernameComboBox->lineEdit()->setText(username); 1251 UsernameComboBox->lineEdit()->setText(username);
1242 1252 qDebug(username);
1243// qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); 1253// qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org"));
1244 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); 1254 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org"));
1245 1255// UsernameComboBox
1256// PasswordEdit
1257
1246 cfg.setGroup("Server"); 1258 cfg.setGroup("Server");
1247 temp.sprintf("%d",currentServerConfig); 1259 temp.sprintf("%d",currentServerConfig);
1248 cfg.writeEntry("currentServer", temp); 1260 cfg.writeEntry("currentServer", temp);
1249 update(); 1261 update();
1250} 1262}
1251// UsernameComboBox->lineEdit()->setText("root"); 1263// UsernameComboBox->lineEdit()->setText("root");
1252// PasswordEdit->setText( tr( "" ) ); 1264// PasswordEdit->setText( tr( "" ) );
1253// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 1265// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
1254// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); 1266// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
1255// PortSpinBox->setValue( 4242); 1267// PortSpinBox->setValue( 4242);
1256 1268
1257void OpieFtp::deleteServer() 1269void OpieFtp::deleteServer()
1258{ 1270{
1259 QString username, remoteServerStr, remotePathStr, password, port, temp; 1271 QString username, remoteServerStr, remotePathStr, password, port, temp;
1260 remoteServerStr = ServerComboBox->currentText( ); 1272 remoteServerStr = ServerComboBox->currentText( );
1261 username = UsernameComboBox->currentText(); 1273 username = UsernameComboBox->currentText();
1262 Config cfg("opieftp"); 1274 Config cfg("opieftp");
1263 cfg.setGroup("Server"); 1275 cfg.setGroup("Server");
1264 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 1276 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1265 for (int i = 0; i <= numberOfEntries; i++) { 1277 for (int i = 0; i <= numberOfEntries; i++) {
1266 temp.setNum(i+1); 1278 temp.setNum(i+1);
1267 cfg.setGroup("Server"); 1279 cfg.setGroup("Server");
1268 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 1280 if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1
1269 && cfg.readEntry(temp).find(username,0,TRUE) != -1 1281 && cfg.readEntry(temp).find(username,0,TRUE) != -1
1270 && !remoteServerStr.isEmpty()) { 1282 && !remoteServerStr.isEmpty()) {
1271 qDebug(temp); 1283 qDebug(temp);
1272 } 1284 }
1273 } 1285 }
1274} 1286}
1275 1287
1276void OpieFtp::upDir() 1288void OpieFtp::upDir()
1277{ 1289{
1278 if (TabWidget->currentPageIndex() == 0) { 1290 if (TabWidget->currentPageIndex() == 0) {
1279 QString current = currentDir.canonicalPath(); 1291 QString current = currentDir.canonicalPath();
1280 QDir dir(current); 1292 QDir dir(current);
1281 dir.cdUp(); 1293 dir.cdUp();
1282 current = dir.canonicalPath(); 1294 current = dir.canonicalPath();
1283 chdir( current.latin1() ); 1295 chdir( current.latin1() );
1284 currentDir.cd( current, TRUE); 1296 currentDir.cd( current, TRUE);
1285 populateLocalView(); 1297 populateLocalView();
1286 update(); 1298 update();
1287 } else { 1299 } else {
1288 if( FtpCDUp( conn) == 0) { 1300 if( FtpCDUp( conn) == 0) {
1289 QString msg; 1301 QString msg;
1290 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); 1302 msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn));
1291 msg.replace(QRegExp(":"),"\n"); 1303 msg.replace(QRegExp(":"),"\n");
1292 QMessageBox::message(tr("Note"),msg); 1304 QMessageBox::message(tr("Note"),msg);
1293// qDebug(msg); 1305// qDebug(msg);
1294 } 1306 }
1295 char path[256]; 1307 char path[256];
1296 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string 1308 if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string
1297 QString msg; 1309 QString msg;
1298 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); 1310 msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn));
1299 msg.replace(QRegExp(":"),"\n"); 1311 msg.replace(QRegExp(":"),"\n");
1300 QMessageBox::message(tr("Note"),msg); 1312 QMessageBox::message(tr("Note"),msg);
1301// qDebug(msg); 1313// qDebug(msg);
1302 } 1314 }
1303 currentRemoteDir=path; 1315 currentRemoteDir=path;
1304 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate 1316 remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
1305 if(currentRemoteDir.right(1) !="/") 1317 if(currentRemoteDir.right(1) !="/")
1306 currentRemoteDir +="/"; 1318 currentRemoteDir +="/";
1307 currentPathCombo->lineEdit()->setText( currentRemoteDir); 1319 currentPathCombo->lineEdit()->setText( currentRemoteDir);
1308 fillRemoteCombo( (const QString &)currentRemoteDir); 1320 fillRemoteCombo( (const QString &)currentRemoteDir);
1309 1321
1310 } 1322 }
1311} 1323}
1312 1324
1313void OpieFtp::docButtonPushed() { 1325void OpieFtp::docButtonPushed() {
1314 QString current = QPEApplication::documentDir(); 1326 QString current = QPEApplication::documentDir();
1315 chdir( current.latin1() ); 1327 chdir( current.latin1() );
1316 currentDir.cd( current, TRUE); 1328 currentDir.cd( current, TRUE);
1317 populateLocalView(); 1329 populateLocalView();
1318 update(); 1330 update();
1319 1331
1320} 1332}
1321 1333
1322void OpieFtp::homeButtonPushed() { 1334void OpieFtp::homeButtonPushed() {
1323 QString current = QDir::homeDirPath(); 1335 QString current = QDir::homeDirPath();
1324 chdir( current.latin1() ); 1336 chdir( current.latin1() );
1325 currentDir.cd( current, TRUE); 1337 currentDir.cd( current, TRUE);
1326 populateLocalView(); 1338 populateLocalView();
1327 update(); 1339 update();
1328} 1340}
1329 1341
1330void OpieFtp::doAbout() { 1342void OpieFtp::doAbout() {
1331 QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n" 1343 QMessageBox::message("OpieFtp","Opie ftp client is copyright 2002 by\n"
1332 "L.J.Potter<llornkcor@handhelds.org>\n" 1344 "L.J.Potter<llornkcor@handhelds.org>\n"
1333 "and uses ftplib copyright 1996-2000\n" 1345 "and uses ftplib copyright 1996-2000\n"
1334 "by Thomas Pfau, pfau@cnj.digex.net\n\n" 1346 "by Thomas Pfau, pfau@cnj.digex.net\n\n"
1335 "and is licensed by the GPL"); 1347 "and is licensed by the GPL");
1336} 1348}