summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-21 13:59:50 (UTC)
committer llornkcor <llornkcor>2002-03-21 13:59:50 (UTC)
commit60c9126183ea72c08ad5cb77b8939812627aae17 (patch) (unidiff)
tree60852886d3352fbca6a52bc5c0fb88e521d08145
parent9030459d54a67bd2e6201e0c1641c1f23d9af0ec (diff)
downloadopie-60c9126183ea72c08ad5cb77b8939812627aae17.zip
opie-60c9126183ea72c08ad5cb77b8939812627aae17.tar.gz
opie-60c9126183ea72c08ad5cb77b8939812627aae17.tar.bz2
added some combo stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp175
-rw-r--r--noncore/net/opieftp/opieftp.h7
2 files changed, 170 insertions, 12 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 82776d0..eed133e 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -6,24 +6,27 @@
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 DEVELOPER_VERSION
12 13
13#include "opieftp.h" 14#include "opieftp.h"
14#include "ftplib.h" 15#include "ftplib.h"
15#include "inputDialog.h" 16#include "inputDialog.h"
16 17
17#include <qpe/qpemenubar.h> 18#include <qpe/qpemenubar.h>
18#include <qpe/qpetoolbar.h> 19#include <qpe/qpetoolbar.h>
19#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
20#include <qpe/resource.h> 21#include <qpe/resource.h>
21#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/config.h>
22 24
23#include <qtextstream.h> 25#include <qtextstream.h>
26#include <qpushbutton.h>
24#include <qtoolbutton.h> 27#include <qtoolbutton.h>
25#include <qdatetime.h> 28#include <qdatetime.h>
26#include <qdir.h> 29#include <qdir.h>
27#include <qfile.h> 30#include <qfile.h>
28#include <qstring.h> 31#include <qstring.h>
29#include <qcombobox.h> 32#include <qcombobox.h>
@@ -168,58 +171,65 @@ OpieFtp::OpieFtp( )
168 TextLabel1 = new QLabel( tab_3, "TextLabel1" ); 171 TextLabel1 = new QLabel( tab_3, "TextLabel1" );
169 TextLabel1->setText( tr( "Username" ) ); 172 TextLabel1->setText( tr( "Username" ) );
170 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); 173 tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
171 174
172 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); 175 UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" );
173 UsernameComboBox->setEditable(TRUE); 176 UsernameComboBox->setEditable(TRUE);
174 UsernameComboBox->lineEdit()->setText("anonymous"); 177// UsernameComboBox->lineEdit()->setText("anonymous");
175// UsernameComboBox->lineEdit()->setText("root");
176// UsernameComboBox->lineEdit()->setText("llornkcor");
177 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); 178 tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 );
178 179
179 TextLabel2 = new QLabel( tab_3, "TextLabel2" ); 180 TextLabel2 = new QLabel( tab_3, "TextLabel2" );
180 TextLabel2->setText( tr( "Password" ) ); 181 TextLabel2->setText( tr( "Password" ) );
181 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 ); 182 tabLayout_3->addMultiCellWidget( TextLabel2, 0, 0, 2, 3 );
182 183
183 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" ); 184 PasswordEdit = new QLineEdit( "", tab_3, "PasswordComboBox" );
184 PasswordEdit->setEchoMode(QLineEdit::Password); 185 PasswordEdit->setEchoMode(QLineEdit::Password);
185 PasswordEdit->setText( tr( "me@opieftp.org" ) ); 186// PasswordEdit->setText( tr( "me@opieftp.org" ) );
186// PasswordEdit->setText( tr( "" ) );
187 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 ); 187 tabLayout_3->addMultiCellWidget( PasswordEdit, 1, 1, 2, 3 );
188 188
189 TextLabel3 = new QLabel( tab_3, "TextLabel3" ); 189 TextLabel3 = new QLabel( tab_3, "TextLabel3" );
190 TextLabel3->setText( tr( "Remote server" ) ); 190 TextLabel3->setText( tr( "Remote server" ) );
191 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 ); 191 tabLayout_3->addMultiCellWidget( TextLabel3, 2, 2, 0, 1 );
192 192
193 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" ); 193 ServerComboBox = new QComboBox( FALSE, tab_3, "ServerComboBox" );
194 ServerComboBox->setEditable(TRUE); 194 ServerComboBox->setEditable(TRUE);
195 ServerComboBox->lineEdit()->setText( tr( "" ) ); 195// ServerComboBox->lineEdit()->setText( tr( "" ) );
196 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 ); 196 tabLayout_3->addMultiCellWidget( ServerComboBox, 3, 3, 0, 1 );
197// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); 197
198// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 198 connect(ServerComboBox,SIGNAL(activated(int)),this,SLOT(serverComboSelected(int ) ));
199 199
200 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" ); 200 QLabel *TextLabel5 = new QLabel( tab_3, "TextLabel5" );
201 TextLabel5->setText( tr( "Remote path" ) ); 201 TextLabel5->setText( tr( "Remote path" ) );
202 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 ); 202 tabLayout_3->addMultiCellWidget( TextLabel5, 2, 2, 2, 3 );
203 203
204 remotePath = new QLineEdit( "/", tab_3, "remotePath" ); 204 remotePath = new QLineEdit( "/", tab_3, "remotePath" );
205 remotePath->setText( currentRemoteDir = "/"); 205 remotePath->setText( currentRemoteDir = "/");
206// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
207 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 ); 206 tabLayout_3->addMultiCellWidget( remotePath, 3, 3, 2, 3 );
208 207
209 TextLabel4 = new QLabel( tab_3, "TextLabel4" ); 208 TextLabel4 = new QLabel( tab_3, "TextLabel4" );
210 TextLabel4->setText( tr( "Port" ) ); 209 TextLabel4->setText( tr( "Port" ) );
211 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 ); 210 tabLayout_3->addMultiCellWidget( TextLabel4, 4, 4, 0, 1 );
212 211
213 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" ); 212 PortSpinBox = new QSpinBox( tab_3, "PortSpinBox" );
214 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows ); 213 PortSpinBox->setButtonSymbols( QSpinBox::UpDownArrows );
215 PortSpinBox->setMaxValue(32786); 214 PortSpinBox->setMaxValue(32786);
216// PortSpinBox->setValue( 4242);
217 PortSpinBox->setValue( 21); 215 PortSpinBox->setValue( 21);
218 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1); 216 tabLayout_3->addMultiCellWidget( PortSpinBox, 4, 4, 1, 1);
219 217
218 QPushButton *deleteServerBtn;
219 deleteServerBtn = new QPushButton( "Delete Server",this, "OpenButton" );
220 tabLayout_3->addMultiCellWidget( deleteServerBtn, 5, 5, 2, 3);
221
222 connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer()));
223
224 QPushButton *connectServerBtn;
225 connectServerBtn = new QPushButton( "Connect",this, "ConnectButton" );
226 tabLayout_3->addMultiCellWidget( connectServerBtn, 5, 5, 0, 1);
227 connect(connectServerBtn,SIGNAL( clicked()),SLOT( connector() ));
228
229
220 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 230 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
221 tabLayout_3->addItem( spacer, 5, 0 ); 231 tabLayout_3->addItem( spacer, 5, 0 );
222 232
223 TabWidget->insertTab( tab_3, tr( "Config" ) ); 233 TabWidget->insertTab( tab_3, tr( "Config" ) );
224 234
225 connect(TabWidget,SIGNAL(currentChanged(QWidget *)), 235 connect(TabWidget,SIGNAL(currentChanged(QWidget *)),
@@ -234,15 +244,28 @@ OpieFtp::OpieFtp( )
234 currentPathEdit->setText( currentDir.canonicalPath()); 244 currentPathEdit->setText( currentDir.canonicalPath());
235 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); 245 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
236 246
237 ProgressBar = new QProgressBar( this, "ProgressBar" ); 247 ProgressBar = new QProgressBar( this, "ProgressBar" );
238 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 248 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
239 249
250 serverComboSelected(0);
251#ifdef DEVELOPER_VERSION
252// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
253 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
254 UsernameComboBox->lineEdit()->setText("root");
255// UsernameComboBox->lineEdit()->setText("llornkcor");
256 PortSpinBox->setValue( 4242);
257 remotePath->setText( currentRemoteDir = "/");
258 PasswordEdit->setText( tr( "" ) );
259
260#endif
261 fillCombos();
240 filterStr="*"; 262 filterStr="*";
241 b=FALSE; 263 b=FALSE;
242 populateLocalView(); 264 populateLocalView();
265 TabWidget->setCurrentPage(2);
243} 266}
244 267
245OpieFtp::~OpieFtp() 268OpieFtp::~OpieFtp()
246{ 269{
247} 270}
248 271
@@ -366,13 +389,19 @@ void OpieFtp::remoteDownload()
366 QCopEnvelope ( "QPE/System", "notBusy()" ); 389 QCopEnvelope ( "QPE/System", "notBusy()" );
367} 390}
368 391
369 392
370void OpieFtp::newConnection() 393void OpieFtp::newConnection()
371{ 394{
372 TabWidget->setCurrentPage(2); 395 UsernameComboBox->lineEdit()->setText("");
396 PasswordEdit->setText( "" );
397 ServerComboBox->lineEdit()->setText( "");
398 remotePath->setText( currentRemoteDir = "/");
399 PortSpinBox->setValue( 21);
400 TabWidget->setCurrentPage(2);
401
373} 402}
374 403
375void OpieFtp::connector() 404void OpieFtp::connector()
376{ 405{
377 QCopEnvelope ( "QPE/System", "busy()" ); 406 QCopEnvelope ( "QPE/System", "busy()" );
378 qApp->processEvents(); 407 qApp->processEvents();
@@ -405,12 +434,13 @@ void OpieFtp::connector()
405 QMessageBox::message(tr("Note"),msg); 434 QMessageBox::message(tr("Note"),msg);
406 FtpQuit(conn); 435 FtpQuit(conn);
407 return ; 436 return ;
408 } 437 }
409 remoteDirList("/") ; 438 remoteDirList("/") ;
410 setCaption(ftp_host); 439 setCaption(ftp_host);
440 writeConfig();
411 QCopEnvelope ( "QPE/System", "notBusy()" ); 441 QCopEnvelope ( "QPE/System", "notBusy()" );
412} 442}
413 443
414void OpieFtp::disConnector() 444void OpieFtp::disConnector()
415{ 445{
416 FtpQuit(conn); 446 FtpQuit(conn);
@@ -914,6 +944,129 @@ void OpieFtp::switchToRemoteTab()
914} 944}
915 945
916void OpieFtp::switchToConfigTab() 946void OpieFtp::switchToConfigTab()
917{ 947{
918 TabWidget->setCurrentPage(2); 948 TabWidget->setCurrentPage(2);
919} 949}
950
951void OpieFtp::readConfig() {
952
953 Config cfg("opieftp");
954 cfg.setGroup("Server");
955 QString username, remoteServer, remotePathStr, password, port, temp;
956 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
957 for (int i = 0; i <= numberOfEntries; i++) {
958 temp.setNum(i+1);
959 cfg.setGroup("Server");
960 remoteServer = cfg.readEntry( temp,"");
961 ServerComboBox->insertItem( remoteServer );
962 cfg.setGroup(temp);
963
964 remotePathStr = cfg.readEntry(remoteServer,"");
965 int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
966 port = remoteServer.right( divider+1);
967 bool ok;
968 PortSpinBox->setValue( port.toInt(&ok,10));
969
970 remoteServer = remoteServer.left(divider - 1);
971 remotePath->setText( remotePathStr);
972 username = cfg.readEntry(temp);
973 UsernameComboBox->insertItem(username);
974 password = cfg.readEntryCrypt(username,"");
975 PasswordEdit->setText(password);
976
977 }
978
979}
980
981void OpieFtp::writeConfig() {
982
983 Config cfg("opieftp");
984 cfg.setGroup("Server");
985 QString temp;
986 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
987 temp.setNum(numberOfEntries+1);
988 cfg.setGroup("Server");
989 cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() );
990 cfg.setGroup(temp);
991 cfg.writeEntry("RemotePath", remotePath->text());
992 cfg.writeEntry("Username", UsernameComboBox->currentText());
993 cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text());
994 cfg.setGroup("Server");
995 cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 ));
996
997}
998
999void OpieFtp::fillCombos() {
1000 Config cfg("opieftp");
1001 cfg.setGroup("Server");
1002 QString username, remoteServerStr, remotePathStr, password, port, temp;
1003 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1004 for (int i = 1; i <= numberOfEntries; i++) {
1005 temp.setNum(i);
1006 cfg.setGroup("Server");
1007 remoteServerStr = cfg.readEntry( temp,"");
1008 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1009 port = remoteServerStr.right( divider - 1);
1010 bool ok;
1011 PortSpinBox->setValue( port.toInt(&ok,10));
1012
1013 remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider);
1014 ServerComboBox->insertItem( remoteServerStr );
1015// cfg.setGroup(temp);
1016
1017// remotePathStr = cfg.readEntry(remoteServer,"");
1018// int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
1019// port = remoteServer.right( divider+1);
1020// PortSpinBox->setValue( port);
1021
1022// remoteServer = remoteServer.left(divider - 1);
1023// remotePath->setText( remotePathStr);
1024
1025// username = cfg.readEntry(temp);
1026// UsernameComboBox->insertItem(username);
1027// password = cfg.readEntryCrypt(username,"");
1028// PasswordEdit->setText(password);
1029
1030 }
1031
1032}
1033
1034
1035void OpieFtp::serverComboSelected(int index) {
1036
1037 QString username, remoteServerStr, remotePathStr, password, port, temp;
1038// remoteServerStr = ServerComboBox->text(index);
1039 Config cfg("opieftp");
1040 cfg.setGroup("Server");
1041 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1042
1043// for (int i = 0; i <= numberOfEntries; i++) {
1044 temp.setNum(index+1);
1045 remoteServerStr = cfg.readEntry( temp,"");
1046 // if( remoteServerStr.find( ServerComboBox->text(index),0,TRUE) != -1 ) {
1047 cfg.setGroup(temp);
1048 qDebug(temp);
1049 int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE);
1050 port = remoteServerStr.right( divider - 1);
1051 bool ok;
1052 PortSpinBox->setValue( port.toInt(&ok,10));
1053
1054 remotePath->setText(cfg.readEntry("RemotePath", ""));
1055 username = cfg.readEntry("Username", "");
1056 UsernameComboBox->lineEdit()->setText(username);
1057 PasswordEdit->setText(cfg.readEntryCrypt(username, ""));
1058
1059// }
1060
1061 // }
1062 update();
1063}
1064// UsernameComboBox->lineEdit()->setText("root");
1065// PasswordEdit->setText( tr( "" ) );
1066// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
1067// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
1068// PortSpinBox->setValue( 4242);
1069
1070void OpieFtp::deleteServer() {
1071
1072}
diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h
index 1e5fffa..c88a15b 100644
--- a/noncore/net/opieftp/opieftp.h
+++ b/noncore/net/opieftp/opieftp.h
@@ -70,13 +70,14 @@ protected slots:
70 void newConnection(); 70 void newConnection();
71 void connector(); 71 void connector();
72 void disConnector(); 72 void disConnector();
73 void populateLocalView(); 73 void populateLocalView();
74 bool populateRemoteView(); 74 bool populateRemoteView();
75 void showHidden(); 75 void showHidden();
76 76 void writeConfig();
77 void readConfig();
77 void localListClicked(QListViewItem *); 78 void localListClicked(QListViewItem *);
78 void remoteListClicked(QListViewItem *); 79 void remoteListClicked(QListViewItem *);
79 void ListPressed( int, QListViewItem *, const QPoint&, int); 80 void ListPressed( int, QListViewItem *, const QPoint&, int);
80 void RemoteListPressed( int, QListViewItem *, const QPoint&, int); 81 void RemoteListPressed( int, QListViewItem *, const QPoint&, int);
81 void localMakDir(); 82 void localMakDir();
82 void localDelete(); 83 void localDelete();
@@ -89,12 +90,16 @@ protected slots:
89 void remoteRename(); 90 void remoteRename();
90 void localRename(); 91 void localRename();
91 void currentPathEditChanged(); 92 void currentPathEditChanged();
92 void switchToLocalTab(); 93 void switchToLocalTab();
93 void switchToRemoteTab(); 94 void switchToRemoteTab();
94 void switchToConfigTab(); 95 void switchToConfigTab();
96 void fillCombos();
97 void serverComboSelected(int);
98 void deleteServer();
99
95protected: 100protected:
96 void nullifyCallBack(); 101 void nullifyCallBack();
97 QGridLayout* tabLayout; 102 QGridLayout* tabLayout;
98 QGridLayout* tabLayout_2; 103 QGridLayout* tabLayout_2;
99 QGridLayout* tabLayout_3; 104 QGridLayout* tabLayout_3;
100 105