-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 175 | ||||
-rw-r--r-- | noncore/net/opieftp/opieftp.h | 7 |
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 | |||
@@ -9,6 +9,7 @@ | |||
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" |
@@ -19,8 +20,10 @@ | |||
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> |
@@ -171,9 +174,7 @@ OpieFtp::OpieFtp( ) | |||
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" ); |
@@ -182,8 +183,7 @@ OpieFtp::OpieFtp( ) | |||
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" ); |
@@ -192,10 +192,10 @@ OpieFtp::OpieFtp( ) | |||
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" ) ); |
@@ -203,7 +203,6 @@ OpieFtp::OpieFtp( ) | |||
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" ); |
@@ -213,10 +212,21 @@ OpieFtp::OpieFtp( ) | |||
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 | ||
@@ -237,9 +247,22 @@ OpieFtp::OpieFtp( ) | |||
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 | ||
245 | OpieFtp::~OpieFtp() | 268 | OpieFtp::~OpieFtp() |
@@ -369,7 +392,13 @@ void OpieFtp::remoteDownload() | |||
369 | 392 | ||
370 | void OpieFtp::newConnection() | 393 | void 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 | ||
375 | void OpieFtp::connector() | 404 | void OpieFtp::connector() |
@@ -408,6 +437,7 @@ void OpieFtp::connector() | |||
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 | ||
@@ -917,3 +947,126 @@ void OpieFtp::switchToConfigTab() | |||
917 | { | 947 | { |
918 | TabWidget->setCurrentPage(2); | 948 | TabWidget->setCurrentPage(2); |
919 | } | 949 | } |
950 | |||
951 | void 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 | |||
981 | void 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 | |||
999 | void 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 | |||
1035 | void 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 | |||
1070 | void 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 | |||
@@ -73,7 +73,8 @@ protected slots: | |||
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); |
@@ -92,6 +93,10 @@ protected slots: | |||
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 | |||
95 | protected: | 100 | protected: |
96 | void nullifyCallBack(); | 101 | void nullifyCallBack(); |
97 | QGridLayout* tabLayout; | 102 | QGridLayout* tabLayout; |