summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2005-02-09 19:31:50 (UTC)
committer zautrix <zautrix>2005-02-09 19:31:50 (UTC)
commita9eff860d8399a198a9fdc04e09ed369097fc745 (patch) (unidiff)
treec953f38ef75bed96bdedd61b1b4bf369e08cddee /libkdepim
parent22d5db839c9741cb2e988e84bbb367617934ebd9 (diff)
downloadkdepimpi-a9eff860d8399a198a9fdc04e09ed369097fc745.zip
kdepimpi-a9eff860d8399a198a9fdc04e09ed369097fc745.tar.gz
kdepimpi-a9eff860d8399a198a9fdc04e09ed369097fc745.tar.bz2
fixes
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp13
-rw-r--r--libkdepim/ksyncmanager.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 9177f63..c8d0e0d 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -51,58 +51,62 @@
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
58QDateTime KSyncManager::mRequestedSyncEvent; 58QDateTime KSyncManager::mRequestedSyncEvent;
59 59
60 60
61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 61KSyncManager::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 int w = 300;
69 if ( QApplication::desktop()->width() < 320 ) 69 if ( QApplication::desktop()->width() < 320 )
70 w = 220; 70 w = 220;
71 int h = bar->sizeHint().height() ; 71 int h = bar->sizeHint().height() ;
72 int dw = QApplication::desktop()->width(); 72 int dw = QApplication::desktop()->width();
73 int dh = QApplication::desktop()->height(); 73 int dh = QApplication::desktop()->height();
74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
75 if ( mPrefs->mPassiveSyncAutoStart )
76 enableQuick( false );
77 75
78} 76}
79 77
80KSyncManager::~KSyncManager() 78KSyncManager::~KSyncManager()
81{ 79{
82 delete bar; 80 delete bar;
83} 81}
84 82
83void KSyncManager::setDefaultFileName( QString s)
84{
85 mDefFileName = s ;
86 if ( mPrefs->mPassiveSyncAutoStart )
87 enableQuick( false );
88}
85 89
86void KSyncManager::fillSyncMenu() 90void KSyncManager::fillSyncMenu()
87{ 91{
88 if ( mSyncMenu->count() ) 92 if ( mSyncMenu->count() )
89 mSyncMenu->clear(); 93 mSyncMenu->clear();
90 94
91 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 95 mSyncMenu->insertItem( i18n("Configure..."), 0 );
92 mSyncMenu->insertSeparator(); 96 mSyncMenu->insertSeparator();
93 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 97 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
94 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 98 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
95 clearMenu->insertItem( i18n("For all profiles"), 1 ); 99 clearMenu->insertItem( i18n("For all profiles"), 1 );
96 clearMenu->insertSeparator(); 100 clearMenu->insertSeparator();
97 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 101 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
98 mSyncMenu->insertSeparator(); 102 mSyncMenu->insertSeparator();
99 if ( mServerSocket == 0 ) { 103 if ( mServerSocket == 0 ) {
100 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 104 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
101 } else { 105 } else {
102 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 106 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
103 } 107 }
104 mSyncMenu->insertSeparator(); 108 mSyncMenu->insertSeparator();
105 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 109 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
106 mSyncMenu->insertSeparator(); 110 mSyncMenu->insertSeparator();
107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 111 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
108 config.setGroup("General"); 112 config.setGroup("General");
@@ -391,49 +395,48 @@ void KSyncManager::enableQuick( bool ask )
391 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 395 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
392 mPrefs->mPassiveSyncPort = lab.text(); 396 mPrefs->mPassiveSyncPort = lab.text();
393 changed = true; 397 changed = true;
394 } 398 }
395 autoStart = autostart.isChecked(); 399 autoStart = autostart.isChecked();
396 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 400 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
397 changed = true; 401 changed = true;
398 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 402 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
399 } 403 }
400 } 404 }
401 else 405 else
402 autoStart = mPrefs->mPassiveSyncAutoStart; 406 autoStart = mPrefs->mPassiveSyncAutoStart;
403 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 407 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
404 changed = true; 408 changed = true;
405 bool ok; 409 bool ok;
406 mPrefs->mPassiveSyncAutoStart = false; 410 mPrefs->mPassiveSyncAutoStart = false;
407 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 411 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
408 if ( ! ok ) { 412 if ( ! ok ) {
409 KMessageBox::information( 0, i18n("No valid port")); 413 KMessageBox::information( 0, i18n("No valid port"));
410 return; 414 return;
411 } 415 }
412 //qDebug("port %d ", port); 416 //qDebug("port %d ", port);
413 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 417 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
414 mServerSocket->setFileName( defaultFileName() );//bbb 418 mServerSocket->setFileName( defaultFileName() );//bbb
415 //qDebug("connected ");
416 if ( !mServerSocket->ok() ) { 419 if ( !mServerSocket->ok() ) {
417 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 420 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
418 delete mServerSocket; 421 delete mServerSocket;
419 mServerSocket = 0; 422 mServerSocket = 0;
420 return; 423 return;
421 } 424 }
422 mPrefs->mPassiveSyncAutoStart = autoStart; 425 mPrefs->mPassiveSyncAutoStart = autoStart;
423 if ( changed ) { 426 if ( changed ) {
424 mPrefs->writeConfig(); 427 mPrefs->writeConfig();
425 } 428 }
426 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 429 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
427 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 430 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
428} 431}
429 432
430void KSyncManager::syncLocalFile() 433void KSyncManager::syncLocalFile()
431{ 434{
432 435
433 QString fn =mPrefs->mLastSyncedLocalFile; 436 QString fn =mPrefs->mLastSyncedLocalFile;
434 QString ext; 437 QString ext;
435 438
436 switch(mTargetApp) 439 switch(mTargetApp)
437 { 440 {
438 case (KAPI): 441 case (KAPI):
439 ext = "(*.vcf)"; 442 ext = "(*.vcf)";
@@ -1096,49 +1099,49 @@ void KSyncManager::readFileFromSocket()
1096 QString fileName = syncFileName(); 1099 QString fileName = syncFileName();
1097 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1100 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1098 if ( ! syncWithFile( fileName , true ) ) { 1101 if ( ! syncWithFile( fileName , true ) ) {
1099 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1102 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1100 mPisyncFinished = true; 1103 mPisyncFinished = true;
1101 return; 1104 return;
1102 } 1105 }
1103 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1106 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1104 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1107 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1105 if ( mWriteBackFile ) 1108 if ( mWriteBackFile )
1106 commandSocket->writeFile( fileName ); 1109 commandSocket->writeFile( fileName );
1107 else { 1110 else {
1108 commandSocket->sendStop(); 1111 commandSocket->sendStop();
1109 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1112 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1110 mPisyncFinished = true; 1113 mPisyncFinished = true;
1111 } 1114 }
1112} 1115}
1113 1116
1114KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1117KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1115{ 1118{
1116 mPassWord = pw; 1119 mPassWord = pw;
1117 mSocket = 0; 1120 mSocket = 0;
1118 mSyncActionDialog = 0; 1121 mSyncActionDialog = 0;
1119 blockRC = false; 1122 blockRC = false;
1120}; 1123}
1121 1124
1122void KServerSocket::newConnection ( int socket ) 1125void KServerSocket::newConnection ( int socket )
1123{ 1126{
1124 // qDebug("KServerSocket:New connection %d ", socket); 1127 // qDebug("KServerSocket:New connection %d ", socket);
1125 if ( mSocket ) { 1128 if ( mSocket ) {
1126 qDebug("KSS::newConnection Socket deleted! "); 1129 qDebug("KSS::newConnection Socket deleted! ");
1127 delete mSocket; 1130 delete mSocket;
1128 mSocket = 0; 1131 mSocket = 0;
1129 } 1132 }
1130 mSocket = new QSocket( this ); 1133 mSocket = new QSocket( this );
1131 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1134 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1132 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1135 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1133 mSocket->setSocket( socket ); 1136 mSocket->setSocket( socket );
1134} 1137}
1135 1138
1136void KServerSocket::discardClient() 1139void KServerSocket::discardClient()
1137{ 1140{
1138 //qDebug(" KServerSocket::discardClient()"); 1141 //qDebug(" KServerSocket::discardClient()");
1139 if ( mSocket ) { 1142 if ( mSocket ) {
1140 delete mSocket; 1143 delete mSocket;
1141 mSocket = 0; 1144 mSocket = 0;
1142 } 1145 }
1143 //emit endConnect(); 1146 //emit endConnect();
1144} 1147}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 9a3066e..09bd1c1 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -100,49 +100,49 @@ class KCommandSocket : public QObject
100 QTimer* mTimerSocket; 100 QTimer* mTimerSocket;
101 int mRetVal; 101 int mRetVal;
102 QTime mTime; 102 QTime mTime;
103 QString mFileString; 103 QString mFileString;
104 bool mFirst; 104 bool mFirst;
105}; 105};
106 106
107 107
108class KSyncManager : public QObject 108class KSyncManager : public QObject
109{ 109{
110 Q_OBJECT 110 Q_OBJECT
111 111
112 public: 112 public:
113 enum TargetApp { 113 enum TargetApp {
114 KOPI = 0, 114 KOPI = 0,
115 KAPI = 1, 115 KAPI = 1,
116 PWMPI = 2 }; 116 PWMPI = 2 };
117 117
118 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 118 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
119 ~KSyncManager() ; 119 ~KSyncManager() ;
120 120
121 void multiSync( bool askforPrefs ); 121 void multiSync( bool askforPrefs );
122 bool blockSave() { return mBlockSaveFlag; } 122 bool blockSave() { return mBlockSaveFlag; }
123 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 123 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
124 void setDefaultFileName( QString s) { mDefFileName = s ;} 124 void setDefaultFileName( QString s) ;
125 QString defaultFileName() { return mDefFileName ;} 125 QString defaultFileName() { return mDefFileName ;}
126 QString syncFileName(); 126 QString syncFileName();
127 void enableQuick( bool ask = true); 127 void enableQuick( bool ask = true);
128 128
129 bool syncWithDesktop () { return mSyncWithDesktop;} 129 bool syncWithDesktop () { return mSyncWithDesktop;}
130 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 130 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
131 QString getCurrentSyncName() { return mCurrentSyncName; } 131 QString getCurrentSyncName() { return mCurrentSyncName; }
132 132
133 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 133 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
134 void hideProgressBar(); 134 void hideProgressBar();
135 bool isProgressBarCanceled(); 135 bool isProgressBarCanceled();
136 136
137 // sync stuff 137 // sync stuff
138 QString mLocalMachineName; 138 QString mLocalMachineName;
139 QStringList mExternSyncProfiles; 139 QStringList mExternSyncProfiles;
140 QStringList mSyncProfileNames; 140 QStringList mSyncProfileNames;
141 bool mAskForPreferences; 141 bool mAskForPreferences;
142 bool mShowSyncSummary; 142 bool mShowSyncSummary;
143 bool mIsKapiFile; 143 bool mIsKapiFile;
144 bool mWriteBackExistingOnly; 144 bool mWriteBackExistingOnly;
145 int mSyncAlgoPrefs; 145 int mSyncAlgoPrefs;
146 bool mWriteBackFile; 146 bool mWriteBackFile;
147 int mWriteBackInFuture; 147 int mWriteBackInFuture;
148 int mWriteBackInPast; 148 int mWriteBackInPast;