From 02c813356a95dc20d3e81fbc2ec8315e196e8e44 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 10 Sep 2011 22:29:00 +0000 Subject: [PATCH] Enhance libkrsync git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1252638 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- krsync/CMakeLists.txt | 2 +- krsync/krsync.cpp | 70 +++++++++++++------------------------------ krsync/krsync.h | 44 +++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 51 deletions(-) diff --git a/krsync/CMakeLists.txt b/krsync/CMakeLists.txt index 0edb0ef5f..1552e2a1e 100644 --- a/krsync/CMakeLists.txt +++ b/krsync/CMakeLists.txt @@ -34,7 +34,7 @@ install( FILES DESTINATION ${INCLUDE_INSTALL_DIR}/libkrsync ) -##### krandr #################################### +##### krsync #################################### set( target krsync ) diff --git a/krsync/krsync.cpp b/krsync/krsync.cpp index 96de71b10..21d35f04e 100644 --- a/krsync/krsync.cpp +++ b/krsync/krsync.cpp @@ -50,48 +50,6 @@ #include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - #include #include @@ -103,7 +61,7 @@ #define CONFIGURATION_FILE_SEPARATOR ';' KRsync::KRsync (TQObject* parent, const char* name) - : TQObject (parent, name) + : TQObject (parent, name), m_bSettingsLoaded(false), m_progressDialog(false), m_progressDialogExists(false), m_bInSpecialSync(false) { loadSettings(); @@ -506,7 +464,7 @@ int KRsync::establishConnectionRsync(char *buffer, KIO::fileoffset_t len) { continue; //if (str.contains("rsync error:")) { if (str.contains("rsync:") || str.contains("failed.") || (str.contains("Could not") && str.endsWith("."))) { - KMessageBox::error(NULL, str); + KMessageBox::error(NULL, str, i18n("Remote Folder Synchronization")); } else if (!str.isEmpty()) { thisFn += str; @@ -519,6 +477,7 @@ int KRsync::establishConnectionRsync(char *buffer, KIO::fileoffset_t len) { m_progressDialog->progressBar()->setTotalSteps(2); m_progressDialog->progressBar()->setValue(1); connect (m_progressDialog, TQT_SIGNAL(cancelClicked()), TQT_SLOT(slotRsyncCancelled())); + if (m_bInSpecialSync) m_progressDialog->move(0,0); m_progressDialog->show(); m_progressDialogExists = true; } @@ -553,7 +512,7 @@ int KRsync::establishConnectionRsync(char *buffer, KIO::fileoffset_t len) { return 0; } else if (buf.endsWith("?")) { - int rc = KMessageBox::questionYesNo(NULL, thisFn+buf); + int rc = KMessageBox::questionYesNo(NULL, thisFn+buf, i18n("Remote Folder Synchronization")); if (rc == KMessageBox::Yes) { writeChild("yes\n",4); } else { @@ -620,7 +579,7 @@ int KRsync::establishConnectionUnison(char *buffer, KIO::fileoffset_t len, TQStr continue; //if (str.contains("rsync error:")) { if (((str.contains("rsync:") || str.contains("failed.") || str.contains("Could not")) && str.endsWith("."))) { - KMessageBox::error(NULL, str); + KMessageBox::error(NULL, str, i18n("Remote Folder Synchronization")); } else if (str.startsWith("Fatal error")) { TQString fullError = str + buf; @@ -629,7 +588,7 @@ int KRsync::establishConnectionUnison(char *buffer, KIO::fileoffset_t len, TQStr fullError.replace(": unable", ":
Unable"); fullError.replace(")", ")
"); fullError.replace("(", "
("); - KMessageBox::error(NULL, fullError); + KMessageBox::error(NULL, fullError, i18n("Remote Folder Synchronization")); } else if (!str.isEmpty()) { thisFn += str; @@ -641,6 +600,7 @@ int KRsync::establishConnectionUnison(char *buffer, KIO::fileoffset_t len, TQStr m_progressDialog->progressBar()->setTotalSteps(0); m_progressDialog->setAutoClose(true); connect (m_progressDialog, TQT_SIGNAL(cancelClicked()), TQT_SLOT(slotUnisonCancelled())); + if (m_bInSpecialSync) m_progressDialog->move(0,0); m_progressDialog->show(); m_progressDialogExists = true; } @@ -681,7 +641,7 @@ int KRsync::establishConnectionUnison(char *buffer, KIO::fileoffset_t len, TQStr writeChild("y\n",3); } else { - int rc = KMessageBox::questionYesNo(NULL, buf); + int rc = KMessageBox::questionYesNo(NULL, buf, i18n("Remote Folder Synchronization")); if (rc == KMessageBox::Yes) { writeChild("y\n",3); } else { @@ -694,7 +654,7 @@ int KRsync::establishConnectionUnison(char *buffer, KIO::fileoffset_t len, TQStr writeChild("y\n",3); } else { - int rc = KMessageBox::questionYesNo(NULL, buf); + int rc = KMessageBox::questionYesNo(NULL, buf, i18n("Remote Folder Synchronization")); if (rc == KMessageBox::Yes) { writeChild("yes\n",4); } else { @@ -744,7 +704,7 @@ int KRsync::establishConnectionUnison(char *buffer, KIO::fileoffset_t len, TQStr } if (m_progressDialogExists == true) { - if (str.contains("exit()") && str.contains("ICE default IO")) { + if ((str.contains("exit()") && str.contains("ICE default IO")) || (str.startsWith("Fatal error"))) { if (m_progressDialogExists == true) { while (!m_progressDialog) { usleep(100); @@ -835,6 +795,16 @@ void KRsync::loadSettings() m_bSettingsLoaded = true; } +void KRsync::executeLogoutAutoSync() +{ + for (TQStringList::Iterator i(cfgautosync_onlogout_list.begin()); i != cfgautosync_onlogout_list.end(); ++i) { + setCurrentDirectoryURL(*i); + m_bInSpecialSync = true; + slotSync(); + m_bInSpecialSync = false; + } +} + TQString KRsync::findLocalFolderByName(TQString folderurl) { TQString folderurl_stripped; diff --git a/krsync/krsync.h b/krsync/krsync.h index 629da475a..4c457e333 100644 --- a/krsync/krsync.h +++ b/krsync/krsync.h @@ -30,6 +30,48 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + class KActionMenu; class KonqDirPart; class KLineEdit; @@ -88,6 +130,7 @@ public slots: void slotSetupCancelled(); void slotRsyncCancelled(); void slotUnisonCancelled(); + void executeLogoutAutoSync(); signals: void setupDone(); @@ -103,6 +146,7 @@ private: bool m_progressDialogExists; bool m_bSettingsLoaded; + bool m_bInSpecialSync; /** true if connection is logged in successfully */ bool isLoggedIn;