author | zautrix <zautrix> | 2004-10-29 14:01:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-29 14:01:58 (UTC) |
commit | 102cc4a711e303372efea9797623ee2d9f27f63c (patch) (unidiff) | |
tree | 32e56b436e52b5b1bab701839a24fc175288d57c | |
parent | 8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8 (diff) | |
download | kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.zip kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.tar.gz kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.tar.bz2 |
removed debug output
-rw-r--r-- | kabc/addressbook.cpp | 11 | ||||
-rw-r--r-- | kabc/addressbook.h | 1 | ||||
-rw-r--r-- | kabc/addressee.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 215 | ||||
-rw-r--r-- | kabc/tmpaddressbook.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 31 |
6 files changed, 78 insertions, 191 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 4c4ae09..8487ff3 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1151,24 +1151,35 @@ QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | |||
1151 | bool AddressBook::addResource( Resource *resource ) | 1151 | bool AddressBook::addResource( Resource *resource ) |
1152 | { | 1152 | { |
1153 | if ( !resource->open() ) { | 1153 | if ( !resource->open() ) { |
1154 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 1154 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
1155 | return false; | 1155 | return false; |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | resource->setAddressBook( this ); | 1158 | resource->setAddressBook( this ); |
1159 | 1159 | ||
1160 | d->mManager->add( resource ); | 1160 | d->mManager->add( resource ); |
1161 | return true; | 1161 | return true; |
1162 | } | 1162 | } |
1163 | void AddressBook::removeResources() | ||
1164 | { | ||
1165 | //remove all possible resources. This should cleanup the configfile. | ||
1166 | QPtrList<KABC::Resource> mResources = resources(); | ||
1167 | |||
1168 | QPtrListIterator<KABC::Resource> it(mResources); | ||
1169 | for ( ; it.current(); ++it ) { | ||
1170 | KABC::Resource *res = it.current(); | ||
1171 | removeResource(res); | ||
1172 | } | ||
1173 | } | ||
1163 | 1174 | ||
1164 | bool AddressBook::removeResource( Resource *resource ) | 1175 | bool AddressBook::removeResource( Resource *resource ) |
1165 | { | 1176 | { |
1166 | resource->close(); | 1177 | resource->close(); |
1167 | 1178 | ||
1168 | if ( resource == standardResource() ) | 1179 | if ( resource == standardResource() ) |
1169 | d->mManager->setStandardResource( 0 ); | 1180 | d->mManager->setStandardResource( 0 ); |
1170 | 1181 | ||
1171 | resource->setAddressBook( 0 ); | 1182 | resource->setAddressBook( 0 ); |
1172 | 1183 | ||
1173 | d->mManager->remove( resource ); | 1184 | d->mManager->remove( resource ); |
1174 | return true; | 1185 | return true; |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 75f8b51..2351add 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -265,24 +265,25 @@ class AddressBook : public QObject | |||
265 | const QString &key = QString::null, | 265 | const QString &key = QString::null, |
266 | const QString &app = QString::null ); | 266 | const QString &app = QString::null ); |
267 | 267 | ||
268 | 268 | ||
269 | /** | 269 | /** |
270 | Add address book resource. | 270 | Add address book resource. |
271 | */ | 271 | */ |
272 | bool addResource( Resource * ); | 272 | bool addResource( Resource * ); |
273 | 273 | ||
274 | /** | 274 | /** |
275 | Remove address book resource. | 275 | Remove address book resource. |
276 | */ | 276 | */ |
277 | void removeResources(); | ||
277 | bool removeResource( Resource * ); | 278 | bool removeResource( Resource * ); |
278 | 279 | ||
279 | /** | 280 | /** |
280 | Return pointer list of all resources. | 281 | Return pointer list of all resources. |
281 | */ | 282 | */ |
282 | QPtrList<Resource> resources(); | 283 | QPtrList<Resource> resources(); |
283 | 284 | ||
284 | /** | 285 | /** |
285 | Set the @p ErrorHandler, that is used by @ref error() to | 286 | Set the @p ErrorHandler, that is used by @ref error() to |
286 | provide gui-independend error messages. | 287 | provide gui-independend error messages. |
287 | */ | 288 | */ |
288 | void setErrorHandler( ErrorHandler * ); | 289 | void setErrorHandler( ErrorHandler * ); |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3d4992c..028d3bb 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -263,25 +263,25 @@ void Addressee::computeCsum(const QString &dev) | |||
263 | l.append( t[iii] ); | 263 | l.append( t[iii] ); |
264 | 264 | ||
265 | } | 265 | } |
266 | KABC::Address::List::Iterator addressIter; | 266 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 268 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 269 | t = (*addressIter).asList(); |
270 | t.sort(); | 270 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 271 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 272 | l.append( t[iii] ); |
273 | } | 273 | } |
274 | uint cs = getCsum4List(l); | 274 | uint cs = getCsum4List(l); |
275 | #if 1 | 275 | #if 0 |
276 | for ( iii = 0; iii < l.count(); ++iii) | 276 | for ( iii = 0; iii < l.count(); ++iii) |
277 | qDebug("%d***%s***",iii,l[iii].latin1()); | 277 | qDebug("%d***%s***",iii,l[iii].latin1()); |
278 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 278 | qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
279 | #endif | 279 | #endif |
280 | setCsum( dev, QString::number (cs )); | 280 | setCsum( dev, QString::number (cs )); |
281 | } | 281 | } |
282 | 282 | ||
283 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 283 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
284 | { | 284 | { |
285 | 285 | ||
286 | detach(); | 286 | detach(); |
287 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 287 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index ba17c50..48b7d91 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -58,184 +58,145 @@ using namespace KABC; | |||
58 | extern "C" | 58 | extern "C" |
59 | { | 59 | { |
60 | void *init_microkabc_sharpdtm() | 60 | void *init_microkabc_sharpdtm() |
61 | { | 61 | { |
62 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>(); | 62 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>(); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) | 66 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) |
67 | : Resource( config ), mConverter (0) | 67 | : Resource( config ), mConverter (0) |
68 | { | 68 | { |
69 | // we can not choose the filename. Therefore use the default to display | 69 | // we can not choose the filename. Therefore use the default to display |
70 | 70 | mAccess = 0; | |
71 | QString fileName = SlZDataBase::addressbookFileName(); | 71 | QString fileName = SlZDataBase::addressbookFileName(); |
72 | init( fileName ); | 72 | init( fileName ); |
73 | } | 73 | } |
74 | 74 | ||
75 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName ) | 75 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName ) |
76 | : Resource( 0 ) | 76 | : Resource( 0 ) |
77 | { | 77 | { |
78 | init( fileName ); | 78 | mAccess = 0; |
79 | init( fileName ); | ||
79 | } | 80 | } |
80 | 81 | ||
81 | void ResourceSharpDTM::init( const QString &fileName ) | 82 | void ResourceSharpDTM::init( const QString &fileName ) |
82 | { | 83 | { |
83 | |||
84 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | ||
85 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | ||
86 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | ||
87 | |||
88 | setFileName( fileName ); | 84 | setFileName( fileName ); |
89 | } | 85 | } |
90 | 86 | ||
91 | ResourceSharpDTM::~ResourceSharpDTM() | 87 | ResourceSharpDTM::~ResourceSharpDTM() |
92 | { | 88 | { |
93 | if (mConverter != 0) | 89 | if (mConverter != 0) |
94 | delete mConverter; | 90 | delete mConverter; |
95 | 91 | ||
96 | if(mAccess != 0) | 92 | if(mAccess != 0) |
97 | delete mAccess; | 93 | delete mAccess; |
98 | } | 94 | } |
99 | 95 | ||
100 | void ResourceSharpDTM::writeConfig( KConfig *config ) | 96 | void ResourceSharpDTM::writeConfig( KConfig *config ) |
101 | { | 97 | { |
102 | Resource::writeConfig( config ); | 98 | Resource::writeConfig( config ); |
103 | } | 99 | } |
104 | 100 | ||
105 | Ticket *ResourceSharpDTM::requestSaveTicket() | 101 | Ticket *ResourceSharpDTM::requestSaveTicket() |
106 | { | 102 | { |
107 | |||
108 | 103 | ||
109 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); | 104 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); |
110 | 105 | ||
111 | if ( !addressBook() ) return 0; | 106 | if ( !addressBook() ) return 0; |
112 | |||
113 | #ifdef ALLOW_LOCKING | ||
114 | if ( !lock( fileName() ) ) { | ||
115 | qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); | ||
116 | return 0; | ||
117 | } | ||
118 | #endif | ||
119 | return createTicket( this ); | 107 | return createTicket( this ); |
120 | } | 108 | } |
121 | 109 | ||
122 | 110 | ||
123 | bool ResourceSharpDTM::doOpen() | 111 | bool ResourceSharpDTM::doOpen() |
124 | { | 112 | { |
125 | qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1()); | 113 | qDebug("%xResourceSharpDTM::doOpen: %s", this,fileName().latin1()); |
126 | |||
127 | // the last parameter in the SlZDataBase constructor means "readonly" | ||
128 | mAccess = new SlZDataBase(fileName(), | ||
129 | SlZDataBase::addressbookItems(), | ||
130 | NULL, false); | ||
131 | 114 | ||
132 | if ( !mAccess ) { | 115 | if ( ! mAccess ) { |
133 | qDebug("Unable to load file() %s", fileName().latin1()); | 116 | // the last parameter in the SlZDataBase constructor means "readonly" |
134 | return false; | 117 | mAccess = new SlZDataBase(fileName(), |
135 | } | 118 | SlZDataBase::addressbookItems(), |
136 | 119 | NULL, false); | |
137 | if (mConverter == 0) | ||
138 | { | ||
139 | mConverter = new SharpDTMConverter(); | ||
140 | bool res = mConverter->init(); | ||
141 | if ( !res ) | ||
142 | { | ||
143 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); | ||
144 | |||
145 | qDebug(msg); | ||
146 | delete mAccess; | ||
147 | mAccess = 0; | ||
148 | return false; | ||
149 | } | 120 | } |
150 | } | 121 | if ( !mAccess ) { |
151 | 122 | qDebug("Unable to load file() %s", fileName().latin1()); | |
152 | return true; | 123 | return false; |
124 | } | ||
125 | if (mConverter == 0) { | ||
126 | mConverter = new SharpDTMConverter(); | ||
127 | bool res = mConverter->init(); | ||
128 | if ( !res ) | ||
129 | { | ||
130 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); | ||
131 | qDebug(msg); | ||
132 | delete mAccess; | ||
133 | mAccess = 0; | ||
134 | return false; | ||
135 | } | ||
136 | } | ||
137 | return true; | ||
153 | } | 138 | } |
154 | 139 | ||
155 | void ResourceSharpDTM::doClose() | 140 | void ResourceSharpDTM::doClose() |
156 | { | 141 | { |
157 | qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1()); | ||
158 | |||
159 | if(mAccess) | ||
160 | { | ||
161 | delete mAccess; | ||
162 | mAccess = 0; | ||
163 | } | ||
164 | // it seems so, that deletion of access deletes backend as well | ||
165 | //delete backend; | ||
166 | |||
167 | return; | 142 | return; |
168 | } | 143 | } |
169 | 144 | ||
170 | bool ResourceSharpDTM::load() | 145 | bool ResourceSharpDTM::load() |
171 | { | 146 | { |
172 | qDebug("ResourceSharpDTM::load: %s", fileName().latin1()); | 147 | qDebug("%xResourceSharpDTM::load: %s",this, fileName().latin1()); |
173 | 148 | bool res = false; | |
174 | bool res = false; | 149 | CardId id; |
175 | 150 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) | |
176 | CardId id; | 151 | { |
177 | 152 | id = mAccess->cardId(); | |
178 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) | 153 | KABC::Addressee addressee; |
179 | { | 154 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
180 | id = mAccess->cardId(); | 155 | if ( !addressee.isEmpty() && res ) |
181 | 156 | { | |
182 | KABC::Addressee addressee; | 157 | addressee.setResource( this ); |
183 | 158 | addressBook()->insertAddressee( addressee ); | |
184 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 159 | } |
185 | 160 | } | |
186 | if ( !addressee.isEmpty() && res ) | 161 | return true; |
187 | { | ||
188 | addressee.setResource( this ); | ||
189 | addressBook()->insertAddressee( addressee ); | ||
190 | } | ||
191 | } | ||
192 | |||
193 | return true; | ||
194 | } | 162 | } |
195 | 163 | ||
196 | bool ResourceSharpDTM::save( Ticket *ticket ) | 164 | bool ResourceSharpDTM::save( Ticket *ticket ) |
197 | { | 165 | { |
198 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); | 166 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); |
199 | |||
200 | mDirWatch.stopScan(); | ||
201 | |||
202 | KABC::AddressBook::Iterator it; | 167 | KABC::AddressBook::Iterator it; |
203 | bool res; | 168 | bool res; |
204 | KABC::Addressee::List changedAddressees; | 169 | KABC::Addressee::List changedAddressees; |
205 | typedef QMap<int,QString> AddresseeMap; | 170 | typedef QMap<int,QString> AddresseeMap; |
206 | AddresseeMap map; | 171 | AddresseeMap map; |
207 | CardId id ; | 172 | CardId id ; |
208 | |||
209 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 173 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
210 | 174 | ||
211 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 175 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
212 | QString uid = (*it).originalExternalUID(); | 176 | QString uid = (*it).originalExternalUID(); |
213 | bool res; | 177 | bool res; |
214 | if ( uid.isEmpty() ) | 178 | if ( uid.isEmpty() ) |
215 | id = 0; | 179 | id = 0; |
216 | else | 180 | else |
217 | id = uid.toUInt(); | 181 | id = uid.toUInt(); |
218 | KABC::Addressee addressee = (*it); | 182 | KABC::Addressee addressee = (*it); |
219 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | 183 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { |
220 | res = mAccess->startEditCard(id); | 184 | res = mAccess->startEditCard(id); |
221 | if (res == true) | 185 | if (res == true) |
222 | { | 186 | { |
223 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 187 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
224 | if (res == true) | 188 | if (res == true) |
225 | { | 189 | { |
226 | res = mAccess->finishEditCard(&id); | 190 | res = mAccess->finishEditCard(&id);; |
227 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
228 | //(*it).setExternalUID( QString::number( id ) ); | ||
229 | //(*it).setOriginalExternalUID( QString::number( id ) ); | ||
230 | map.insert(id,(*it).uid()); | 191 | map.insert(id,(*it).uid()); |
231 | if (res == false) | 192 | if (res == false) |
232 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 193 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
233 | 194 | ||
234 | } | 195 | } |
235 | else | 196 | else |
236 | { | 197 | { |
237 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 198 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
238 | mAccess->cancelEditCard(); | 199 | mAccess->cancelEditCard(); |
239 | } | 200 | } |
240 | } | 201 | } |
241 | 202 | ||
@@ -245,29 +206,27 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
245 | qDebug("delete error "); | 206 | qDebug("delete error "); |
246 | 207 | ||
247 | 208 | ||
248 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 209 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
249 | //changed | 210 | //changed |
250 | res = mAccess->startEditCard(id); | 211 | res = mAccess->startEditCard(id); |
251 | if (res == true) | 212 | if (res == true) |
252 | { | 213 | { |
253 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 214 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
254 | if (res == true) | 215 | if (res == true) |
255 | { | 216 | { |
256 | res = mAccess->finishEditCard(&id); | 217 | res = mAccess->finishEditCard(&id); |
257 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | ||
258 | map.insert(id,(*it).uid()); | 218 | map.insert(id,(*it).uid()); |
259 | if (res == false) | 219 | if (res == false) |
260 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 220 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
261 | |||
262 | } | 221 | } |
263 | else | 222 | else |
264 | { | 223 | { |
265 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 224 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
266 | mAccess->cancelEditCard(); | 225 | mAccess->cancelEditCard(); |
267 | } | 226 | } |
268 | } | 227 | } |
269 | } | 228 | } |
270 | } | 229 | } |
271 | 230 | ||
272 | } | 231 | } |
273 | AddresseeMap::Iterator itam; | 232 | AddresseeMap::Iterator itam; |
@@ -280,126 +239,46 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
280 | KABC::Addressee addressee; | 239 | KABC::Addressee addressee; |
281 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 240 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
282 | 241 | ||
283 | if ( !addressee.isEmpty() && res ) | 242 | if ( !addressee.isEmpty() && res ) |
284 | { | 243 | { |
285 | addressee.setResource( this ); | 244 | addressee.setResource( this ); |
286 | addressee.setUid( itam.data() ); | 245 | addressee.setUid( itam.data() ); |
287 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 246 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
288 | addressBook()->insertAddressee( addressee , false ); | 247 | addressBook()->insertAddressee( addressee , false ); |
289 | } | 248 | } |
290 | } | 249 | } |
291 | } | 250 | } |
292 | |||
293 | //US mAccess->save(); | ||
294 | |||
295 | mDirWatch.startScan(); | ||
296 | delete ticket; | 251 | delete ticket; |
297 | unlock( fileName() ); | ||
298 | 252 | ||
299 | return true; | 253 | return true; |
300 | } | 254 | } |
301 | 255 | ||
302 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 256 | bool ResourceSharpDTM::lock( const QString &lockfileName ) |
303 | { | 257 | { |
304 | #ifdef ALLOW_LOCKING | ||
305 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); | ||
306 | |||
307 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; | ||
308 | |||
309 | QString fn = lockfileName; | ||
310 | |||
311 | KURL url(fn); | ||
312 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | ||
313 | |||
314 | kdDebug(5700) << "-- lock name: " << lockName << endl; | ||
315 | |||
316 | if (QFile::exists( lockName )) | ||
317 | { | ||
318 | qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName()); | ||
319 | return false; | ||
320 | } | ||
321 | |||
322 | |||
323 | QString lockUniqueName; | ||
324 | lockUniqueName = fn + KApplication::randomString( 8 ); | ||
325 | |||
326 | url = lockUniqueName; | ||
327 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); | ||
328 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); | ||
329 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; | ||
330 | |||
331 | // Create unique file | ||
332 | QFile file( mLockUniqueName ); | ||
333 | file.open( IO_WriteOnly ); | ||
334 | file.close(); | ||
335 | |||
336 | // Create lock file | ||
337 | int result = 0; | ||
338 | #ifndef _WIN32_ | ||
339 | result = ::link( QFile::encodeName( mLockUniqueName ), | ||
340 | QFile::encodeName( lockName ) ); | ||
341 | #endif | ||
342 | if ( result == 0 ) { | ||
343 | addressBook()->emitAddressBookLocked(); | ||
344 | return true; | ||
345 | } | ||
346 | |||
347 | // TODO: check stat | ||
348 | |||
349 | return false; | ||
350 | #else | ||
351 | return true; | ||
352 | #endif | ||
353 | } | 258 | } |
354 | 259 | ||
355 | void ResourceSharpDTM::unlock( const QString &fileName ) | 260 | void ResourceSharpDTM::unlock( const QString &fileName ) |
356 | { | 261 | { |
357 | #ifdef ALLOW_LOCKING | ||
358 | qDebug("ResourceSharpDTM::unlock() %s", fileName.latin1()); | ||
359 | 262 | ||
360 | QString fn = fileName; | ||
361 | KURL url(fn); | ||
362 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | ||
363 | |||
364 | QFile::remove( lockName ); | ||
365 | QFile::remove( mLockUniqueName ); | ||
366 | addressBook()->emitAddressBookUnlocked(); | ||
367 | #endif | ||
368 | } | 263 | } |
369 | 264 | ||
370 | void ResourceSharpDTM::setFileName( const QString &newFileName ) | 265 | void ResourceSharpDTM::setFileName( const QString &newFileName ) |
371 | { | 266 | { |
372 | mDirWatch.stopScan(); | 267 | Resource::setFileName( newFileName ); |
373 | mDirWatch.removeFile( fileName() ); | ||
374 | |||
375 | Resource::setFileName( newFileName ); | ||
376 | |||
377 | mDirWatch.addFile( fileName() ); | ||
378 | mDirWatch.startScan(); | ||
379 | |||
380 | } | 268 | } |
381 | 269 | ||
382 | void ResourceSharpDTM::fileChanged() | 270 | void ResourceSharpDTM::fileChanged() |
383 | { | 271 | { |
384 | // There is a small theoretical chance that KDirWatch calls us before | 272 | |
385 | // we are fully constructed | ||
386 | if (!addressBook()) | ||
387 | return; | ||
388 | |||
389 | QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); | ||
390 | if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { | ||
391 | load(); | ||
392 | addressBook()->emitAddressBookChanged(); | ||
393 | } | ||
394 | } | 273 | } |
395 | 274 | ||
396 | void ResourceSharpDTM::removeAddressee( const Addressee &addr ) | 275 | void ResourceSharpDTM::removeAddressee( const Addressee &addr ) |
397 | { | 276 | { |
398 | } | 277 | } |
399 | 278 | ||
400 | void ResourceSharpDTM::cleanUp() | 279 | void ResourceSharpDTM::cleanUp() |
401 | { | 280 | { |
402 | unlock( fileName() ); | 281 | unlock( fileName() ); |
403 | } | 282 | } |
404 | 283 | ||
405 | 284 | ||
diff --git a/kabc/tmpaddressbook.cpp b/kabc/tmpaddressbook.cpp index 6e24302..cfa57e3 100644 --- a/kabc/tmpaddressbook.cpp +++ b/kabc/tmpaddressbook.cpp | |||
@@ -35,22 +35,15 @@ using namespace KABC; | |||
35 | TmpAddressBook::TmpAddressBook() | 35 | TmpAddressBook::TmpAddressBook() |
36 | : AddressBook(0, "tmpcontact") | 36 | : AddressBook(0, "tmpcontact") |
37 | { | 37 | { |
38 | } | 38 | } |
39 | 39 | ||
40 | TmpAddressBook::TmpAddressBook( const QString &config ) | 40 | TmpAddressBook::TmpAddressBook( const QString &config ) |
41 | : AddressBook( config, "tmpcontact" ) | 41 | : AddressBook( config, "tmpcontact" ) |
42 | { | 42 | { |
43 | } | 43 | } |
44 | 44 | ||
45 | TmpAddressBook::~TmpAddressBook() | 45 | TmpAddressBook::~TmpAddressBook() |
46 | { | 46 | { |
47 | //remove all possible resources. This should cleanup the configfile. | 47 | removeResources(); |
48 | QPtrList<KABC::Resource> mResources = resources(); | ||
49 | |||
50 | QPtrListIterator<KABC::Resource> it(mResources); | ||
51 | for ( ; it.current(); ++it ) { | ||
52 | KABC::Resource *res = it.current(); | ||
53 | removeResource(res); | ||
54 | } | ||
55 | } | 48 | } |
56 | 49 | ||
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 6e482b5..e6bdde9 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2233,37 +2233,37 @@ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString | |||
2233 | else | 2233 | else |
2234 | formattedbday = "NOTVALID"; | 2234 | formattedbday = "NOTVALID"; |
2235 | if (anni.isEmpty()) | 2235 | if (anni.isEmpty()) |
2236 | anni = "INVALID"; | 2236 | anni = "INVALID"; |
2237 | 2237 | ||
2238 | birthdayList.append(formattedbday); | 2238 | birthdayList.append(formattedbday); |
2239 | anniversaryList.append(anni); //should be ISODate | 2239 | anniversaryList.append(anni); //should be ISODate |
2240 | realNameList.append((*it).realName()); | 2240 | realNameList.append((*it).realName()); |
2241 | preferredEmailList.append((*it).preferredEmail()); | 2241 | preferredEmailList.append((*it).preferredEmail()); |
2242 | assembledNameList.append((*it).assembledName()); | 2242 | assembledNameList.append((*it).assembledName()); |
2243 | uidList.append((*it).uid()); | 2243 | uidList.append((*it).uid()); |
2244 | 2244 | ||
2245 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2245 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2246 | } | 2246 | } |
2247 | } | 2247 | } |
2248 | 2248 | ||
2249 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2249 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2250 | 2250 | ||
2251 | } | 2251 | } |
2252 | 2252 | ||
2253 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2253 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2254 | */ | 2254 | */ |
2255 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2255 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2256 | { | 2256 | { |
2257 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2257 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2258 | 2258 | ||
2259 | QString foundUid = QString::null; | 2259 | QString foundUid = QString::null; |
2260 | if ( ! uid.isEmpty() ) { | 2260 | if ( ! uid.isEmpty() ) { |
2261 | Addressee adrr = mAddressBook->findByUid( uid ); | 2261 | Addressee adrr = mAddressBook->findByUid( uid ); |
2262 | if ( !adrr.isEmpty() ) { | 2262 | if ( !adrr.isEmpty() ) { |
2263 | foundUid = uid; | 2263 | foundUid = uid; |
2264 | } | 2264 | } |
2265 | if ( email == "sendbacklist" ) { | 2265 | if ( email == "sendbacklist" ) { |
2266 | //qDebug("ssssssssssssssssssssssend "); | 2266 | //qDebug("ssssssssssssssssssssssend "); |
2267 | QStringList nameList; | 2267 | QStringList nameList; |
2268 | QStringList emailList; | 2268 | QStringList emailList; |
2269 | QStringList uidList; | 2269 | QStringList uidList; |
@@ -2280,25 +2280,25 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses | |||
2280 | return; | 2280 | return; |
2281 | if (foundUid.isEmpty()) | 2281 | if (foundUid.isEmpty()) |
2282 | { | 2282 | { |
2283 | //find the uid of the person first | 2283 | //find the uid of the person first |
2284 | Addressee::List namelist; | 2284 | Addressee::List namelist; |
2285 | Addressee::List emaillist; | 2285 | Addressee::List emaillist; |
2286 | 2286 | ||
2287 | if (!name.isEmpty()) | 2287 | if (!name.isEmpty()) |
2288 | namelist = mAddressBook->findByName( name ); | 2288 | namelist = mAddressBook->findByName( name ); |
2289 | 2289 | ||
2290 | if (!email.isEmpty()) | 2290 | if (!email.isEmpty()) |
2291 | emaillist = mAddressBook->findByEmail( email ); | 2291 | emaillist = mAddressBook->findByEmail( email ); |
2292 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2292 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2293 | //check if we have a match in Namelist and Emaillist | 2293 | //check if we have a match in Namelist and Emaillist |
2294 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2294 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2295 | foundUid = emaillist[0].uid(); | 2295 | foundUid = emaillist[0].uid(); |
2296 | } | 2296 | } |
2297 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2297 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2298 | foundUid = namelist[0].uid(); | 2298 | foundUid = namelist[0].uid(); |
2299 | else | 2299 | else |
2300 | { | 2300 | { |
2301 | for (int i = 0; i < namelist.count(); i++) | 2301 | for (int i = 0; i < namelist.count(); i++) |
2302 | { | 2302 | { |
2303 | for (int j = 0; j < emaillist.count(); j++) | 2303 | for (int j = 0; j < emaillist.count(); j++) |
2304 | { | 2304 | { |
@@ -2397,62 +2397,62 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2397 | // 1 take local | 2397 | // 1 take local |
2398 | // 2 take remote | 2398 | // 2 take remote |
2399 | // 3 cancel | 2399 | // 3 cancel |
2400 | QDateTime lastSync = mLastAddressbookSync; | 2400 | QDateTime lastSync = mLastAddressbookSync; |
2401 | QDateTime localMod = local->revision(); | 2401 | QDateTime localMod = local->revision(); |
2402 | QDateTime remoteMod = remote->revision(); | 2402 | QDateTime remoteMod = remote->revision(); |
2403 | 2403 | ||
2404 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2404 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2405 | 2405 | ||
2406 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2406 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2407 | bool remCh, locCh; | 2407 | bool remCh, locCh; |
2408 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2408 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2409 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2409 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2410 | locCh = ( localMod > mLastAddressbookSync ); | 2410 | locCh = ( localMod > mLastAddressbookSync ); |
2411 | if ( !remCh && ! locCh ) { | 2411 | if ( !remCh && ! locCh ) { |
2412 | qDebug("both not changed "); | 2412 | //qDebug("both not changed "); |
2413 | lastSync = localMod.addDays(1); | 2413 | lastSync = localMod.addDays(1); |
2414 | if ( mode <= SYNC_PREF_ASK ) | 2414 | if ( mode <= SYNC_PREF_ASK ) |
2415 | return 0; | 2415 | return 0; |
2416 | } else { | 2416 | } else { |
2417 | if ( locCh ) { | 2417 | if ( locCh ) { |
2418 | qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2418 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2419 | lastSync = localMod.addDays( -1 ); | 2419 | lastSync = localMod.addDays( -1 ); |
2420 | if ( !remCh ) | 2420 | if ( !remCh ) |
2421 | remoteMod =( lastSync.addDays( -1 ) ); | 2421 | remoteMod =( lastSync.addDays( -1 ) ); |
2422 | } else { | 2422 | } else { |
2423 | qDebug(" not loc changed "); | 2423 | //qDebug(" not loc changed "); |
2424 | lastSync = localMod.addDays( 1 ); | 2424 | lastSync = localMod.addDays( 1 ); |
2425 | if ( remCh ) { | 2425 | if ( remCh ) { |
2426 | qDebug("rem changed "); | 2426 | //qDebug("rem changed "); |
2427 | remoteMod =( lastSync.addDays( 1 ) ); | 2427 | remoteMod =( lastSync.addDays( 1 ) ); |
2428 | } | 2428 | } |
2429 | 2429 | ||
2430 | } | 2430 | } |
2431 | } | 2431 | } |
2432 | full = true; | 2432 | full = true; |
2433 | if ( mode < SYNC_PREF_ASK ) | 2433 | if ( mode < SYNC_PREF_ASK ) |
2434 | mode = SYNC_PREF_ASK; | 2434 | mode = SYNC_PREF_ASK; |
2435 | } else { | 2435 | } else { |
2436 | if ( localMod == remoteMod ) | 2436 | if ( localMod == remoteMod ) |
2437 | return 0; | 2437 | return 0; |
2438 | 2438 | ||
2439 | } | 2439 | } |
2440 | qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2440 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2441 | qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2441 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2442 | //full = true; //debug only | 2442 | //full = true; //debug only |
2443 | if ( full ) { | 2443 | if ( full ) { |
2444 | bool equ = ( (*local) == (*remote) ); | 2444 | bool equ = ( (*local) == (*remote) ); |
2445 | if ( equ ) { | 2445 | if ( equ ) { |
2446 | qDebug("equal "); | 2446 | //qDebug("equal "); |
2447 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2447 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2448 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2448 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2449 | } | 2449 | } |
2450 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2450 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2451 | return 0; | 2451 | return 0; |
2452 | 2452 | ||
2453 | }//else //debug only | 2453 | }//else //debug only |
2454 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2454 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2455 | } | 2455 | } |
2456 | int result; | 2456 | int result; |
2457 | bool localIsNew; | 2457 | bool localIsNew; |
2458 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2458 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
@@ -2547,45 +2547,45 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2547 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2547 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2548 | addresseeLSync = getLastSyncAddressee(); | 2548 | addresseeLSync = getLastSyncAddressee(); |
2549 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2549 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2550 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2550 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2551 | if ( !addresseeR.isEmpty() ) { | 2551 | if ( !addresseeR.isEmpty() ) { |
2552 | addresseeRSync = addresseeR; | 2552 | addresseeRSync = addresseeR; |
2553 | remote->removeAddressee(addresseeR ); | 2553 | remote->removeAddressee(addresseeR ); |
2554 | 2554 | ||
2555 | } else { | 2555 | } else { |
2556 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2556 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2557 | addresseeRSync = addresseeLSync ; | 2557 | addresseeRSync = addresseeLSync ; |
2558 | } else { | 2558 | } else { |
2559 | qDebug("FULLDATE 1"); | 2559 | //qDebug("FULLDATE 1"); |
2560 | fullDateRange = true; | 2560 | fullDateRange = true; |
2561 | Addressee newAdd; | 2561 | Addressee newAdd; |
2562 | addresseeRSync = newAdd; | 2562 | addresseeRSync = newAdd; |
2563 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2563 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2564 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2564 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2565 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2565 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2566 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2566 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2567 | } | 2567 | } |
2568 | } | 2568 | } |
2569 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2569 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2570 | qDebug("FULLDATE 2"); | 2570 | // qDebug("FULLDATE 2"); |
2571 | fullDateRange = true; | 2571 | fullDateRange = true; |
2572 | } | 2572 | } |
2573 | if ( ! fullDateRange ) { | 2573 | if ( ! fullDateRange ) { |
2574 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2574 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2575 | 2575 | ||
2576 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2576 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2577 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2577 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2578 | fullDateRange = true; | 2578 | fullDateRange = true; |
2579 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2579 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2580 | } | 2580 | } |
2581 | } | 2581 | } |
2582 | // fullDateRange = true; // debug only! | 2582 | // fullDateRange = true; // debug only! |
2583 | if ( fullDateRange ) | 2583 | if ( fullDateRange ) |
2584 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2584 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2585 | else | 2585 | else |
2586 | mLastAddressbookSync = addresseeLSync.revision(); | 2586 | mLastAddressbookSync = addresseeLSync.revision(); |
2587 | // for resyncing if own file has changed | 2587 | // for resyncing if own file has changed |
2588 | // PENDING fixme later when implemented | 2588 | // PENDING fixme later when implemented |
2589 | #if 0 | 2589 | #if 0 |
2590 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2590 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2591 | mLastAddressbookSync = loadedFileVersion; | 2591 | mLastAddressbookSync = loadedFileVersion; |
@@ -2847,24 +2847,25 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | |||
2847 | qDebug("Saving remote AB "); | 2847 | qDebug("Saving remote AB "); |
2848 | if ( ! abLocal.saveAB()) | 2848 | if ( ! abLocal.saveAB()) |
2849 | qDebug("Error writing back AB to file "); | 2849 | qDebug("Error writing back AB to file "); |
2850 | if ( external ) { | 2850 | if ( external ) { |
2851 | // afterwrite processing | 2851 | // afterwrite processing |
2852 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 2852 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
2853 | } | 2853 | } |
2854 | } | 2854 | } |
2855 | } | 2855 | } |
2856 | setModified(); | 2856 | setModified(); |
2857 | 2857 | ||
2858 | } | 2858 | } |
2859 | abLocal.removeResources(); | ||
2859 | if ( syncOK ) | 2860 | if ( syncOK ) |
2860 | mViewManager->refreshView(); | 2861 | mViewManager->refreshView(); |
2861 | return syncOK; | 2862 | return syncOK; |
2862 | 2863 | ||
2863 | } | 2864 | } |
2864 | void KABCore::removeSyncInfo( QString syncProfile) | 2865 | void KABCore::removeSyncInfo( QString syncProfile) |
2865 | { | 2866 | { |
2866 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2867 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2867 | mAddressBook->removeSyncInfo( syncProfile ); | 2868 | mAddressBook->removeSyncInfo( syncProfile ); |
2868 | setModified(); | 2869 | setModified(); |
2869 | } | 2870 | } |
2870 | 2871 | ||
@@ -2885,24 +2886,25 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) | |||
2885 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2886 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2886 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2887 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2887 | if ( syncOK ) { | 2888 | if ( syncOK ) { |
2888 | if ( syncManager->mWriteBackFile ) { | 2889 | if ( syncManager->mWriteBackFile ) { |
2889 | abLocal.removeSyncAddressees( false ); | 2890 | abLocal.removeSyncAddressees( false ); |
2890 | abLocal.saveAB(); | 2891 | abLocal.saveAB(); |
2891 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2892 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2892 | } | 2893 | } |
2893 | } else | 2894 | } else |
2894 | message( i18n("Sync cancelled or failed.") ); | 2895 | message( i18n("Sync cancelled or failed.") ); |
2895 | setModified(); | 2896 | setModified(); |
2896 | } | 2897 | } |
2898 | abLocal.removeResources(); | ||
2897 | if ( syncOK ) | 2899 | if ( syncOK ) |
2898 | mViewManager->refreshView(); | 2900 | mViewManager->refreshView(); |
2899 | disableBR( false ); | 2901 | disableBR( false ); |
2900 | return syncOK; | 2902 | return syncOK; |
2901 | 2903 | ||
2902 | } | 2904 | } |
2903 | void KABCore::message( QString m ) | 2905 | void KABCore::message( QString m ) |
2904 | { | 2906 | { |
2905 | topLevelWidget()->setCaption( m ); | 2907 | topLevelWidget()->setCaption( m ); |
2906 | mMessageTimer->start( 15000, true ); | 2908 | mMessageTimer->start( 15000, true ); |
2907 | } | 2909 | } |
2908 | bool KABCore::syncPhone() | 2910 | bool KABCore::syncPhone() |
@@ -2924,24 +2926,25 @@ bool KABCore::syncPhone() | |||
2924 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2926 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2925 | if ( syncOK ) { | 2927 | if ( syncOK ) { |
2926 | if ( syncManager->mWriteBackFile ) { | 2928 | if ( syncManager->mWriteBackFile ) { |
2927 | abLocal.removeSyncAddressees( true ); | 2929 | abLocal.removeSyncAddressees( true ); |
2928 | abLocal.saveABphone( fileName ); | 2930 | abLocal.saveABphone( fileName ); |
2929 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2931 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2930 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2932 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2931 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2933 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2932 | } | 2934 | } |
2933 | } | 2935 | } |
2934 | setModified(); | 2936 | setModified(); |
2935 | } | 2937 | } |
2938 | abLocal.removeResources(); | ||
2936 | if ( syncOK ) | 2939 | if ( syncOK ) |
2937 | mViewManager->refreshView(); | 2940 | mViewManager->refreshView(); |
2938 | return syncOK; | 2941 | return syncOK; |
2939 | } | 2942 | } |
2940 | void KABCore::getFile( bool success ) | 2943 | void KABCore::getFile( bool success ) |
2941 | { | 2944 | { |
2942 | if ( ! success ) { | 2945 | if ( ! success ) { |
2943 | message( i18n("Error receiving file. Nothing changed!") ); | 2946 | message( i18n("Error receiving file. Nothing changed!") ); |
2944 | return; | 2947 | return; |
2945 | } | 2948 | } |
2946 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2949 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2947 | if ( count ) | 2950 | if ( count ) |