summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieftp/opieftp.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp
index 6684abb..6d0be57 100644
--- a/noncore/net/opieftp/opieftp.cpp
+++ b/noncore/net/opieftp/opieftp.cpp
@@ -369,243 +369,244 @@ void OpieFtp::newConnection()
PortSpinBox->setValue( 21);
TabWidget->setCurrentPage(2);
}
void OpieFtp::serverComboEdited(const QString & edit)
{
if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) {
qDebug("ServerComboEdited");
currentServerConfig = -1;
}
}
void OpieFtp::connectorBtnToggled(bool On)
{
if(On) {
connector();
} else {
disConnector();
}
}
void OpieFtp::connector()
{
- QCopEnvelope ( "QPE/System", "busy()" );
+// QCopEnvelope ( "QPE/System", "busy()" );
// qApp->processEvents();
currentRemoteDir=remotePath->text();
if(ServerComboBox->currentText().isEmpty()) {
QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0);
TabWidget->setCurrentPage(2);
ServerComboBox->setFocus();
connectServerBtn->setOn(FALSE);
connectServerBtn->setText( tr("Connect"));
return;
}
FtpInit();
TabWidget->setCurrentPage(1);
QString ftp_host = ServerComboBox->currentText();
QString ftp_user = UsernameComboBox->currentText();
QString ftp_pass = PasswordEdit->text();
QString port=PortSpinBox->cleanText();
port.stripWhiteSpace();
if(ftp_host.find("ftp://",0, TRUE) != -1 )
ftp_host=ftp_host.right(ftp_host.length()-6);
ftp_host+=":"+port;
if (!FtpConnect( ftp_host.latin1(), &conn)) {
QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host);
connectServerBtn->setOn(FALSE);
connectServerBtn->setText( tr("Connect"));
return ;
}
if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
QString msg;
msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
if(conn)
FtpQuit(conn);
connectServerBtn->setOn(FALSE);
connectServerBtn->setText( tr("Connect"));
return ;
}
remoteDirList("/") ;
setCaption(ftp_host);
writeConfig();
connectServerBtn->setText( tr("Disconnect"));
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
}
void OpieFtp::disConnector()
{
if(conn)
FtpQuit(conn);
setCaption("OpieFtp");
currentRemoteDir="/";
Remote_View->clear();
connectServerBtn->setText( tr("Connect"));
connectServerBtn->setOn(FALSE);
+ setCaption("OpieFtp");
}
void OpieFtp::localUpload()
{
int fsz;
// QCopEnvelope ( "QPE/System", "busy()" );
// qApp->processEvents();
QList<QListViewItem> * getSelectedItems( QListView * Local_View );
QListViewItemIterator it( Local_View );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
QString strItem = it.current()->text(0);
QString localFile = currentDir.canonicalPath()+"/"+strItem;
QString remoteFile= currentRemoteDir+strItem;
QFileInfo fi(localFile);
if( !fi.isDir()) {
fsz=fi.size();
ProgressBar->setTotalSteps(fsz);
FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1());
if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
QString msg;
msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
}
} else {
QMessageBox::message(tr("Note"),tr("Cannot upload directories"));
}
ProgressBar->reset();
nullifyCallBack();
it.current()->setSelected(FALSE);
} //end currentSelected
}
for ( ; it.current(); ++it ) {
Local_View->clearSelection();
}
Local_View->clearFocus();
TabWidget->setCurrentPage(1);
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
}
void OpieFtp::nullifyCallBack()
{
FtpOptions(FTPLIB_CALLBACK, NULL, conn);
FtpOptions(FTPLIB_IDLETIME, NULL, conn);
FtpOptions(FTPLIB_CALLBACKARG, NULL, conn);
FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn);
}
void OpieFtp::remoteDownload()
{
// qApp->processEvents();
int fsz;
- QCopEnvelope ( "QPE/System", "busy()" );
+// QCopEnvelope ( "QPE/System", "busy()" );
QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
QListViewItemIterator it( Remote_View );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
QString strItem = it.current()->text(0);
// strItem=strItem.right(strItem.length()-1);
QString localFile = currentDir.canonicalPath();
if(localFile.right(1).find("/",0,TRUE) == -1)
localFile += "/";
localFile += strItem;
// QString localFile = currentDir.canonicalPath()+"/"+strItem;
QString remoteFile= currentRemoteDir+strItem;
if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn))
fsz = 0;
QString temp;
temp.sprintf( remoteFile+" "+" %dkb", fsz);
ProgressBar->setTotalSteps(fsz);
FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn);
FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn);
FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn);
FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn);
qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1());
if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) {
QString msg;
msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
}
ProgressBar->reset();
nullifyCallBack();
it.current()->setSelected(FALSE);
}
}
for ( ; it.current(); ++it ) {
Remote_View->clearSelection();
}
Remote_View->setFocus();
TabWidget->setCurrentPage(0);
populateLocalView();
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
}
bool OpieFtp::remoteDirList(const QString &dir)
{
QString tmp = QDir::homeDirPath();
if(tmp.right(1) != "/")
tmp+="/._temp";
else
tmp+="._temp";
// qDebug("Listing remote dir "+tmp);
- QCopEnvelope ( "QPE/System", "busy()" );
+// QCopEnvelope ( "QPE/System", "busy()" );
if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) {
QString msg;
msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) );
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
return false;
}
populateRemoteView() ;
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
return true;
}
bool OpieFtp::remoteChDir(const QString &dir)
{
- QCopEnvelope ( "QPE/System", "busy()" );
+// QCopEnvelope ( "QPE/System", "busy()" );
if (!FtpChdir( dir.latin1(), conn )) {
QString msg;
msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
// qDebug(msg);
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
return FALSE;
}
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
return TRUE;
}
void OpieFtp::populateLocalView()
{
Local_View->clear();
currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
currentDir.setMatchAllDirs(TRUE);
currentDir.setNameFilter(filterStr);
QString fileL, fileS, fileDate;
bool isDir=FALSE;
const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
QFileInfoListIterator it(*list);
QFileInfo *fi;
while ( (fi=it.current()) ) {
if (fi->isSymLink() ){
QString symLink=fi->readLink();
// qDebug("Symlink detected "+symLink);
QFileInfo sym( symLink);
fileS.sprintf( "%10li", sym.size() );
fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
fileDate = sym.lastModified().toString();
} else {
// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
@@ -734,49 +735,49 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem)
QMessageBox::message(tr("Note"),msg);
// qDebug(msg);
}
currentRemoteDir=path;
} else {
if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers
strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 );
strItem = strItem.stripWhiteSpace();
currentRemoteDir = strItem;
if( !remoteChDir( (const QString &)strItem)) {
currentRemoteDir = oldRemoteCurrentDir;
strItem="";
// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
}
} else if(strItem.find("/",0,TRUE) != -1) { // this is a directory
if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) {
currentRemoteDir = oldRemoteCurrentDir;
strItem="";
// qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir);
} else {
currentRemoteDir = currentRemoteDir+strItem;
}
} else {
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
return;
}
}
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
if(currentRemoteDir.right(1) !="/")
currentRemoteDir +="/";
currentPathCombo->lineEdit()->setText( currentRemoteDir);
fillRemoteCombo( (const QString &)currentRemoteDir);
// QCopEnvelope ( "QPE/System", "notBusy()" );
}
}
void OpieFtp::localListClicked(QListViewItem *selectedItem)
{
if(selectedItem!= NULL) {
QString strItem=selectedItem->text(0);
QString strSize=selectedItem->text(1);
strSize=strSize.stripWhiteSpace();
if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
// is symlink
QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4);
if(QDir(strItem2).exists() ) {
currentDir.cd(strItem2, TRUE);
@@ -936,124 +937,124 @@ void OpieFtp::localDelete()
f=currentDir.canonicalPath()+"/"+f;
QString cmd="rm "+f;
system( cmd.latin1());
}
break;
case 1:
// exit
break;
};
}
}
}
populateLocalView();
}
void OpieFtp::remoteMakDir()
{
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();//+".playlist";
QString tmp=currentRemoteDir+filename;
- QCopEnvelope ( "QPE/System", "busy()" );
+// QCopEnvelope ( "QPE/System", "busy()" );
if(FtpMkdir( tmp.latin1(), conn) == 0) {
QString msg;
msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
}
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
}
}
void OpieFtp::remoteDelete()
{
QList<QListViewItem> * getSelectedItems( QListView * Remote_View );
QListViewItemIterator it( Remote_View );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
QString f = it.current()->text(0);
// QString f = Remote_View->currentItem()->text(0);
- QCopEnvelope ( "QPE/System", "busy()" );
+// QCopEnvelope ( "QPE/System", "busy()" );
if( f.right(1) =="/") {
QString path= currentRemoteDir+f;
switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
,tr("Yes"),tr("No"),0,0,1) ) {
case 0: {
f=currentDir.canonicalPath()+"/"+f;
if(FtpRmdir( path.latin1(), conn) ==0) {
QString msg;
msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
}
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
}
break;
};
} else {
switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?"
,tr("Yes"),tr("No"),0,0,1) ) {
case 0: {
QString path= currentRemoteDir+f;
if(FtpDelete( path.latin1(), conn)==0) {
QString msg;
msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
}
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
}
break;
};
}
}
}
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
}
void OpieFtp::remoteRename()
{
QString curFile = Remote_View->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
fileDlg->setTextEdit((const QString &)curFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString oldName = currentRemoteDir +"/"+ curFile;
QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist";
- QCopEnvelope ( "QPE/System", "busy()" );
+// QCopEnvelope ( "QPE/System", "busy()" );
if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) {
QString msg;
msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn));
msg.replace(QRegExp(":"),"\n");
QMessageBox::message(tr("Note"),msg);
}
- QCopEnvelope ( "QPE/System", "notBusy()" );
+// QCopEnvelope ( "QPE/System", "notBusy()" );
remoteDirList( (const QString &)currentRemoteDir); //this also calls populate
}
}
void OpieFtp::localRename()
{
QString curFile = Local_View->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
fileDlg->setTextEdit((const QString &)curFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString oldname = currentDir.canonicalPath() + "/" + curFile;
QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
if( rename(oldname.latin1(), newName.latin1())== -1)
QMessageBox::message(tr("Note"),tr("Could not rename"));
}
populateLocalView();
}
void OpieFtp::currentPathComboActivated(const QString & currentPath) {
if (TabWidget->currentPageIndex() == 0) {
chdir( currentPath.latin1() );
currentDir.cd( currentPath, TRUE);