summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2004-10-07 09:56:31 (UTC)
committer zautrix <zautrix>2004-10-07 09:56:31 (UTC)
commitedd36b813763c304b104f276437c2c60ee9bd1f1 (patch) (unidiff)
treeda3a9f6fbd905fe876131af5025690806ce60704 /libkdepim
parent9345818e9c291130691288e4b065190259eb4e01 (diff)
downloadkdepimpi-edd36b813763c304b104f276437c2c60ee9bd1f1.zip
kdepimpi-edd36b813763c304b104f276437c2c60ee9bd1f1.tar.gz
kdepimpi-edd36b813763c304b104f276437c2c60ee9bd1f1.tar.bz2
sync fixes
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp5
-rw-r--r--libkdepim/ksyncmanager.h5
2 files changed, 5 insertions, 5 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 5d48884..ea543dd 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -254,49 +254,50 @@ void KSyncManager::enableQuick()
254 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 254 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
255 dia.show(); 255 dia.show();
256 if ( ! dia.exec() ) 256 if ( ! dia.exec() )
257 return; 257 return;
258 dia.hide(); 258 dia.hide();
259 qApp->processEvents(); 259 qApp->processEvents();
260 mPrefs->mPassiveSyncPw = lepw.text(); 260 mPrefs->mPassiveSyncPw = lepw.text();
261 mPrefs->mPassiveSyncPort = lab.text(); 261 mPrefs->mPassiveSyncPort = lab.text();
262 bool ok; 262 bool ok;
263 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 263 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
264 if ( ! ok ) { 264 if ( ! ok ) {
265 KMessageBox::information( 0, i18n("No valid port")); 265 KMessageBox::information( 0, i18n("No valid port"));
266 return; 266 return;
267 } 267 }
268 //qDebug("port %d ", port); 268 //qDebug("port %d ", port);
269 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 269 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
270 mServerSocket->setFileName( defaultFileName() ); 270 mServerSocket->setFileName( defaultFileName() );
271 //qDebug("connected "); 271 //qDebug("connected ");
272 if ( !mServerSocket->ok() ) { 272 if ( !mServerSocket->ok() ) {
273 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 273 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
274 delete mServerSocket; 274 delete mServerSocket;
275 mServerSocket = 0; 275 mServerSocket = 0;
276 return; 276 return;
277 } 277 }
278 connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); 278 //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
279 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
279 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 280 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
280} 281}
281 282
282void KSyncManager::syncLocalFile() 283void KSyncManager::syncLocalFile()
283{ 284{
284 285
285 QString fn =mLastSyncedLocalFile; 286 QString fn =mLastSyncedLocalFile;
286 QString ext; 287 QString ext;
287 288
288 switch(mTargetApp) 289 switch(mTargetApp)
289 { 290 {
290 case (KAPI): 291 case (KAPI):
291 ext = "(*.vcf)"; 292 ext = "(*.vcf)";
292 break; 293 break;
293 case (KOPI): 294 case (KOPI):
294 ext = "(*.ics/*.vcs)"; 295 ext = "(*.ics/*.vcs)";
295 break; 296 break;
296 case (PWMPI): 297 case (PWMPI):
297 ext = "(*.pwm)"; 298 ext = "(*.pwm)";
298 break; 299 break;
299 default: 300 default:
300 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 301 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
301 break; 302 break;
302 303
@@ -907,49 +908,49 @@ void KServerSocket::readClient()
907 end_connect(); 908 end_connect();
908 } 909 }
909 } 910 }
910} 911}
911void KServerSocket::end_connect() 912void KServerSocket::end_connect()
912{ 913{
913 delete mSyncActionDialog; 914 delete mSyncActionDialog;
914 mSyncActionDialog = 0; 915 mSyncActionDialog = 0;
915} 916}
916void KServerSocket::send_file() 917void KServerSocket::send_file()
917{ 918{
918 //qDebug("MainWindow::sendFile(QSocket* s) "); 919 //qDebug("MainWindow::sendFile(QSocket* s) ");
919 if ( mSyncActionDialog ) 920 if ( mSyncActionDialog )
920 delete mSyncActionDialog; 921 delete mSyncActionDialog;
921 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 922 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
922 mSyncActionDialog->setCaption(i18n("Received sync request")); 923 mSyncActionDialog->setCaption(i18n("Received sync request"));
923 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 924 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
924 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 925 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
925 lay->addWidget( label); 926 lay->addWidget( label);
926 lay->setMargin(7); 927 lay->setMargin(7);
927 lay->setSpacing(7); 928 lay->setSpacing(7);
928 mSyncActionDialog->setFixedSize( 230, 120); 929 mSyncActionDialog->setFixedSize( 230, 120);
929 mSyncActionDialog->show(); 930 mSyncActionDialog->show();
930 qDebug("KSS::saving ... "); 931 qDebug("KSS::saving ... ");
931 emit saveFile(); 932 emit request_file();
932 qApp->processEvents(); 933 qApp->processEvents();
933 QString fileName = mFileName; 934 QString fileName = mFileName;
934 QFile file( fileName ); 935 QFile file( fileName );
935 if (!file.open( IO_ReadOnly ) ) { 936 if (!file.open( IO_ReadOnly ) ) {
936 delete mSyncActionDialog; 937 delete mSyncActionDialog;
937 mSyncActionDialog = 0; 938 mSyncActionDialog = 0;
938 qDebug("KSS::error open file "); 939 qDebug("KSS::error open file ");
939 mSocket->close(); 940 mSocket->close();
940 if ( mSocket->state() == QSocket::Idle ) 941 if ( mSocket->state() == QSocket::Idle )
941 QTimer::singleShot( 10, this , SLOT ( discardClient())); 942 QTimer::singleShot( 10, this , SLOT ( discardClient()));
942 return ; 943 return ;
943 944
944 } 945 }
945 mSyncActionDialog->setCaption( i18n("Sending file...") ); 946 mSyncActionDialog->setCaption( i18n("Sending file...") );
946 QTextStream ts( &file ); 947 QTextStream ts( &file );
947 ts.setCodec( QTextCodec::codecForName("utf8") ); 948 ts.setCodec( QTextCodec::codecForName("utf8") );
948 QTextStream os( mSocket ); 949 QTextStream os( mSocket );
949 os.setCodec( QTextCodec::codecForName("utf8") ); 950 os.setCodec( QTextCodec::codecForName("utf8") );
950 //os.setEncoding( QTextStream::UnicodeUTF8 ); 951 //os.setEncoding( QTextStream::UnicodeUTF8 );
951 while ( ! ts.atEnd() ) { 952 while ( ! ts.atEnd() ) {
952 os << ts.readLine() << "\n"; 953 os << ts.readLine() << "\n";
953 } 954 }
954 //os << ts.read(); 955 //os << ts.read();
955 file.close(); 956 file.close();
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 52e2772..0eb3323 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -29,52 +29,50 @@ $Id$
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 51
52signals: 52signals:
53 //void sendFile(QSocket*);
54 //void getFile(QSocket*);
55 void file_received( bool ); 53 void file_received( bool );
56 //void file_sent(); 54 void request_file();
57 void saveFile(); 55 void saveFile();
58 void endConnect(); 56 void endConnect();
59private slots: 57private slots:
60 void discardClient(); 58 void discardClient();
61 void readClient(); 59 void readClient();
62 void readBackFileFromSocket(); 60 void readBackFileFromSocket();
63 private : 61 private :
64 bool blockRC; 62 bool blockRC;
65 void send_file(); 63 void send_file();
66 void get_file(); 64 void get_file();
67 void end_connect(); 65 void end_connect();
68 QDialog* mSyncActionDialog; 66 QDialog* mSyncActionDialog;
69 QSocket* mSocket; 67 QSocket* mSocket;
70 QString mPassWord; 68 QString mPassWord;
71 QString mFileName; 69 QString mFileName;
72 QTime piTime; 70 QTime piTime;
73 QString piFileString; 71 QString piFileString;
74}; 72};
75 73
76class KCommandSocket : public QObject 74class KCommandSocket : public QObject
77{ 75{
78 Q_OBJECT 76 Q_OBJECT
79public: 77public:
80 enum state { successR, errorR, successW, errorW, quiet }; 78 enum state { successR, errorR, successW, errorW, quiet };
@@ -135,48 +133,49 @@ class KSyncManager : public QObject
135 133
136 // sync stuff 134 // sync stuff
137 QString mLocalMachineName; 135 QString mLocalMachineName;
138 QStringList mExternSyncProfiles; 136 QStringList mExternSyncProfiles;
139 QStringList mSyncProfileNames; 137 QStringList mSyncProfileNames;
140 bool mAskForPreferences; 138 bool mAskForPreferences;
141 bool mShowSyncSummary; 139 bool mShowSyncSummary;
142 bool mShowSyncEvents; 140 bool mShowSyncEvents;
143 bool mShowTodoInAgenda; 141 bool mShowTodoInAgenda;
144 bool mWriteBackExistingOnly; 142 bool mWriteBackExistingOnly;
145 int mSyncAlgoPrefs; 143 int mSyncAlgoPrefs;
146 int mRingSyncAlgoPrefs; 144 int mRingSyncAlgoPrefs;
147 bool mWriteBackFile; 145 bool mWriteBackFile;
148 int mWriteBackInFuture; 146 int mWriteBackInFuture;
149 QString mPhoneDevice; 147 QString mPhoneDevice;
150 QString mPhoneConnection; 148 QString mPhoneConnection;
151 QString mPhoneModel; 149 QString mPhoneModel;
152 QString mLastSyncedLocalFile; // save! 150 QString mLastSyncedLocalFile; // save!
153 QString mPassWordPiSync; 151 QString mPassWordPiSync;
154 QString mActiveSyncPort; 152 QString mActiveSyncPort;
155 QString mActiveSyncIP ; 153 QString mActiveSyncIP ;
156 154
157 signals: 155 signals:
158 void save(); 156 void save();
157 void request_file();
159 void getFile( bool ); 158 void getFile( bool );
160 159
161 public slots: 160 public slots:
162 void slotSyncMenu( int ); 161 void slotSyncMenu( int );
163 162
164 private: 163 private:
165 // LR ******************************* 164 // LR *******************************
166 // sync stuff! 165 // sync stuff!
167 void syncPi(); 166 void syncPi();
168 void deleteCommandSocket(KCommandSocket*s, int state); 167 void deleteCommandSocket(KCommandSocket*s, int state);
169 void readFileFromSocket(); 168 void readFileFromSocket();
170 KServerSocket * mServerSocket; 169 KServerSocket * mServerSocket;
171 void enableQuick(); 170 void enableQuick();
172 KPimPrefs* mPrefs; 171 KPimPrefs* mPrefs;
173 QString mDefFileName; 172 QString mDefFileName;
174 QString mCurrentSyncDevice; 173 QString mCurrentSyncDevice;
175 QString mCurrentSyncName; 174 QString mCurrentSyncName;
176 void quickSyncLocalFile(); 175 void quickSyncLocalFile();
177 bool syncWithFile( QString fn , bool quick ); 176 bool syncWithFile( QString fn , bool quick );
178 void syncLocalFile(); 177 void syncLocalFile();
179 void syncPhone(); 178 void syncPhone();
180 void syncSharp(); 179 void syncSharp();
181 bool syncExternalApplication(QString); 180 bool syncExternalApplication(QString);
182 void multiSync( bool askforPrefs ); 181 void multiSync( bool askforPrefs );