-rw-r--r-- | libkdepim/ksyncprofile.cpp | 140 |
1 files changed, 79 insertions, 61 deletions
diff --git a/libkdepim/ksyncprofile.cpp b/libkdepim/ksyncprofile.cpp index fcbb326..15dc152 100644 --- a/libkdepim/ksyncprofile.cpp +++ b/libkdepim/ksyncprofile.cpp | |||
@@ -1,173 +1,191 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
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 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include <qcolor.h> | 23 | #include <qcolor.h> |
24 | 24 | ||
25 | #include <kconfig.h> | 25 | #include <kconfig.h> |
26 | #include <kstandarddirs.h> | 26 | #include <kstandarddirs.h> |
27 | #include <kglobal.h> | 27 | #include <kglobal.h> |
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include "ksyncprofile.h" | 30 | #include "ksyncprofile.h" |
31 | 31 | ||
32 | 32 | ||
33 | KSyncProfile::KSyncProfile( const char * name): QObject (0, name ) | 33 | KSyncProfile::KSyncProfile( const char * identifier): QObject (0, identifier ) |
34 | { | 34 | { |
35 | setDefault(); | 35 | setIdentifier( identifier ); |
36 | |||
37 | if (getIdentifier().isEmpty()) | ||
38 | setIdentifier( "noID" ); | ||
39 | |||
40 | setDefault(); | ||
36 | } | 41 | } |
37 | KSyncProfile::~KSyncProfile() | 42 | KSyncProfile::~KSyncProfile() |
38 | { | 43 | { |
39 | 44 | ||
40 | } | 45 | } |
41 | 46 | ||
42 | 47 | ||
43 | KSyncProfile* KSyncProfile::clone() | 48 | KSyncProfile* KSyncProfile::clone() |
44 | { | 49 | { |
45 | KSyncProfile* myClone = new KSyncProfile(); | 50 | KSyncProfile* myClone = new KSyncProfile(); |
46 | myClone->setPreSyncCommand( mPreSyncCommand ); | 51 | myClone->setPreSyncCommand( mPreSyncCommand ); |
47 | myClone->setPostSyncCommand( mPostSyncCommand ); | 52 | myClone->setPostSyncCommand( mPostSyncCommand ); |
48 | myClone->setLocalTempFile( mLocalTempFile); | 53 | myClone->setLocalTempFile( mLocalTempFile); |
49 | myClone->setRemoteFileName( mRemoteFileName ); | 54 | myClone->setRemoteFileName( mRemoteFileName ); |
50 | myClone->setPreSyncCommandAB( mPreSyncCommandAB ); | 55 | myClone->setPreSyncCommandAB( mPreSyncCommandAB ); |
51 | myClone->setPostSyncCommandAB( mPostSyncCommandAB ); | 56 | myClone->setPostSyncCommandAB( mPostSyncCommandAB ); |
52 | myClone->setLocalTempFileAB( mLocalTempFileAB); | 57 | myClone->setLocalTempFileAB( mLocalTempFileAB); |
53 | myClone->setRemoteFileNameAB( mRemoteFileNameAB ); | 58 | myClone->setRemoteFileNameAB( mRemoteFileNameAB ); |
54 | myClone->setShowSummaryAfterSync( mShowSummaryAfterSync ); | 59 | myClone->setShowSummaryAfterSync( mShowSummaryAfterSync ); |
55 | myClone->setAskForPreferences( mAskForPreferences); | 60 | myClone->setAskForPreferences( mAskForPreferences); |
56 | myClone->setWriteBackExisting(mWriteBackExisting ); | 61 | myClone->setWriteBackExisting(mWriteBackExisting ); |
57 | myClone->setWriteBackFile( mWriteBackFile); | 62 | myClone->setWriteBackFile( mWriteBackFile); |
58 | myClone->setWriteBackFuture( mWriteBackFuture ); | 63 | myClone->setWriteBackFuture( mWriteBackFuture ); |
59 | myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks ); | 64 | myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks ); |
60 | myClone->setIncludeInRingSync( mIncludeInRingSync ); | 65 | myClone->setIncludeInRingSync( mIncludeInRingSync ); |
61 | myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB ); | 66 | myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB ); |
62 | myClone->setSyncPrefs( mSyncPrefs); | 67 | myClone->setSyncPrefs( mSyncPrefs); |
63 | myClone->setIsLocalFileSync( mIsLocalFileSync ); | 68 | myClone->setIsLocalFileSync( mIsLocalFileSync ); |
64 | myClone->setIsPhoneSync( mIsPhoneSync ); | 69 | myClone->setIsPhoneSync( mIsPhoneSync ); |
65 | myClone->setName( "noName" ); | 70 | myClone->setName( "noName" ); |
71 | myClone->setIdentifier( "noID" ); | ||
66 | return myClone; | 72 | return myClone; |
67 | } | 73 | } |
68 | 74 | ||
69 | 75 | ||
70 | void KSyncProfile::setDefault() | 76 | void KSyncProfile::setDefault() |
71 | { | 77 | { |
72 | mName = "noName"; | ||
73 | mPreSyncCommand = i18n("command for downloading remote file to local device"); | 78 | mPreSyncCommand = i18n("command for downloading remote file to local device"); |
74 | mPostSyncCommand = i18n("command for uploading local temp file to remote device"); | 79 | mPostSyncCommand = i18n("command for uploading local temp file to remote device"); |
75 | mLocalTempFile = "/tmp/mycalendar.ics"; | 80 | mLocalTempFile = "/tmp/mycalendar.ics"; |
76 | mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics"; | 81 | mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics"; |
77 | mPreSyncCommandAB = i18n("command for downloading remote file to local device"); | 82 | mPreSyncCommandAB = i18n("command for downloading remote file to local device"); |
78 | mPostSyncCommandAB = i18n("command for uploading local temp file to remote device"); | 83 | mPostSyncCommandAB = i18n("command for uploading local temp file to remote device"); |
79 | mLocalTempFileAB = "/tmp/std.vcf"; | 84 | mLocalTempFileAB = "/tmp/std.vcf"; |
80 | mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf"; | 85 | mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf"; |
81 | mShowSummaryAfterSync = true; | 86 | mShowSummaryAfterSync = true; |
82 | mAskForPreferences = true; | 87 | mAskForPreferences = true; |
83 | mWriteBackExisting = false; | 88 | mWriteBackExisting = false; |
84 | mWriteBackFuture = false; | 89 | mWriteBackFuture = false; |
85 | mWriteBackFutureWeeks = 12; | 90 | mWriteBackFutureWeeks = 12; |
86 | mWriteBackFile = true; | 91 | mWriteBackFile = true; |
87 | mIncludeInRingSync = false; | 92 | mIncludeInRingSync = false; |
88 | mIncludeInRingSyncAB = false; | 93 | mIncludeInRingSyncAB = false; |
89 | mSyncPrefs = SYNC_PREF_ASK; | 94 | mSyncPrefs = SYNC_PREF_ASK; |
90 | mIsLocalFileSync = true; | 95 | mIsLocalFileSync = true; |
91 | mIsPhoneSync = false; | 96 | mName = "noName"; |
97 | mIsPhoneSync = false; | ||
92 | mPhoneDevice = "/dev/ircomm"; | 98 | mPhoneDevice = "/dev/ircomm"; |
93 | mPhoneConnection = "irda"; | 99 | mPhoneConnection = "irda"; |
94 | mPhoneModel = "6310i"; | 100 | mPhoneModel = "6310i"; |
95 | |||
96 | } | 101 | } |
97 | void KSyncProfile::readConfig(KConfig *config ) | 102 | void KSyncProfile::readConfig(KConfig *config ) |
98 | { | 103 | { |
99 | config->setGroup(mName); | 104 | if (config) |
100 | QString prefix = ""; | 105 | { |
101 | //mName = config->readEntry( prefix+ "Name", mName ); | 106 | |
102 | mPreSyncCommand = config->readEntry( prefix+ "PreSyncCommand",mPreSyncCommand ); | 107 | config->setGroup("SyncProfile_" + mIdentifier); |
103 | mPostSyncCommand = config->readEntry( prefix+ "PostSyncCommand", mPostSyncCommand );; | 108 | |
104 | mLocalTempFile = config->readEntry( prefix+ "LocalTempFile", mLocalTempFile ); | 109 | mName = config->readEntry( "Name", mName ); |
105 | mRemoteFileName = config->readEntry( prefix+ "RemoteFileName", mRemoteFileName ); | 110 | mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand ); |
106 | 111 | mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand ); | |
107 | mPreSyncCommandAB = config->readEntry( prefix+ "PreSyncCommandAB",mPreSyncCommandAB ); | 112 | mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile ); |
108 | mPostSyncCommandAB = config->readEntry( prefix+ "PostSyncCommandAB", mPostSyncCommandAB ); | 113 | mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName ); |
109 | mLocalTempFileAB = config->readEntry( prefix+ "LocalTempFileAB", mLocalTempFileAB ); | 114 | |
110 | mRemoteFileNameAB = config->readEntry( prefix+ "RemoteFileNameAB", mRemoteFileNameAB ); | 115 | mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB ); |
111 | 116 | mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB ); | |
112 | 117 | mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB ); | |
113 | mPhoneDevice = config->readEntry( prefix+ "PhoneDevice", mPhoneDevice ); | 118 | mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB ); |
114 | mPhoneConnection = config->readEntry( prefix+ "PhoneConnection", mPhoneConnection ); | 119 | |
115 | mPhoneModel = config->readEntry( prefix+ "PhoneModel", mPhoneModel ); | 120 | mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice ); |
116 | 121 | mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection ); | |
117 | mIncludeInRingSync = config->readBoolEntry( prefix+ "IncludeInRingSync",mIncludeInRingSync ); | 122 | mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel ); |
118 | mIncludeInRingSyncAB = config->readBoolEntry( prefix+ "IncludeInRingSyncAB",mIncludeInRingSyncAB ); | 123 | |
119 | mShowSummaryAfterSync = config->readBoolEntry( prefix+ "ShowSummaryAfterSync", mShowSummaryAfterSync ); | 124 | mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync ); |
120 | mAskForPreferences = config->readBoolEntry( prefix+ "AskForPreferences",mAskForPreferences ); | 125 | mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); |
121 | mWriteBackExisting = config->readBoolEntry( prefix+ "WriteBackExisting",mWriteBackExisting ); | 126 | mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); |
122 | mWriteBackFuture = config->readBoolEntry( prefix+ "WriteBackFuture",mWriteBackFuture ); | 127 | mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences ); |
123 | mSyncPrefs = config->readNumEntry( prefix+ "SyncPrefs", mSyncPrefs ); | 128 | mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting ); |
124 | mWriteBackFutureWeeks = config->readNumEntry( prefix+ "WriteBackFutureWeeks", mWriteBackFutureWeeks ); | 129 | mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture ); |
125 | mIsLocalFileSync= config->readBoolEntry( prefix+ "IsLocalFileSync", mIsLocalFileSync ); | 130 | mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs ); |
126 | mIsPhoneSync= config->readBoolEntry( prefix+ "IsPhoneSync", mIsPhoneSync ); | 131 | mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks ); |
132 | mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync ); | ||
133 | mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync ); | ||
134 | } | ||
135 | else | ||
136 | { | ||
137 | setDefault(); | ||
138 | } | ||
127 | } | 139 | } |
140 | |||
141 | void KSyncProfile::deleteConfig(KConfig *config ) | ||
142 | { | ||
143 | config->deleteGroup( "SyncProfile_" + mIdentifier ); | ||
144 | } | ||
145 | |||
128 | void KSyncProfile::writeConfig( KConfig * config ) | 146 | void KSyncProfile::writeConfig( KConfig * config ) |
129 | { | 147 | { |
130 | config->setGroup(mName ); | 148 | config->setGroup("SyncProfile_" + mIdentifier); |
131 | QString prefix = ""; | 149 | |
132 | // config->writeEntry( prefix+ "Name", mName ); | 150 | config->writeEntry( "Name", mName ); |
133 | config->writeEntry( prefix+ "PreSyncCommand",mPreSyncCommand ); | 151 | config->writeEntry( "PreSyncCommand",mPreSyncCommand ); |
134 | config->writeEntry( prefix+ "PostSyncCommand", mPostSyncCommand ); | 152 | config->writeEntry( "PostSyncCommand", mPostSyncCommand ); |
135 | config->writeEntry( prefix+ "LocalTempFile", mLocalTempFile ); | 153 | config->writeEntry( "LocalTempFile", mLocalTempFile ); |
136 | config->writeEntry( prefix+ "RemoteFileName", mRemoteFileName ); | 154 | config->writeEntry( "RemoteFileName", mRemoteFileName ); |
137 | 155 | ||
138 | config->writeEntry( prefix+ "PreSyncCommandAB",mPreSyncCommandAB ); | 156 | config->writeEntry( "PreSyncCommandAB",mPreSyncCommandAB ); |
139 | config->writeEntry( prefix+ "PostSyncCommandAB", mPostSyncCommandAB ); | 157 | config->writeEntry( "PostSyncCommandAB", mPostSyncCommandAB ); |
140 | config->writeEntry( prefix+ "LocalTempFileAB", mLocalTempFileAB ); | 158 | config->writeEntry( "LocalTempFileAB", mLocalTempFileAB ); |
141 | config->writeEntry( prefix+ "RemoteFileNameAB", mRemoteFileNameAB ); | 159 | config->writeEntry( "RemoteFileNameAB", mRemoteFileNameAB ); |
142 | 160 | ||
143 | config->writeEntry( prefix+ "PhoneDevice", mPhoneDevice ); | 161 | config->writeEntry( "PhoneDevice", mPhoneDevice ); |
144 | config->writeEntry( prefix+ "PhoneConnection", mPhoneConnection ); | 162 | config->writeEntry( "PhoneConnection", mPhoneConnection ); |
145 | config->writeEntry( prefix+ "PhoneModel", mPhoneModel ); | 163 | config->writeEntry( "PhoneModel", mPhoneModel ); |
146 | 164 | ||
147 | config->writeEntry( prefix+ "IncludeInRingSync",mIncludeInRingSync ); | 165 | config->writeEntry( "IncludeInRingSync",mIncludeInRingSync ); |
148 | config->writeEntry( prefix+ "IncludeInRingSyncAB",mIncludeInRingSyncAB ); | 166 | config->writeEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); |
149 | config->writeEntry( prefix+ "ShowSummaryAfterSync", mShowSummaryAfterSync ); | 167 | config->writeEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); |
150 | config->writeEntry( prefix+ "AskForPreferences",mAskForPreferences ); | 168 | config->writeEntry( "AskForPreferences",mAskForPreferences ); |
151 | config->writeEntry( prefix+ "WriteBackExisting",mWriteBackExisting ); | 169 | config->writeEntry( "WriteBackExisting",mWriteBackExisting ); |
152 | config->writeEntry( prefix+ "WriteBackFuture",mWriteBackFuture ); | 170 | config->writeEntry( "WriteBackFuture",mWriteBackFuture ); |
153 | config->writeEntry( prefix+ "SyncPrefs", mSyncPrefs ); | 171 | config->writeEntry( "SyncPrefs", mSyncPrefs ); |
154 | config->writeEntry( prefix+ "WriteBackFutureWeeks", mWriteBackFutureWeeks); | 172 | config->writeEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks); |
155 | config->writeEntry( prefix+ "IsLocalFileSync", mIsLocalFileSync ); | 173 | config->writeEntry( "IsLocalFileSync", mIsLocalFileSync ); |
156 | config->writeEntry( prefix+ "IsPhoneSync", mIsPhoneSync ); | 174 | config->writeEntry( "IsPhoneSync", mIsPhoneSync ); |
157 | } | 175 | } |
158 | 176 | ||
159 | /* | 177 | /* |
160 | class KPrefsItemInt : public KPrefsItem { | 178 | class KPrefsItemInt : public KPrefsItem { |
161 | public: | 179 | public: |
162 | KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0); | 180 | KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0); |
163 | virtual ~KPrefsItemInt() {} | 181 | virtual ~KPrefsItemInt() {} |
164 | 182 | ||
165 | void setDefault(); | 183 | void setDefault(); |
166 | void readConfig(KConfig *); | 184 | void readConfig(KConfig *); |
167 | void writeConfig(KConfig *); | 185 | void writeConfig(KConfig *); |
168 | 186 | ||
169 | private: | 187 | private: |
170 | int *mReference; | 188 | int *mReference; |
171 | int mDefault; | 189 | int mDefault; |
172 | }; | 190 | }; |
173 | */ | 191 | */ |