author | zautrix <zautrix> | 2005-03-25 00:08:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-25 00:08:08 (UTC) |
commit | 7c2e130ddd194f1c4b5365af6999a27c08232f4b (patch) (unidiff) | |
tree | 75665681327ee49d7650f4d840b5c8c772180fb4 /libkdepim | |
parent | 5cf054b82738d65f9b0a34ccb51c993ee4a0189f (diff) | |
download | kdepimpi-7c2e130ddd194f1c4b5365af6999a27c08232f4b.zip kdepimpi-7c2e130ddd194f1c4b5365af6999a27c08232f4b.tar.gz kdepimpi-7c2e130ddd194f1c4b5365af6999a27c08232f4b.tar.bz2 |
fixes
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index 7319285..184cb39 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -20,103 +20,97 @@ | |||
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | 52 | ||
53 | #include <klocale.h> | 53 | #include <klocale.h> |
54 | #include <kglobal.h> | 54 | #include <kglobal.h> |
55 | #include <kconfig.h> | 55 | #include <kconfig.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | 57 | ||
58 | QDateTime KSyncManager::mRequestedSyncEvent; | 58 | QDateTime KSyncManager::mRequestedSyncEvent; |
59 | 59 | ||
60 | 60 | ||
61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
62 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) | 62 | : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) |
63 | { | 63 | { |
64 | mServerSocket = 0; | 64 | mServerSocket = 0; |
65 | bar = new QProgressBar ( 1, 0 ); | 65 | bar = new QProgressBar ( 1, 0 ); |
66 | bar->setCaption (""); | 66 | bar->setCaption (""); |
67 | mWriteBackInPast = 2; | 67 | mWriteBackInPast = 2; |
68 | int w = 300; | 68 | |
69 | if ( QApplication::desktop()->width() < 320 ) | ||
70 | w = 220; | ||
71 | int h = bar->sizeHint().height() ; | ||
72 | int dw = QApplication::desktop()->width(); | ||
73 | int dh = QApplication::desktop()->height(); | ||
74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
75 | 69 | ||
76 | } | 70 | } |
77 | 71 | ||
78 | KSyncManager::~KSyncManager() | 72 | KSyncManager::~KSyncManager() |
79 | { | 73 | { |
80 | delete bar; | 74 | delete bar; |
81 | } | 75 | } |
82 | 76 | ||
83 | void KSyncManager::setDefaultFileName( QString s) | 77 | void KSyncManager::setDefaultFileName( QString s) |
84 | { | 78 | { |
85 | mDefFileName = s ; | 79 | mDefFileName = s ; |
86 | if ( mPrefs->mPassiveSyncAutoStart ) | 80 | if ( mPrefs->mPassiveSyncAutoStart ) |
87 | enableQuick( false ); | 81 | enableQuick( false ); |
88 | } | 82 | } |
89 | 83 | ||
90 | void KSyncManager::fillSyncMenu() | 84 | void KSyncManager::fillSyncMenu() |
91 | { | 85 | { |
92 | if ( mSyncMenu->count() ) | 86 | if ( mSyncMenu->count() ) |
93 | mSyncMenu->clear(); | 87 | mSyncMenu->clear(); |
94 | 88 | ||
95 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 89 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
96 | mSyncMenu->insertSeparator(); | 90 | mSyncMenu->insertSeparator(); |
97 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 91 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
98 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 92 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
99 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 93 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
100 | clearMenu->insertSeparator(); | 94 | clearMenu->insertSeparator(); |
101 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 95 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
102 | mSyncMenu->insertSeparator(); | 96 | mSyncMenu->insertSeparator(); |
103 | if ( mServerSocket == 0 ) { | 97 | if ( mServerSocket == 0 ) { |
104 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 98 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
105 | } else { | 99 | } else { |
106 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 100 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
107 | } | 101 | } |
108 | mSyncMenu->insertSeparator(); | 102 | mSyncMenu->insertSeparator(); |
109 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 103 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
110 | mSyncMenu->insertSeparator(); | 104 | mSyncMenu->insertSeparator(); |
111 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 105 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
112 | config.setGroup("General"); | 106 | config.setGroup("General"); |
113 | QStringList prof = config.readListEntry("SyncProfileNames"); | 107 | QStringList prof = config.readListEntry("SyncProfileNames"); |
114 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 108 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
115 | if ( prof.count() < 2 ) { | 109 | if ( prof.count() < 2 ) { |
116 | prof.clear(); | 110 | prof.clear(); |
117 | QString externalName; | 111 | QString externalName; |
118 | #ifdef DESKTOP_VERSION | 112 | #ifdef DESKTOP_VERSION |
119 | #ifdef _WIN32_ | 113 | #ifdef _WIN32_ |
120 | externalName = "OutLook(not_implemented)"; | 114 | externalName = "OutLook(not_implemented)"; |
121 | #else | 115 | #else |
122 | externalName = "KDE_Desktop"; | 116 | externalName = "KDE_Desktop"; |
@@ -964,96 +958,103 @@ void KSyncManager::syncKDE() | |||
964 | break; | 958 | break; |
965 | case (PWMPI): | 959 | case (PWMPI): |
966 | 960 | ||
967 | break; | 961 | break; |
968 | default: | 962 | default: |
969 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); | 963 | qDebug("KSM::slotSyncMenu: invalid apptype selected"); |
970 | break; | 964 | break; |
971 | 965 | ||
972 | } | 966 | } |
973 | } | 967 | } |
974 | 968 | ||
975 | void KSyncManager::syncSharp() | 969 | void KSyncManager::syncSharp() |
976 | { | 970 | { |
977 | 971 | ||
978 | if ( ! syncExternalApplication("sharp") ) | 972 | if ( ! syncExternalApplication("sharp") ) |
979 | qDebug("KSM::ERROR sync sharp "); | 973 | qDebug("KSM::ERROR sync sharp "); |
980 | } | 974 | } |
981 | 975 | ||
982 | bool KSyncManager::syncExternalApplication(QString resource) | 976 | bool KSyncManager::syncExternalApplication(QString resource) |
983 | { | 977 | { |
984 | 978 | ||
985 | emit save(); | 979 | emit save(); |
986 | 980 | ||
987 | if ( mAskForPreferences ) | 981 | if ( mAskForPreferences ) |
988 | if ( !edit_sync_options()) { | 982 | if ( !edit_sync_options()) { |
989 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 983 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
990 | return false; | 984 | return false; |
991 | } | 985 | } |
992 | 986 | ||
993 | qDebug("KSM::Sync extern %s", resource.latin1()); | 987 | qDebug("KSM::Sync extern %s", resource.latin1()); |
994 | 988 | ||
995 | bool syncOK = mImplementation->syncExternal(this, resource); | 989 | bool syncOK = mImplementation->syncExternal(this, resource); |
996 | 990 | ||
997 | return syncOK; | 991 | return syncOK; |
998 | 992 | ||
999 | } | 993 | } |
1000 | 994 | ||
1001 | void KSyncManager::syncPhone() | 995 | void KSyncManager::syncPhone() |
1002 | { | 996 | { |
1003 | 997 | ||
1004 | syncExternalApplication("phone"); | 998 | syncExternalApplication("phone"); |
1005 | 999 | ||
1006 | } | 1000 | } |
1007 | 1001 | ||
1008 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 1002 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
1009 | { | 1003 | { |
1010 | if (!bar->isVisible()) | 1004 | if (!bar->isVisible()) |
1011 | { | 1005 | { |
1006 | int w = 300; | ||
1007 | if ( QApplication::desktop()->width() < 320 ) | ||
1008 | w = 220; | ||
1009 | int h = bar->sizeHint().height() ; | ||
1010 | int dw = QApplication::desktop()->width(); | ||
1011 | int dh = QApplication::desktop()->height(); | ||
1012 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
1012 | bar->setCaption (caption); | 1013 | bar->setCaption (caption); |
1013 | bar->setTotalSteps ( total ) ; | 1014 | bar->setTotalSteps ( total ) ; |
1014 | bar->show(); | 1015 | bar->show(); |
1015 | } | 1016 | } |
1016 | bar->raise(); | 1017 | bar->raise(); |
1017 | bar->setProgress( percentage ); | 1018 | bar->setProgress( percentage ); |
1018 | qApp->processEvents(); | 1019 | qApp->processEvents(); |
1019 | } | 1020 | } |
1020 | 1021 | ||
1021 | void KSyncManager::hideProgressBar() | 1022 | void KSyncManager::hideProgressBar() |
1022 | { | 1023 | { |
1023 | bar->hide(); | 1024 | bar->hide(); |
1024 | qApp->processEvents(); | 1025 | qApp->processEvents(); |
1025 | } | 1026 | } |
1026 | 1027 | ||
1027 | bool KSyncManager::isProgressBarCanceled() | 1028 | bool KSyncManager::isProgressBarCanceled() |
1028 | { | 1029 | { |
1029 | return !bar->isVisible(); | 1030 | return !bar->isVisible(); |
1030 | } | 1031 | } |
1031 | 1032 | ||
1032 | QString KSyncManager::syncFileName() | 1033 | QString KSyncManager::syncFileName() |
1033 | { | 1034 | { |
1034 | 1035 | ||
1035 | QString fn = "tempfile"; | 1036 | QString fn = "tempfile"; |
1036 | switch(mTargetApp) | 1037 | switch(mTargetApp) |
1037 | { | 1038 | { |
1038 | case (KAPI): | 1039 | case (KAPI): |
1039 | fn = "tempsyncab.vcf"; | 1040 | fn = "tempsyncab.vcf"; |
1040 | break; | 1041 | break; |
1041 | case (KOPI): | 1042 | case (KOPI): |
1042 | fn = "tempsynccal.ics"; | 1043 | fn = "tempsynccal.ics"; |
1043 | break; | 1044 | break; |
1044 | case (PWMPI): | 1045 | case (PWMPI): |
1045 | fn = "tempsyncpw.pwm"; | 1046 | fn = "tempsyncpw.pwm"; |
1046 | break; | 1047 | break; |
1047 | default: | 1048 | default: |
1048 | break; | 1049 | break; |
1049 | } | 1050 | } |
1050 | #ifdef _WIN32_ | 1051 | #ifdef _WIN32_ |
1051 | return locateLocal( "tmp", fn ); | 1052 | return locateLocal( "tmp", fn ); |
1052 | #else | 1053 | #else |
1053 | return (QString( "/tmp/" )+ fn ); | 1054 | return (QString( "/tmp/" )+ fn ); |
1054 | #endif | 1055 | #endif |
1055 | } | 1056 | } |
1056 | 1057 | ||
1057 | void KSyncManager::syncPi() | 1058 | void KSyncManager::syncPi() |
1058 | { | 1059 | { |
1059 | mIsKapiFile = true; | 1060 | mIsKapiFile = true; |