1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
|
/*
This file is part of tdepim.
Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <tqapplication.h>
#include <tqfile.h>
#include <kabc/addressee.h>
#include <kabc/vcardconverter.h>
#include <tdeconfig.h>
#include <kdebug.h>
#include <klocale.h>
#include "kabc_groupwiseprefs.h"
#include "kabc_resourcegroupwise.h"
using namespace KABC;
ResourceGroupwise::ResourceGroupwise( const TDEConfig *config )
: ResourceCached( config )
{
init();
mPrefs->addGroupPrefix( identifier() );
if ( config ) {
readConfig( config );
}
initGroupwise();
}
ResourceGroupwise::ResourceGroupwise( const KURL &url,
const TQString &user,
const TQString &password,
const TQStringList &readAddressBooks,
const TQString &writeAddressBook )
: ResourceCached( 0 )
{
init();
mPrefs->addGroupPrefix( identifier() );
mPrefs->setUrl( url.url() );
mPrefs->setUser( user );
mPrefs->setPassword( password );
mPrefs->setReadAddressBooks( readAddressBooks );
mPrefs->setWriteAddressBook( writeAddressBook );
initGroupwise();
}
void ResourceGroupwise::init()
{
mJob = 0;
mProgress = 0;
mSABProgress = 0;
mUABProgress = 0;
mServerFirstSequence = 0;
mServerLastSequence = 0;
mServerLastPORebuildTime = 0;
mPrefs = new GroupwisePrefs;
mState = Start;
setType( "groupwise" );
}
void ResourceGroupwise::initGroupwise()
{
mServer = new GroupwiseServer( mPrefs->url(), mPrefs->user(),
mPrefs->password(), this );
}
ResourceGroupwise::~ResourceGroupwise()
{
delete mServer;
mServer = 0;
delete mPrefs;
mPrefs = 0;
}
void ResourceGroupwise::readConfig( const TDEConfig * )
{
mPrefs->readConfig();
readAddressBooks();
}
void ResourceGroupwise::writeConfig( TDEConfig *config )
{
Resource::writeConfig( config );
writeAddressBooks();
mPrefs->writeConfig();
}
void ResourceGroupwise::clearCache()
{
idMapper().clear();
mAddrMap.clear();
TQFile file( cacheFile() );
file.remove();
}
void ResourceGroupwise::readAddressBooks()
{
TQStringList ids = prefs()->ids();
TQStringList names = prefs()->names();
TQStringList personals = prefs()->personals();
TQStringList frequents = prefs()->frequents();
if ( ids.count() != names.count() || ids.count() != personals.count() ||
ids.count() != frequents.count() ) {
kdError() << "Corrupt addressbook configuration" << endl;
return;
}
mAddressBooks.clear();
for( uint i = 0; i < ids.count(); ++i ) {
GroupWise::AddressBook ab;
ab.id = ids[ i ];
ab.name = names[ i ];
ab.isPersonal = personals[ i ] == "1";
ab.isFrequentContacts = frequents[ i ] == "1";
mAddressBooks.append( ab );
}
}
void ResourceGroupwise::writeAddressBooks()
{
TQStringList ids;
TQStringList names;
TQStringList personals;
TQStringList frequents;
GroupWise::AddressBook::List::ConstIterator it;
for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) {
ids.append( (*it).id );
names.append( (*it).name );
personals.append( (*it).isPersonal ? "1" : "0" );
frequents.append( (*it).isFrequentContacts ? "1" : "0" );
}
prefs()->setIds( ids );
prefs()->setNames( names );
prefs()->setPersonals( personals );
prefs()->setFrequents( frequents );
}
void ResourceGroupwise::retrieveAddressBooks()
{
bool firstRetrieve = mAddressBooks.isEmpty();
GroupwiseServer server( prefs()->url(),
prefs()->user(),
prefs()->password(), this );
if ( server.login() )
{
mAddressBooks = server.addressBookList();
server.logout();
TQStringList reads;
TQString write;
GroupWise::AddressBook::List::ConstIterator it;
for( it = mAddressBooks.begin(); it != mAddressBooks.end(); ++it ) {
reads.append( (*it).id );
if ( (*it).isPersonal ) {
if ( write.isEmpty() ) write = (*it).id;
}
else
prefs()->setSystemAddressBook( (*it).id );
}
if ( firstRetrieve ) {
prefs()->setReadAddressBooks( reads );
prefs()->setWriteAddressBook( write );
}
}
else
emit loadingError( this, server.errorText() );
}
Ticket *ResourceGroupwise::requestSaveTicket()
{
if ( !addressBook() ) {
kdDebug(5700) << "no addressbook" << endl;
return 0;
}
return createTicket( this );
}
void ResourceGroupwise::releaseSaveTicket( Ticket *ticket )
{
delete ticket;
}
bool ResourceGroupwise::doOpen()
{
return true;
}
void ResourceGroupwise::doClose()
{
kdDebug() << "ResourceGroupwise::doClose()" << endl;
cancelLoad();
}
bool ResourceGroupwise::save( Ticket *ticket )
{
return asyncSave( ticket );
}
bool ResourceGroupwise::asyncSave( Ticket* )
{
if ( !mServer->login() ) return false;
KABC::Addressee::List::Iterator it;
KABC::Addressee::List addedList = addedAddressees();
for ( it = addedList.begin(); it != addedList.end(); ++it ) {
if ( mServer->insertAddressee( mPrefs->writeAddressBook(), *it ) ) {
clearChange( *it );
idMapper().setRemoteId( (*it).uid(), (*it).custom( "GWRESOURCE", "UID" ) );
}
}
KABC::Addressee::List changedList = changedAddressees();
for ( it = changedList.begin(); it != changedList.end(); ++it ) {
if ( mServer->changeAddressee( *it ) )
clearChange( *it );
}
KABC::Addressee::List deletedList = deletedAddressees();
for ( it = deletedList.begin(); it != deletedList.end(); ++it ) {
if ( mServer->removeAddressee( *it ) )
clearChange( *it );
}
if ( appIsWhiteListedForSAB() )
saveCache();
mServer->logout();
return true;
}
bool ResourceGroupwise::load()
{
return asyncLoad();
}
bool ResourceGroupwise::asyncLoad()
{
kdDebug() << "ResourceGroupwise::asyncLoad()" << endl;
//mPrefs->readConfig(); TODO: remove if the system addressbook is not read when disabled in config
if ( mState != Start )
{
kdDebug() << " Download still in progress" << endl;
return true;
}
if ( appIsWhiteListedForSAB() )
loadCache();
if ( !mProgress )
{
mProgress = KPIM::ProgressManager::instance()->createProgressItem(
KPIM::ProgressManager::getUniqueID(), i18n( "Loading GroupWise resource %1" ).arg( resourceName() ), TQString(), true /*CanBeCancelled*/, mPrefs->url().startsWith("https" ) );
connect( mProgress, TQT_SIGNAL( progressItemCanceled( KPIM::ProgressItem * ) ),
TQT_SLOT( cancelLoad() ) );
}
if ( addressBooks().isEmpty() ) {
kdDebug() << " Retrieving default addressbook list." << endl;
retrieveAddressBooks();
writeAddressBooks();
}
SABState sabState = systemAddressBookState();
if ( shouldFetchSystemAddressBook() )
{
if ( sabState == RefreshNeeded )
{
kdDebug() << " Fetching system addressbook" << endl;
fetchAddressBooks( System );
return true;
}
else if ( sabState == Stale )
{
kdDebug() << " Updating system addressbook" << endl;
updateSystemAddressBook(); // we then fetch the user address books after doing this
return true;
}
}
else if ( shouldFetchUserAddressBooks() )
{
kdDebug() << " Fetching user addressbook" << endl;
fetchAddressBooks( User );
return true;
}
return true;
}
void ResourceGroupwise::fetchAddressBooks( const BookType bookType )
{
KURL url = createAccessUrl( bookType, Fetch );
if ( !url.isValid() )
return;
kdDebug() << k_funcinfo << ( bookType == System ? " System" : " User" ) << " URL: " << url << endl;
// sanity check
if ( bookType == User && !( mState == SABUptodate || mState == Start ) )
{
kdDebug() << " **ERROR** - fetchAddressBooks( User ) called when SAB not up to date" << endl;
return;
}
mState = ( bookType == System ? FetchingSAB : FetchingUAB );
mJobData = TQString();
if ( mJob )
{
kdDebug() << " **ERROR** - fetchAddressBooks() called when a job was already running!" << endl;
return;
}
mJob = TDEIO::get( url, false, false ); // TODO: make the GW jobs call finished if the URL
// contains no address book IDs
kdDebug() << " Job address: " << mJob << endl;
connect( mJob, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray & ) ),
TQT_SLOT( slotReadJobData( TDEIO::Job *, const TQByteArray & ) ) );
connect( mJob, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ),
TQT_SLOT( slotJobPercent( TDEIO::Job *, unsigned long ) ) );
if ( bookType == System )
{
connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ),
TQT_SLOT( fetchSABResult( TDEIO::Job * ) ) );
mSABProgress = KPIM::ProgressManager::instance()->createProgressItem(
mProgress, KPIM::ProgressManager::getUniqueID(),
i18n( "Fetching System Address Book" ), TQString(),
false /*CannotBeCancelled*/,
mPrefs->url().startsWith("https" ) );
}
else
{
connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ),
TQT_SLOT( fetchUABResult( TDEIO::Job * ) ) );
mUABProgress = KPIM::ProgressManager::instance()->createProgressItem(
mProgress, KPIM::ProgressManager::getUniqueID(),
i18n( "Fetching User Address Books" ), TQString(),
false /*CannotBeCancelled*/,
mPrefs->url().startsWith("https" ) );
}
return;
}
void ResourceGroupwise::fetchSABResult( TDEIO::Job *job )
{
kdDebug() << "ResourceGroupwise::fetchSABResult() " << endl;
if ( job->error() ) {
kdError() << job->errorString() << endl;
emit loadingError( this, job->errorString() );
// TODO kill the rest of the load sequence as well
}
mJob->disconnect( this );
mJob = 0;
mState = SABUptodate;
if ( mSABProgress )
mSABProgress->setComplete();
storeDeltaInfo();
if ( shouldFetchUserAddressBooks() )
fetchAddressBooks( User );
else
loadCompleted();
}
void ResourceGroupwise::fetchUABResult( TDEIO::Job *job )
{
kdDebug() << "ResourceGroupwise::fetchUABResult() " << endl;
if ( job->error() ) {
kdError() << job->errorString() << endl;
emit loadingError( this, job->errorString() );
}
mJob->disconnect( this );
mJob = 0;
mState = Uptodate;
if ( mUABProgress )
mUABProgress->setComplete();
loadCompleted();
}
void ResourceGroupwise::updateSystemAddressBook()
{
kdDebug() << "ResourceGroupwise::updateSystemAddressBook()" << endl;
if ( mState != Start ) {
kdWarning() << " Action already in progress" << endl;
return;
}
if ( addressBooks().isEmpty() ) {
kdDebug() << " Retrieving default addressbook list." << endl;
retrieveAddressBooks();
writeAddressBooks();
}
KURL url = createAccessUrl( System, Update, mPrefs->lastSequenceNumber(), mPrefs->lastTimePORebuild() );
kdDebug() << " Update URL: " << url << endl;
mJobData = TQString();
mSABProgress = KPIM::ProgressManager::instance()->createProgressItem(
mProgress, KPIM::ProgressManager::getUniqueID(),
i18n( "Updating System Address Book" ), TQString(),
false /*CannotBeCancelled*/,
mPrefs->url().startsWith("https" ) );
mJob = TDEIO::get( url, false, false );
mJob->setInteractive( false );
connect( mJob, TQT_SIGNAL( result( TDEIO::Job * ) ),
TQT_SLOT( updateSABResult( TDEIO::Job * ) ) );
connect( mJob, TQT_SIGNAL( data( TDEIO::Job *, const TQByteArray & ) ),
TQT_SLOT( slotUpdateJobData( TDEIO::Job *, const TQByteArray & ) ) );
connect( mJob, TQT_SIGNAL( percent( TDEIO::Job *, unsigned long ) ),
TQT_SLOT( slotJobPercent( TDEIO::Job *, unsigned long ) ) );
return;
}
void ResourceGroupwise::updateSABResult( TDEIO::Job *job )
{
kdDebug() << "ResourceGroupwise::updateSABResult() " << endl;
mSABProgress->setComplete();
mSABProgress = 0;
mJob->disconnect( this );
mJob = 0;
int errorCode = job->error();
if ( errorCode != 0 ) {
if ( errorCode == TDEIO::ERR_NO_CONTENT ) // we need to refresh the SAB
{
kdDebug() << " update SAB failed, fetching all of it again" << endl;
mPrefs->setLastSequenceNumber( 0 );
mPrefs->setFirstSequenceNumber( 0 );
fetchAddressBooks( System );
return;
}
}
mState = SABUptodate;
storeDeltaInfo();
if ( shouldFetchUserAddressBooks() )
fetchAddressBooks( User );
else
loadCompleted();
}
void ResourceGroupwise::slotReadJobData( TDEIO::Job *job , const TQByteArray &data )
{
kdDebug() << "ResourceGroupwise::slotReadJobData()" << endl;
Q_UNUSED( job );
mJobData.append( data.data() );
KABC::VCardConverter conv;
TQTime profile;
profile.start();
Addressee::List addressees = conv.parseVCards( mJobData );
// kdDebug() << " parsed " << addressees.count() << " contacts in " << profile.elapsed() << "ms, now adding to resource..." << endl;
Addressee::List::ConstIterator it;
for( it = addressees.begin(); it != addressees.end(); ++it ) {
KABC::Addressee addr = *it;
if ( !addr.isEmpty() ) {
addr.setResource( this );
TQString remote = addr.custom( "GWRESOURCE", "UID" );
TQString local = idMapper().localId( remote );
if ( local.isEmpty() ) {
idMapper().setRemoteId( addr.uid(), remote );
} else {
addr.setUid( local );
}
insertAddressee( addr );
clearChange( addr );
}
}
mJobData = TQString();
}
void ResourceGroupwise::slotUpdateJobData( TDEIO::Job *job, const TQByteArray &data )
{
kdDebug() << "ResourceGroupwise::slotUpdateJobData()" << endl;
kdDebug() << " Job address: " << job << endl;
KABC::VCardConverter conv;
mJobData.append( data.data() );
Addressee::List addressees = conv.parseVCards( mJobData );
Addressee::List::ConstIterator it;
for( it = addressees.begin(); it != addressees.end(); ++it ) {
KABC::Addressee addr = *it;
if ( !addr.isEmpty() ) {
// if added or changed
TQString syncType = addr.custom( "GWRESOURCE", "SYNC" );
TQString remote = addr.custom( "GWRESOURCE", "UID" );
TQString local = idMapper().localId( remote );
if ( syncType == "ADD" || syncType == "UPD" )
{
addr.setResource( this );
if ( local.isEmpty() ) {
idMapper().setRemoteId( addr.uid(), remote );
} else {
addr.setUid( local );
}
insertAddressee( addr );
clearChange( addr );
}
else if ( syncType == "DEL" )
{
// if deleted
if ( !remote.isEmpty() )
{
if ( !local.isEmpty() )
{
idMapper().removeRemoteId( remote );
KABC::Addressee addrToDelete = findByUid( local );
removeAddressee( addrToDelete );
}
}
else
kdError() << "Addressee to delete did not have a remote UID, unable to find the corresponding local contact" << endl;
}
}
}
mJobData = TQString();
}
void ResourceGroupwise::loadCompleted()
{
kdDebug() << "ResourceGroupwise::loadCompleted()" << endl;
if ( mProgress )
mProgress->setComplete();
mProgress = 0;
mSABProgress = 0;
mUABProgress = 0;
mState = Start;
if ( appIsWhiteListedForSAB() )
saveCache();
emit loadingFinished( this );
addressBook()->emitAddressBookChanged();
}
void ResourceGroupwise::slotJobPercent( TDEIO::Job *, unsigned long percent )
{
// TODO: make this act on the correct progress item
kdDebug() << "ResourceGroupwise::slotJobPercent() " << percent << endl;
if ( mProgress ) mProgress->setProgress( percent );
}
void ResourceGroupwise::cancelLoad()
{
if ( mJob )
{
mJob->disconnect( this );
mJob->kill();
}
mJob = 0;
if ( mProgress ) mProgress->setComplete();
mProgress = 0;
mState = Start;
}
ResourceGroupwise::SABState ResourceGroupwise::systemAddressBookState()
{
unsigned long storedFirstSequence = mPrefs->firstSequenceNumber();
unsigned long storedLastSequence = mPrefs->lastSequenceNumber();
unsigned long storedLastPORebuildTime = mPrefs->lastTimePORebuild();
kdDebug() << "ResourceGroupwise::systemAddressBookState()" << endl;
kdDebug() << " Stored first seq no: " << storedFirstSequence << endl;
kdDebug() << " Stored last seq no: " << storedLastSequence << endl;
kdDebug() << " Stored last PO Rebuild time: " << storedLastPORebuildTime << endl;
kdDebug() << " Fetching delta info to check if update possible" << endl;
if ( mServer->login() )
{
GroupWise::DeltaInfo deltaInfo = mServer->getDeltaInfo( mPrefs->systemAddressBook() );
mServer->logout();
mServerFirstSequence = deltaInfo.firstSequence;
mServerLastSequence = deltaInfo.lastSequence;
mServerLastPORebuildTime = deltaInfo.lastTimePORebuild;
kdDebug() << " Server first seq no: " << mServerFirstSequence << endl;
kdDebug() << " Server last seq no: " << mServerLastSequence << endl;
kdDebug() << " Server last PO Rebuild time: " << mServerLastPORebuildTime << endl;
if ( storedFirstSequence == 0 || storedLastSequence == 0 )
{
kdDebug() << " no fetched SAB exists yet, can't update" << endl;
return RefreshNeeded;
}
if ( mServerFirstSequence > storedLastSequence || storedLastPORebuildTime != mServerLastPORebuildTime)
{
kdDebug() << " New entries since the last fetch are no longer available as deltas, or the PO was rebuilt, refresh needed" << endl;
return RefreshNeeded;
}
if ( mServerLastSequence == storedLastSequence )
{
kdDebug() << " The local data is up to date" << endl;
return InSync;
}
}
else
emit loadingError( this, mServer->errorText() );
if ( storedFirstSequence == 0 || storedLastSequence == 0 )
{
kdDebug() << " Fallthrough - no fetched SAB exists yet, refresh" << endl;
return RefreshNeeded;
}
else
kdDebug() << " Fallthrough - returning Stale" << endl;
return Stale;
}
bool ResourceGroupwise::shouldFetchSystemAddressBook()
{
TQStringList ids = mPrefs->readAddressBooks();
return ( appIsWhiteListedForSAB() && ids.find( mPrefs->systemAddressBook() ) != ids.end() );
}
bool ResourceGroupwise::shouldFetchUserAddressBooks()
{
TQStringList ids = mPrefs->readAddressBooks();
return ( ids.count() > 1 || ids.find( mPrefs->systemAddressBook() ) == ids.end() );
}
KURL ResourceGroupwise::createAccessUrl( BookType bookType, AccessMode mode, unsigned long lastSequenceNumber, unsigned long lastPORebuildTime )
{
// set up list of address book IDs to fetch
TQStringList ids;
if ( bookType == System )
ids.append( mPrefs->systemAddressBook() );
else
{
ids = mPrefs->readAddressBooks();
ids.remove( mPrefs->systemAddressBook() );
}
if ( ids.isEmpty() )
return KURL();
KURL url( prefs()->url() );
if ( url.protocol() == "http" )
url.setProtocol( "groupwise" );
else
url.setProtocol( "groupwises" );
url.setPath( url.path() + "/addressbook/" );
url.setUser( prefs()->user() );
url.setPass( prefs()->password() );
TQString query = "?";
TQStringList::ConstIterator it;
for( it = ids.begin(); it != ids.end(); ++it ) {
if ( it != ids.begin() ) query += "&";
query += "addressbookid=" + *it;
}
if ( mode == Update && lastSequenceNumber > 0 && lastPORebuildTime > 0 )
{
query += TQString::fromLatin1( "&update=true&lastSeqNo=%1&PORebuildTime=%2" ).arg( lastSequenceNumber ).arg( lastPORebuildTime );;
}
url.setQuery( query );
return url;
}
void ResourceGroupwise::storeDeltaInfo()
{
// update SAB delta info
kdDebug() << "ResourceGroupwise::storeDeltaInfo()" << endl;
kdDebug() << " Server first seq no: " << mServerFirstSequence << endl;
kdDebug() << " Server last seq no: " << mServerLastSequence << endl;
kdDebug() << " Server last PO Rebuild time: " << mServerLastPORebuildTime << endl;
if ( mServerFirstSequence == 0 || mServerLastSequence == 0 || mServerLastPORebuildTime == 0 )
return;
mPrefs->setFirstSequenceNumber( mServerFirstSequence );
mPrefs->setLastSequenceNumber( mServerLastSequence );
mPrefs->setLastTimePORebuild( mServerLastPORebuildTime );
mPrefs->writeConfig();
}
bool ResourceGroupwise::appIsWhiteListedForSAB()
{
if ( !mPrefs->systemAddressBookWhiteList().contains( tqApp->argv()[ 0 ] ) )
{
kdDebug() << "Application " << tqApp->argv()[ 0 ] << " is _blacklisted_ to load the SAB" << endl;
return false;
}
return true;
}
#include "kabc_resourcegroupwise.moc"
|