summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-24 17:03:37 (UTC)
committer llornkcor <llornkcor>2002-03-24 17:03:37 (UTC)
commit6ce8bbff9eb16e0d731755010bda63e7fb43f70b (patch) (unidiff)
tree0f3cf5476398743f86fa6d884d86751a7251df3e
parent368d5032f4ff4566dea1e99aa2bb782300e0bfd5 (diff)
downloadopie-6ce8bbff9eb16e0d731755010bda63e7fb43f70b.zip
opie-6ce8bbff9eb16e0d731755010bda63e7fb43f70b.tar.gz
opie-6ce8bbff9eb16e0d731755010bda63e7fb43f70b.tar.bz2
config last server on startup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp46
1 files changed, 17 insertions, 29 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index e2a6cad..e97a9bf 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -142,24 +142,26 @@ OpieFtp::OpieFtp( )
142 142
143 tab_2 = new QWidget( TabWidget, "tab_2" ); 143 tab_2 = new QWidget( TabWidget, "tab_2" );
144 tabLayout_2 = new QGridLayout( tab_2 ); 144 tabLayout_2 = new QGridLayout( tab_2 );
145 tabLayout_2->setSpacing( 2); 145 tabLayout_2->setSpacing( 2);
146 tabLayout_2->setMargin( 2); 146 tabLayout_2->setMargin( 2);
147 147
148 Remote_View = new QListView( tab_2, "Remote_View" ); 148 Remote_View = new QListView( tab_2, "Remote_View" );
149 Remote_View->addColumn( tr("File"),120); 149 Remote_View->addColumn( tr("File"),120);
150 Remote_View->addColumn( tr("Size"),-1); 150 Remote_View->addColumn( tr("Size"),-1);
151 Remote_View->setColumnAlignment(1,QListView::AlignRight); 151 Remote_View->setColumnAlignment(1,QListView::AlignRight);
152 Remote_View->addColumn( tr("Date"),-1); 152 Remote_View->addColumn( tr("Date"),-1);
153 Remote_View->setColumnAlignment(2,QListView::AlignRight); 153 Remote_View->setColumnAlignment(2,QListView::AlignRight);
154 Remote_View->addColumn( tr("Dir"),-1);
155 Remote_View->setColumnAlignment(4,QListView::AlignRight);
154 Remote_View->setAllColumnsShowFocus(TRUE); 156 Remote_View->setAllColumnsShowFocus(TRUE);
155 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); 157 QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold);
156 158
157 connect( Remote_View, SIGNAL( clicked( QListViewItem*)), 159 connect( Remote_View, SIGNAL( clicked( QListViewItem*)),
158 this,SLOT( remoteListClicked(QListViewItem *)) ); 160 this,SLOT( remoteListClicked(QListViewItem *)) );
159 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 161 connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
160 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); 162 this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) );
161 163
162 tabLayout_2->addWidget( Remote_View, 0, 0 ); 164 tabLayout_2->addWidget( Remote_View, 0, 0 );
163 165
164 TabWidget->insertTab( tab_2, tr( "Remote" ) ); 166 TabWidget->insertTab( tab_2, tr( "Remote" ) );
165 167
@@ -234,41 +236,42 @@ OpieFtp::OpieFtp( )
234 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); 236 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
235 currentDir.setPath( QDir::currentDirPath()); 237 currentDir.setPath( QDir::currentDirPath());
236// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 238// currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
237 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); 239 currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" );
238 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); 240 layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 );
239 241
240 currentPathEdit->setText( currentDir.canonicalPath()); 242 currentPathEdit->setText( currentDir.canonicalPath());
241 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); 243 connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged()));
242 244
243 ProgressBar = new QProgressBar( this, "ProgressBar" ); 245 ProgressBar = new QProgressBar( this, "ProgressBar" );
244 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); 246 layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 );
245 247
246 serverComboSelected(0); 248// fillCombos();
247 fillCombos();
248 249
249#ifdef DEVELOPERS_VERSION 250#ifdef DEVELOPERS_VERSION
250 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 251 ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
251 UsernameComboBox->lineEdit()->setText("root"); 252 UsernameComboBox->lineEdit()->setText("root");
252 PortSpinBox->setValue( 4242); 253 PortSpinBox->setValue( 4242);
253 remotePath->setText( currentRemoteDir = "/"); 254 remotePath->setText( currentRemoteDir = "/");
254// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); 255// ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) );
255// UsernameComboBox->lineEdit()->setText("llornkcor"); 256// UsernameComboBox->lineEdit()->setText("llornkcor");
256// PortSpinBox->setValue( 21); 257// PortSpinBox->setValue( 21);
257// remotePath->setText( currentRemoteDir = "/home/llornkcor"); 258// remotePath->setText( currentRemoteDir = "/home/llornkcor");
258 PasswordEdit->setText( tr( "" ) ); 259 PasswordEdit->setText( tr( "" ) );
259#endif 260#endif
260 filterStr="*"; 261 filterStr="*";
261 b=FALSE; 262 b=FALSE;
262 populateLocalView(); 263 populateLocalView();
264 readConfig();
265 ServerComboBox->setCurrentItem(currentServerConfig);
263 TabWidget->setCurrentPage(2); 266 TabWidget->setCurrentPage(2);
264} 267}
265 268
266OpieFtp::~OpieFtp() 269OpieFtp::~OpieFtp()
267{ 270{
268} 271}
269 272
270void OpieFtp::cleanUp() 273void OpieFtp::cleanUp()
271{ 274{
272 if(conn) 275 if(conn)
273 FtpQuit(conn); 276 FtpQuit(conn);
274 QString sfile=QDir::homeDirPath(); 277 QString sfile=QDir::homeDirPath();
@@ -572,47 +575,48 @@ bool OpieFtp::populateRemoteView( )
572 while ( !t.eof()) { 575 while ( !t.eof()) {
573 s = t.readLine(); 576 s = t.readLine();
574 fileL = s.right(s.length()-55); 577 fileL = s.right(s.length()-55);
575 fileL = fileL.stripWhiteSpace(); 578 fileL = fileL.stripWhiteSpace();
576 if(s.left(1) == "d") 579 if(s.left(1) == "d")
577 fileL = fileL+"/"; 580 fileL = fileL+"/";
578// fileL = "/"+fileL+"/"; 581// fileL = "/"+fileL+"/";
579 fileS = s.mid( 30, 42-30); 582 fileS = s.mid( 30, 42-30);
580 fileS = fileS.stripWhiteSpace(); 583 fileS = fileS.stripWhiteSpace();
581 fileDate = s.mid( 42, 55-42); 584 fileDate = s.mid( 42, 55-42);
582 fileDate = fileDate.stripWhiteSpace(); 585 fileDate = fileDate.stripWhiteSpace();
583 if(fileL.find("total",0,TRUE) == -1) { 586 if(fileL.find("total",0,TRUE) == -1) {
584 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate);
585 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { 587 if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) {
588 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d");
586 item->setPixmap( 0, Resource::loadPixmap( "folder" )); 589 item->setPixmap( 0, Resource::loadPixmap( "folder" ));
587 if(itemDir) 590// if(itemDir)
588 item->moveItem(itemDir); 591 item->moveItem(itemDir);
589 itemDir=item; 592 itemDir=item;
590 } else { 593 } else {
594 QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f");
591 item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); 595 item->setPixmap( 0, Resource::loadPixmap( "fileopen" ));
592 if(itemFile) 596// if(itemFile)
597 item->moveItem(itemDir);
593 item->moveItem(itemFile); 598 item->moveItem(itemFile);
594 itemFile=item; 599 itemFile=item;
595 } 600 }
596 } 601 }
597 } 602 }
598 QListViewItem * item1 = new QListViewItem( Remote_View, "../"); 603 QListViewItem * item1 = new QListViewItem( Remote_View, "../");
599 item1->setPixmap( 0, Resource::loadPixmap( "folder" )); 604 item1->setPixmap( 0, Resource::loadPixmap( "folder" ));
600 file.close(); 605 file.close();
601 if( file.exists()) 606 if( file.exists())
602 file. remove(); 607 file. remove();
603 } else 608 } else
604 qDebug("temp file not opened successfullly "+sfile); 609 qDebug("temp file not opened successfullly "+sfile);
605 Remote_View->setSorting( 4,TRUE); 610 Remote_View->setSorting( 4,TRUE);
606
607 return true; 611 return true;
608} 612}
609 613
610void OpieFtp::remoteListClicked(QListViewItem *selectedItem) 614void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
611{ 615{
612 QCopEnvelope ( "QPE/System", "busy()" ); 616 QCopEnvelope ( "QPE/System", "busy()" );
613 QString oldRemoteCurrentDir = currentRemoteDir; 617 QString oldRemoteCurrentDir = currentRemoteDir;
614 QString strItem=selectedItem->text(0); 618 QString strItem=selectedItem->text(0);
615 strItem=strItem.simplifyWhiteSpace(); 619 strItem=strItem.simplifyWhiteSpace();
616 if(strItem == "../") { // the user wants to go ^ 620 if(strItem == "../") { // the user wants to go ^
617 if( FtpCDUp( conn) == 0) { 621 if( FtpCDUp( conn) == 0) {
618 QString msg; 622 QString msg;
@@ -963,49 +967,29 @@ void OpieFtp::switchToLocalTab()
963void OpieFtp::switchToRemoteTab() 967void OpieFtp::switchToRemoteTab()
964{ 968{
965 TabWidget->setCurrentPage(1); 969 TabWidget->setCurrentPage(1);
966} 970}
967 971
968void OpieFtp::switchToConfigTab() 972void OpieFtp::switchToConfigTab()
969{ 973{
970 TabWidget->setCurrentPage(2); 974 TabWidget->setCurrentPage(2);
971} 975}
972 976
973void OpieFtp::readConfig() 977void OpieFtp::readConfig()
974{ 978{
975 979 fillCombos();
976 Config cfg("opieftp"); 980 Config cfg("opieftp");
977 cfg.setGroup("Server"); 981 cfg.setGroup("Server");
978 QString username, remoteServer, remotePathStr, password, port, temp; 982 currentServerConfig = cfg.readNumEntry("currentServer", -1);
979 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 983 serverComboSelected( currentServerConfig);
980 for (int i = 0; i <= numberOfEntries; i++) {
981 temp.setNum(i+1);
982 cfg.setGroup("Server");
983 remoteServer = cfg.readEntry( temp,"");
984 ServerComboBox->insertItem( remoteServer );
985 cfg.setGroup(temp);
986
987 remotePathStr = cfg.readEntry(remoteServer,"");
988 int divider = remoteServer.length() - remoteServer.find(":",0,TRUE);
989 port = remoteServer.right( divider+1);
990 bool ok;
991 PortSpinBox->setValue( port.toInt(&ok,10));
992
993 remoteServer = remoteServer.left(divider - 1);
994 remotePath->setText( remotePathStr);
995 username = cfg.readEntry(temp);
996 UsernameComboBox->insertItem(username);
997 password = cfg.readEntryCrypt(username,"");
998 PasswordEdit->setText(password);
999 }
1000} 984}
1001 985
1002void OpieFtp::writeConfig() 986void OpieFtp::writeConfig()
1003{ 987{
1004 988
1005 Config cfg("opieftp"); 989 Config cfg("opieftp");
1006 cfg.setGroup("Server"); 990 cfg.setGroup("Server");
1007 QString username, remoteServerStr, remotePathStr, password, port, temp; 991 QString username, remoteServerStr, remotePathStr, password, port, temp;
1008 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); 992 int numberOfEntries = cfg.readNumEntry("numberOfEntries",0);
1009 if( currentServerConfig == -1) { 993 if( currentServerConfig == -1) {
1010 994
1011 temp.setNum( numberOfEntries + 1); 995 temp.setNum( numberOfEntries + 1);
@@ -1079,24 +1063,28 @@ void OpieFtp::serverComboSelected(int index)
1079 port = remoteServerStr.right( divider - 1); 1063 port = remoteServerStr.right( divider - 1);
1080 bool ok; 1064 bool ok;
1081 int portInt = port.toInt(&ok,10); 1065 int portInt = port.toInt(&ok,10);
1082 if( portInt == 0) portInt = 21; 1066 if( portInt == 0) portInt = 21;
1083 1067
1084 PortSpinBox->setValue( portInt); 1068 PortSpinBox->setValue( portInt);
1085 1069
1086 remotePath->setText(cfg.readEntry("RemotePath", "/")); 1070 remotePath->setText(cfg.readEntry("RemotePath", "/"));
1087 1071
1088 username = cfg.readEntry("Username", "anonymous"); 1072 username = cfg.readEntry("Username", "anonymous");
1089 UsernameComboBox->lineEdit()->setText(username); 1073 UsernameComboBox->lineEdit()->setText(username);
1090 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); 1074 PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org"));
1075
1076 cfg.setGroup("Server");
1077 temp.sprintf("%d",currentServerConfig);
1078 cfg.writeEntry("currentServer", temp);
1091 update(); 1079 update();
1092} 1080}
1093// UsernameComboBox->lineEdit()->setText("root"); 1081// UsernameComboBox->lineEdit()->setText("root");
1094// PasswordEdit->setText( tr( "" ) ); 1082// PasswordEdit->setText( tr( "" ) );
1095// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); 1083// ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) );
1096// remotePath->setText( currentRemoteDir = "/home/llornkcor/"); 1084// remotePath->setText( currentRemoteDir = "/home/llornkcor/");
1097// PortSpinBox->setValue( 4242); 1085// PortSpinBox->setValue( 4242);
1098 1086
1099void OpieFtp::deleteServer() 1087void OpieFtp::deleteServer()
1100{ 1088{
1101 QString username, remoteServerStr, remotePathStr, password, port, temp; 1089 QString username, remoteServerStr, remotePathStr, password, port, temp;
1102 remoteServerStr = ServerComboBox->currentText( ); 1090 remoteServerStr = ServerComboBox->currentText( );