-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 46 |
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 @@ -130,48 +130,50 @@ OpieFtp::OpieFtp( ) Local_View->setColumnAlignment(2,QListView::AlignRight); Local_View->setAllColumnsShowFocus(TRUE); QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); tabLayout->addWidget( Local_View, 0, 0 ); connect( Local_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( localListClicked(QListViewItem *)) ); connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); TabWidget->insertTab( tab, tr( "Local" ) ); tab_2 = new QWidget( TabWidget, "tab_2" ); tabLayout_2 = new QGridLayout( tab_2 ); tabLayout_2->setSpacing( 2); tabLayout_2->setMargin( 2); Remote_View = new QListView( tab_2, "Remote_View" ); Remote_View->addColumn( tr("File"),120); Remote_View->addColumn( tr("Size"),-1); Remote_View->setColumnAlignment(1,QListView::AlignRight); Remote_View->addColumn( tr("Date"),-1); Remote_View->setColumnAlignment(2,QListView::AlignRight); + Remote_View->addColumn( tr("Dir"),-1); + Remote_View->setColumnAlignment(4,QListView::AlignRight); Remote_View->setAllColumnsShowFocus(TRUE); QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); connect( Remote_View, SIGNAL( clicked( QListViewItem*)), this,SLOT( remoteListClicked(QListViewItem *)) ); connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( RemoteListPressed(int, QListViewItem *, const QPoint&, int)) ); tabLayout_2->addWidget( Remote_View, 0, 0 ); TabWidget->insertTab( tab_2, tr( "Remote" ) ); tab_3 = new QWidget( TabWidget, "tab_3" ); tabLayout_3 = new QGridLayout( tab_3 ); tabLayout_3->setSpacing( 2); tabLayout_3->setMargin( 2); TextLabel1 = new QLabel( tab_3, "TextLabel1" ); TextLabel1->setText( tr( "Username" ) ); tabLayout_3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 ); UsernameComboBox = new QComboBox( FALSE, tab_3, "UsernameComboBox" ); UsernameComboBox->setEditable(TRUE); tabLayout_3->addMultiCellWidget( UsernameComboBox, 1, 1, 0, 1 ); @@ -222,65 +224,66 @@ OpieFtp::OpieFtp( ) connectServerBtn->setToggleButton(TRUE); connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); tabLayout_3->addItem( spacer, 5, 0 ); TabWidget->insertTab( tab_3, tr( "Config" ) ); connect(TabWidget,SIGNAL(currentChanged(QWidget *)), this,SLOT(tabChanged(QWidget*))); currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); currentDir.setPath( QDir::currentDirPath()); // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentPathEdit = new QLineEdit( "/", this, "currentPathEdit" ); layout->addMultiCellWidget( currentPathEdit, 3, 3, 0, 3 ); currentPathEdit->setText( currentDir.canonicalPath()); connect( currentPathEdit,SIGNAL(returnPressed()),this,SLOT(currentPathEditChanged())); ProgressBar = new QProgressBar( this, "ProgressBar" ); layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 3 ); - serverComboSelected(0); - fillCombos(); +// fillCombos(); #ifdef DEVELOPERS_VERSION ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); UsernameComboBox->lineEdit()->setText("root"); PortSpinBox->setValue( 4242); remotePath->setText( currentRemoteDir = "/"); // ServerComboBox->lineEdit()->setText( tr( "llornkcor.com" ) ); // UsernameComboBox->lineEdit()->setText("llornkcor"); // PortSpinBox->setValue( 21); // remotePath->setText( currentRemoteDir = "/home/llornkcor"); PasswordEdit->setText( tr( "" ) ); #endif filterStr="*"; b=FALSE; populateLocalView(); + readConfig(); + ServerComboBox->setCurrentItem(currentServerConfig); TabWidget->setCurrentPage(2); } OpieFtp::~OpieFtp() { } void OpieFtp::cleanUp() { if(conn) FtpQuit(conn); QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") sfile+="/._temp"; else sfile+="._temp"; QFile file( sfile); if(file.exists()) file.remove(); } void OpieFtp::tabChanged(QWidget *w) { if (TabWidget->currentPageIndex() == 0) { @@ -560,71 +563,72 @@ bool OpieFtp::populateRemoteView( ) QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") sfile+="/._temp"; else sfile+="._temp"; QFile file( sfile); Remote_View->clear(); QString s, File_Name; QListViewItem *itemDir=NULL, *itemFile=NULL; QString fileL, fileS, fileDate; if ( file.open(IO_ReadOnly)) { QTextStream t( &file ); // use a text stream while ( !t.eof()) { s = t.readLine(); fileL = s.right(s.length()-55); fileL = fileL.stripWhiteSpace(); if(s.left(1) == "d") fileL = fileL+"/"; // fileL = "/"+fileL+"/"; fileS = s.mid( 30, 42-30); fileS = fileS.stripWhiteSpace(); fileDate = s.mid( 42, 55-42); fileDate = fileDate.stripWhiteSpace(); if(fileL.find("total",0,TRUE) == -1) { - QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate); if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { + QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"d"); item->setPixmap( 0, Resource::loadPixmap( "folder" )); - if(itemDir) +// if(itemDir) item->moveItem(itemDir); itemDir=item; } else { + QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate,"f"); item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); - if(itemFile) +// if(itemFile) + item->moveItem(itemDir); item->moveItem(itemFile); itemFile=item; } } } QListViewItem * item1 = new QListViewItem( Remote_View, "../"); item1->setPixmap( 0, Resource::loadPixmap( "folder" )); file.close(); if( file.exists()) file. remove(); } else qDebug("temp file not opened successfullly "+sfile); Remote_View->setSorting( 4,TRUE); - return true; } void OpieFtp::remoteListClicked(QListViewItem *selectedItem) { QCopEnvelope ( "QPE/System", "busy()" ); QString oldRemoteCurrentDir = currentRemoteDir; QString strItem=selectedItem->text(0); strItem=strItem.simplifyWhiteSpace(); if(strItem == "../") { // the user wants to go ^ if( FtpCDUp( conn) == 0) { QString msg; msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); qDebug(msg); } char path[256]; if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string QString msg; msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); qDebug(msg); @@ -951,73 +955,53 @@ void OpieFtp::currentPathEditChanged() currentPathEdit->setText( currentRemoteDir ); } remoteDirList( (const QString &)currentRemoteDir); } } void OpieFtp::switchToLocalTab() { TabWidget->setCurrentPage(0); } void OpieFtp::switchToRemoteTab() { TabWidget->setCurrentPage(1); } void OpieFtp::switchToConfigTab() { TabWidget->setCurrentPage(2); } void OpieFtp::readConfig() { - + fillCombos(); Config cfg("opieftp"); cfg.setGroup("Server"); - QString username, remoteServer, remotePathStr, password, port, temp; - int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); - for (int i = 0; i <= numberOfEntries; i++) { - temp.setNum(i+1); - cfg.setGroup("Server"); - remoteServer = cfg.readEntry( temp,""); - ServerComboBox->insertItem( remoteServer ); - cfg.setGroup(temp); - - remotePathStr = cfg.readEntry(remoteServer,""); - int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); - port = remoteServer.right( divider+1); - bool ok; - PortSpinBox->setValue( port.toInt(&ok,10)); - - remoteServer = remoteServer.left(divider - 1); - remotePath->setText( remotePathStr); - username = cfg.readEntry(temp); - UsernameComboBox->insertItem(username); - password = cfg.readEntryCrypt(username,""); - PasswordEdit->setText(password); - } + currentServerConfig = cfg.readNumEntry("currentServer", -1); + serverComboSelected( currentServerConfig); } void OpieFtp::writeConfig() { Config cfg("opieftp"); cfg.setGroup("Server"); QString username, remoteServerStr, remotePathStr, password, port, temp; int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); if( currentServerConfig == -1) { temp.setNum( numberOfEntries + 1); cfg.setGroup("Server"); remoteServerStr = cfg.readEntry( temp,""); int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); temp.setNum(numberOfEntries+1); cfg.setGroup("Server"); cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); cfg.setGroup(temp); cfg.writeEntry("RemotePath", remotePath->text()); cfg.writeEntry("Username", UsernameComboBox->currentText()); cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); @@ -1067,48 +1051,52 @@ void OpieFtp::serverComboSelected(int index) currentServerConfig = index; QString username, remoteServerStr, remotePathStr, password, port, temp; // remoteServerStr = ServerComboBox->text(index); Config cfg("opieftp"); cfg.setGroup("Server"); int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); temp.setNum(index+1); remoteServerStr = cfg.readEntry( temp,""); cfg.setGroup(temp); qDebug(temp); int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); port = remoteServerStr.right( divider - 1); bool ok; int portInt = port.toInt(&ok,10); if( portInt == 0) portInt = 21; PortSpinBox->setValue( portInt); remotePath->setText(cfg.readEntry("RemotePath", "/")); username = cfg.readEntry("Username", "anonymous"); UsernameComboBox->lineEdit()->setText(username); PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); + + cfg.setGroup("Server"); + temp.sprintf("%d",currentServerConfig); + cfg.writeEntry("currentServer", temp); update(); } // UsernameComboBox->lineEdit()->setText("root"); // PasswordEdit->setText( tr( "" ) ); // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); // PortSpinBox->setValue( 4242); void OpieFtp::deleteServer() { QString username, remoteServerStr, remotePathStr, password, port, temp; remoteServerStr = ServerComboBox->currentText( ); username = UsernameComboBox->currentText(); Config cfg("opieftp"); cfg.setGroup("Server"); int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); for (int i = 0; i <= numberOfEntries; i++) { temp.setNum(i+1); cfg.setGroup("Server"); if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 && cfg.readEntry(temp).find(username,0,TRUE) != -1 && !remoteServerStr.isEmpty()) { qDebug(temp); } |