summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.h
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.h107
1 files changed, 94 insertions, 13 deletions
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 6b10016..52e2772 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,147 +1,228 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20$Id$ 20$Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h>
28#include <qdatetime.h>
29#include <qserversocket.h>
30#include <qtextstream.h>
31#include <qregexp.h>
27 32
28class QPopupMenu; 33class QPopupMenu;
29class KSyncProfile; 34class KSyncProfile;
30class KPimPrefs; 35class KPimPrefs;
31class QWidget; 36class QWidget;
32class KSyncManager; 37class KSyncManager;
33class KSyncInterface; 38class KSyncInterface;
34class QProgressBar; 39class QProgressBar;
35 40
41
42class KServerSocket : public QServerSocket
43{
44 Q_OBJECT
45
46public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48
49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;};
51
52signals:
53 //void sendFile(QSocket*);
54 //void getFile(QSocket*);
55 void file_received( bool );
56 //void file_sent();
57 void saveFile();
58 void endConnect();
59private slots:
60 void discardClient();
61 void readClient();
62 void readBackFileFromSocket();
63 private :
64 bool blockRC;
65 void send_file();
66 void get_file();
67 void end_connect();
68 QDialog* mSyncActionDialog;
69 QSocket* mSocket;
70 QString mPassWord;
71 QString mFileName;
72 QTime piTime;
73 QString piFileString;
74};
75
76class KCommandSocket : public QObject
77{
78 Q_OBJECT
79public:
80 enum state { successR, errorR, successW, errorW, quiet };
81 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
82 void readFile( QString );
83 void writeFile( QString );
84 void sendStop();
85
86
87signals:
88 void commandFinished( KCommandSocket*, int );
89private slots:
90 void startReadFileFromSocket();
91 void readFileFromSocket();
92 void deleteSocket();
93 void writeFileToSocket();
94 private :
95 QSocket* mSocket;
96 QString mPassWord;
97 Q_UINT16 mPort;
98 QString mHost;
99 QString mFileName;
100 QTimer* mTimerSocket;
101 int mRetVal;
102 QTime mTime;
103 QString mFileString;
104 bool mFirst;
105};
106
107
36class KSyncManager : public QObject 108class KSyncManager : public QObject
37{ 109{
38 Q_OBJECT 110 Q_OBJECT
39 111
40 public: 112 public:
41 enum TargetApp { 113 enum TargetApp {
42 KOPI = 0, 114 KOPI = 0,
43 KAPI = 1, 115 KAPI = 1,
44 PWMPI = 2 }; 116 PWMPI = 2 };
45 117
46 118
47 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 119 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
48 ~KSyncManager() ; 120 ~KSyncManager() ;
49 121
50 bool blockSave() { return mBlockSaveFlag; } 122 bool blockSave() { return mBlockSaveFlag; }
51 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 123 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
52 124 void setDefaultFileName( QString s) { mDefFileName = s ;}
125 QString defaultFileName() { return mDefFileName ;}
126 QString syncFileName();
53 void fillSyncMenu(); 127 void fillSyncMenu();
54 128
55 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 129 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
56 QString getCurrentSyncName() { return mCurrentSyncName; } 130 QString getCurrentSyncName() { return mCurrentSyncName; }
57 131
58 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 132 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
59 void hideProgressBar(); 133 void hideProgressBar();
60 bool isProgressBarCanceled(); 134 bool isProgressBarCanceled();
61 135
62 // sync stuff 136 // sync stuff
63 QString mLocalMachineName; 137 QString mLocalMachineName;
64 QStringList mExternSyncProfiles; 138 QStringList mExternSyncProfiles;
65 QStringList mSyncProfileNames; 139 QStringList mSyncProfileNames;
66 bool mAskForPreferences; 140 bool mAskForPreferences;
67 bool mShowSyncSummary; 141 bool mShowSyncSummary;
68 bool mShowSyncEvents; 142 bool mShowSyncEvents;
69 bool mShowTodoInAgenda; 143 bool mShowTodoInAgenda;
70 bool mWriteBackExistingOnly; 144 bool mWriteBackExistingOnly;
71 int mSyncAlgoPrefs; 145 int mSyncAlgoPrefs;
72 int mRingSyncAlgoPrefs; 146 int mRingSyncAlgoPrefs;
73 bool mWriteBackFile; 147 bool mWriteBackFile;
74 int mWriteBackInFuture; 148 int mWriteBackInFuture;
75 QString mPhoneDevice; 149 QString mPhoneDevice;
76 QString mPhoneConnection; 150 QString mPhoneConnection;
77 QString mPhoneModel; 151 QString mPhoneModel;
78 QString mLastSyncedLocalFile; // save! 152 QString mLastSyncedLocalFile; // save!
153 QString mPassWordPiSync;
154 QString mActiveSyncPort;
155 QString mActiveSyncIP ;
79 156
80 157 signals:
158 void save();
159 void getFile( bool );
81 160
82 public slots: 161 public slots:
83 void slotSyncMenu( int ); 162 void slotSyncMenu( int );
84 163
85 private: 164 private:
86 // LR ******************************* 165 // LR *******************************
87 // sync stuff! 166 // sync stuff!
167 void syncPi();
168 void deleteCommandSocket(KCommandSocket*s, int state);
169 void readFileFromSocket();
170 KServerSocket * mServerSocket;
171 void enableQuick();
172 KPimPrefs* mPrefs;
173 QString mDefFileName;
88 QString mCurrentSyncDevice; 174 QString mCurrentSyncDevice;
89 QString mCurrentSyncName; 175 QString mCurrentSyncName;
90 void quickSyncLocalFile(); 176 void quickSyncLocalFile();
91 bool syncWithFile( QString fn , bool quick ); 177 bool syncWithFile( QString fn , bool quick );
92 void syncLocalFile(); 178 void syncLocalFile();
93 void syncPhone(); 179 void syncPhone();
94 void syncSharp(); 180 void syncSharp();
95 bool syncExternalApplication(QString); 181 bool syncExternalApplication(QString);
96 void multiSync( bool askforPrefs ); 182 void multiSync( bool askforPrefs );
97 int mCurrentSyncProfile ; 183 int mCurrentSyncProfile ;
98 void syncRemote( KSyncProfile* prof, bool ask = true); 184 void syncRemote( KSyncProfile* prof, bool ask = true);
99 void edit_sync_options(); 185 void edit_sync_options();
100 int ringSync(); 186 int ringSync();
101 QString getPassword( ); 187 QString getPassword( );
102 188
103 private slots: 189 private slots:
104 void confSync(); 190 void confSync();
105 // ********************* 191 // *********************
106 192
107 private: 193 private:
108 bool mBlockSaveFlag; 194 bool mBlockSaveFlag;
109 195
110 196
111 QWidget* mParent; 197 QWidget* mParent;
112 KSyncInterface* mImplementation; 198 KSyncInterface* mImplementation;
113 TargetApp mTargetApp; 199 TargetApp mTargetApp;
114 QPopupMenu* mSyncMenu; 200 QPopupMenu* mSyncMenu;
115 201
116 QProgressBar* bar; 202 QProgressBar* bar;
117 203
118 204
119 205
120 206
121 207
122}; 208};
123 209
124 210
125class KSyncInterface 211class KSyncInterface
126{ 212{
127 public: 213
214
215 public :
128 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 216 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
129 217
130 virtual bool syncExternal(KSyncManager* manager, QString resource) 218 virtual bool syncExternal(KSyncManager* manager, QString resource)
131 { 219 {
132 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. 220 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager.
133 return false; 221 return false;
134 } 222 }
135 223
136 //called by the syncmanager to indicate that the work has to be marked as dirty. 224
137 virtual void sync_setModified() = 0;
138
139 //called by the syncmanager to ask if the dirty flag is set.
140 virtual bool sync_isModified() = 0;
141
142 //called by the syncmanager to indicate that the work has to be saved.
143 virtual void sync_save() = 0;
144}; 225};
145 226
146 227
147#endif 228#endif