summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/NetworkDialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/NetworkDialog.cpp67
1 files changed, 33 insertions, 34 deletions
diff --git a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
index a321952..ba583ad 100644
--- a/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/NetworkDialog.cpp
@@ -146,88 +146,87 @@ bool NetworkDialog::downloadFile( QString networkUrl )
if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) {
FtpQuit(conn);
successDownload=false;
msg.sprintf("Unable to log in\n%s",FtpLastResponse(conn));
QMessageBox::message("Note",msg);
return false;
}
odebug << "Changing directories." << oendl;
TextLabel3->setText("Changing directories.");
qApp->processEvents();
if (!FtpChdir( dir.latin1(), conn )) {
successDownload=false;
msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn));
QMessageBox::message("Note",msg);
FtpQuit(conn);
return false;
}
// if (!FtpNlst( "./.guten_temp", dir, conn)) {
// successDownload=false;
// msg.sprintf("Unable to change directories "+dir+"\n%s",FtpLastResponse(conn));
// QMessageBox::message("Note",msg);
// FtpQuit(conn);
// return false;
// }
- odebug << "Requesting directory list." << oendl;
- TextLabel3->setText("Getting directory list.");
- qApp->processEvents();
- if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) {
- msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn));
- QMessageBox::message("Note",msg);
- successDownload=false;
- FtpQuit(conn);
- return false;
- }
- QFile tmp("./.guten_temp");
- QString s, File_Name;
+ QString File_Name;
- if (tmp.open(IO_ReadOnly)) {
- QTextStream t( &tmp ); // use a text stream
- odebug << "Finding partial filename "+s_partialFileName << oendl;
- while ( !t.eof()) {
- s = t.readLine();
+ if( s_partialFileName.right(4) != ".txt") {
+ TextLabel3->setText("Getting directory list.");
+ qApp->processEvents();
+ if (!FtpDir( "./.guten_temp", dir.latin1(), conn) ) {
+ msg.sprintf("Unable to list the directory\n"+dir+"\n%s",FtpLastResponse(conn));
+ QMessageBox::message("Note",msg);
+ successDownload = false;
+ FtpQuit(conn);
+ return false;
+ }
+ QFile tmp("./.guten_temp");
+ if (tmp.open(IO_ReadOnly)) {
+ QTextStream t( &tmp ); // use a text stream
+ //odebug << "Finding partial filename "+s_partialFileName << oendl;
+ QString s;
- if (s.contains(s_partialFileName, FALSE)) {
- QString str = s.right( (s.length()) - (s.find(s_partialFileName, FALSE)) );
+ while ( !t.eof()) {
+ s = t.readLine();
- if (str.contains(".txt")) {
- File_Name = str;
- odebug << "Found file_name "+ File_Name << oendl;
- break;
- }
-// if (str.contains(".zip")) {
-// File_Name = str;
-// odebug << "Found file_name "+ File_Name << oendl;
-// break;
-// }
+ if (s.contains(s_partialFileName, FALSE)) {
+ QString str = s.right( (s.length()) - (s.find(s_partialFileName, FALSE)) );
- }
- } //end of while loop
- tmp.close();
+ if (str.contains(".txt")) {
+ File_Name = str;
+ //odebug << "Found file_name "+ File_Name << oendl;
+ break;
+ }
+ }
+ } //end of while loop
+ tmp.close();
// tmp.remove(); ///TODO this is for release version Zaurus
+ }
+ } else {
+ File_Name = s_partialFileName;
+ qDebug("new dir " + File_Name);
}
- else
- odebug << "Error opening temp file." << oendl;
+
Config cfg("Gutenbrowser");
cfg.setGroup("General");
QString temp=cfg.readEntry("DownloadDirectory",local_library);
localFileName = temp+File_Name;
odebug << "Requesting file "+ File_Name << oendl;
odebug << "Saving as "+localFileName << oendl;
msg="Requesting file "+ File_Name;
TextLabel3->setText(msg);
qApp->processEvents();
if( File_Name.length()>3) {
if (!FtpSize( File_Name.latin1(), &fsz, FTPLIB_ASCII, conn))
fsz = 0;
QString temp;
temp.sprintf( File_Name+" "+" %dkb", fsz);
TextLabel3->setText(temp);
ProgressBar1->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);