summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp2
-rw-r--r--kaddressbook/kabcore.h2
-rw-r--r--korganizer/calendarview.cpp19
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/koprefs.cpp10
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--libkdepim/ksyncmanager.cpp51
-rw-r--r--libkdepim/ksyncmanager.h8
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
9 files changed, 80 insertions, 21 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 033e537..2dea619 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -3116,380 +3116,380 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
3116 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3116 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3118 //qDebug("take %d %s ", take, inL.summary().latin1()); 3118 //qDebug("take %d %s ", take, inL.summary().latin1());
3119 if ( take == 3 ) 3119 if ( take == 3 )
3120 return false; 3120 return false;
3121 if ( take == 1 ) {// take local ********************** 3121 if ( take == 1 ) {// take local **********************
3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3125 local->insertAddressee( inL, false ); 3125 local->insertAddressee( inL, false );
3126 idS = inR.externalUID(); 3126 idS = inR.externalUID();
3127 OidS = inR.originalExternalUID(); 3127 OidS = inR.originalExternalUID();
3128 } 3128 }
3129 else 3129 else
3130 idS = inR.IDStr(); 3130 idS = inR.IDStr();
3131 remote->removeAddressee( inR ); 3131 remote->removeAddressee( inR );
3132 inR = inL; 3132 inR = inL;
3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3135 inR.setOriginalExternalUID( OidS ); 3135 inR.setOriginalExternalUID( OidS );
3136 inR.setExternalUID( idS ); 3136 inR.setExternalUID( idS );
3137 if ( syncManager->syncWithDesktop() ) { 3137 if ( syncManager->syncWithDesktop() ) {
3138 inR.setIDStr("changed" ); 3138 inR.setIDStr("changed" );
3139 } 3139 }
3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3141 } else { 3141 } else {
3142 inR.setIDStr( idS ); 3142 inR.setIDStr( idS );
3143 } 3143 }
3144 inR.setResource( 0 ); 3144 inR.setResource( 0 );
3145 remote->insertAddressee( inR , false); 3145 remote->insertAddressee( inR , false);
3146 ++changedRemote; 3146 ++changedRemote;
3147 } else { // take == 2 take remote ********************** 3147 } else { // take == 2 take remote **********************
3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3149 if ( inR.revision().date().year() < 2004 ) 3149 if ( inR.revision().date().year() < 2004 )
3150 inR.setRevision( modifiedCalendar ); 3150 inR.setRevision( modifiedCalendar );
3151 } 3151 }
3152 idS = inL.IDStr(); 3152 idS = inL.IDStr();
3153 local->removeAddressee( inL ); 3153 local->removeAddressee( inL );
3154 inL = inR; 3154 inL = inR;
3155 inL.setIDStr( idS ); 3155 inL.setIDStr( idS );
3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3159 } 3159 }
3160 inL.setResource( 0 ); 3160 inL.setResource( 0 );
3161 local->insertAddressee( inL , false ); 3161 local->insertAddressee( inL , false );
3162 ++changedLocal; 3162 ++changedLocal;
3163 } 3163 }
3164 } 3164 }
3165 } 3165 }
3166 } else { // no conflict ********** add or delete remote 3166 } else { // no conflict ********** add or delete remote
3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3169 QString des = addresseeLSync.note(); 3169 QString des = addresseeLSync.note();
3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3172 remote->insertAddressee( inR, false ); 3172 remote->insertAddressee( inR, false );
3173 ++deletedAddresseeR; 3173 ++deletedAddresseeR;
3174 } else { 3174 } else {
3175 inR.setRevision( modifiedCalendar ); 3175 inR.setRevision( modifiedCalendar );
3176 remote->insertAddressee( inR, false ); 3176 remote->insertAddressee( inR, false );
3177 inL = inR; 3177 inL = inR;
3178 inL.setIDStr( ":" ); 3178 inL.setIDStr( ":" );
3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3181 inL.setResource( 0 ); 3181 inL.setResource( 0 );
3182 local->insertAddressee( inL , false); 3182 local->insertAddressee( inL , false);
3183 ++addedAddressee; 3183 ++addedAddressee;
3184 } 3184 }
3185 } else { 3185 } else {
3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3187 inR.setRevision( modifiedCalendar ); 3187 inR.setRevision( modifiedCalendar );
3188 remote->insertAddressee( inR, false ); 3188 remote->insertAddressee( inR, false );
3189 inR.setResource( 0 ); 3189 inR.setResource( 0 );
3190 local->insertAddressee( inR, false ); 3190 local->insertAddressee( inR, false );
3191 ++addedAddressee; 3191 ++addedAddressee;
3192 } else { 3192 } else {
3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3194 remote->removeAddressee( inR ); 3194 remote->removeAddressee( inR );
3195 ++deletedAddresseeR; 3195 ++deletedAddresseeR;
3196 } 3196 }
3197 } 3197 }
3198 } else { 3198 } else {
3199 ++filteredIN; 3199 ++filteredIN;
3200 } 3200 }
3201 } 3201 }
3202 } 3202 }
3203 ++incCounter; 3203 ++incCounter;
3204 } 3204 }
3205 er.clear(); 3205 er.clear();
3206 QStringList el = local->uidList(); 3206 QStringList el = local->uidList();
3207 modulo = (el.count()/10)+1; 3207 modulo = (el.count()/10)+1;
3208 3208
3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3210 incCounter = 0; 3210 incCounter = 0;
3211 while ( incCounter < el.count()) { 3211 while ( incCounter < el.count()) {
3212 qApp->processEvents(); 3212 qApp->processEvents();
3213 if (syncManager->isProgressBarCanceled()) 3213 if (syncManager->isProgressBarCanceled())
3214 return false; 3214 return false;
3215 if ( incCounter % modulo == 0 ) 3215 if ( incCounter % modulo == 0 )
3216 syncManager->showProgressBar(incCounter); 3216 syncManager->showProgressBar(incCounter);
3217 uid = el[ incCounter ]; 3217 uid = el[ incCounter ];
3218 bool skipIncidence = false; 3218 bool skipIncidence = false;
3219 if ( uid.left(19) == QString("last-syncAddressee-") ) 3219 if ( uid.left(19) == QString("last-syncAddressee-") )
3220 skipIncidence = true; 3220 skipIncidence = true;
3221 if ( !skipIncidence ) { 3221 if ( !skipIncidence ) {
3222 inL = local->findByUid( uid ); 3222 inL = local->findByUid( uid );
3223 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3223 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3224 inR = remote->findByUid( uid ); 3224 inR = remote->findByUid( uid );
3225 if ( inR.isEmpty() ){ 3225 if ( inR.isEmpty() ){
3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3227 // no conflict ********** add or delete local 3227 // no conflict ********** add or delete local
3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3231 local->removeAddressee( inL ); 3231 local->removeAddressee( inL );
3232 ++deletedAddresseeL; 3232 ++deletedAddresseeL;
3233 } else { 3233 } else {
3234 if ( ! syncManager->mWriteBackExistingOnly ) { 3234 if ( ! syncManager->mWriteBackExistingOnly ) {
3235 inL.removeID(mCurrentSyncDevice ); 3235 inL.removeID(mCurrentSyncDevice );
3236 ++addedAddresseeR; 3236 ++addedAddresseeR;
3237 inL.setRevision( modifiedCalendar ); 3237 inL.setRevision( modifiedCalendar );
3238 local->insertAddressee( inL, false ); 3238 local->insertAddressee( inL, false );
3239 inR = inL; 3239 inR = inL;
3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3241 inR.setResource( 0 ); 3241 inR.setResource( 0 );
3242 remote->insertAddressee( inR, false ); 3242 remote->insertAddressee( inR, false );
3243 } 3243 }
3244 } 3244 }
3245 } else { 3245 } else {
3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3247 //qDebug("data %s ", inL.revision().toString().latin1()); 3247 //qDebug("data %s ", inL.revision().toString().latin1());
3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3249 local->removeAddressee( inL ); 3249 local->removeAddressee( inL );
3250 ++deletedAddresseeL; 3250 ++deletedAddresseeL;
3251 } else { 3251 } else {
3252 if ( ! syncManager->mWriteBackExistingOnly ) { 3252 if ( ! syncManager->mWriteBackExistingOnly ) {
3253 ++addedAddresseeR; 3253 ++addedAddresseeR;
3254 inL.setRevision( modifiedCalendar ); 3254 inL.setRevision( modifiedCalendar );
3255 local->insertAddressee( inL, false ); 3255 local->insertAddressee( inL, false );
3256 inR = inL; 3256 inR = inL;
3257 inR.setIDStr( ":" ); 3257 inR.setIDStr( ":" );
3258 inR.setResource( 0 ); 3258 inR.setResource( 0 );
3259 remote->insertAddressee( inR, false ); 3259 remote->insertAddressee( inR, false );
3260 } 3260 }
3261 } 3261 }
3262 } 3262 }
3263 } else { 3263 } else {
3264 ++filteredOUT; 3264 ++filteredOUT;
3265 } 3265 }
3266 } 3266 }
3267 } 3267 }
3268 } 3268 }
3269 ++incCounter; 3269 ++incCounter;
3270 } 3270 }
3271 el.clear(); 3271 el.clear();
3272 syncManager->hideProgressBar(); 3272 syncManager->hideProgressBar();
3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3274 // get rid of micro seconds 3274 // get rid of micro seconds
3275 QTime t = mLastAddressbookSync.time(); 3275 QTime t = mLastAddressbookSync.time();
3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3277 addresseeLSync.setRevision( mLastAddressbookSync ); 3277 addresseeLSync.setRevision( mLastAddressbookSync );
3278 addresseeRSync.setRevision( mLastAddressbookSync ); 3278 addresseeRSync.setRevision( mLastAddressbookSync );
3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3285 addresseeRSync.setNote( "" ) ; 3285 addresseeRSync.setNote( "" ) ;
3286 addresseeLSync.setNote( "" ); 3286 addresseeLSync.setNote( "" );
3287 3287
3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3289 remote->insertAddressee( addresseeRSync, false ); 3289 remote->insertAddressee( addresseeRSync, false );
3290 local->insertAddressee( addresseeLSync, false ); 3290 local->insertAddressee( addresseeLSync, false );
3291 QString mes; 3291 QString mes;
3292 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3292 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3293 qDebug( mes ); 3293 qDebug( mes );
3294 mes = i18n("Local addressbook changed!\n") +mes; 3294 mes = i18n("Local addressbook changed!\n") +mes;
3295 if ( syncManager->mShowSyncSummary ) { 3295 if ( syncManager->mShowSyncSummary ) {
3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3298 qDebug("KA: WB cancelled "); 3298 qDebug("KA: WB cancelled ");
3299 syncManager->mWriteBackFile = false; 3299 syncManager->mWriteBackFile = false;
3300 return syncOK; 3300 return syncOK;
3301 } 3301 }
3302 } 3302 }
3303 return syncOK; 3303 return syncOK;
3304} 3304}
3305 3305
3306 3306
3307//this is a overwritten callbackmethods from the syncinterface 3307//this is a overwritten callbackmethods from the syncinterface
3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource)
3309{ 3309{
3310 3310
3311 //pending prepare addresseeview for output 3311 //pending prepare addresseeview for output
3312 //pending detect, if remote file has REV field. if not switch to external sync 3312 //pending detect, if remote file has REV field. if not switch to external sync
3313 mGlobalSyncMode = SYNC_MODE_NORMAL; 3313 mGlobalSyncMode = SYNC_MODE_NORMAL;
3314 if ( manager != syncManager ) 3314 if ( manager != syncManager )
3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3317 3317
3318 AddressBook abLocal(filename,"syncContact"); 3318 AddressBook abLocal(filename,"syncContact");
3319 bool syncOK = false; 3319 bool syncOK = false;
3320 if ( abLocal.load() ) { 3320 if ( abLocal.load() ) {
3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3322 bool external = false; 3322 bool external = false;
3323 bool isXML = false; 3323 bool isXML = false;
3324 if ( filename.right(4) == ".xml") { 3324 if ( filename.right(4) == ".xml") {
3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3326 isXML = true; 3326 isXML = true;
3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3328 } else { 3328 } else {
3329 external = !manager->mIsKapiFile; 3329 external = !manager->mIsKapiFile;
3330 if ( external ) { 3330 if ( external ) {
3331 qDebug("KA: Sync::Setting vcf mode to external "); 3331 qDebug("KA: Sync::Setting vcf mode to external ");
3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3333 AddressBook::Iterator it; 3333 AddressBook::Iterator it;
3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3335 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3335 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3336 (*it).computeCsum( mCurrentSyncDevice ); 3336 (*it).computeCsum( mCurrentSyncDevice );
3337 } 3337 }
3338 } 3338 }
3339 } 3339 }
3340 //AddressBook::Iterator it; 3340 //AddressBook::Iterator it;
3341 //QStringList vcards; 3341 //QStringList vcards;
3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3343 // qDebug("Name %s ", (*it).familyName().latin1()); 3343 // qDebug("Name %s ", (*it).familyName().latin1());
3344 //} 3344 //}
3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3346 syncManager->hideProgressBar(); 3346 syncManager->hideProgressBar();
3347 if ( syncOK ) { 3347 if ( syncOK ) {
3348 if ( syncManager->mWriteBackFile ) 3348 if ( syncManager->mWriteBackFile )
3349 { 3349 {
3350 if ( external ) 3350 if ( external )
3351 abLocal.removeSyncAddressees( !isXML); 3351 abLocal.removeSyncAddressees( !isXML);
3352 qDebug("KA: Sync::Saving remote AB "); 3352 qDebug("KA: Sync::Saving remote AB ");
3353 if ( ! abLocal.saveAB()) 3353 if ( ! abLocal.saveAB())
3354 qDebug("KA: sync::Error writing back AB to file "); 3354 qDebug("KA: sync::Error writing back AB to file ");
3355 if ( external ) { 3355 if ( external ) {
3356 // afterwrite processing 3356 // afterwrite processing
3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3358 } 3358 }
3359 } 3359 }
3360 } 3360 }
3361 setModified(); 3361 setModified();
3362 3362
3363 } 3363 }
3364 abLocal.removeResources(); 3364 abLocal.removeResources();
3365 if ( syncOK ) 3365 if ( syncOK )
3366 mViewManager->refreshView(); 3366 mViewManager->refreshView();
3367 return syncOK; 3367 return syncOK;
3368 3368
3369} 3369}
3370void KABCore::removeSyncInfo( QString syncProfile) 3370void KABCore::removeSyncInfo( QString syncProfile)
3371{ 3371{
3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3373 mAddressBook->removeSyncInfo( syncProfile ); 3373 mAddressBook->removeSyncInfo( syncProfile );
3374 setModified(); 3374 setModified();
3375} 3375}
3376 3376
3377 3377
3378//this is a overwritten callbackmethods from the syncinterface 3378//this is a overwritten callbackmethods from the syncinterface
3379bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3379bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3380{ 3380{
3381 if ( resource == "phone" ) 3381 if ( resource == "phone" )
3382 return syncPhone(); 3382 return syncPhone();
3383 disableBR( true ); 3383 disableBR( true );
3384 if ( manager != syncManager ) 3384 if ( manager != syncManager )
3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3387 3387
3388 AddressBook abLocal( resource,"syncContact"); 3388 AddressBook abLocal( resource,"syncContact");
3389 bool syncOK = false; 3389 bool syncOK = false;
3390 message(i18n("Loading DTM address data..."), false); 3390 message(i18n("Loading DTM address data..."), false);
3391 if ( abLocal.load() ) { 3391 if ( abLocal.load() ) {
3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3394 message(i18n("Sync preprocessing..."),false); 3394 message(i18n("Sync preprocessing..."),false);
3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3396 message(i18n("Synchronizing..."),false); 3396 message(i18n("Synchronizing..."),false);
3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3398 syncManager->hideProgressBar(); 3398 syncManager->hideProgressBar();
3399 if ( syncOK ) { 3399 if ( syncOK ) {
3400 if ( syncManager->mWriteBackFile ) { 3400 if ( syncManager->mWriteBackFile ) {
3401 abLocal.removeSyncAddressees( false ); 3401 abLocal.removeSyncAddressees( false );
3402 message(i18n("Saving DTM address data..."),false); 3402 message(i18n("Saving DTM address data..."),false);
3403 abLocal.saveAB(); 3403 abLocal.saveAB();
3404 message(i18n("Sync postprocessing..."),false); 3404 message(i18n("Sync postprocessing..."),false);
3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3406 } 3406 }
3407 } else 3407 } else
3408 message( i18n("Sync cancelled or failed.") ); 3408 message( i18n("Sync cancelled or failed.") );
3409 setModified(); 3409 setModified();
3410 } 3410 }
3411 abLocal.removeResources(); 3411 abLocal.removeResources();
3412 if ( syncOK ) { 3412 if ( syncOK ) {
3413 mViewManager->refreshView(); 3413 mViewManager->refreshView();
3414 message(i18n("DTM syncing finished.")); 3414 message(i18n("DTM syncing finished."));
3415 } 3415 }
3416 disableBR( false ); 3416 disableBR( false );
3417 return syncOK; 3417 return syncOK;
3418 3418
3419} 3419}
3420void KABCore::message( QString m, bool startTimer) 3420void KABCore::message( QString m, bool startTimer)
3421{ 3421{
3422 topLevelWidget()->setCaption( m ); 3422 topLevelWidget()->setCaption( m );
3423 qApp->processEvents(); 3423 qApp->processEvents();
3424 if ( startTimer ) 3424 if ( startTimer )
3425 mMessageTimer->start( 15000, true ); 3425 mMessageTimer->start( 15000, true );
3426 else 3426 else
3427 mMessageTimer->stop(); 3427 mMessageTimer->stop();
3428} 3428}
3429bool KABCore::syncPhone() 3429bool KABCore::syncPhone()
3430{ 3430{
3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3432 QString fileName = getPhoneFile(); 3432 QString fileName = getPhoneFile();
3433 if ( !PhoneAccess::readFromPhone( fileName) ) { 3433 if ( !PhoneAccess::readFromPhone( fileName) ) {
3434 message(i18n("Phone access failed!")); 3434 message(i18n("Phone access failed!"));
3435 return false; 3435 return false;
3436 } 3436 }
3437 AddressBook abLocal( fileName,"syncContact"); 3437 AddressBook abLocal( fileName,"syncContact");
3438 bool syncOK = false; 3438 bool syncOK = false;
3439 { 3439 {
3440 abLocal.importFromFile( fileName ); 3440 abLocal.importFromFile( fileName );
3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3446 syncManager->hideProgressBar(); 3446 syncManager->hideProgressBar();
3447 if ( syncOK ) { 3447 if ( syncOK ) {
3448 if ( syncManager->mWriteBackFile ) { 3448 if ( syncManager->mWriteBackFile ) {
3449 abLocal.removeSyncAddressees( true ); 3449 abLocal.removeSyncAddressees( true );
3450 abLocal.saveABphone( fileName ); 3450 abLocal.saveABphone( fileName );
3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3454 } 3454 }
3455 } 3455 }
3456 setModified(); 3456 setModified();
3457 } 3457 }
3458 abLocal.removeResources(); 3458 abLocal.removeResources();
3459 if ( syncOK ) 3459 if ( syncOK )
3460 mViewManager->refreshView(); 3460 mViewManager->refreshView();
3461 return syncOK; 3461 return syncOK;
3462} 3462}
3463void KABCore::getFile( bool success ) 3463void KABCore::getFile( bool success )
3464{ 3464{
3465 if ( ! success ) { 3465 if ( ! success ) {
3466 message( i18n("Error receiving file. Nothing changed!") ); 3466 message( i18n("Error receiving file. Nothing changed!") );
3467 return; 3467 return;
3468 } 3468 }
3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3470 if ( count ) 3470 if ( count )
3471 setModified( true ); 3471 setModified( true );
3472 message( i18n("Pi-Sync successful!") ); 3472 message( i18n("Pi-Sync successful!") );
3473 mViewManager->refreshView(); 3473 mViewManager->refreshView();
3474} 3474}
3475void KABCore::syncFileRequest() 3475void KABCore::syncFileRequest()
3476{ 3476{
3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3478 syncManager->slotSyncMenu( 999 ); 3478 syncManager->slotSyncMenu( 999 );
3479 } 3479 }
3480 mAddressBook->export2File( sentSyncFile() ); 3480 mAddressBook->export2File( sentSyncFile() );
3481} 3481}
3482QString KABCore::sentSyncFile() 3482QString KABCore::sentSyncFile()
3483{ 3483{
3484#ifdef DESKTOP_VERSION 3484#ifdef DESKTOP_VERSION
3485 return locateLocal( "tmp", "copysyncab.vcf" ); 3485 return locateLocal( "tmp", "copysyncab.vcf" );
3486#else 3486#else
3487 return QString( "/tmp/copysyncab.vcf" ); 3487 return QString( "/tmp/copysyncab.vcf" );
3488#endif 3488#endif
3489} 3489}
3490 3490
3491void KABCore::setCaptionBack() 3491void KABCore::setCaptionBack()
3492{ 3492{
3493 mMessageTimer->stop(); 3493 mMessageTimer->stop();
3494 topLevelWidget()->setCaption( i18n("KA/Pi") ); 3494 topLevelWidget()->setCaption( i18n("KA/Pi") );
3495} 3495}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 42b7709..c4a0b3b 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -323,213 +323,213 @@ class KABCore : public QWidget, public KSyncInterface
323 */ 323 */
324 void executeContact( const QString &uid /*US = QString::null*/ ); 324 void executeContact( const QString &uid /*US = QString::null*/ );
325 325
326 /** 326 /**
327 Launches the configuration dialog. 327 Launches the configuration dialog.
328 */ 328 */
329 void openConfigDialog(); 329 void openConfigDialog();
330 void openConfigGlobalDialog(); 330 void openConfigGlobalDialog();
331 331
332 /** 332 /**
333 Launches the ldap search dialog. 333 Launches the ldap search dialog.
334 */ 334 */
335 void openLDAPDialog(); 335 void openLDAPDialog();
336 336
337 /** 337 /**
338 Creates a KAddressBookPrinter, which will display the print 338 Creates a KAddressBookPrinter, which will display the print
339 dialog and do the printing. 339 dialog and do the printing.
340 */ 340 */
341 void print(); 341 void print();
342 342
343 /** 343 /**
344 Registers a new GUI client, so plugins can register its actions. 344 Registers a new GUI client, so plugins can register its actions.
345 */ 345 */
346 void addGUIClient( KXMLGUIClient *client ); 346 void addGUIClient( KXMLGUIClient *client );
347 347
348 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 348 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
349 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 349 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
350 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 350 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
351 351
352 352
353 signals: 353 signals:
354 void contactSelected( const QString &name ); 354 void contactSelected( const QString &name );
355 void contactSelected( const QPixmap &pixmap ); 355 void contactSelected( const QPixmap &pixmap );
356 public slots: 356 public slots:
357 void loadDataAfterStart(); 357 void loadDataAfterStart();
358 void recieve(QString cmsg ); 358 void recieve(QString cmsg );
359 void getFile( bool success ); 359 void getFile( bool success );
360 void syncFileRequest(); 360 void syncFileRequest();
361 void setDetailsVisible( bool visible ); 361 void setDetailsVisible( bool visible );
362 void setDetailsToState(); 362 void setDetailsToState();
363 363
364 void saveSettings(); 364 void saveSettings();
365 365
366 private slots: 366 private slots:
367 void updateToolBar(); 367 void updateToolBar();
368 void updateMainWindow(); 368 void updateMainWindow();
369 void receive( const QCString& cmsg, const QByteArray& data ); 369 void receive( const QCString& cmsg, const QByteArray& data );
370 void receiveStart( const QCString& cmsg, const QByteArray& data ); 370 void receiveStart( const QCString& cmsg, const QByteArray& data );
371 void toggleBeamReceive( ); 371 void toggleBeamReceive( );
372 void disableBR(bool); 372 void disableBR(bool);
373 void setJumpButtonBarVisible( bool visible ); 373 void setJumpButtonBarVisible( bool visible );
374 void setJumpButtonBar( bool visible ); 374 void setJumpButtonBar( bool visible );
375 void setCaptionBack(); 375 void setCaptionBack();
376 void resizeAndCallContactdialog(); 376 void resizeAndCallContactdialog();
377 void callContactdialog(); 377 void callContactdialog();
378 void doRingSync(); 378 void doRingSync();
379 379
380 void importFromOL(); 380 void importFromOL();
381 void extensionModified( const KABC::Addressee::List &list ); 381 void extensionModified( const KABC::Addressee::List &list );
382 void extensionChanged( int id ); 382 void extensionChanged( int id );
383 void clipboardDataChanged(); 383 void clipboardDataChanged();
384 void updateActionMenu(); 384 void updateActionMenu();
385 void configureKeyBindings(); 385 void configureKeyBindings();
386 void removeVoice(); 386 void removeVoice();
387 void setFormattedName(); 387 void setFormattedName();
388#ifdef KAB_EMBEDDED 388#ifdef KAB_EMBEDDED
389 void configureResources(); 389 void configureResources();
390#endif //KAB_EMBEDDED 390#endif //KAB_EMBEDDED
391 391
392 void slotEditorDestroyed( const QString &uid ); 392 void slotEditorDestroyed( const QString &uid );
393 void configurationChanged(); 393 void configurationChanged();
394 void addressBookChanged(); 394 void addressBookChanged();
395 395
396 private: 396 private:
397 QCString mCStringMess; 397 QCString mCStringMess;
398 QByteArray mByteData; 398 QByteArray mByteData;
399 QString mEmailSourceChannel; 399 QString mEmailSourceChannel;
400 QString mEmailSourceUID; 400 QString mEmailSourceUID;
401 void resizeEvent(QResizeEvent* e ); 401 void resizeEvent(QResizeEvent* e );
402 bool mBRdisabled; 402 bool mBRdisabled;
403#ifndef DESKTOP_VERSION 403#ifndef DESKTOP_VERSION
404 QCopChannel* infrared; 404 QCopChannel* infrared;
405#endif 405#endif
406 QTimer *mMessageTimer; 406 QTimer *mMessageTimer;
407 void initGUI(); 407 void initGUI();
408 void initActions(); 408 void initActions();
409 QString getPhoneFile(); 409 QString getPhoneFile();
410 410
411 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 411 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
412 const char *name = 0 ); 412 const char *name = 0 );
413 413
414 KXMLGUIClient *mGUIClient; 414 KXMLGUIClient *mGUIClient;
415 415
416 KABC::AddressBook *mAddressBook; 416 KABC::AddressBook *mAddressBook;
417 417
418 ViewManager *mViewManager; 418 ViewManager *mViewManager;
419 // QSplitter *mDetailsSplitter; 419 // QSplitter *mDetailsSplitter;
420 KDGanttMinimizeSplitter *mExtensionBarSplitter; 420 KDGanttMinimizeSplitter *mExtensionBarSplitter;
421 ViewContainer *mDetails; 421 ViewContainer *mDetails;
422 KDGanttMinimizeSplitter* mMiniSplitter; 422 KDGanttMinimizeSplitter* mMiniSplitter;
423 XXPortManager *mXXPortManager; 423 XXPortManager *mXXPortManager;
424 JumpButtonBar *mJumpButtonBar; 424 JumpButtonBar *mJumpButtonBar;
425 IncSearchWidget *mIncSearchWidget; 425 IncSearchWidget *mIncSearchWidget;
426 ExtensionManager *mExtensionManager; 426 ExtensionManager *mExtensionManager;
427 427
428 KCMultiDialog *mConfigureDialog; 428 KCMultiDialog *mConfigureDialog;
429 429
430#ifndef KAB_EMBEDDED 430#ifndef KAB_EMBEDDED
431 LDAPSearchDialog *mLdapSearchDialog; 431 LDAPSearchDialog *mLdapSearchDialog;
432#endif //KAB_EMBEDDED 432#endif //KAB_EMBEDDED
433 // QDict<AddresseeEditorDialog> mEditorDict; 433 // QDict<AddresseeEditorDialog> mEditorDict;
434 AddresseeEditorDialog *mEditorDialog; 434 AddresseeEditorDialog *mEditorDialog;
435 bool mReadWrite; 435 bool mReadWrite;
436 bool mModified; 436 bool mModified;
437 bool mIsPart; 437 bool mIsPart;
438 bool mMultipleViewsAtOnce; 438 bool mMultipleViewsAtOnce;
439 439
440 440
441 //US file menu 441 //US file menu
442 KAction *mActionMail; 442 KAction *mActionMail;
443 KAction *mActionBeam; 443 KAction *mActionBeam;
444 KToggleAction *mActionBR; 444 KToggleAction *mActionBR;
445 KAction *mActionExport2phone; 445 KAction *mActionExport2phone;
446 KAction* mActionPrint; 446 KAction* mActionPrint;
447 KAction* mActionPrintDetails; 447 KAction* mActionPrintDetails;
448 KAction* mActionNewContact; 448 KAction* mActionNewContact;
449 KAction *mActionSave; 449 KAction *mActionSave;
450 KAction *mActionEditAddressee; 450 KAction *mActionEditAddressee;
451 KAction *mActionMailVCard; 451 KAction *mActionMailVCard;
452 KAction *mActionBeamVCard; 452 KAction *mActionBeamVCard;
453 453
454 KAction *mActionQuit; 454 KAction *mActionQuit;
455 455
456 //US edit menu 456 //US edit menu
457 KAction *mActionCopy; 457 KAction *mActionCopy;
458 KAction *mActionCut; 458 KAction *mActionCut;
459 KAction *mActionPaste; 459 KAction *mActionPaste;
460 KAction *mActionSelectAll; 460 KAction *mActionSelectAll;
461 KAction *mActionUndo; 461 KAction *mActionUndo;
462 KAction *mActionRedo; 462 KAction *mActionRedo;
463 KAction *mActionDelete; 463 KAction *mActionDelete;
464 464
465 //US settings menu 465 //US settings menu
466 KAction *mActionConfigResources; 466 KAction *mActionConfigResources;
467 KAction *mActionConfigGlobal; 467 KAction *mActionConfigGlobal;
468 KAction *mActionConfigKAddressbook; 468 KAction *mActionConfigKAddressbook;
469 KAction *mActionConfigShortcuts; 469 KAction *mActionConfigShortcuts;
470 KAction *mActionConfigureToolbars; 470 KAction *mActionConfigureToolbars;
471 KAction *mActionKeyBindings; 471 KAction *mActionKeyBindings;
472 KToggleAction *mActionJumpBar; 472 KToggleAction *mActionJumpBar;
473 KToggleAction *mActionDetails; 473 KToggleAction *mActionDetails;
474 KAction *mActionWhoAmI; 474 KAction *mActionWhoAmI;
475 KAction *mActionCategories; 475 KAction *mActionCategories;
476 KAction *mActionEditCategories; 476 KAction *mActionEditCategories;
477 KAction *mActionManageCategories; 477 KAction *mActionManageCategories;
478 KAction *mActionAboutKAddressbook; 478 KAction *mActionAboutKAddressbook;
479 KAction *mActionLicence; 479 KAction *mActionLicence;
480 KAction *mActionFaq; 480 KAction *mActionFaq;
481 KAction *mActionWN; 481 KAction *mActionWN;
482 KAction *mActionSyncHowto; 482 KAction *mActionSyncHowto;
483 KAction *mActionStorageHowto; 483 KAction *mActionStorageHowto;
484 KAction *mActionKdeSyncHowto; 484 KAction *mActionKdeSyncHowto;
485 KAction *mActionMultiSyncHowto; 485 KAction *mActionMultiSyncHowto;
486 486
487 KAction *mActionDeleteView; 487 KAction *mActionDeleteView;
488 488
489 QPopupMenu *viewMenu; 489 QPopupMenu *viewMenu;
490 QPopupMenu *filterMenu; 490 QPopupMenu *filterMenu;
491 QPopupMenu *settingsMenu; 491 QPopupMenu *settingsMenu;
492 QPopupMenu *changeMenu; 492 QPopupMenu *changeMenu;
493 QPopupMenu *beamMenu; 493 QPopupMenu *beamMenu;
494//US QAction *mActionSave; 494//US QAction *mActionSave;
495 QPopupMenu *ImportMenu; 495 QPopupMenu *ImportMenu;
496 QPopupMenu *ExportMenu; 496 QPopupMenu *ExportMenu;
497 //LR additional methods 497 //LR additional methods
498 KAction *mActionRemoveVoice; 498 KAction *mActionRemoveVoice;
499 KAction *mActionSetFormattedName; 499 KAction *mActionSetFormattedName;
500 KAction * mActionImportOL; 500 KAction * mActionImportOL;
501 501
502#ifndef KAB_EMBEDDED 502#ifndef KAB_EMBEDDED
503 KAddressBookService *mAddressBookService; 503 KAddressBookService *mAddressBookService;
504#endif //KAB_EMBEDDED 504#endif //KAB_EMBEDDED
505 505
506 class KABCorePrivate; 506 class KABCorePrivate;
507 KABCorePrivate *d; 507 KABCorePrivate *d;
508 //US bool mBlockSaveFlag; 508 //US bool mBlockSaveFlag;
509 509
510#ifdef KAB_EMBEDDED 510#ifdef KAB_EMBEDDED
511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
512#endif //KAB_EMBEDDED 512#endif //KAB_EMBEDDED
513 513
514 //this are the overwritten callbackmethods from the syncinterface 514 //this are the overwritten callbackmethods from the syncinterface
515 virtual bool sync(KSyncManager* manager, QString filename, int mode); 515 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
516 virtual bool syncExternal(KSyncManager* manager, QString resource); 516 virtual bool syncExternal(KSyncManager* manager, QString resource);
517 virtual void removeSyncInfo( QString syncProfile); 517 virtual void removeSyncInfo( QString syncProfile);
518 bool syncPhone(); 518 bool syncPhone();
519 void message( QString m , bool startTimer = true); 519 void message( QString m , bool startTimer = true);
520 520
521 // LR ******************************* 521 // LR *******************************
522 // sync stuff! 522 // sync stuff!
523 QString sentSyncFile(); 523 QString sentSyncFile();
524 QPopupMenu *syncMenu; 524 QPopupMenu *syncMenu;
525 KSyncManager* syncManager; 525 KSyncManager* syncManager;
526 int mGlobalSyncMode; 526 int mGlobalSyncMode;
527 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 527 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
528 KABC::Addressee getLastSyncAddressee(); 528 KABC::Addressee getLastSyncAddressee();
529 QDateTime mLastAddressbookSync; 529 QDateTime mLastAddressbookSync;
530 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 530 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
531 // ********************* 531 // *********************
532 532
533}; 533};
534 534
535#endif 535#endif
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 31e103d..8965d3b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1789,385 +1789,384 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1789 1789
1790 } else { 1790 } else {
1791 checkExternSyncEvent(eventRSyncSharp, inR); 1791 checkExternSyncEvent(eventRSyncSharp, inR);
1792 remote->deleteIncidence( inR ); 1792 remote->deleteIncidence( inR );
1793 ++deletedEventR; 1793 ++deletedEventR;
1794 } 1794 }
1795 } 1795 }
1796 } else { 1796 } else {
1797 ++filteredIN; 1797 ++filteredIN;
1798 } 1798 }
1799 } 1799 }
1800 } 1800 }
1801 inR = er.next(); 1801 inR = er.next();
1802 } 1802 }
1803 QPtrList<Incidence> el = local->rawIncidences(); 1803 QPtrList<Incidence> el = local->rawIncidences();
1804 inL = el.first(); 1804 inL = el.first();
1805 modulo = (el.count()/10)+1; 1805 modulo = (el.count()/10)+1;
1806 bar.setCaption (i18n("Add / remove events") ); 1806 bar.setCaption (i18n("Add / remove events") );
1807 bar.setTotalSteps ( el.count() ) ; 1807 bar.setTotalSteps ( el.count() ) ;
1808 bar.show(); 1808 bar.show();
1809 incCounter = 0; 1809 incCounter = 0;
1810 1810
1811 while ( inL ) { 1811 while ( inL ) {
1812 1812
1813 qApp->processEvents(); 1813 qApp->processEvents();
1814 if ( ! bar.isVisible() ) 1814 if ( ! bar.isVisible() )
1815 return false; 1815 return false;
1816 if ( incCounter % modulo == 0 ) 1816 if ( incCounter % modulo == 0 )
1817 bar.setProgress( incCounter ); 1817 bar.setProgress( incCounter );
1818 ++incCounter; 1818 ++incCounter;
1819 uid = inL->uid(); 1819 uid = inL->uid();
1820 bool skipIncidence = false; 1820 bool skipIncidence = false;
1821 if ( uid.left(15) == QString("last-syncEvent-") ) 1821 if ( uid.left(15) == QString("last-syncEvent-") )
1822 skipIncidence = true; 1822 skipIncidence = true;
1823 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1823 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1824 skipIncidence = true; 1824 skipIncidence = true;
1825 if ( !skipIncidence ) { 1825 if ( !skipIncidence ) {
1826 inR = remote->incidenceForUid( uid , true ); 1826 inR = remote->incidenceForUid( uid , true );
1827 if ( ! inR ) { 1827 if ( ! inR ) {
1828 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1828 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1829 // no conflict ********** add or delete local 1829 // no conflict ********** add or delete local
1830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1831 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1831 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1832 checkExternSyncEvent(eventLSyncSharp, inL); 1832 checkExternSyncEvent(eventLSyncSharp, inL);
1833 local->deleteIncidence( inL ); 1833 local->deleteIncidence( inL );
1834 ++deletedEventL; 1834 ++deletedEventL;
1835 } else { 1835 } else {
1836 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1836 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1837 inL->removeID(mCurrentSyncDevice ); 1837 inL->removeID(mCurrentSyncDevice );
1838 ++addedEventR; 1838 ++addedEventR;
1839 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1839 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1840 inL->setLastModified( modifiedCalendar ); 1840 inL->setLastModified( modifiedCalendar );
1841 inR = inL->clone(); 1841 inR = inL->clone();
1842 inR->setIDStr( ":" ); 1842 inR->setIDStr( ":" );
1843 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1843 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1844 inR->setCalID( 0 );// add to default cal 1844 inR->setCalID( 0 );// add to default cal
1845 remote->addIncidence( inR ); 1845 remote->addIncidence( inR );
1846 } 1846 }
1847 } 1847 }
1848 } else { 1848 } else {
1849 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1849 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1850 checkExternSyncEvent(eventLSyncSharp, inL); 1850 checkExternSyncEvent(eventLSyncSharp, inL);
1851 local->deleteIncidence( inL ); 1851 local->deleteIncidence( inL );
1852 ++deletedEventL; 1852 ++deletedEventL;
1853 } else { 1853 } else {
1854 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1854 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1855 ++addedEventR; 1855 ++addedEventR;
1856 inL->setLastModified( modifiedCalendar ); 1856 inL->setLastModified( modifiedCalendar );
1857 inR = inL->clone(); 1857 inR = inL->clone();
1858 inR->setIDStr( ":" ); 1858 inR->setIDStr( ":" );
1859 inR->setCalID( 0 );// add to default cal 1859 inR->setCalID( 0 );// add to default cal
1860 remote->addIncidence( inR ); 1860 remote->addIncidence( inR );
1861 } 1861 }
1862 } 1862 }
1863 } 1863 }
1864 } else { 1864 } else {
1865 ++filteredOUT; 1865 ++filteredOUT;
1866 } 1866 }
1867 } 1867 }
1868 } 1868 }
1869 inL = el.next(); 1869 inL = el.next();
1870 } 1870 }
1871 int delFut = 0; 1871 int delFut = 0;
1872 int remRem = 0; 1872 int remRem = 0;
1873 if ( mSyncManager->mWriteBackInFuture ) { 1873 if ( mSyncManager->mWriteBackInFuture ) {
1874 er = remote->rawIncidences(); 1874 er = remote->rawIncidences();
1875 remRem = er.count(); 1875 remRem = er.count();
1876 inR = er.first(); 1876 inR = er.first();
1877 QDateTime dt; 1877 QDateTime dt;
1878 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1878 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1879 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1879 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1880 while ( inR ) { 1880 while ( inR ) {
1881 if ( inR->typeID() == todoID ) { 1881 if ( inR->typeID() == todoID ) {
1882 Todo * t = (Todo*)inR; 1882 Todo * t = (Todo*)inR;
1883 if ( t->hasDueDate() ) 1883 if ( t->hasDueDate() )
1884 dt = t->dtDue(); 1884 dt = t->dtDue();
1885 else 1885 else
1886 dt = cur.addSecs( 62 ); 1886 dt = cur.addSecs( 62 );
1887 } 1887 }
1888 else if (inR->typeID() == eventID ) { 1888 else if (inR->typeID() == eventID ) {
1889 bool ok; 1889 bool ok;
1890 dt = inR->getNextOccurence( cur, &ok ); 1890 dt = inR->getNextOccurence( cur, &ok );
1891 if ( !ok ) 1891 if ( !ok )
1892 dt = cur.addSecs( -62 ); 1892 dt = cur.addSecs( -62 );
1893 } 1893 }
1894 else 1894 else
1895 dt = inR->dtStart(); 1895 dt = inR->dtStart();
1896 if ( dt < cur || dt > end ) { 1896 if ( dt < cur || dt > end ) {
1897 remote->deleteIncidence( inR ); 1897 remote->deleteIncidence( inR );
1898 ++delFut; 1898 ++delFut;
1899 } 1899 }
1900 inR = er.next(); 1900 inR = er.next();
1901 } 1901 }
1902 } 1902 }
1903 bar.hide(); 1903 bar.hide();
1904 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1904 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1905 eventLSync->setReadOnly( false ); 1905 eventLSync->setReadOnly( false );
1906 eventLSync->setDtStart( mLastCalendarSync ); 1906 eventLSync->setDtStart( mLastCalendarSync );
1907 eventRSync->setDtStart( mLastCalendarSync ); 1907 eventRSync->setDtStart( mLastCalendarSync );
1908 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1908 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1909 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1909 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1910 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1910 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1911 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1911 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1912 eventLSync->setReadOnly( true ); 1912 eventLSync->setReadOnly( true );
1913 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1913 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1914 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1914 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1915 remote->addEvent( eventRSync ); 1915 remote->addEvent( eventRSync );
1916 else 1916 else
1917 delete eventRSync; 1917 delete eventRSync;
1918 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1918 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1919 QString mes; 1919 QString mes;
1920 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1920 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1921 QString delmess; 1921 QString delmess;
1922 if ( delFut ) { 1922 if ( delFut ) {
1923 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1923 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1924 mes += delmess; 1924 mes += delmess;
1925 } 1925 }
1926 mes = i18n("Local calendar changed!\n") +mes; 1926 mes = i18n("Local calendar changed!\n") +mes;
1927 mCalendar->checkAlarmForIncidence( 0, true ); 1927 mCalendar->checkAlarmForIncidence( 0, true );
1928 qDebug( mes ); 1928 qDebug( mes );
1929 if ( mSyncManager->mShowSyncSummary ) { 1929 if ( mSyncManager->mShowSyncSummary ) {
1930 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1930 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1931 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1931 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1932 qDebug("KO: WB cancelled "); 1932 qDebug("KO: WB cancelled ");
1933 mSyncManager->mWriteBackFile = false; 1933 mSyncManager->mWriteBackFile = false;
1934 return syncOK; 1934 return syncOK;
1935 } 1935 }
1936 } 1936 }
1937 return syncOK; 1937 return syncOK;
1938} 1938}
1939 1939
1940void CalendarView::setSyncDevice( QString s ) 1940void CalendarView::setSyncDevice( QString s )
1941{ 1941{
1942 mCurrentSyncDevice= s; 1942 mCurrentSyncDevice= s;
1943} 1943}
1944void CalendarView::setSyncName( QString s ) 1944void CalendarView::setSyncName( QString s )
1945{ 1945{
1946 mCurrentSyncName= s; 1946 mCurrentSyncName= s;
1947} 1947}
1948bool CalendarView::syncCalendar(QString filename, int mode) 1948bool CalendarView::syncCalendar(QString filename, int mode)
1949{ 1949{
1950 //qDebug("syncCalendar %s ", filename.latin1()); 1950 //qDebug("syncCalendar %s ", filename.latin1());
1951 mGlobalSyncMode = SYNC_MODE_NORMAL; 1951 mGlobalSyncMode = SYNC_MODE_NORMAL;
1952 CalendarLocal* calendar = new CalendarLocal(); 1952 CalendarLocal* calendar = new CalendarLocal();
1953 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1953 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1954 FileStorage* storage = new FileStorage( calendar ); 1954 FileStorage* storage = new FileStorage( calendar );
1955 bool syncOK = false; 1955 bool syncOK = false;
1956 storage->setFileName( filename ); 1956 storage->setFileName( filename );
1957 // qDebug("loading ... "); 1957 // qDebug("loading ... ");
1958 if ( storage->load() ) { 1958 if ( storage->load() ) {
1959 getEventViewerDialog()->setSyncMode( true ); 1959 getEventViewerDialog()->setSyncMode( true );
1960 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1960 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1961 getEventViewerDialog()->setSyncMode( false ); 1961 getEventViewerDialog()->setSyncMode( false );
1962 if ( syncOK ) { 1962 if ( syncOK ) {
1963 if ( mSyncManager->mWriteBackFile ) 1963 if ( mSyncManager->mWriteBackFile )
1964 { 1964 {
1965 storage->setSaveFormat( new ICalFormat() ); 1965 storage->setSaveFormat( new ICalFormat() );
1966 storage->save(); 1966 storage->save();
1967 } 1967 }
1968 } 1968 }
1969 setModified( true ); 1969 setModified( true );
1970 } 1970 }
1971 delete storage; 1971 delete storage;
1972 delete calendar; 1972 delete calendar;
1973 if ( syncOK ) 1973 if ( syncOK )
1974 updateView(); 1974 updateView();
1975 return syncOK; 1975 return syncOK;
1976} 1976}
1977 1977
1978void CalendarView::syncExternal( int mode ) 1978void CalendarView::syncExternal( int mode )
1979{ 1979{
1980 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1980 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1981
1982 qApp->processEvents(); 1981 qApp->processEvents();
1983 CalendarLocal* calendar = new CalendarLocal(); 1982 CalendarLocal* calendar = new CalendarLocal();
1984 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1983 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1985 bool syncOK = false; 1984 bool syncOK = false;
1986 bool loadSuccess = false; 1985 bool loadSuccess = false;
1987 PhoneFormat* phoneFormat = 0; 1986 PhoneFormat* phoneFormat = 0;
1988 emit tempDisableBR(true); 1987 emit tempDisableBR(true);
1989#ifndef DESKTOP_VERSION 1988#ifndef DESKTOP_VERSION
1990 SharpFormat* sharpFormat = 0; 1989 SharpFormat* sharpFormat = 0;
1991 if ( mode == 0 ) { // sharp 1990 if ( mode == 0 ) { // sharp
1992 sharpFormat = new SharpFormat () ; 1991 sharpFormat = new SharpFormat () ;
1993 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1992 loadSuccess = sharpFormat->load( calendar, mCalendar );
1994 1993
1995 } else 1994 } else
1996#endif 1995#endif
1997 if ( mode == 1 ) { // phone 1996 if ( mode == 1 ) { // phone
1998 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1997 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1999 mSyncManager->mPhoneDevice, 1998 mSyncManager->mPhoneDevice,
2000 mSyncManager->mPhoneConnection, 1999 mSyncManager->mPhoneConnection,
2001 mSyncManager->mPhoneModel); 2000 mSyncManager->mPhoneModel);
2002 loadSuccess = phoneFormat->load( calendar,mCalendar); 2001 loadSuccess = phoneFormat->load( calendar,mCalendar);
2003 2002
2004 } else { 2003 } else {
2005 emit tempDisableBR(false); 2004 emit tempDisableBR(false);
2006 return; 2005 return;
2007 } 2006 }
2008 if ( loadSuccess ) { 2007 if ( loadSuccess ) {
2009 getEventViewerDialog()->setSyncMode( true ); 2008 getEventViewerDialog()->setSyncMode( true );
2010 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2009 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2011 getEventViewerDialog()->setSyncMode( false ); 2010 getEventViewerDialog()->setSyncMode( false );
2012 qApp->processEvents(); 2011 qApp->processEvents();
2013 if ( syncOK ) { 2012 if ( syncOK ) {
2014 if ( mSyncManager->mWriteBackFile ) 2013 if ( mSyncManager->mWriteBackFile )
2015 { 2014 {
2016 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 2015 QPtrList<Incidence> iL = mCalendar->rawIncidences();
2017 Incidence* inc = iL.first(); 2016 Incidence* inc = iL.first();
2018 if ( phoneFormat ) { 2017 if ( phoneFormat ) {
2019 while ( inc ) { 2018 while ( inc ) {
2020 inc->removeID(mCurrentSyncDevice); 2019 inc->removeID(mCurrentSyncDevice);
2021 inc = iL.next(); 2020 inc = iL.next();
2022 } 2021 }
2023 } 2022 }
2024#ifndef DESKTOP_VERSION 2023#ifndef DESKTOP_VERSION
2025 if ( sharpFormat ) 2024 if ( sharpFormat )
2026 sharpFormat->save(calendar); 2025 sharpFormat->save(calendar);
2027#endif 2026#endif
2028 if ( phoneFormat ) 2027 if ( phoneFormat )
2029 phoneFormat->save(calendar); 2028 phoneFormat->save(calendar);
2030 iL = calendar->rawIncidences(); 2029 iL = calendar->rawIncidences();
2031 inc = iL.first(); 2030 inc = iL.first();
2032 Incidence* loc; 2031 Incidence* loc;
2033 while ( inc ) { 2032 while ( inc ) {
2034 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 2033 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
2035 loc = mCalendar->incidence(inc->uid() ); 2034 loc = mCalendar->incidence(inc->uid() );
2036 if ( loc ) { 2035 if ( loc ) {
2037 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 2036 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
2038 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 2037 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
2039 } 2038 }
2040 } 2039 }
2041 inc = iL.next(); 2040 inc = iL.next();
2042 } 2041 }
2043 Incidence* lse = getLastSyncEvent(); 2042 Incidence* lse = getLastSyncEvent();
2044 if ( lse ) { 2043 if ( lse ) {
2045 lse->setReadOnly( false ); 2044 lse->setReadOnly( false );
2046 lse->setDescription( "" ); 2045 lse->setDescription( "" );
2047 lse->setReadOnly( true ); 2046 lse->setReadOnly( true );
2048 } 2047 }
2049 } 2048 }
2050 } else { 2049 } else {
2051 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 2050 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
2052 } 2051 }
2053 setModified( true ); 2052 setModified( true );
2054 } else { 2053 } else {
2055 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 2054 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
2056 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 2055 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
2057 question, i18n("Ok")) ; 2056 question, i18n("Ok")) ;
2058 2057
2059 } 2058 }
2060 delete calendar; 2059 delete calendar;
2061 updateView(); 2060 updateView();
2062 emit tempDisableBR(false); 2061 emit tempDisableBR(false);
2063 return ;//syncOK; 2062 return ;//syncOK;
2064 2063
2065} 2064}
2066 2065
2067bool CalendarView::importBday() 2066bool CalendarView::importBday()
2068{ 2067{
2069#ifndef KORG_NOKABC 2068#ifndef KORG_NOKABC
2070 2069
2071#ifdef DESKTOP_VERSION 2070#ifdef DESKTOP_VERSION
2072 int curCal = mCalendar->defaultCalendar(); 2071 int curCal = mCalendar->defaultCalendar();
2073 int bd = mCalEditView->getBirtdayID(); 2072 int bd = mCalEditView->getBirtdayID();
2074 if ( bd == 0 ) 2073 if ( bd == 0 )
2075 return false; 2074 return false;
2076 mCalendar->setDefaultCalendar( bd ); 2075 mCalendar->setDefaultCalendar( bd );
2077 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2076 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2078 KABC::AddressBook::Iterator it; 2077 KABC::AddressBook::Iterator it;
2079 int count = 0; 2078 int count = 0;
2080 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2079 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2081 ++count; 2080 ++count;
2082 } 2081 }
2083 QProgressBar bar(count,0 ); 2082 QProgressBar bar(count,0 );
2084 int w = 300; 2083 int w = 300;
2085 if ( QApplication::desktop()->width() < 320 ) 2084 if ( QApplication::desktop()->width() < 320 )
2086 w = 220; 2085 w = 220;
2087 int h = bar.sizeHint().height() ; 2086 int h = bar.sizeHint().height() ;
2088 int dw = QApplication::desktop()->width(); 2087 int dw = QApplication::desktop()->width();
2089 int dh = QApplication::desktop()->height(); 2088 int dh = QApplication::desktop()->height();
2090 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2089 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2091 bar.show(); 2090 bar.show();
2092 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2091 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2093 qApp->processEvents(); 2092 qApp->processEvents();
2094 count = 0; 2093 count = 0;
2095 int addCount = 0; 2094 int addCount = 0;
2096 KCal::Attendee* a = 0; 2095 KCal::Attendee* a = 0;
2097 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2096 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2098 if ( ! bar.isVisible() ) 2097 if ( ! bar.isVisible() )
2099 return false; 2098 return false;
2100 bar.setProgress( count++ ); 2099 bar.setProgress( count++ );
2101 qApp->processEvents(); 2100 qApp->processEvents();
2102 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2101 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2103 if ( (*it).birthday().date().isValid() ){ 2102 if ( (*it).birthday().date().isValid() ){
2104 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2103 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2105 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2104 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2106 ++addCount; 2105 ++addCount;
2107 } 2106 }
2108 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 2107 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
2109 if ( anni.isValid() ){ 2108 if ( anni.isValid() ){
2110 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2109 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2111 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 2110 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
2112 ++addCount; 2111 ++addCount;
2113 } 2112 }
2114 } 2113 }
2115 mCalendar->setDefaultCalendar( curCal ); 2114 mCalendar->setDefaultCalendar( curCal );
2116 updateView(); 2115 updateView();
2117 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2116 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2118#else //DESKTOP_VERSION 2117#else //DESKTOP_VERSION
2119 2118
2120 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 2119 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
2121 // the result should now arrive through method insertBirthdays 2120 // the result should now arrive through method insertBirthdays
2122 2121
2123#endif //DESKTOP_VERSION 2122#endif //DESKTOP_VERSION
2124 2123
2125#endif //KORG_NOKABC 2124#endif //KORG_NOKABC
2126 2125
2127 2126
2128 return true; 2127 return true;
2129} 2128}
2130 2129
2131// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2130// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2132void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2131void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2133 const QStringList& anniversaryList, const QStringList& realNameList, 2132 const QStringList& anniversaryList, const QStringList& realNameList,
2134 const QStringList& emailList, const QStringList& assembledNameList, 2133 const QStringList& emailList, const QStringList& assembledNameList,
2135 const QStringList& uidList) 2134 const QStringList& uidList)
2136{ 2135{
2137 2136
2138 //qDebug("KO::CalendarView::insertBirthdays"); 2137 //qDebug("KO::CalendarView::insertBirthdays");
2139 if (uid == this->name()) 2138 if (uid == this->name())
2140 { 2139 {
2141 int curCal = mCalendar->defaultCalendar(); 2140 int curCal = mCalendar->defaultCalendar();
2142 int bd = mCalEditView->getBirtdayID(); 2141 int bd = mCalEditView->getBirtdayID();
2143 if ( bd == 0 ) 2142 if ( bd == 0 )
2144 return; 2143 return;
2145 mCalendar->setDefaultCalendar( bd ); 2144 mCalendar->setDefaultCalendar( bd );
2146 2145
2147 2146
2148 int count = birthdayList.count(); 2147 int count = birthdayList.count();
2149 int addCount = 0; 2148 int addCount = 0;
2150 KCal::Attendee* a = 0; 2149 KCal::Attendee* a = 0;
2151 2150
2152 //qDebug("CalView 1 %i", count); 2151 //qDebug("CalView 1 %i", count);
2153 2152
2154 QProgressBar bar(count,0 ); 2153 QProgressBar bar(count,0 );
2155 int w = 300; 2154 int w = 300;
2156 if ( QApplication::desktop()->width() < 320 ) 2155 if ( QApplication::desktop()->width() < 320 )
2157 w = 220; 2156 w = 220;
2158 int h = bar.sizeHint().height() ; 2157 int h = bar.sizeHint().height() ;
2159 int dw = QApplication::desktop()->width(); 2158 int dw = QApplication::desktop()->width();
2160 int dh = QApplication::desktop()->height(); 2159 int dh = QApplication::desktop()->height();
2161 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2160 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2162 bar.show(); 2161 bar.show();
2163 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2162 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2164 qApp->processEvents(); 2163 qApp->processEvents();
2165 2164
2166 QDate birthday; 2165 QDate birthday;
2167 QDate anniversary; 2166 QDate anniversary;
2168 QString realName; 2167 QString realName;
2169 QString email; 2168 QString email;
2170 QString assembledName; 2169 QString assembledName;
2171 QString uid; 2170 QString uid;
2172 bool ok = true; 2171 bool ok = true;
2173 for ( int i = 0; i < count; i++) 2172 for ( int i = 0; i < count; i++)
@@ -4845,332 +4844,346 @@ void CalendarView::toggleAllDaySize()
4845 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4844 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4846 */ 4845 */
4847 viewManager()->agendaView()->toggleAllDay(); 4846 viewManager()->agendaView()->toggleAllDay();
4848} 4847}
4849void CalendarView::toggleExpand() 4848void CalendarView::toggleExpand()
4850{ 4849{
4851 // if ( mLeftFrame->isHidden() ) { 4850 // if ( mLeftFrame->isHidden() ) {
4852 // mLeftFrame->show(); 4851 // mLeftFrame->show();
4853 // emit calendarViewExpanded( false ); 4852 // emit calendarViewExpanded( false );
4854 // } else { 4853 // } else {
4855 // mLeftFrame->hide(); 4854 // mLeftFrame->hide();
4856 // emit calendarViewExpanded( true ); 4855 // emit calendarViewExpanded( true );
4857 // } 4856 // }
4858 //qDebug(" CalendarView::toggleExpand()"); 4857 //qDebug(" CalendarView::toggleExpand()");
4859 globalFlagBlockAgenda = 1; 4858 globalFlagBlockAgenda = 1;
4860 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4859 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4861 globalFlagBlockAgenda = 5; 4860 globalFlagBlockAgenda = 5;
4862 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4861 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4863 //mViewManager->showView( 0, true ); 4862 //mViewManager->showView( 0, true );
4864} 4863}
4865 4864
4866void CalendarView::calendarModified( bool modified, Calendar * ) 4865void CalendarView::calendarModified( bool modified, Calendar * )
4867{ 4866{
4868 setModified( modified ); 4867 setModified( modified );
4869} 4868}
4870 4869
4871Todo *CalendarView::selectedTodo() 4870Todo *CalendarView::selectedTodo()
4872{ 4871{
4873 Incidence *incidence = currentSelection(); 4872 Incidence *incidence = currentSelection();
4874 if ( incidence && incidence->typeID() == todoID ) { 4873 if ( incidence && incidence->typeID() == todoID ) {
4875 return static_cast<Todo *>( incidence ); 4874 return static_cast<Todo *>( incidence );
4876 } 4875 }
4877 4876
4878 incidence = mTodoList->selectedIncidences().first(); 4877 incidence = mTodoList->selectedIncidences().first();
4879 if ( incidence && incidence->typeID() == todoID ) { 4878 if ( incidence && incidence->typeID() == todoID ) {
4880 return static_cast<Todo *>( incidence ); 4879 return static_cast<Todo *>( incidence );
4881 } 4880 }
4882 4881
4883 return 0; 4882 return 0;
4884} 4883}
4885 4884
4886void CalendarView::showIncidence() 4885void CalendarView::showIncidence()
4887{ 4886{
4888 mViewerCallerIsSearchDialog = false; 4887 mViewerCallerIsSearchDialog = false;
4889 Incidence *incidence = currentSelection(); 4888 Incidence *incidence = currentSelection();
4890 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4889 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4891 if ( incidence ) { 4890 if ( incidence ) {
4892 ShowIncidenceVisitor v; 4891 ShowIncidenceVisitor v;
4893 v.act( incidence, this ); 4892 v.act( incidence, this );
4894 } 4893 }
4895} 4894}
4896void CalendarView::editIncidenceDescription() 4895void CalendarView::editIncidenceDescription()
4897{ 4896{
4898 mFlagEditDescription = true; 4897 mFlagEditDescription = true;
4899 editIncidence(); 4898 editIncidence();
4900 mFlagEditDescription = false; 4899 mFlagEditDescription = false;
4901} 4900}
4902void CalendarView::editIncidence() 4901void CalendarView::editIncidence()
4903{ 4902{
4904 // qDebug("editIncidence() "); 4903 // qDebug("editIncidence() ");
4905 Incidence *incidence = currentSelection(); 4904 Incidence *incidence = currentSelection();
4906 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4905 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4907 if ( incidence ) { 4906 if ( incidence ) {
4908 EditIncidenceVisitor v; 4907 EditIncidenceVisitor v;
4909 v.act( incidence, this ); 4908 v.act( incidence, this );
4910 } 4909 }
4911} 4910}
4912 4911
4913void CalendarView::deleteIncidence() 4912void CalendarView::deleteIncidence()
4914{ 4913{
4915 Incidence *incidence = currentSelection(); 4914 Incidence *incidence = currentSelection();
4916 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4915 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4917 if ( incidence ) { 4916 if ( incidence ) {
4918 deleteIncidence(incidence); 4917 deleteIncidence(incidence);
4919 } 4918 }
4920} 4919}
4921void CalendarView::showIncidence(QString uid) 4920void CalendarView::showIncidence(QString uid)
4922{ 4921{
4923 Incidence *inc = mCalendar->incidence( uid ); 4922 Incidence *inc = mCalendar->incidence( uid );
4924 if ( inc ) 4923 if ( inc )
4925 showIncidence( inc ); 4924 showIncidence( inc );
4926} 4925}
4927void CalendarView::showIncidence(Incidence *incidence) 4926void CalendarView::showIncidence(Incidence *incidence)
4928{ 4927{
4929 mViewerCallerIsSearchDialog = false; 4928 mViewerCallerIsSearchDialog = false;
4930 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4929 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4931 if ( sender() && mDialogManager->getSearchDialog() ) { 4930 if ( sender() && mDialogManager->getSearchDialog() ) {
4932 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4931 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4933 mViewerCallerIsSearchDialog = true; 4932 mViewerCallerIsSearchDialog = true;
4934 } 4933 }
4935 } 4934 }
4936 if ( incidence ) { 4935 if ( incidence ) {
4937 ShowIncidenceVisitor v; 4936 ShowIncidenceVisitor v;
4938 v.act( incidence, this ); 4937 v.act( incidence, this );
4939 } 4938 }
4940} 4939}
4941 4940
4942void CalendarView::editIncidence(Incidence *incidence) 4941void CalendarView::editIncidence(Incidence *incidence)
4943{ 4942{
4944 if ( incidence ) { 4943 if ( incidence ) {
4945 4944
4946 EditIncidenceVisitor v; 4945 EditIncidenceVisitor v;
4947 v.act( incidence, this ); 4946 v.act( incidence, this );
4948 4947
4949 } 4948 }
4950} 4949}
4951 4950
4952void CalendarView::deleteIncidence(Incidence *incidence) 4951void CalendarView::deleteIncidence(Incidence *incidence)
4953{ 4952{
4954 //qDebug(" CalendarView::deleteIncidence "); 4953 //qDebug(" CalendarView::deleteIncidence ");
4955 if ( incidence == 0 ) { 4954 if ( incidence == 0 ) {
4956 updateView(); 4955 updateView();
4957 emit updateSearchDialog(); 4956 emit updateSearchDialog();
4958 return; 4957 return;
4959 } 4958 }
4960 if ( incidence ) { 4959 if ( incidence ) {
4961 DeleteIncidenceVisitor v; 4960 DeleteIncidenceVisitor v;
4962 v.act( incidence, this ); 4961 v.act( incidence, this );
4963 } 4962 }
4964} 4963}
4965 4964
4966 4965
4967void CalendarView::lookForOutgoingMessages() 4966void CalendarView::lookForOutgoingMessages()
4968{ 4967{
4969 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4968 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4970 ogd->loadMessages(); 4969 ogd->loadMessages();
4971} 4970}
4972 4971
4973void CalendarView::lookForIncomingMessages() 4972void CalendarView::lookForIncomingMessages()
4974{ 4973{
4975 IncomingDialog *icd = mDialogManager->incomingDialog(); 4974 IncomingDialog *icd = mDialogManager->incomingDialog();
4976 icd->retrieve(); 4975 icd->retrieve();
4977} 4976}
4978 4977
4979bool CalendarView::removeCompletedSubTodos( Todo* t ) 4978bool CalendarView::removeCompletedSubTodos( Todo* t )
4980{ 4979{
4981 bool deleteTodo = true; 4980 bool deleteTodo = true;
4982 QPtrList<Incidence> subTodos; 4981 QPtrList<Incidence> subTodos;
4983 Incidence *aTodo; 4982 Incidence *aTodo;
4984 subTodos = t->relations(); 4983 subTodos = t->relations();
4985 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4984 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4986 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4985 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4987 deleteTodo = false; 4986 deleteTodo = false;
4988 } 4987 }
4989 if ( deleteTodo ) { 4988 if ( deleteTodo ) {
4990 if ( t->isCompleted() && !t->doesRecur()) { 4989 if ( t->isCompleted() && !t->doesRecur()) {
4991 checkExternalId( t ); 4990 checkExternalId( t );
4992 mCalendar->deleteTodo( t ); 4991 mCalendar->deleteTodo( t );
4993 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4992 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4994 } 4993 }
4995 else 4994 else
4996 deleteTodo = false; 4995 deleteTodo = false;
4997 } 4996 }
4998 return deleteTodo; 4997 return deleteTodo;
4999 4998
5000} 4999}
5001void CalendarView::purgeCompleted() 5000void CalendarView::purgeCompleted()
5002{ 5001{
5003 int result = KMessageBox::warningContinueCancel(this, 5002 int result = KMessageBox::warningContinueCancel(this,
5004 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 5003 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
5005 5004
5006 if (result == KMessageBox::Continue) { 5005 if (result == KMessageBox::Continue) {
5007 5006
5008 QPtrList<Todo> todoCal; 5007 QPtrList<Todo> todoCal;
5009 QPtrList<Todo> rootTodos; 5008 QPtrList<Todo> rootTodos;
5010 //QPtrList<Incidence> rel; 5009 //QPtrList<Incidence> rel;
5011 Todo *aTodo; 5010 Todo *aTodo;
5012 todoCal = calendar()->todos(); 5011 todoCal = calendar()->todos();
5013 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 5012 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
5014 if ( !aTodo->relatedTo() ) 5013 if ( !aTodo->relatedTo() )
5015 rootTodos.append( aTodo ); 5014 rootTodos.append( aTodo );
5016 } 5015 }
5017 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 5016 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
5018 removeCompletedSubTodos( aTodo ); 5017 removeCompletedSubTodos( aTodo );
5019 } 5018 }
5020 5019
5021 updateView(); 5020 updateView();
5022 } 5021 }
5023} 5022}
5024 5023
5025void CalendarView::slotCalendarChanged() 5024void CalendarView::slotCalendarChanged()
5026{ 5025{
5027 ; 5026 ;
5028} 5027}
5029 5028
5030void CalendarView::keyPressEvent ( QKeyEvent *e) 5029void CalendarView::keyPressEvent ( QKeyEvent *e)
5031{ 5030{
5032 //qDebug("CalendarView::keyPressEvent "); 5031 //qDebug("CalendarView::keyPressEvent ");
5033 e->ignore(); 5032 e->ignore();
5034} 5033}
5035 5034
5036 5035
5037bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 5036bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource)
5038{ 5037{
5039 5038
5040 if ( manager != mSyncManager) 5039 if ( manager != mSyncManager)
5041 qDebug("KO: Internal error-1. SyncManager mismatch "); 5040 qDebug("KO: Internal error-1. SyncManager mismatch ");
5042 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 5041 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
5043 qDebug("KO: SyncKDE request detected!"); 5042 qDebug("KO: SyncKDE request detected!");
5044 } 5043 }
5045 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5044 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5046 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5045 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5047 return syncCalendar( filename, mode ); 5046 if ( !resource.isEmpty() ) {
5047 int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
5048 qDebug( "KO: Sync request for resource: %s", resource.latin1() );
5049
5050 if ( !exclusiveSyncResource ) {
5051 qDebug( "KO: Requested sync resource not found: %s", resource.latin1() );
5052 return false;
5053 }
5054 mCalendar->setDefaultCalendar( exclusiveSyncResource );
5055 mCalendar->setDefaultCalendarEnabledOnly();
5056 }
5057 bool result = syncCalendar( filename, mode );
5058 if ( !resource.isEmpty() )
5059 restoreCalendarSettings();
5060 return result;
5048} 5061}
5049bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 5062bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
5050{ 5063{
5051 //mSyncManager = manager; 5064 //mSyncManager = manager;
5052 if ( manager != mSyncManager) 5065 if ( manager != mSyncManager)
5053 qDebug("KO: Internal error-2. SyncManager mismatch "); 5066 qDebug("KO: Internal error-2. SyncManager mismatch ");
5054 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5067 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5055 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5068 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5056 if ( resource == "sharp" ) 5069 if ( resource == "sharp" )
5057 syncExternal( 0 ); 5070 syncExternal( 0 );
5058 if ( resource == "phone" ) 5071 if ( resource == "phone" )
5059 syncExternal( 1 ); 5072 syncExternal( 1 );
5060 // pending setmodified 5073 // pending setmodified
5061 return true; 5074 return true;
5062} 5075}
5063void CalendarView::setSyncManager(KSyncManager* manager) 5076void CalendarView::setSyncManager(KSyncManager* manager)
5064{ 5077{
5065 mSyncManager = manager; 5078 mSyncManager = manager;
5066} 5079}
5067 5080
5068void CalendarView::removeSyncInfo( QString syncProfile) 5081void CalendarView::removeSyncInfo( QString syncProfile)
5069{ 5082{
5070 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 5083 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
5071 mCalendar->removeSyncInfo( syncProfile ); 5084 mCalendar->removeSyncInfo( syncProfile );
5072 5085
5073} 5086}
5074 5087
5075void CalendarView::undo_delete() 5088void CalendarView::undo_delete()
5076{ 5089{
5077 //qDebug("undo_delete() "); 5090 //qDebug("undo_delete() ");
5078 Incidence* undo = mCalendar->undoIncidence(); 5091 Incidence* undo = mCalendar->undoIncidence();
5079 if ( !undo ) { 5092 if ( !undo ) {
5080 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 5093 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
5081 i18n("KO/Pi")); 5094 i18n("KO/Pi"));
5082 return; 5095 return;
5083 } 5096 }
5084 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + 5097 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) +
5085 i18n("\nAre you sure you want\nto restore this?"), 5098 i18n("\nAre you sure you want\nto restore this?"),
5086 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 5099 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
5087 mCalendar->undoDeleteIncidence(); 5100 mCalendar->undoDeleteIncidence();
5088 updateView(); 5101 updateView();
5089 } 5102 }
5090} 5103}
5091 5104
5092void CalendarView::slotViewerClosed() 5105void CalendarView::slotViewerClosed()
5093{ 5106{
5094 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 5107 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
5095} 5108}
5096 5109
5097void CalendarView::resetFocus() 5110void CalendarView::resetFocus()
5098{ 5111{
5099 if ( mViewerCallerIsSearchDialog ) { 5112 if ( mViewerCallerIsSearchDialog ) {
5100 if ( mDialogManager->getSearchDialog()->isVisible() ){ 5113 if ( mDialogManager->getSearchDialog()->isVisible() ){
5101 mDialogManager->getSearchDialog()->raise(); 5114 mDialogManager->getSearchDialog()->raise();
5102 mDialogManager->getSearchDialog()->setActiveWindow(); 5115 mDialogManager->getSearchDialog()->setActiveWindow();
5103 mDialogManager->getSearchDialog()->listview()->resetFocus(); 5116 mDialogManager->getSearchDialog()->listview()->resetFocus();
5104 } else 5117 } else
5105 mViewerCallerIsSearchDialog = false; 5118 mViewerCallerIsSearchDialog = false;
5106 } 5119 }
5107 if ( !mViewerCallerIsSearchDialog ) { 5120 if ( !mViewerCallerIsSearchDialog ) {
5108 //mViewManager->currentView()->setFocus(); 5121 //mViewManager->currentView()->setFocus();
5109 //qDebug("sssssssssssssssset focus "); 5122 //qDebug("sssssssssssssssset focus ");
5110 topLevelWidget()->raise(); 5123 topLevelWidget()->raise();
5111 setActiveWindow(); 5124 setActiveWindow();
5112 //setFocus(); 5125 //setFocus();
5113 } 5126 }
5114 mViewerCallerIsSearchDialog = false; 5127 mViewerCallerIsSearchDialog = false;
5115} 5128}
5116 5129
5117void CalendarView::showNextAlarms() 5130void CalendarView::showNextAlarms()
5118{ 5131{
5119 QString message; 5132 QString message;
5120 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 5133 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
5121 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 5134 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
5122 QString sum = mCalendar->nextSummary(); 5135 QString sum = mCalendar->nextSummary();
5123 QDateTime nextA = mNextAlarmDateTime; 5136 QDateTime nextA = mNextAlarmDateTime;
5124 QDateTime cur = QDateTime::currentDateTime(); 5137 QDateTime cur = QDateTime::currentDateTime();
5125 int secs = cur.secsTo( nextA ); 5138 int secs = cur.secsTo( nextA );
5126 int min = secs /60; 5139 int min = secs /60;
5127 int hours = min /60; 5140 int hours = min /60;
5128 min = min % 60; 5141 min = min % 60;
5129 int days = hours /24; 5142 int days = hours /24;
5130 hours = hours % 24; 5143 hours = hours % 24;
5131 5144
5132 //message = i18n("The next alarm is in:\n"); 5145 //message = i18n("The next alarm is in:\n");
5133 if ( days > 1 ) 5146 if ( days > 1 )
5134 message += i18n("%1 days\n").arg( days ); 5147 message += i18n("%1 days\n").arg( days );
5135 else if ( days == 1 ) 5148 else if ( days == 1 )
5136 message += i18n("1 day\n"); 5149 message += i18n("1 day\n");
5137 if ( hours > 1 ) 5150 if ( hours > 1 )
5138 message += i18n("%1 hours\n").arg( hours ); 5151 message += i18n("%1 hours\n").arg( hours );
5139 else if ( hours == 1 ) 5152 else if ( hours == 1 )
5140 message += i18n("1 hour\n"); 5153 message += i18n("1 hour\n");
5141 if ( min > 1 ) 5154 if ( min > 1 )
5142 message += i18n("%1 minutes\n").arg( min ); 5155 message += i18n("%1 minutes\n").arg( min );
5143 else if ( min == 1 ) 5156 else if ( min == 1 )
5144 message += i18n("1 minute\n"); 5157 message += i18n("1 minute\n");
5145 if ( message.isEmpty() ) 5158 if ( message.isEmpty() )
5146 message = i18n("The next alarm is in\nless than one minute!"); 5159 message = i18n("The next alarm is in\nless than one minute!");
5147 else 5160 else
5148 message = i18n("The next alarm is in:\n") + message; 5161 message = i18n("The next alarm is in:\n") + message;
5149 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 5162 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
5150 } else { 5163 } else {
5151 message = i18n("There is no next alarm."); 5164 message = i18n("There is no next alarm.");
5152 5165
5153 } 5166 }
5154#ifdef DESKTOP_VERSION 5167#ifdef DESKTOP_VERSION
5155 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 5168 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
5156 message += i18n("\nThe internal alarm notification is disabled!\n"); 5169 message += i18n("\nThe internal alarm notification is disabled!\n");
5157 message += i18n("Enable it in the settings menu, TAB alarm."); 5170 message += i18n("Enable it in the settings menu, TAB alarm.");
5158 } 5171 }
5159 5172
5160#endif 5173#endif
5161 KMessageBox::information( this, message); 5174 KMessageBox::information( this, message);
5162} 5175}
5163 5176
5164void CalendarView::displayCalendarInfo( int id ) 5177void CalendarView::displayCalendarInfo( int id )
5165{ 5178{
5166 int e, t,j; 5179 int e, t,j;
5167 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 5180 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
5168 QString name = kkf->mName; 5181 QString name = kkf->mName;
5169 mCalendar->getIncidenceCount( id, e, t, j ); 5182 mCalendar->getIncidenceCount( id, e, t, j );
5170 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 5183 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
5171 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); 5184 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file);
5172 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); 5185 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j );
5173 KMessageBox::information( this, mess ); 5186 KMessageBox::information( this, mess );
5174 5187
5175 5188
5176} 5189}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 80f7ed4..f85b6a3 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -329,347 +329,347 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
329 void readFilterSettings(KConfig *config); 329 void readFilterSettings(KConfig *config);
330 330
331 /** write settings for calendar filters */ 331 /** write settings for calendar filters */
332 void writeFilterSettings(KConfig *config); 332 void writeFilterSettings(KConfig *config);
333 333
334 /** passes on the message that an event has changed to the currently 334 /** passes on the message that an event has changed to the currently
335 * activated view so that it can make appropriate display changes. */ 335 * activated view so that it can make appropriate display changes. */
336 void changeEventDisplay(Event *, int); 336 void changeEventDisplay(Event *, int);
337 void changeIncidenceDisplay(Incidence *, int); 337 void changeIncidenceDisplay(Incidence *, int);
338 void changeTodoDisplay(Todo *, int); 338 void changeTodoDisplay(Todo *, int);
339 339
340 void eventAdded(Event *); 340 void eventAdded(Event *);
341 void eventChanged(Event *); 341 void eventChanged(Event *);
342 void eventToBeDeleted(Event *); 342 void eventToBeDeleted(Event *);
343 void eventDeleted(); 343 void eventDeleted();
344 344
345 void todoAdded(Todo *); 345 void todoAdded(Todo *);
346 void todoChanged(Todo *); 346 void todoChanged(Todo *);
347 void todoToBeDeleted(Todo *); 347 void todoToBeDeleted(Todo *);
348 void todoDeleted(); 348 void todoDeleted();
349 349
350 void updateView(const QDate &start, const QDate &end); 350 void updateView(const QDate &start, const QDate &end);
351 void updateView(); 351 void updateView();
352 void clearAllViews(); 352 void clearAllViews();
353 353
354 /** Full update of visible todo views */ 354 /** Full update of visible todo views */
355 void updateTodoViews(); 355 void updateTodoViews();
356 356
357 void updateUnmanagedViews(); 357 void updateUnmanagedViews();
358 358
359 /** cut the current appointment to the clipboard */ 359 /** cut the current appointment to the clipboard */
360 void edit_cut(); 360 void edit_cut();
361 361
362 /** copy the current appointment(s) to the clipboard */ 362 /** copy the current appointment(s) to the clipboard */
363 void edit_copy(); 363 void edit_copy();
364 364
365 /** paste the current vobject(s) in the clipboard buffer into calendar */ 365 /** paste the current vobject(s) in the clipboard buffer into calendar */
366 void edit_paste(); 366 void edit_paste();
367 367
368 /** edit viewing and configuration options. */ 368 /** edit viewing and configuration options. */
369 void edit_options(); 369 void edit_options();
370 void edit_global_options(); 370 void edit_global_options();
371 /** 371 /**
372 Functions for printing, previewing a print, and setting up printing 372 Functions for printing, previewing a print, and setting up printing
373 parameters. 373 parameters.
374 */ 374 */
375 void print(); 375 void print();
376 void printSetup(); 376 void printSetup();
377 void printPreview(); 377 void printPreview();
378 378
379 /** Export as iCalendar file */ 379 /** Export as iCalendar file */
380 bool exportICalendar(); 380 bool exportICalendar();
381 bool exportICalendar( QString fn ); 381 bool exportICalendar( QString fn );
382 382
383 /** Export as vCalendar file */ 383 /** Export as vCalendar file */
384 bool exportVCalendar( QString fn); 384 bool exportVCalendar( QString fn);
385 385
386 /** pop up a dialog to show an existing appointment. */ 386 /** pop up a dialog to show an existing appointment. */
387 void appointment_show(); 387 void appointment_show();
388 /** 388 /**
389 * pop up an Appointment Dialog to edit an existing appointment.Get 389 * pop up an Appointment Dialog to edit an existing appointment.Get
390 * information on the appointment from the list of unique IDs that is 390 * information on the appointment from the list of unique IDs that is
391 * currently in the View, called currIds. 391 * currently in the View, called currIds.
392 */ 392 */
393 void appointment_edit(); 393 void appointment_edit();
394 /** 394 /**
395 * pop up dialog confirming deletion of currently selected event in the 395 * pop up dialog confirming deletion of currently selected event in the
396 * View. 396 * View.
397 */ 397 */
398 void appointment_delete(); 398 void appointment_delete();
399 399
400 /** mails the currently selected event to a particular user as a vCalendar 400 /** mails the currently selected event to a particular user as a vCalendar
401 attachment. */ 401 attachment. */
402 void action_mail(); 402 void action_mail();
403 403
404 /* frees a subtodo from it's relation */ 404 /* frees a subtodo from it's relation */
405 void todo_unsub( Todo * ); 405 void todo_unsub( Todo * );
406 void todo_resub( Todo * parent, Todo * sub ); 406 void todo_resub( Todo * parent, Todo * sub );
407 407
408 /** Take ownership of selected event. */ 408 /** Take ownership of selected event. */
409 void takeOverEvent(); 409 void takeOverEvent();
410 410
411 /** Take ownership of all events in calendar. */ 411 /** Take ownership of all events in calendar. */
412 void takeOverCalendar(); 412 void takeOverCalendar();
413 413
414 /** query whether or not the calendar is "dirty". */ 414 /** query whether or not the calendar is "dirty". */
415 bool isModified(); 415 bool isModified();
416 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 416 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
417 void setModified(bool modified=true); 417 void setModified(bool modified=true);
418 418
419 /** query if the calendar is read-only. */ 419 /** query if the calendar is read-only. */
420 bool isReadOnly(); 420 bool isReadOnly();
421 /** set state of calendar to read-only */ 421 /** set state of calendar to read-only */
422 void setReadOnly(bool readOnly=true); 422 void setReadOnly(bool readOnly=true);
423 423
424 void eventUpdated(Incidence *); 424 void eventUpdated(Incidence *);
425 425
426 /* iTIP scheduling actions */ 426 /* iTIP scheduling actions */
427 void schedule_publish(Incidence *incidence = 0); 427 void schedule_publish(Incidence *incidence = 0);
428 void schedule_request(Incidence *incidence = 0); 428 void schedule_request(Incidence *incidence = 0);
429 void schedule_refresh(Incidence *incidence = 0); 429 void schedule_refresh(Incidence *incidence = 0);
430 void schedule_cancel(Incidence *incidence = 0); 430 void schedule_cancel(Incidence *incidence = 0);
431 void schedule_add(Incidence *incidence = 0); 431 void schedule_add(Incidence *incidence = 0);
432 void schedule_reply(Incidence *incidence = 0); 432 void schedule_reply(Incidence *incidence = 0);
433 void schedule_counter(Incidence *incidence = 0); 433 void schedule_counter(Incidence *incidence = 0);
434 void schedule_declinecounter(Incidence *incidence = 0); 434 void schedule_declinecounter(Incidence *incidence = 0);
435 void schedule_publish_freebusy(int daysToPublish = 30); 435 void schedule_publish_freebusy(int daysToPublish = 30);
436 436
437 void openAddressbook(); 437 void openAddressbook();
438 438
439 void editFilters(); 439 void editFilters();
440 void toggleFilerEnabled(); 440 void toggleFilerEnabled();
441 QPtrList<CalFilter> filters(); 441 QPtrList<CalFilter> filters();
442 void toggleFilter(); 442 void toggleFilter();
443 void showFilter(bool visible); 443 void showFilter(bool visible);
444 void updateFilter(); 444 void updateFilter();
445 void filterEdited(); 445 void filterEdited();
446 void selectFilter( int ); 446 void selectFilter( int );
447 KOFilterView *filterView(); 447 KOFilterView *filterView();
448 448
449 void showIntro(); 449 void showIntro();
450 450
451 /** Move the curdatepient view date to today */ 451 /** Move the curdatepient view date to today */
452 void goToday(); 452 void goToday();
453 453
454 /** Move to the next date(s) in the current view */ 454 /** Move to the next date(s) in the current view */
455 void goNext(); 455 void goNext();
456 456
457 /** Move to the previous date(s) in the current view */ 457 /** Move to the previous date(s) in the current view */
458 void goPrevious(); 458 void goPrevious();
459 /** Move to the next date(s) in the current view */ 459 /** Move to the next date(s) in the current view */
460 void goNextMonth(); 460 void goNextMonth();
461 461
462 /** Move to the previous date(s) in the current view */ 462 /** Move to the previous date(s) in the current view */
463 void goPreviousMonth(); 463 void goPreviousMonth();
464 464
465 void toggleExpand(); 465 void toggleExpand();
466 void toggleDateNavigatorWidget(); 466 void toggleDateNavigatorWidget();
467 void toggleAllDaySize(); 467 void toggleAllDaySize();
468 468
469 /** Look for new messages in the inbox */ 469 /** Look for new messages in the inbox */
470 void lookForIncomingMessages(); 470 void lookForIncomingMessages();
471 /** Look for new messages in the outbox */ 471 /** Look for new messages in the outbox */
472 void lookForOutgoingMessages(); 472 void lookForOutgoingMessages();
473 473
474 void processMainViewSelection( Incidence * ); 474 void processMainViewSelection( Incidence * );
475 void processTodoListSelection( Incidence * ); 475 void processTodoListSelection( Incidence * );
476 476
477 void processIncidenceSelection( Incidence * ); 477 void processIncidenceSelection( Incidence * );
478 478
479 void purgeCompleted(); 479 void purgeCompleted();
480 bool removeCompletedSubTodos( Todo* ); 480 bool removeCompletedSubTodos( Todo* );
481 void slotCalendarChanged(); 481 void slotCalendarChanged();
482 bool importBday(); 482 bool importBday();
483 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 483 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
484 bool importQtopia( const QString &categoriesFile, 484 bool importQtopia( const QString &categoriesFile,
485 const QString &datebookFile, 485 const QString &datebookFile,
486 const QString &tasklistFile ); 486 const QString &tasklistFile );
487 void syncExternal( int mode ); 487 void syncExternal( int mode );
488 void slotSelectPickerDate( QDate ) ; 488 void slotSelectPickerDate( QDate ) ;
489 void showDatePicker() ; 489 void showDatePicker() ;
490 void showDatePickerPopup() ; 490 void showDatePickerPopup() ;
491 void moveIncidence(Incidence *) ; 491 void moveIncidence(Incidence *) ;
492 void beamIncidence(Incidence *) ; 492 void beamIncidence(Incidence *) ;
493 void beamCalendar() ; 493 void beamCalendar() ;
494 void beamFilteredCalendar() ; 494 void beamFilteredCalendar() ;
495 void beamIncidenceList(QPtrList<Incidence>) ; 495 void beamIncidenceList(QPtrList<Incidence>) ;
496 void manageCategories(); 496 void manageCategories();
497 void editCategories(); 497 void editCategories();
498 int addCategories(); 498 int addCategories();
499 void removeCategories(); 499 void removeCategories();
500 void setSyncDevice( QString ); 500 void setSyncDevice( QString );
501 void setSyncName( QString ); 501 void setSyncName( QString );
502 void showDay( QDate ); 502 void showDay( QDate );
503 void undo_delete(); 503 void undo_delete();
504 protected slots: 504 protected slots:
505 void resetFocus(); 505 void resetFocus();
506 void scrollBarValue(int); 506 void scrollBarValue(int);
507 void slotViewerClosed(); 507 void slotViewerClosed();
508 void timerAlarm(); 508 void timerAlarm();
509 void suspendAlarm(); 509 void suspendAlarm();
510 void beamDone( Ir *ir ); 510 void beamDone( Ir *ir );
511 /** Select a view or adapt the current view to display the specified dates. */ 511 /** Select a view or adapt the current view to display the specified dates. */
512 void showDates( const KCal::DateList & ); 512 void showDates( const KCal::DateList & );
513 void selectWeekNum ( int ); 513 void selectWeekNum ( int );
514 void checkConflictForEvent(); 514 void checkConflictForEvent();
515 515
516 public: 516 public:
517 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); 517 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval );
518 // show a standard warning 518 // show a standard warning
519 // returns KMsgBox::yesNoCancel() 519 // returns KMsgBox::yesNoCancel()
520 int msgCalModified(); 520 int msgCalModified();
521 virtual bool sync(KSyncManager* manager, QString filename, int mode); 521 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource);
522 522
523 virtual bool syncExternal(KSyncManager* manager, QString resource); 523 virtual bool syncExternal(KSyncManager* manager, QString resource);
524 virtual void removeSyncInfo( QString syncProfile); 524 virtual void removeSyncInfo( QString syncProfile);
525 void setSyncManager(KSyncManager* manager); 525 void setSyncManager(KSyncManager* manager);
526 void setLoadedFileVersion(QDateTime); 526 void setLoadedFileVersion(QDateTime);
527 bool checkFileVersion(QString fn); 527 bool checkFileVersion(QString fn);
528 bool checkAllFileVersions(); 528 bool checkAllFileVersions();
529 bool checkFileChanged(QString fn); 529 bool checkFileChanged(QString fn);
530 Event* getLastSyncEvent(); 530 Event* getLastSyncEvent();
531 /** Adapt navigation units correpsonding to step size of navigation of the 531 /** Adapt navigation units correpsonding to step size of navigation of the
532 * current view. 532 * current view.
533 */ 533 */
534 void adaptNavigationUnits(); 534 void adaptNavigationUnits();
535 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 535 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
536 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 536 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
537 //Attendee* getYourAttendee(Event *event); 537 //Attendee* getYourAttendee(Event *event);
538 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 538 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
539 void setScrollBarStep(int val ); 539 void setScrollBarStep(int val );
540 540
541 protected: 541 protected:
542 Event *mConflictingEvent; 542 Event *mConflictingEvent;
543 void schedule(Scheduler::Method, Incidence *incidence = 0); 543 void schedule(Scheduler::Method, Incidence *incidence = 0);
544 544
545 // returns KMsgBox::OKCandel() 545 // returns KMsgBox::OKCandel()
546 int msgItemDelete(const QString name); 546 int msgItemDelete(const QString name);
547 void showEventEditor(); 547 void showEventEditor();
548 void showTodoEditor(); 548 void showTodoEditor();
549 Todo *selectedTodo(); 549 Todo *selectedTodo();
550 private: 550 private:
551#ifdef DESKTOP_VERSION 551#ifdef DESKTOP_VERSION
552 QScrollBar * mDateScrollBar; 552 QScrollBar * mDateScrollBar;
553#endif 553#endif
554 bool flag_blockConflict; 554 bool flag_blockConflict;
555 bool flag_blockScrollBar; 555 bool flag_blockScrollBar;
556 bool flag_checkFileFirsttime; 556 bool flag_checkFileFirsttime;
557 bool flag_clearallviewsEventDisplay; 557 bool flag_clearallviewsEventDisplay;
558 bool flag_clearallviewsupdateView; 558 bool flag_clearallviewsupdateView;
559 QDateTime mNextAlarmDateTime; 559 QDateTime mNextAlarmDateTime;
560 bool mViewerCallerIsSearchDialog; 560 bool mViewerCallerIsSearchDialog;
561 bool mBlockShowDates; 561 bool mBlockShowDates;
562 KSyncManager* mSyncManager; 562 KSyncManager* mSyncManager;
563 AlarmDialog * mAlarmDialog; 563 AlarmDialog * mAlarmDialog;
564 QString mAlarmNotification; 564 QString mAlarmNotification;
565 QString mSuspendAlarmNotification; 565 QString mSuspendAlarmNotification;
566 QTimer* mSuspendTimer; 566 QTimer* mSuspendTimer;
567 QTimer* mAlarmTimer; 567 QTimer* mAlarmTimer;
568 QTimer* mRecheckAlarmTimer; 568 QTimer* mRecheckAlarmTimer;
569 void computeAlarm( QString ); 569 void computeAlarm( QString );
570 void startAlarm( QString, QString ); 570 void startAlarm( QString, QString );
571 void setSyncEventsReadOnly(); 571 void setSyncEventsReadOnly();
572 572
573 QDateTime loadedFileVersion; 573 QDateTime loadedFileVersion;
574 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 574 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
575 void checkExternalId( Incidence * inc ); 575 void checkExternalId( Incidence * inc );
576 int mGlobalSyncMode; 576 int mGlobalSyncMode;
577 QString mCurrentSyncDevice; 577 QString mCurrentSyncDevice;
578 QString mCurrentSyncName; 578 QString mCurrentSyncName;
579 void init(); 579 void init();
580 int mDatePickerMode; 580 int mDatePickerMode;
581 bool mFlagEditDescription; 581 bool mFlagEditDescription;
582 QDateTime mLastCalendarSync; 582 QDateTime mLastCalendarSync;
583 void createPrinter(); 583 void createPrinter();
584 584
585 void calendarModified( bool, Calendar * ); 585 void calendarModified( bool, Calendar * );
586 586
587 CalPrinter *mCalPrinter; 587 CalPrinter *mCalPrinter;
588 588
589 QSplitter *mPanner; 589 QSplitter *mPanner;
590 QSplitter *mLeftSplitter; 590 QSplitter *mLeftSplitter;
591 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 591 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
592 QWidgetStack *mRightFrame; 592 QWidgetStack *mRightFrame;
593 593
594 KDatePicker* mDatePicker; 594 KDatePicker* mDatePicker;
595 QVBox* mDateFrame; 595 QVBox* mDateFrame;
596 596
597 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 597 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
598 598
599 KOFilterView *mFilterView; 599 KOFilterView *mFilterView;
600 KOCalEditView *mCalEditView; 600 KOCalEditView *mCalEditView;
601 601
602 ResourceView *mResourceView; 602 ResourceView *mResourceView;
603 603
604 // calendar object for this viewing instance 604 // calendar object for this viewing instance
605 Calendar *mCalendar; 605 Calendar *mCalendar;
606 606
607 CalendarResourceManager *mResourceManager; 607 CalendarResourceManager *mResourceManager;
608 608
609 FileStorage *mStorage; 609 FileStorage *mStorage;
610 610
611 DateNavigator *mNavigator; 611 DateNavigator *mNavigator;
612 612
613 KOViewManager *mViewManager; 613 KOViewManager *mViewManager;
614 KODialogManager *mDialogManager; 614 KODialogManager *mDialogManager;
615 615
616 // Calendar filters 616 // Calendar filters
617 QPtrList<CalFilter> mFilters; 617 QPtrList<CalFilter> mFilters;
618 618
619 // various housekeeping variables. 619 // various housekeeping variables.
620 bool mModified; // flag indicating if calendar is modified 620 bool mModified; // flag indicating if calendar is modified
621 bool mReadOnly; // flag indicating if calendar is read-only 621 bool mReadOnly; // flag indicating if calendar is read-only
622 QDate mSaveSingleDate; 622 QDate mSaveSingleDate;
623 623
624 Incidence *mSelectedIncidence; 624 Incidence *mSelectedIncidence;
625 Incidence *mMoveIncidence; 625 Incidence *mMoveIncidence;
626 QDate mMoveIncidenceOldDate; 626 QDate mMoveIncidenceOldDate;
627 KOTodoView *mTodoList; 627 KOTodoView *mTodoList;
628 KOEventEditor * mEventEditor; 628 KOEventEditor * mEventEditor;
629 KOTodoEditor * mTodoEditor; 629 KOTodoEditor * mTodoEditor;
630 KOEventViewerDialog * mEventViewerDialog; 630 KOEventViewerDialog * mEventViewerDialog;
631 void keyPressEvent ( QKeyEvent *e) ; 631 void keyPressEvent ( QKeyEvent *e) ;
632 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 632 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
633}; 633};
634 634
635 635
636class CalendarViewVisitor : public Incidence::Visitor 636class CalendarViewVisitor : public Incidence::Visitor
637{ 637{
638 public: 638 public:
639 CalendarViewVisitor() : mView( 0 ) {} 639 CalendarViewVisitor() : mView( 0 ) {}
640 640
641 bool act( Incidence *incidence, CalendarView *view ) 641 bool act( Incidence *incidence, CalendarView *view )
642 { 642 {
643 mView = view; 643 mView = view;
644 return incidence->accept( *this ); 644 return incidence->accept( *this );
645 } 645 }
646 646
647 protected: 647 protected:
648 CalendarView *mView; 648 CalendarView *mView;
649}; 649};
650 650
651class ShowIncidenceVisitor : public CalendarViewVisitor 651class ShowIncidenceVisitor : public CalendarViewVisitor
652{ 652{
653 protected: 653 protected:
654 bool visit( Event *event ) { mView->showEvent( event ); return true; } 654 bool visit( Event *event ) { mView->showEvent( event ); return true; }
655 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 655 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
656 bool visit( Journal * j ) { mView->showJournal( j );return true; } 656 bool visit( Journal * j ) { mView->showJournal( j );return true; }
657}; 657};
658 658
659class EditIncidenceVisitor : public CalendarViewVisitor 659class EditIncidenceVisitor : public CalendarViewVisitor
660{ 660{
661 protected: 661 protected:
662 bool visit( Event *event ) { mView->editEvent( event ); return true; } 662 bool visit( Event *event ) { mView->editEvent( event ); return true; }
663 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 663 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
664 bool visit( Journal *j ) { mView->editJournal( j); return true; } 664 bool visit( Journal *j ) { mView->editJournal( j); return true; }
665}; 665};
666 666
667class DeleteIncidenceVisitor : public CalendarViewVisitor 667class DeleteIncidenceVisitor : public CalendarViewVisitor
668{ 668{
669 protected: 669 protected:
670 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 670 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
671 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 671 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
672 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 672 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
673}; 673};
674 674
675#endif 675#endif
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 1b0e5f4..31ef338 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -339,298 +339,308 @@ KOPrefs::KOPrefs() :
339KOPrefs::~KOPrefs() 339KOPrefs::~KOPrefs()
340{ 340{
341 if (mInstance == this) 341 if (mInstance == this)
342 mInstance = insd.setObject(0); 342 mInstance = insd.setObject(0);
343 mCalendars.setAutoDelete( true ); 343 mCalendars.setAutoDelete( true );
344 mCalendars.clear(); 344 mCalendars.clear();
345 //qDebug("KOPrefs::~KOPrefs() "); 345 //qDebug("KOPrefs::~KOPrefs() ");
346} 346}
347 347
348 348
349KOPrefs *KOPrefs::instance() 349KOPrefs *KOPrefs::instance()
350{ 350{
351 if (!mInstance) { 351 if (!mInstance) {
352 mInstance = insd.setObject(new KOPrefs()); 352 mInstance = insd.setObject(new KOPrefs());
353 mInstance->readConfig(); 353 mInstance->readConfig();
354 } 354 }
355 355
356 return mInstance; 356 return mInstance;
357} 357}
358 358
359void KOPrefs::usrSetDefaults() 359void KOPrefs::usrSetDefaults()
360{ 360{
361 361
362} 362}
363 363
364void KOPrefs::fillMailDefaults() 364void KOPrefs::fillMailDefaults()
365{ 365{
366 if (mName.isEmpty()) mName = i18n("Anonymous"); 366 if (mName.isEmpty()) mName = i18n("Anonymous");
367 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 367 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
368} 368}
369 369
370void KOPrefs::setTimeZoneIdDefault() 370void KOPrefs::setTimeZoneIdDefault()
371{ 371{
372 ; 372 ;
373} 373}
374 374
375void KOPrefs::setAllDefaults() 375void KOPrefs::setAllDefaults()
376{ 376{
377 setCategoryDefaults(); 377 setCategoryDefaults();
378 mEventSummaryUser = getDefaultList() ; 378 mEventSummaryUser = getDefaultList() ;
379 mTodoSummaryUser = getDefaultList() ; 379 mTodoSummaryUser = getDefaultList() ;
380 mJournalSummaryUser = getDefaultList() ; 380 mJournalSummaryUser = getDefaultList() ;
381 mLocationDefaults = getLocationDefaultList(); 381 mLocationDefaults = getLocationDefaultList();
382} 382}
383 383
384void KOPrefs::setCategoryDefaults() 384void KOPrefs::setCategoryDefaults()
385{ 385{
386 mCustomCategories.clear(); 386 mCustomCategories.clear();
387 mCustomCategories = getDefaultList(); 387 mCustomCategories = getDefaultList();
388 388
389 QStringList::Iterator it; 389 QStringList::Iterator it;
390 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 390 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
391 setCategoryColor(*it,mDefaultCategoryColor); 391 setCategoryColor(*it,mDefaultCategoryColor);
392 } 392 }
393} 393}
394QStringList KOPrefs::getLocationDefaultList() 394QStringList KOPrefs::getLocationDefaultList()
395{ 395{
396 QStringList retval ; 396 QStringList retval ;
397 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 397 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
398 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 398 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
399 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 399 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
400 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 400 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
401 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 401 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
402 402
403 retval.sort(); 403 retval.sort();
404 return retval; 404 return retval;
405} 405}
406QStringList KOPrefs::getDefaultList() 406QStringList KOPrefs::getDefaultList()
407{ 407{
408 QStringList retval ; 408 QStringList retval ;
409 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") 409 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer")
410 << i18n("Break") 410 << i18n("Break")
411 << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") 411 << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts")
412 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") 412 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts")
413 << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") 413 << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal")
414 << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") 414 << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping")
415 << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") 415 << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")
416 << i18n("Vacation") ; 416 << i18n("Vacation") ;
417 retval.sort(); 417 retval.sort();
418 //qDebug("cat %s ", retval.join("-").latin1()); 418 //qDebug("cat %s ", retval.join("-").latin1());
419 return retval; 419 return retval;
420} 420}
421// << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") 421// << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema")
422void KOPrefs::usrReadConfig() 422void KOPrefs::usrReadConfig()
423{ 423{
424 config()->setGroup("General"); 424 config()->setGroup("General");
425 425
426 //qDebug("KOPrefs::usrReadConfig() "); 426 //qDebug("KOPrefs::usrReadConfig() ");
427 mCustomCategories = config()->readListEntry("Custom Categories"); 427 mCustomCategories = config()->readListEntry("Custom Categories");
428 mOldLoadedLanguage = mOldLanguage ; 428 mOldLoadedLanguage = mOldLanguage ;
429 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 429 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
430 if (mLocationDefaults.isEmpty()) { 430 if (mLocationDefaults.isEmpty()) {
431 mLocationDefaults = getLocationDefaultList(); 431 mLocationDefaults = getLocationDefaultList();
432 } 432 }
433 433
434 if (mEventSummaryUser.isEmpty()) { 434 if (mEventSummaryUser.isEmpty()) {
435 mEventSummaryUser = getDefaultList() ; 435 mEventSummaryUser = getDefaultList() ;
436 } 436 }
437 if (mTodoSummaryUser.isEmpty()) { 437 if (mTodoSummaryUser.isEmpty()) {
438 mTodoSummaryUser = getDefaultList() ; 438 mTodoSummaryUser = getDefaultList() ;
439 } 439 }
440 440
441 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 441 if (mCustomCategories.isEmpty()) setCategoryDefaults();
442 442
443 config()->setGroup("Personal Settings"); 443 config()->setGroup("Personal Settings");
444 mName = config()->readEntry("user_name",""); 444 mName = config()->readEntry("user_name","");
445 mEmail = config()->readEntry("user_email",""); 445 mEmail = config()->readEntry("user_email","");
446 fillMailDefaults(); 446 fillMailDefaults();
447 447
448 config()->setGroup("Category Colors"); 448 config()->setGroup("Category Colors");
449 QStringList::Iterator it; 449 QStringList::Iterator it;
450 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 450 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
451 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 451 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
452 452
453 } 453 }
454 KConfig fc (locateLocal("config","kopicalendarrc")); 454 KConfig fc (locateLocal("config","kopicalendarrc"));
455 fc.setGroup("CC"); 455 fc.setGroup("CC");
456 int numCals = fc.readNumEntry("NumberCalendars",0 ); 456 int numCals = fc.readNumEntry("NumberCalendars",0 );
457 mNextAvailableCalendar = 1; 457 mNextAvailableCalendar = 1;
458 if ( numCals == 0 ) { 458 if ( numCals == 0 ) {
459 KopiCalendarFile *kkf = getNewCalendar(); 459 KopiCalendarFile *kkf = getNewCalendar();
460 kkf->isStandard = true; 460 kkf->isStandard = true;
461 kkf->mName = i18n("Standard"); 461 kkf->mName = i18n("Standard");
462 kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); 462 kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) );
463 } 463 }
464 while ( mNextAvailableCalendar <= numCals ) { 464 while ( mNextAvailableCalendar <= numCals ) {
465 //qDebug("Read cal #%d ", mNextAvailableCalendar ); 465 //qDebug("Read cal #%d ", mNextAvailableCalendar );
466 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); 466 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
467 KopiCalendarFile *kkf = getNewCalendar(); 467 KopiCalendarFile *kkf = getNewCalendar();
468 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); 468 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false );
469 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); 469 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true);
470 kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); 470 kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false );
471 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); 471 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true);
472 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); 472 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false);
473 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); 473 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar");
474 kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); 474 kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) );
475 kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); 475 kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) );
476 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); 476 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor);
477 if ( kkf->mCalNumber == 1 ) { 477 if ( kkf->mCalNumber == 1 ) {
478 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 478 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
479 } 479 }
480 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); 480 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() );
481 if ( kkf->mName == i18n("Birthdays") ) { 481 if ( kkf->mName == i18n("Birthdays") ) {
482 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); 482 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" );
483 } 483 }
484 if ( kkf->isRelative ) 484 if ( kkf->isRelative )
485 kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); 485 kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName );
486 } 486 }
487 487
488 KPimPrefs::usrReadConfig(); 488 KPimPrefs::usrReadConfig();
489} 489}
490 490
491KopiCalendarFile * KOPrefs::getCalendar( int num ) 491KopiCalendarFile * KOPrefs::getCalendar( int num )
492{ 492{
493 return mDefCalColors[num-1]; 493 return mDefCalColors[num-1];
494} 494}
495 495
496KopiCalendarFile * KOPrefs::getNewCalendar() 496KopiCalendarFile * KOPrefs::getNewCalendar()
497{ 497{
498 KopiCalendarFile * kkf = new KopiCalendarFile(); 498 KopiCalendarFile * kkf = new KopiCalendarFile();
499 kkf->mCalNumber = mNextAvailableCalendar; 499 kkf->mCalNumber = mNextAvailableCalendar;
500 mDefCalColors.resize( mNextAvailableCalendar ); 500 mDefCalColors.resize( mNextAvailableCalendar );
501 mDefCalColors[mNextAvailableCalendar-1] = kkf; 501 mDefCalColors[mNextAvailableCalendar-1] = kkf;
502 ++mNextAvailableCalendar; 502 ++mNextAvailableCalendar;
503 kkf->mDefaultColor = mEventColor; 503 kkf->mDefaultColor = mEventColor;
504 kkf->mName = i18n("New Calendar"); 504 kkf->mName = i18n("New Calendar");
505 mCalendars.append( kkf ); 505 mCalendars.append( kkf );
506 return kkf; 506 return kkf;
507} 507}
508void KOPrefs::deleteCalendar( int num ) 508void KOPrefs::deleteCalendar( int num )
509{ 509{
510 KopiCalendarFile * kkf = mCalendars.first(); 510 KopiCalendarFile * kkf = mCalendars.first();
511 while ( kkf ) { 511 while ( kkf ) {
512 if ( kkf->mCalNumber == num ) { 512 if ( kkf->mCalNumber == num ) {
513 qDebug("KOPrefs::deleteCalendar %d ", num ); 513 qDebug("KOPrefs::deleteCalendar %d ", num );
514 mCalendars.remove( kkf ); 514 mCalendars.remove( kkf );
515 delete kkf; 515 delete kkf;
516 return; 516 return;
517 } 517 }
518 kkf = mCalendars.next(); 518 kkf = mCalendars.next();
519 } 519 }
520} 520}
521int KOPrefs::getCalendarID( const QString & name ) 521int KOPrefs::getCalendarID( const QString & name )
522{ 522{
523 KopiCalendarFile * kkf = mCalendars.first(); 523 KopiCalendarFile * kkf = mCalendars.first();
524 while ( kkf ) { 524 while ( kkf ) {
525 if ( name == kkf->mName) 525 if ( name == kkf->mName)
526 return kkf->mCalNumber; 526 return kkf->mCalNumber;
527 kkf = mCalendars.next(); 527 kkf = mCalendars.next();
528 } 528 }
529 return 1; 529 return 1;
530} 530}
531int KOPrefs::getFuzzyCalendarID( const QString & name )
532{
533 KopiCalendarFile * kkf = mCalendars.first();
534 while ( kkf ) {
535 if ( name.lower() == kkf->mName.lower())
536 return kkf->mCalNumber;
537 kkf = mCalendars.next();
538 }
539 return 0;
540}
531QString KOPrefs::calName( int calNum) const 541QString KOPrefs::calName( int calNum) const
532{ 542{
533 return (mDefCalColors[calNum-1])->mName; 543 return (mDefCalColors[calNum-1])->mName;
534} 544}
535QColor KOPrefs::defaultColor( int calNum ) const 545QColor KOPrefs::defaultColor( int calNum ) const
536{ 546{
537 if ( calNum == 1 ) return mEventColor; 547 if ( calNum == 1 ) return mEventColor;
538 return (mDefCalColors[calNum-1])->mDefaultColor; 548 return (mDefCalColors[calNum-1])->mDefaultColor;
539} 549}
540void KOPrefs::usrWriteConfig() 550void KOPrefs::usrWriteConfig()
541{ 551{
542 config()->setGroup("General"); 552 config()->setGroup("General");
543 config()->writeEntry("Custom Categories",mCustomCategories); 553 config()->writeEntry("Custom Categories",mCustomCategories);
544 554
545 config()->setGroup("Personal Settings"); 555 config()->setGroup("Personal Settings");
546 config()->writeEntry("user_name",mName); 556 config()->writeEntry("user_name",mName);
547 config()->writeEntry("user_email",mEmail); 557 config()->writeEntry("user_email",mEmail);
548 558
549 config()->setGroup("Category Colors"); 559 config()->setGroup("Category Colors");
550 QDictIterator<QColor> it(mCategoryColors); 560 QDictIterator<QColor> it(mCategoryColors);
551 while (it.current()) { 561 while (it.current()) {
552 config()->writeEntry(it.currentKey(),*(it.current())); 562 config()->writeEntry(it.currentKey(),*(it.current()));
553 ++it; 563 ++it;
554 } 564 }
555 KConfig fc (locateLocal("config","kopicalendarrc")); 565 KConfig fc (locateLocal("config","kopicalendarrc"));
556 fc.setGroup("CC"); 566 fc.setGroup("CC");
557 fc.deleteGroup( "CC"); 567 fc.deleteGroup( "CC");
558 fc.setGroup("CC"); 568 fc.setGroup("CC");
559 fc.writeEntry("NumberCalendars",mCalendars.count()); 569 fc.writeEntry("NumberCalendars",mCalendars.count());
560 int numCal = 1; 570 int numCal = 1;
561 int writeCal = 0; 571 int writeCal = 0;
562 while ( numCal < mNextAvailableCalendar ) { 572 while ( numCal < mNextAvailableCalendar ) {
563 KopiCalendarFile * kkf = mCalendars.first(); 573 KopiCalendarFile * kkf = mCalendars.first();
564 while ( kkf ) { 574 while ( kkf ) {
565 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); 575 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
566 if ( kkf->mCalNumber == numCal ) { 576 if ( kkf->mCalNumber == numCal ) {
567 ++writeCal; 577 ++writeCal;
568 //qDebug("Write calendar %d %d ", numCal , writeCal); 578 //qDebug("Write calendar %d %d ", numCal , writeCal);
569 QString prefix = "Cal_" + QString::number( writeCal ); 579 QString prefix = "Cal_" + QString::number( writeCal );
570 fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); 580 fc.writeEntry( prefix+"_isStandard", kkf->isStandard );
571 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); 581 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled );
572 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); 582 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
573 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); 583 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
574 fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); 584 fc.writeEntry( prefix+"_isRelative", kkf->isRelative );
575 fc.writeEntry( prefix+"_Name", kkf->mName); 585 fc.writeEntry( prefix+"_Name", kkf->mName);
576 fc.writeEntry( prefix+"_FileName", kkf->mFileName); 586 fc.writeEntry( prefix+"_FileName", kkf->mFileName);
577 fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); 587 fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName);
578 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); 588 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor);
579 } 589 }
580 kkf = mCalendars.next(); 590 kkf = mCalendars.next();
581 } 591 }
582 ++numCal; 592 ++numCal;
583 } 593 }
584 fc.sync(); 594 fc.sync();
585 KPimPrefs::usrWriteConfig(); 595 KPimPrefs::usrWriteConfig();
586} 596}
587 597
588void KOPrefs::setCategoryColor(QString cat,const QColor & color) 598void KOPrefs::setCategoryColor(QString cat,const QColor & color)
589{ 599{
590 mCategoryColors.replace(cat,new QColor(color)); 600 mCategoryColors.replace(cat,new QColor(color));
591} 601}
592 602
593QColor *KOPrefs::categoryColor(QString cat) 603QColor *KOPrefs::categoryColor(QString cat)
594{ 604{
595 QColor *color = 0; 605 QColor *color = 0;
596 606
597 if (!cat.isEmpty()) color = mCategoryColors[cat]; 607 if (!cat.isEmpty()) color = mCategoryColors[cat];
598 608
599 if (color) return color; 609 if (color) return color;
600 else return &mDefaultCategoryColor; 610 else return &mDefaultCategoryColor;
601} 611}
602 612
603void KOPrefs::setFullName(const QString &name) 613void KOPrefs::setFullName(const QString &name)
604{ 614{
605 mName = name; 615 mName = name;
606} 616}
607 617
608void KOPrefs::setEmail(const QString &email) 618void KOPrefs::setEmail(const QString &email)
609{ 619{
610 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 620 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
611 mEmail = email; 621 mEmail = email;
612} 622}
613 623
614QString KOPrefs::fullName() 624QString KOPrefs::fullName()
615{ 625{
616 if (mEmailControlCenter) { 626 if (mEmailControlCenter) {
617 KEMailSettings settings; 627 KEMailSettings settings;
618 return settings.getSetting(KEMailSettings::RealName); 628 return settings.getSetting(KEMailSettings::RealName);
619 } else { 629 } else {
620 return mName; 630 return mName;
621 } 631 }
622} 632}
623 633
624QString KOPrefs::email() 634QString KOPrefs::email()
625{ 635{
626 if (mEmailControlCenter) { 636 if (mEmailControlCenter) {
627 KEMailSettings settings; 637 KEMailSettings settings;
628 return settings.getSetting(KEMailSettings::EmailAddress); 638 return settings.getSetting(KEMailSettings::EmailAddress);
629 } else { 639 } else {
630 return mEmail; 640 return mEmail;
631 } 641 }
632} 642}
633KConfig* KOPrefs::getConfig() 643KConfig* KOPrefs::getConfig()
634{ 644{
635 return config(); 645 return config();
636} 646}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index bac8010..70da096 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,299 +1,300 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26 26
27#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
28#include <qdict.h> 28#include <qdict.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qobject.h> 30#include <qobject.h>
31 31
32class KConfig; 32class KConfig;
33class QFont; 33class QFont;
34class QColor; 34class QColor;
35class QStringList; 35class QStringList;
36 36
37#define VIEW_WN_VIEW 1 37#define VIEW_WN_VIEW 1
38#define VIEW_NX_VIEW 2 38#define VIEW_NX_VIEW 2
39#define VIEW_J_VIEW 3 39#define VIEW_J_VIEW 3
40#define VIEW_A_VIEW 4 40#define VIEW_A_VIEW 4
41#define VIEW_ML_VIEW 5 41#define VIEW_ML_VIEW 5
42#define VIEW_M_VIEW 6 42#define VIEW_M_VIEW 6
43#define VIEW_L_VIEW 7 43#define VIEW_L_VIEW 7
44#define VIEW_T_VIEW 8 44#define VIEW_T_VIEW 8
45 45
46class KopiCalendarFile : public QObject 46class KopiCalendarFile : public QObject
47{ 47{
48 public: 48 public:
49 KopiCalendarFile( ) : QObject( ) 49 KopiCalendarFile( ) : QObject( )
50 { 50 {
51 isStandard = false; 51 isStandard = false;
52 isEnabled = true; 52 isEnabled = true;
53 isAlarmEnabled = true; 53 isAlarmEnabled = true;
54 isReadOnly = false; 54 isReadOnly = false;
55 mName = "Calendar"; 55 mName = "Calendar";
56 mFileName = QDir::homeDirPath() + "/icalfile.ics"; 56 mFileName = QDir::homeDirPath() + "/icalfile.ics";
57 mSavedFileName = "icalfile.ics"; 57 mSavedFileName = "icalfile.ics";
58 mCalNumber = 0; 58 mCalNumber = 0;
59 mDefaultColor = Qt::red; 59 mDefaultColor = Qt::red;
60 mErrorOnLoad = false; 60 mErrorOnLoad = false;
61 isRelative = false; 61 isRelative = false;
62 } 62 }
63 bool isStandard; 63 bool isStandard;
64 bool isEnabled; 64 bool isEnabled;
65 bool isAlarmEnabled; 65 bool isAlarmEnabled;
66 bool isReadOnly; 66 bool isReadOnly;
67 bool mErrorOnLoad; 67 bool mErrorOnLoad;
68 QString mName; 68 QString mName;
69 QString mFileName; 69 QString mFileName;
70 QString mSavedFileName; 70 QString mSavedFileName;
71 bool isRelative; 71 bool isRelative;
72 int mCalNumber; 72 int mCalNumber;
73 QColor mDefaultColor; 73 QColor mDefaultColor;
74 QDateTime mLoadDt; 74 QDateTime mLoadDt;
75}; 75};
76class KOPrefs : public KPimPrefs 76class KOPrefs : public KPimPrefs
77{ 77{
78 public: 78 public:
79 enum { FormatVCalendar, FormatICalendar }; 79 enum { FormatVCalendar, FormatICalendar };
80 enum { MailClientKMail, MailClientSendmail }; 80 enum { MailClientKMail, MailClientSendmail };
81 enum { IMIPDummy, IMIPKMail }; 81 enum { IMIPDummy, IMIPKMail };
82 enum { IMIPOutbox, IMIPdirectsend }; 82 enum { IMIPOutbox, IMIPdirectsend };
83 enum { neverAuto, addressbookAuto, selectedAuto }; 83 enum { neverAuto, addressbookAuto, selectedAuto };
84 enum { standardDestination, askDestination }; 84 enum { standardDestination, askDestination };
85 85
86 virtual ~KOPrefs(); 86 virtual ~KOPrefs();
87 87
88 /** Get instance of KOPrefs. It is made sure that there is only one 88 /** Get instance of KOPrefs. It is made sure that there is only one
89 instance. */ 89 instance. */
90 static KOPrefs *instance(); 90 static KOPrefs *instance();
91 91
92 /** Set preferences to default values */ 92 /** Set preferences to default values */
93 void usrSetDefaults(); 93 void usrSetDefaults();
94 94
95 /** Read preferences from config file */ 95 /** Read preferences from config file */
96 void usrReadConfig(); 96 void usrReadConfig();
97 97
98 /** Write preferences to config file */ 98 /** Write preferences to config file */
99 void usrWriteConfig(); 99 void usrWriteConfig();
100 void setCategoryDefaults(); 100 void setCategoryDefaults();
101 void setAllDefaults(); 101 void setAllDefaults();
102 KopiCalendarFile * getNewCalendar(); 102 KopiCalendarFile * getNewCalendar();
103 KopiCalendarFile * getCalendar( int ); 103 KopiCalendarFile * getCalendar( int );
104 void deleteCalendar( int ); 104 void deleteCalendar( int );
105 QColor defaultColor( int ) const; 105 QColor defaultColor( int ) const;
106 QString calName( int ) const; 106 QString calName( int ) const;
107 int getCalendarID( const QString & name ); 107 int getCalendarID( const QString & name );
108 int getFuzzyCalendarID( const QString & name );
108 protected: 109 protected:
109 void setTimeZoneIdDefault(); 110 void setTimeZoneIdDefault();
110 111
111 /** Fill empty mail fields with default values. */ 112 /** Fill empty mail fields with default values. */
112 void fillMailDefaults(); 113 void fillMailDefaults();
113 114
114 private: 115 private:
115 /** Constructor disabled for public. Use instance() to create a KOPrefs 116 /** Constructor disabled for public. Use instance() to create a KOPrefs
116 object. */ 117 object. */
117 KOPrefs(); 118 KOPrefs();
118 119
119 static KOPrefs *mInstance; 120 static KOPrefs *mInstance;
120 QStringList getDefaultList(); 121 QStringList getDefaultList();
121 QStringList getLocationDefaultList(); 122 QStringList getLocationDefaultList();
122 public: 123 public:
123 // preferences data 124 // preferences data
124 KConfig* getConfig(); 125 KConfig* getConfig();
125 void setFullName(const QString &); 126 void setFullName(const QString &);
126 QString fullName(); 127 QString fullName();
127 void setEmail(const QString &); 128 void setEmail(const QString &);
128 QString email(); 129 QString email();
129 130
130 QString mAdditional; 131 QString mAdditional;
131 132
132 bool mEmailControlCenter; 133 bool mEmailControlCenter;
133 134
134 bool mBcc; 135 bool mBcc;
135 bool mAutoSave; 136 bool mAutoSave;
136 int mAutoSaveInterval; 137 int mAutoSaveInterval;
137 bool mConfirm; 138 bool mConfirm;
138 139
139 bool mEnableGroupScheduling; 140 bool mEnableGroupScheduling;
140 bool mEnableProjectView; 141 bool mEnableProjectView;
141 142
142 int mDefaultFormat; 143 int mDefaultFormat;
143 int mMailClient; 144 int mMailClient;
144 145
145 int mStartTime; 146 int mStartTime;
146 int mDefaultDuration; 147 int mDefaultDuration;
147 int mAlarmTime; 148 int mAlarmTime;
148 149
149 int mWorkingHoursStart; 150 int mWorkingHoursStart;
150 int mWorkingHoursEnd; 151 int mWorkingHoursEnd;
151 bool mExcludeHolidays; 152 bool mExcludeHolidays;
152 bool mExcludeSaturdays; 153 bool mExcludeSaturdays;
153 bool mMarcusBainsShowSeconds; 154 bool mMarcusBainsShowSeconds;
154 155
155 QFont mTimeBarFont; 156 QFont mTimeBarFont;
156 QFont mMonthViewFont; 157 QFont mMonthViewFont;
157 QFont mAgendaViewFont; 158 QFont mAgendaViewFont;
158 QFont mMarcusBainsFont; 159 QFont mMarcusBainsFont;
159 QFont mTimeLabelsFont; 160 QFont mTimeLabelsFont;
160 QFont mTodoViewFont; 161 QFont mTodoViewFont;
161 QFont mListViewFont; 162 QFont mListViewFont;
162 QFont mDateNavigatorFont; 163 QFont mDateNavigatorFont;
163 QFont mEditBoxFont; 164 QFont mEditBoxFont;
164 QFont mJornalViewFont; 165 QFont mJornalViewFont;
165 QFont mWhatsNextFont; 166 QFont mWhatsNextFont;
166 QFont mEventViewFont; 167 QFont mEventViewFont;
167 168
168 169
169 170
170 171
171 QColor mHolidayColor; 172 QColor mHolidayColor;
172 QColor mHighlightColor; 173 QColor mHighlightColor;
173 QColor mEventColor; 174 QColor mEventColor;
174 QColor mTodoDoneColor; 175 QColor mTodoDoneColor;
175 QColor mAgendaBgColor; 176 QColor mAgendaBgColor;
176 QColor mWorkingHoursColor; 177 QColor mWorkingHoursColor;
177 QColor mTodoDueTodayColor; 178 QColor mTodoDueTodayColor;
178 QColor mTodoOverdueColor; 179 QColor mTodoOverdueColor;
179 QColor mTodoRunColor; 180 QColor mTodoRunColor;
180 QColor mMonthViewEvenColor; 181 QColor mMonthViewEvenColor;
181 QColor mMonthViewOddColor; 182 QColor mMonthViewOddColor;
182 QColor mMonthViewHolidayColor; 183 QColor mMonthViewHolidayColor;
183 bool mMonthViewUsesDayColors; 184 bool mMonthViewUsesDayColors;
184 bool mMonthViewSatSunTog; 185 bool mMonthViewSatSunTog;
185 bool mMonthViewWeek; 186 bool mMonthViewWeek;
186 bool mMonthViewWeekRowlayout; 187 bool mMonthViewWeekRowlayout;
187 QColor mAppColor1; 188 QColor mAppColor1;
188 QColor mAppColor2; 189 QColor mAppColor2;
189 bool mUseAppColors; 190 bool mUseAppColors;
190 191
191 int mDayBegins; 192 int mDayBegins;
192 int mHourSize; 193 int mHourSize;
193 int mAllDaySize; 194 int mAllDaySize;
194 bool mShowFullMenu; 195 bool mShowFullMenu;
195 bool mDailyRecur; 196 bool mDailyRecur;
196 bool mWeeklyRecur; 197 bool mWeeklyRecur;
197 bool mLongAllday; 198 bool mLongAllday;
198 bool mMonthDailyRecur; 199 bool mMonthDailyRecur;
199 bool mMonthWeeklyRecur; 200 bool mMonthWeeklyRecur;
200 bool mMonthShowIcons; 201 bool mMonthShowIcons;
201 bool mMonthShowTimes; 202 bool mMonthShowTimes;
202 bool mMonthShowShort; 203 bool mMonthShowShort;
203 bool mEnableToolTips; 204 bool mEnableToolTips;
204 bool mEnableMonthScroll; 205 bool mEnableMonthScroll;
205 bool mFullViewMonth; 206 bool mFullViewMonth;
206 bool mMonthViewUsesCategoryColor; 207 bool mMonthViewUsesCategoryColor;
207 bool mFullViewTodo; 208 bool mFullViewTodo;
208 bool mShowCompletedTodo; 209 bool mShowCompletedTodo;
209 bool mMarcusBainsEnabled; 210 bool mMarcusBainsEnabled;
210 int mNextXDays; 211 int mNextXDays;
211 int mWhatsNextDays; 212 int mWhatsNextDays;
212 bool mWhatsNextTime2Lines; 213 bool mWhatsNextTime2Lines;
213 int mWhatsNextPrios; 214 int mWhatsNextPrios;
214 bool mEnableQuickTodo; 215 bool mEnableQuickTodo;
215 216
216 bool mCompactDialogs; 217 bool mCompactDialogs;
217 bool mVerticalScreen; 218 bool mVerticalScreen;
218 219
219 bool mShowIconNewTodo; 220 bool mShowIconNewTodo;
220 bool mShowIconNewEvent; 221 bool mShowIconNewEvent;
221 bool mShowIconSearch; 222 bool mShowIconSearch;
222 bool mShowIconList; 223 bool mShowIconList;
223 bool mShowIconDay1; 224 bool mShowIconDay1;
224 bool mShowIconDay5; 225 bool mShowIconDay5;
225 bool mShowIconDay6; 226 bool mShowIconDay6;
226 bool mShowIconDay7; 227 bool mShowIconDay7;
227 bool mShowIconMonth; 228 bool mShowIconMonth;
228 bool mShowIconTodoview; 229 bool mShowIconTodoview;
229 bool mShowIconBackFast; 230 bool mShowIconBackFast;
230 bool mShowIconBack; 231 bool mShowIconBack;
231 bool mShowIconToday; 232 bool mShowIconToday;
232 bool mShowIconForward; 233 bool mShowIconForward;
233 bool mShowIconForwardFast; 234 bool mShowIconForwardFast;
234 bool mShowIconWhatsThis; 235 bool mShowIconWhatsThis;
235 bool mShowIconWeekNum; 236 bool mShowIconWeekNum;
236 bool mShowIconNextDays; 237 bool mShowIconNextDays;
237 bool mShowIconNext; 238 bool mShowIconNext;
238 bool mShowIconJournal; 239 bool mShowIconJournal;
239 bool mShowIconFilter; 240 bool mShowIconFilter;
240 bool mShowIconOnetoolbar; 241 bool mShowIconOnetoolbar;
241 bool mShowIconNavigator; 242 bool mShowIconNavigator;
242 bool mShowIconAllday; 243 bool mShowIconAllday;
243 bool mShowIconFilterview; 244 bool mShowIconFilterview;
244 bool mShowIconToggleFull; 245 bool mShowIconToggleFull;
245 246
246 bool mShowIconStretch; 247 bool mShowIconStretch;
247 248
248 bool mToolBarHor; 249 bool mToolBarHor;
249 bool mToolBarUp; 250 bool mToolBarUp;
250 bool mToolBarHorV; 251 bool mToolBarHorV;
251 bool mToolBarUpV; 252 bool mToolBarUpV;
252 bool mToolBarHorN; 253 bool mToolBarHorN;
253 bool mToolBarUpN; 254 bool mToolBarUpN;
254 bool mToolBarHorF; 255 bool mToolBarHorF;
255 bool mToolBarUpF; 256 bool mToolBarUpF;
256 bool mToolBarMiniIcons; 257 bool mToolBarMiniIcons;
257 258
258 bool mAskForQuit; 259 bool mAskForQuit;
259 bool mUsePassWd; 260 bool mUsePassWd;
260 bool mShowSyncEvents; 261 bool mShowSyncEvents;
261 bool mShowTodoInAgenda; 262 bool mShowTodoInAgenda;
262 bool mShowCompletedTodoInAgenda; 263 bool mShowCompletedTodoInAgenda;
263 bool mShowTimeInAgenda; 264 bool mShowTimeInAgenda;
264 bool mHideNonStartedTodos; 265 bool mHideNonStartedTodos;
265 266
266 bool mBlockPopupMenu; 267 bool mBlockPopupMenu;
267 268
268 int mLastSyncTime; 269 int mLastSyncTime;
269 void setCategoryColor(QString cat,const QColor & color); 270 void setCategoryColor(QString cat,const QColor & color);
270 QColor *categoryColor(QString cat); 271 QColor *categoryColor(QString cat);
271 272
272 QString mArchiveFile; 273 QString mArchiveFile;
273 QString mHtmlExportFile; 274 QString mHtmlExportFile;
274 bool mHtmlWithSave; 275 bool mHtmlWithSave;
275 276
276 QStringList mSelectedPlugins; 277 QStringList mSelectedPlugins;
277 278
278 QString mLastImportFile; 279 QString mLastImportFile;
279 QString mLastVcalFile; 280 QString mLastVcalFile;
280 QString mLastSaveFile; 281 QString mLastSaveFile;
281 QString mLastLoadFile; 282 QString mLastLoadFile;
282 283
283 284
284 QString mDefaultAlarmFile; 285 QString mDefaultAlarmFile;
285 int mIMIPScheduler; 286 int mIMIPScheduler;
286 int mIMIPSend; 287 int mIMIPSend;
287 QStringList mAdditionalMails; 288 QStringList mAdditionalMails;
288 int mIMIPAutoRefresh; 289 int mIMIPAutoRefresh;
289 int mIMIPAutoInsertReply; 290 int mIMIPAutoInsertReply;
290 int mIMIPAutoInsertRequest; 291 int mIMIPAutoInsertRequest;
291 int mIMIPAutoFreeBusy; 292 int mIMIPAutoFreeBusy;
292 int mIMIPAutoFreeBusyReply; 293 int mIMIPAutoFreeBusyReply;
293 294
294 QStringList mTodoTemplates; 295 QStringList mTodoTemplates;
295 QStringList mEventTemplates; 296 QStringList mEventTemplates;
296 297
297 int mDestination; 298 int mDestination;
298 299
299 300
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d71264f..a64eb34 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -7,843 +7,851 @@
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 "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qapplication.h> 52#include <qapplication.h>
53 53
54#include <klocale.h> 54#include <klocale.h>
55#include <kglobal.h> 55#include <kglobal.h>
56#include <kconfig.h> 56#include <kconfig.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58 58
59QDateTime KSyncManager::mRequestedSyncEvent; 59QDateTime KSyncManager::mRequestedSyncEvent;
60 60
61 61
62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
64{ 64{
65 mServerSocket = 0; 65 mServerSocket = 0;
66 bar = new QProgressBar ( 1, 0 ); 66 bar = new QProgressBar ( 1, 0 );
67 bar->setCaption (""); 67 bar->setCaption ("");
68 mWriteBackInPast = 2; 68 mWriteBackInPast = 2;
69 69
70 70
71} 71}
72 72
73KSyncManager::~KSyncManager() 73KSyncManager::~KSyncManager()
74{ 74{
75 delete bar; 75 delete bar;
76} 76}
77 77
78void KSyncManager::setDefaultFileName( QString s) 78void KSyncManager::setDefaultFileName( QString s)
79{ 79{
80 mDefFileName = s ; 80 mDefFileName = s ;
81 if ( mPrefs->mPassiveSyncAutoStart ) 81 if ( mPrefs->mPassiveSyncAutoStart )
82 enableQuick( false ); 82 enableQuick( false );
83} 83}
84 84
85void KSyncManager::fillSyncMenu() 85void KSyncManager::fillSyncMenu()
86{ 86{
87 if ( mSyncMenu->count() ) 87 if ( mSyncMenu->count() )
88 mSyncMenu->clear(); 88 mSyncMenu->clear();
89 89
90 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 90 mSyncMenu->insertItem( i18n("Configure..."), 0 );
91 mSyncMenu->insertSeparator(); 91 mSyncMenu->insertSeparator();
92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
94 clearMenu->insertItem( i18n("For all profiles"), 1 ); 94 clearMenu->insertItem( i18n("For all profiles"), 1 );
95 clearMenu->insertSeparator(); 95 clearMenu->insertSeparator();
96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
97 mSyncMenu->insertSeparator(); 97 mSyncMenu->insertSeparator();
98 if ( mServerSocket == 0 ) { 98 if ( mServerSocket == 0 ) {
99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
100 } else { 100 } else {
101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
102 } 102 }
103 mSyncMenu->insertSeparator(); 103 mSyncMenu->insertSeparator();
104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
105 mSyncMenu->insertSeparator(); 105 mSyncMenu->insertSeparator();
106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
107 config.setGroup("General"); 107 config.setGroup("General");
108 QStringList prof = config.readListEntry("SyncProfileNames"); 108 QStringList prof = config.readListEntry("SyncProfileNames");
109 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 109 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
110 if ( prof.count() < 2 ) { 110 if ( prof.count() < 2 ) {
111 prof.clear(); 111 prof.clear();
112 QString externalName; 112 QString externalName;
113#ifdef DESKTOP_VERSION 113#ifdef DESKTOP_VERSION
114#ifdef _WIN32_ 114#ifdef _WIN32_
115 externalName = "OutLook(not_implemented)"; 115 externalName = "OutLook(not_implemented)";
116#else 116#else
117 externalName = "KDE_Desktop"; 117 externalName = "KDE_Desktop";
118#endif 118#endif
119#else 119#else
120 externalName = "Sharp_DTM"; 120 externalName = "Sharp_DTM";
121#endif 121#endif
122 prof << externalName; 122 prof << externalName;
123 prof << i18n("Local_file"); 123 prof << i18n("Local_file");
124 prof << i18n("Last_file"); 124 prof << i18n("Last_file");
125 KSyncProfile* temp = new KSyncProfile (); 125 KSyncProfile* temp = new KSyncProfile ();
126 temp->setName( prof[0] ); 126 temp->setName( prof[0] );
127 temp->writeConfig(&config); 127 temp->writeConfig(&config);
128 temp->setName( prof[1] ); 128 temp->setName( prof[1] );
129 temp->writeConfig(&config); 129 temp->writeConfig(&config);
130 temp->setName( prof[2] ); 130 temp->setName( prof[2] );
131 temp->writeConfig(&config); 131 temp->writeConfig(&config);
132 config.setGroup("General"); 132 config.setGroup("General");
133 config.writeEntry("SyncProfileNames",prof); 133 config.writeEntry("SyncProfileNames",prof);
134 config.writeEntry("ExternSyncProfiles",externalName); 134 config.writeEntry("ExternSyncProfiles",externalName);
135 config.sync(); 135 config.sync();
136 delete temp; 136 delete temp;
137 } 137 }
138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
139 mSyncProfileNames = prof; 139 mSyncProfileNames = prof;
140 unsigned int i; 140 unsigned int i;
141 for ( i = 0; i < prof.count(); ++i ) { 141 for ( i = 0; i < prof.count(); ++i ) {
142 QString insertText = prof[i]; 142 QString insertText = prof[i];
143 if ( i == 0 ) { 143 if ( i == 0 ) {
144#ifdef DESKTOP_VERSION 144#ifdef DESKTOP_VERSION
145#ifdef _WIN32_ 145#ifdef _WIN32_
146 insertText = "OutLook(not_implemented)"; 146 insertText = "OutLook(not_implemented)";
147#else 147#else
148 insertText = "KDE_Desktop"; 148 insertText = "KDE_Desktop";
149#endif 149#endif
150#else 150#else
151 insertText = "Sharp_DTM"; 151 insertText = "Sharp_DTM";
152#endif 152#endif
153 } 153 }
154 mSyncMenu->insertItem( insertText, 1000+i ); 154 mSyncMenu->insertItem( insertText, 1000+i );
155 clearMenu->insertItem( insertText, 1000+i ); 155 clearMenu->insertItem( insertText, 1000+i );
156 if ( i == 2 ) 156 if ( i == 2 )
157 mSyncMenu->insertSeparator(); 157 mSyncMenu->insertSeparator();
158 } 158 }
159 QDir app_dir; 159 QDir app_dir;
160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
161 if ( mTargetApp == PWMPI) { 161 if ( mTargetApp == PWMPI) {
162 mSyncMenu->removeItem( 1000 ); 162 mSyncMenu->removeItem( 1000 );
163 clearMenu->removeItem( 1000 ); 163 clearMenu->removeItem( 1000 );
164 } 164 }
165#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
167 mSyncMenu->removeItem( 1000 ); 167 mSyncMenu->removeItem( 1000 );
168 clearMenu->removeItem( 1000 ); 168 clearMenu->removeItem( 1000 );
169 } 169 }
170#endif 170#endif
171 mSyncMenu->removeItem( 1002 ); 171 mSyncMenu->removeItem( 1002 );
172 clearMenu->removeItem( 1002 ); 172 clearMenu->removeItem( 1002 );
173} 173}
174void KSyncManager::slotClearMenu( int action ) 174void KSyncManager::slotClearMenu( int action )
175{ 175{
176 QString syncDevice; 176 QString syncDevice;
177 if ( action > 999 ) { 177 if ( action > 999 ) {
178 syncDevice = mSyncProfileNames[action - 1000] ; 178 syncDevice = mSyncProfileNames[action - 1000] ;
179 } 179 }
180 180
181 181
182 182
183 int result = 0; 183 int result = 0;
184 QString sd; 184 QString sd;
185 if ( syncDevice.isEmpty() ) 185 if ( syncDevice.isEmpty() )
186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
187 else 187 else
188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
189 189
190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
191 0, 1 ); 191 0, 1 );
192 if ( result ) 192 if ( result )
193 return; 193 return;
194 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
195} 195}
196void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
197{ 197{
198 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = "";
199 if ( action == 5000 ) 200 if ( action == 5000 )
200 return; 201 return;
201 mSyncWithDesktop = false; 202 mSyncWithDesktop = false;
202 if ( action == 0 ) { 203 if ( action == 0 ) {
203 204
204 // seems to be a Qt2 event handling bug 205 // seems to be a Qt2 event handling bug
205 // syncmenu.clear causes a segfault at first time 206 // syncmenu.clear causes a segfault at first time
206 // when we call it after the main event loop, it is ok 207 // when we call it after the main event loop, it is ok
207 // same behaviour when calling OM/Pi via QCOP for the first time 208 // same behaviour when calling OM/Pi via QCOP for the first time
208 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 209 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
209 //confSync(); 210 //confSync();
210 211
211 return; 212 return;
212 } 213 }
213 if ( action == 1 ) { 214 if ( action == 1 ) {
214 multiSync( true ); 215 multiSync( true );
215 return; 216 return;
216 } 217 }
217 if ( action == 2 ) { 218 if ( action == 2 ) {
218 enableQuick(); 219 enableQuick();
219 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 220 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
220 return; 221 return;
221 } 222 }
222 if ( action == 3 ) { 223 if ( action == 3 ) {
223 delete mServerSocket; 224 delete mServerSocket;
224 mServerSocket = 0; 225 mServerSocket = 0;
225 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 226 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
226 return; 227 return;
227 } 228 }
228 229
229 if (blockSave()) 230 if (blockSave())
230 return; 231 return;
231 232
232 setBlockSave(true); 233 setBlockSave(true);
233 bool silent = false; 234 bool silent = false;
234 if ( action == 999 ) { 235 if ( action == 999 ) {
235 //special mode for silent syncing 236 //special mode for silent syncing
236 action = 1000; 237 action = 1000;
237 silent = true; 238 silent = true;
238 } 239 }
239 240
240 mCurrentSyncProfile = action - 1000 ; 241 mCurrentSyncProfile = action - 1000 ;
241 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 242 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
242 mCurrentSyncName = mLocalMachineName ; 243 mCurrentSyncName = mLocalMachineName ;
243 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 244 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
244 KSyncProfile* temp = new KSyncProfile (); 245 KSyncProfile* temp = new KSyncProfile ();
245 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 246 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
246 temp->readConfig(&config); 247 temp->readConfig(&config);
247 if (silent) { 248 if (silent) {
248 mAskForPreferences = false; 249 mAskForPreferences = false;
249 mShowSyncSummary = false; 250 mShowSyncSummary = false;
250 mWriteBackFile = true; 251 mWriteBackFile = true;
251 mSyncAlgoPrefs = 2;// take newest 252 mSyncAlgoPrefs = 2;// take newest
252 } 253 }
253 else { 254 else {
254 mAskForPreferences = temp->getAskForPreferences(); 255 mAskForPreferences = temp->getAskForPreferences();
255 mShowSyncSummary = temp->getShowSummaryAfterSync(); 256 mShowSyncSummary = temp->getShowSummaryAfterSync();
256 mWriteBackFile = temp->getWriteBackFile(); 257 mWriteBackFile = temp->getWriteBackFile();
257 mSyncAlgoPrefs = temp->getSyncPrefs(); 258 mSyncAlgoPrefs = temp->getSyncPrefs();
258 } 259 }
259 mWriteBackExistingOnly = temp->getWriteBackExisting(); 260 mWriteBackExistingOnly = temp->getWriteBackExisting();
260 mIsKapiFile = temp->getIsKapiFile(); 261 mIsKapiFile = temp->getIsKapiFile();
261 mWriteBackInFuture = 0; 262 mWriteBackInFuture = 0;
262 if ( temp->getWriteBackFuture() ) { 263 if ( temp->getWriteBackFuture() ) {
263 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 264 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
264 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 265 mWriteBackInPast = temp->getWriteBackPastWeeks( );
265 } 266 }
266 mFilterInCal = temp->getFilterInCal(); 267 mFilterInCal = temp->getFilterInCal();
267 mFilterOutCal = temp->getFilterOutCal(); 268 mFilterOutCal = temp->getFilterOutCal();
268 mFilterInAB = temp->getFilterInAB(); 269 mFilterInAB = temp->getFilterInAB();
269 mFilterOutAB = temp->getFilterOutAB(); 270 mFilterOutAB = temp->getFilterOutAB();
270 271
271 if ( action == 1000 ) { 272 if ( action == 1000 ) {
272 mIsKapiFile = false; 273 mIsKapiFile = false;
273#ifdef DESKTOP_VERSION 274#ifdef DESKTOP_VERSION
274 syncKDE(); 275 syncKDE();
275#else 276#else
276 syncSharp(); 277 syncSharp();
277#endif 278#endif
278 279
279 } else if ( action == 1001 ) { 280 } else if ( action == 1001 ) {
280 syncLocalFile(); 281 syncLocalFile();
281 282
282 } else if ( action == 1002 ) { 283 } else if ( action == 1002 ) {
283 mWriteBackFile = false; 284 mWriteBackFile = false;
284 mAskForPreferences = false; 285 mAskForPreferences = false;
285 mShowSyncSummary = false; 286 mShowSyncSummary = false;
286 mSyncAlgoPrefs = 3; 287 mSyncAlgoPrefs = 3;
287 quickSyncLocalFile(); 288 quickSyncLocalFile();
288 289
289 } else if ( action >= 1003 ) { 290 } else if ( action >= 1003 ) {
290 if ( temp->getIsLocalFileSync() ) { 291 if ( temp->getIsLocalFileSync() ) {
291 switch(mTargetApp) 292 switch(mTargetApp)
292 { 293 {
293 case (KAPI): 294 case (KAPI):
294 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 295 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
295 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 296 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
296 break; 297 break;
297 case (KOPI): 298 case (KOPI):
298 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 299 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
299 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 300 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
300 break; 301 break;
301 case (PWMPI): 302 case (PWMPI):
302 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 303 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
303 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 304 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
304 break; 305 break;
305 default: 306 default:
306 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 307 qDebug("KSM::slotSyncMenu: invalid apptype selected");
307 break; 308 break;
308 309
309 } 310 }
310 } else { 311 } else {
311 if ( temp->getIsPhoneSync() ) { 312 if ( temp->getIsPhoneSync() ) {
312 mPhoneDevice = temp->getPhoneDevice( ) ; 313 mPhoneDevice = temp->getPhoneDevice( ) ;
313 mPhoneConnection = temp->getPhoneConnection( ); 314 mPhoneConnection = temp->getPhoneConnection( );
314 mPhoneModel = temp->getPhoneModel( ); 315 mPhoneModel = temp->getPhoneModel( );
315 syncPhone(); 316 syncPhone();
316 } else if ( temp->getIsPiSync() ) { 317 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
318 mSpecificResources.clear();
317 if ( mTargetApp == KAPI ) { 319 if ( mTargetApp == KAPI ) {
318 mPassWordPiSync = temp->getRemotePwAB(); 320 mPassWordPiSync = temp->getRemotePwAB();
319 mActiveSyncPort = temp->getRemotePortAB(); 321 mActiveSyncPort = temp->getRemotePortAB();
320 mActiveSyncIP = temp->getRemoteIPAB(); 322 mActiveSyncIP = temp->getRemoteIPAB();
321 } else if ( mTargetApp == KOPI ) { 323 } else if ( mTargetApp == KOPI ) {
324 if ( temp->getIsPiSyncSpec() )
325 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
322 mPassWordPiSync = temp->getRemotePw(); 326 mPassWordPiSync = temp->getRemotePw();
323 mActiveSyncPort = temp->getRemotePort(); 327 mActiveSyncPort = temp->getRemotePort();
324 mActiveSyncIP = temp->getRemoteIP(); 328 mActiveSyncIP = temp->getRemoteIP();
325 } else { 329 } else {
326 mPassWordPiSync = temp->getRemotePwPWM(); 330 mPassWordPiSync = temp->getRemotePwPWM();
327 mActiveSyncPort = temp->getRemotePortPWM(); 331 mActiveSyncPort = temp->getRemotePortPWM();
328 mActiveSyncIP = temp->getRemoteIPPWM(); 332 mActiveSyncIP = temp->getRemoteIPPWM();
329 } 333 }
330 syncPi(); 334 syncPi();
331 while ( !mPisyncFinished ) { 335 while ( !mPisyncFinished ) {
332 //qDebug("waiting "); 336 //qDebug("waiting ");
333 qApp->processEvents(); 337 qApp->processEvents();
334 } 338 }
335 } else 339 } else
336 syncRemote( temp ); 340 syncRemote( temp );
337 341
338 } 342 }
339 } 343 }
340 delete temp; 344 delete temp;
341 setBlockSave(false); 345 setBlockSave(false);
342} 346}
343 347
344void KSyncManager::enableQuick( bool ask ) 348void KSyncManager::enableQuick( bool ask )
345{ 349{
346 bool autoStart; 350 bool autoStart;
347 bool changed = false; 351 bool changed = false;
348 if ( ask ) { 352 if ( ask ) {
349 QDialog dia ( 0, "input-dialog", true ); 353 QDialog dia ( 0, "input-dialog", true );
350 QLineEdit lab ( &dia ); 354 QLineEdit lab ( &dia );
351 QVBoxLayout lay( &dia ); 355 QVBoxLayout lay( &dia );
352 lab.setText( mPrefs->mPassiveSyncPort ); 356 lab.setText( mPrefs->mPassiveSyncPort );
353 lay.setMargin(7); 357 lay.setMargin(7);
354 lay.setSpacing(7); 358 lay.setSpacing(7);
355 int po = 9197+mTargetApp; 359 int po = 9197+mTargetApp;
356 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); 360 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
357 lay.addWidget( &label); 361 lay.addWidget( &label);
358 lay.addWidget( &lab); 362 lay.addWidget( &lab);
359 363
360 QLineEdit lepw ( &dia ); 364 QLineEdit lepw ( &dia );
361 lepw.setText( mPrefs->mPassiveSyncPw ); 365 lepw.setText( mPrefs->mPassiveSyncPw );
362 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 366 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
363 lay.addWidget( &label2); 367 lay.addWidget( &label2);
364 lay.addWidget( &lepw); 368 lay.addWidget( &lepw);
365 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 369 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
366 lay.addWidget( &autostart); 370 lay.addWidget( &autostart);
367 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 371 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
368#ifdef DESKTOP_VERSION 372#ifdef DESKTOP_VERSION
369#ifdef _WIN32_ 373#ifdef _WIN32_
370 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 374 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
371 syncdesktop.hide();// not implemented! 375 syncdesktop.hide();// not implemented!
372#else 376#else
373 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 377 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
374#endif 378#endif
375 lay.addWidget( &syncdesktop); 379 lay.addWidget( &syncdesktop);
376#else 380#else
377 mPrefs->mPassiveSyncWithDesktop = false; 381 mPrefs->mPassiveSyncWithDesktop = false;
378 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 382 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
379 syncdesktop.hide(); 383 syncdesktop.hide();
380#endif 384#endif
381 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 385 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
382 386
383 QPushButton pb ( "OK", &dia); 387 QPushButton pb ( "OK", &dia);
384 lay.addWidget( &pb ); 388 lay.addWidget( &pb );
385 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 389 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
386 dia.resize( 230,120 ); 390 dia.resize( 230,120 );
387 dia.setCaption( i18n("Enter port for Pi-Sync") ); 391 dia.setCaption( i18n("Enter port for Pi-Sync") );
388 dia.show(); 392 dia.show();
389#ifndef DESKTOP_VERSION 393#ifndef DESKTOP_VERSION
390 int dw = QApplication::desktop()->width(); 394 int dw = QApplication::desktop()->width();
391 int dh = QApplication::desktop()->height(); 395 int dh = QApplication::desktop()->height();
392 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 396 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
393#endif 397#endif
394 if ( ! dia.exec() ) 398 if ( ! dia.exec() )
395 return; 399 return;
396 dia.hide(); 400 dia.hide();
397 qApp->processEvents(); 401 qApp->processEvents();
398 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 402 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
399 changed = true; 403 changed = true;
400 mPrefs->mPassiveSyncPw = lepw.text(); 404 mPrefs->mPassiveSyncPw = lepw.text();
401 } 405 }
402 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 406 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
403 mPrefs->mPassiveSyncPort = lab.text(); 407 mPrefs->mPassiveSyncPort = lab.text();
404 changed = true; 408 changed = true;
405 } 409 }
406 autoStart = autostart.isChecked(); 410 autoStart = autostart.isChecked();
407 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 411 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
408 changed = true; 412 changed = true;
409 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 413 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
410 } 414 }
411 } 415 }
412 else 416 else
413 autoStart = mPrefs->mPassiveSyncAutoStart; 417 autoStart = mPrefs->mPassiveSyncAutoStart;
414 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 418 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
415 changed = true; 419 changed = true;
416 bool ok; 420 bool ok;
417 mPrefs->mPassiveSyncAutoStart = false; 421 mPrefs->mPassiveSyncAutoStart = false;
418 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); 422 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok);
419 qDebug("%d ", port_t); 423 qDebug("%d ", port_t);
420 if ( ! ok || port_t > 65535 ) { 424 if ( ! ok || port_t > 65535 ) {
421 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); 425 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error"));
422 return; 426 return;
423 } 427 }
424 Q_UINT16 port = port_t; 428 Q_UINT16 port = port_t;
425 //qDebug("port %d ", port); 429 //qDebug("port %d ", port);
426 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 430 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
427 mServerSocket->setFileName( defaultFileName() );//bbb 431 mServerSocket->setFileName( defaultFileName() );//bbb
428 if ( !mServerSocket->ok() ) { 432 if ( !mServerSocket->ok() ) {
429 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); 433 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) );
430 delete mServerSocket; 434 delete mServerSocket;
431 mServerSocket = 0; 435 mServerSocket = 0;
432 return; 436 return;
433 } 437 }
434 mPrefs->mPassiveSyncAutoStart = autoStart; 438 mPrefs->mPassiveSyncAutoStart = autoStart;
435 if ( changed ) { 439 if ( changed ) {
436 mPrefs->writeConfig(); 440 mPrefs->writeConfig();
437 } 441 }
438 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 442 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
439 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 443 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
440} 444}
441void KSyncManager::displayErrorPort() 445void KSyncManager::displayErrorPort()
442{ 446{
443 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 447 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
444} 448}
445void KSyncManager::syncLocalFile() 449void KSyncManager::syncLocalFile()
446{ 450{
447 451
448 QString fn =mPrefs->mLastSyncedLocalFile; 452 QString fn =mPrefs->mLastSyncedLocalFile;
449 QString ext; 453 QString ext;
450 454
451 switch(mTargetApp) 455 switch(mTargetApp)
452 { 456 {
453 case (KAPI): 457 case (KAPI):
454 ext = "(*.vcf)"; 458 ext = "(*.vcf)";
455 break; 459 break;
456 case (KOPI): 460 case (KOPI):
457 ext = "(*.ics/*.vcs)"; 461 ext = "(*.ics/*.vcs)";
458 break; 462 break;
459 case (PWMPI): 463 case (PWMPI):
460 ext = "(*.pwm)"; 464 ext = "(*.pwm)";
461 break; 465 break;
462 default: 466 default:
463 qDebug("KSM::syncLocalFile: invalid apptype selected"); 467 qDebug("KSM::syncLocalFile: invalid apptype selected");
464 break; 468 break;
465 469
466 } 470 }
467 471
468 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 472 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
469 if ( fn == "" ) 473 if ( fn == "" )
470 return; 474 return;
471 if ( syncWithFile( fn, false ) ) { 475 if ( syncWithFile( fn, false ) ) {
472 qDebug("KSM::syncLocalFile() successful "); 476 qDebug("KSM::syncLocalFile() successful ");
473 } 477 }
474 478
475} 479}
476 480
477bool KSyncManager::syncWithFile( QString fn , bool quick ) 481bool KSyncManager::syncWithFile( QString fn , bool quick )
478{ 482{
479 bool ret = false; 483 bool ret = false;
480 QFileInfo info; 484 QFileInfo info;
481 info.setFile( fn ); 485 info.setFile( fn );
482 QString mess; 486 QString mess;
483 if ( !info. exists() ) { 487 if ( !info. exists() ) {
484 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 488 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
485 QMessageBox::warning( mParent, i18n("Warning!"), 489 QMessageBox::warning( mParent, i18n("Warning!"),
486 mess ); 490 mess );
487 return ret; 491 return ret;
488 } 492 }
489 int result = 0; 493 int result = 0;
490 if ( !quick ) { 494 if ( !quick ) {
491 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 495 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
492 result = QMessageBox::warning( mParent, i18n("Warning!"), 496 result = QMessageBox::warning( mParent, i18n("Warning!"),
493 mess, 497 mess,
494 i18n("Sync"), i18n("Cancel"), 0, 498 i18n("Sync"), i18n("Cancel"), 0,
495 0, 1 ); 499 0, 1 );
496 if ( result ) 500 if ( result )
497 return false; 501 return false;
498 } 502 }
499 if ( mAskForPreferences ) 503 if ( mAskForPreferences )
500 if ( !edit_sync_options()) { 504 if ( !edit_sync_options()) {
501 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 505 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
502 return false; 506 return false;
503 } 507 }
504 if ( result == 0 ) { 508 if ( result == 0 ) {
505 //qDebug("Now sycing ... "); 509 //qDebug("Now sycing ... ");
506 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 510 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
507 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 511 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
508 else 512 else
509 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 513 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
510 if ( ! quick ) 514 if ( ! quick )
511 mPrefs->mLastSyncedLocalFile = fn; 515 mPrefs->mLastSyncedLocalFile = fn;
512 } 516 }
513 return ret; 517 return ret;
514} 518}
515 519
516void KSyncManager::quickSyncLocalFile() 520void KSyncManager::quickSyncLocalFile()
517{ 521{
518 522
519 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 523 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
520 qDebug("KSM::quick syncLocalFile() successful "); 524 qDebug("KSM::quick syncLocalFile() successful ");
521 525
522 } 526 }
523} 527}
524 528
525void KSyncManager::multiSync( bool askforPrefs ) 529void KSyncManager::multiSync( bool askforPrefs )
526{ 530{
527 if (blockSave()) 531 if (blockSave())
528 return; 532 return;
529 setBlockSave(true); 533 setBlockSave(true);
534 mCurrentResourceLocal = "";
530 if ( askforPrefs ) { 535 if ( askforPrefs ) {
531 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 536 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
532 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 537 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
533 question, 538 question,
534 i18n("Yes"), i18n("No"), 539 i18n("Yes"), i18n("No"),
535 0, 0 ) != 0 ) { 540 0, 0 ) != 0 ) {
536 setBlockSave(false); 541 setBlockSave(false);
537 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 542 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
538 return; 543 return;
539 } 544 }
540 } 545 }
541 mCurrentSyncDevice = i18n("Multiple profiles") ; 546 mCurrentSyncDevice = i18n("Multiple profiles") ;
542 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 547 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
543 if ( askforPrefs ) { 548 if ( askforPrefs ) {
544 if ( !edit_sync_options()) { 549 if ( !edit_sync_options()) {
545 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 550 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
546 return; 551 return;
547 } 552 }
548 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 553 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
549 } 554 }
550 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 555 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
551 qApp->processEvents(); 556 qApp->processEvents();
552 int num = ringSync() ; 557 int num = ringSync() ;
553 if ( num > 1 ) 558 if ( num > 1 )
554 ringSync(); 559 ringSync();
555 setBlockSave(false); 560 setBlockSave(false);
556 if ( num ) 561 if ( num )
557 emit save(); 562 emit save();
558 if ( num ) 563 if ( num )
559 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 564 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
560 else 565 else
561 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 566 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
562 return; 567 return;
563} 568}
564 569
565int KSyncManager::ringSync() 570int KSyncManager::ringSync()
566{ 571{
567 572
568 int syncedProfiles = 0; 573 int syncedProfiles = 0;
569 unsigned int i; 574 unsigned int i;
570 QTime timer; 575 QTime timer;
571 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 576 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
572 QStringList syncProfileNames = mSyncProfileNames; 577 QStringList syncProfileNames = mSyncProfileNames;
573 KSyncProfile* temp = new KSyncProfile (); 578 KSyncProfile* temp = new KSyncProfile ();
574 mAskForPreferences = false; 579 mAskForPreferences = false;
580 mCurrentResourceLocal = "";
575 for ( i = 0; i < syncProfileNames.count(); ++i ) { 581 for ( i = 0; i < syncProfileNames.count(); ++i ) {
576 mCurrentSyncProfile = i; 582 mCurrentSyncProfile = i;
577 temp->setName(syncProfileNames[mCurrentSyncProfile]); 583 temp->setName(syncProfileNames[mCurrentSyncProfile]);
578 temp->readConfig(&config); 584 temp->readConfig(&config);
579 585
580 bool includeInRingSync = false; 586 bool includeInRingSync = false;
581 switch(mTargetApp) 587 switch(mTargetApp)
582 { 588 {
583 case (KAPI): 589 case (KAPI):
584 includeInRingSync = temp->getIncludeInRingSyncAB(); 590 includeInRingSync = temp->getIncludeInRingSyncAB();
585 break; 591 break;
586 case (KOPI): 592 case (KOPI):
587 includeInRingSync = temp->getIncludeInRingSync(); 593 includeInRingSync = temp->getIncludeInRingSync();
588 break; 594 break;
589 case (PWMPI): 595 case (PWMPI):
590 includeInRingSync = temp->getIncludeInRingSyncPWM(); 596 includeInRingSync = temp->getIncludeInRingSyncPWM();
591 break; 597 break;
592 default: 598 default:
593 qDebug("KSM::ringSync: invalid apptype selected"); 599 qDebug("KSM::ringSync: invalid apptype selected");
594 break; 600 break;
595 601
596 } 602 }
597 603
598 604
599 if ( includeInRingSync && ( i < 1 || i > 2 )) { 605 if ( includeInRingSync && ( i < 1 || i > 2 )) {
600 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 606 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
601 ++syncedProfiles; 607 ++syncedProfiles;
602 mSyncWithDesktop = false; 608 mSyncWithDesktop = false;
603 // mAskForPreferences = temp->getAskForPreferences(); 609 // mAskForPreferences = temp->getAskForPreferences();
604 mWriteBackFile = temp->getWriteBackFile(); 610 mWriteBackFile = temp->getWriteBackFile();
605 mWriteBackExistingOnly = temp->getWriteBackExisting(); 611 mWriteBackExistingOnly = temp->getWriteBackExisting();
606 mIsKapiFile = temp->getIsKapiFile(); 612 mIsKapiFile = temp->getIsKapiFile();
607 mWriteBackInFuture = 0; 613 mWriteBackInFuture = 0;
608 if ( temp->getWriteBackFuture() ) { 614 if ( temp->getWriteBackFuture() ) {
609 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 615 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
610 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 616 mWriteBackInPast = temp->getWriteBackPastWeeks( );
611 } 617 }
612 mFilterInCal = temp->getFilterInCal(); 618 mFilterInCal = temp->getFilterInCal();
613 mFilterOutCal = temp->getFilterOutCal(); 619 mFilterOutCal = temp->getFilterOutCal();
614 mFilterInAB = temp->getFilterInAB(); 620 mFilterInAB = temp->getFilterInAB();
615 mFilterOutAB = temp->getFilterOutAB(); 621 mFilterOutAB = temp->getFilterOutAB();
616 mShowSyncSummary = false; 622 mShowSyncSummary = false;
617 mCurrentSyncDevice = syncProfileNames[i] ; 623 mCurrentSyncDevice = syncProfileNames[i] ;
618 mCurrentSyncName = mLocalMachineName; 624 mCurrentSyncName = mLocalMachineName;
619 if ( i == 0 ) { 625 if ( i == 0 ) {
620 mIsKapiFile = false; 626 mIsKapiFile = false;
621#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
622 syncKDE(); 628 syncKDE();
623#else 629#else
624 syncSharp(); 630 syncSharp();
625#endif 631#endif
626 } else { 632 } else {
627 if ( temp->getIsLocalFileSync() ) { 633 if ( temp->getIsLocalFileSync() ) {
628 switch(mTargetApp) 634 switch(mTargetApp)
629 { 635 {
630 case (KAPI): 636 case (KAPI):
631 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 637 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
632 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 638 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
633 break; 639 break;
634 case (KOPI): 640 case (KOPI):
635 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 641 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
636 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
637 break; 643 break;
638 case (PWMPI): 644 case (PWMPI):
639 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 645 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
640 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
641 break; 647 break;
642 default: 648 default:
643 qDebug("KSM: invalid apptype selected"); 649 qDebug("KSM: invalid apptype selected");
644 break; 650 break;
645 } 651 }
646 } else { 652 } else {
647 if ( temp->getIsPhoneSync() ) { 653 if ( temp->getIsPhoneSync() ) {
648 mPhoneDevice = temp->getPhoneDevice( ) ; 654 mPhoneDevice = temp->getPhoneDevice( ) ;
649 mPhoneConnection = temp->getPhoneConnection( ); 655 mPhoneConnection = temp->getPhoneConnection( );
650 mPhoneModel = temp->getPhoneModel( ); 656 mPhoneModel = temp->getPhoneModel( );
651 syncPhone(); 657 syncPhone();
652 } else if ( temp->getIsPiSync() ) { 658 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
659 mSpecificResources.clear();
653 if ( mTargetApp == KAPI ) { 660 if ( mTargetApp == KAPI ) {
654 mPassWordPiSync = temp->getRemotePwAB(); 661 mPassWordPiSync = temp->getRemotePwAB();
655 mActiveSyncPort = temp->getRemotePortAB(); 662 mActiveSyncPort = temp->getRemotePortAB();
656 mActiveSyncIP = temp->getRemoteIPAB(); 663 mActiveSyncIP = temp->getRemoteIPAB();
657 } else if ( mTargetApp == KOPI ) { 664 } else if ( mTargetApp == KOPI ) {
665 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
658 mPassWordPiSync = temp->getRemotePw(); 666 mPassWordPiSync = temp->getRemotePw();
659 mActiveSyncPort = temp->getRemotePort(); 667 mActiveSyncPort = temp->getRemotePort();
660 mActiveSyncIP = temp->getRemoteIP(); 668 mActiveSyncIP = temp->getRemoteIP();
661 } else { 669 } else {
662 mPassWordPiSync = temp->getRemotePwPWM(); 670 mPassWordPiSync = temp->getRemotePwPWM();
663 mActiveSyncPort = temp->getRemotePortPWM(); 671 mActiveSyncPort = temp->getRemotePortPWM();
664 mActiveSyncIP = temp->getRemoteIPPWM(); 672 mActiveSyncIP = temp->getRemoteIPPWM();
665 } 673 }
666 syncPi(); 674 syncPi();
667 while ( !mPisyncFinished ) { 675 while ( !mPisyncFinished ) {
668 //qDebug("waiting "); 676 //qDebug("waiting ");
669 qApp->processEvents(); 677 qApp->processEvents();
670 } 678 }
671 timer.start(); 679 timer.start();
672 while ( timer.elapsed () < 2000 ) { 680 while ( timer.elapsed () < 2000 ) {
673 qApp->processEvents(); 681 qApp->processEvents();
674 } 682 }
675 } else 683 } else
676 syncRemote( temp, false ); 684 syncRemote( temp, false );
677 685
678 } 686 }
679 } 687 }
680 timer.start(); 688 timer.start();
681 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 689 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
682 while ( timer.elapsed () < 2000 ) { 690 while ( timer.elapsed () < 2000 ) {
683 qApp->processEvents(); 691 qApp->processEvents();
684#ifndef _WIN32_ 692#ifndef _WIN32_
685 sleep (1); 693 sleep (1);
686#endif 694#endif
687 } 695 }
688 696
689 } 697 }
690 698
691 } 699 }
692 delete temp; 700 delete temp;
693 return syncedProfiles; 701 return syncedProfiles;
694} 702}
695 703
696void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 704void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
697{ 705{
698 QString question; 706 QString question;
699 if ( ask ) { 707 if ( ask ) {
700 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 708 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
701 if ( QMessageBox::information( mParent, i18n("Sync"), 709 if ( QMessageBox::information( mParent, i18n("Sync"),
702 question, 710 question,
703 i18n("Yes"), i18n("No"), 711 i18n("Yes"), i18n("No"),
704 0, 0 ) != 0 ) 712 0, 0 ) != 0 )
705 return; 713 return;
706 } 714 }
707 715
708 QString preCommand; 716 QString preCommand;
709 QString localTempFile; 717 QString localTempFile;
710 QString postCommand; 718 QString postCommand;
711 719
712 switch(mTargetApp) 720 switch(mTargetApp)
713 { 721 {
714 case (KAPI): 722 case (KAPI):
715 preCommand = prof->getPreSyncCommandAB(); 723 preCommand = prof->getPreSyncCommandAB();
716 postCommand = prof->getPostSyncCommandAB(); 724 postCommand = prof->getPostSyncCommandAB();
717 localTempFile = prof->getLocalTempFileAB(); 725 localTempFile = prof->getLocalTempFileAB();
718 break; 726 break;
719 case (KOPI): 727 case (KOPI):
720 preCommand = prof->getPreSyncCommand(); 728 preCommand = prof->getPreSyncCommand();
721 postCommand = prof->getPostSyncCommand(); 729 postCommand = prof->getPostSyncCommand();
722 localTempFile = prof->getLocalTempFile(); 730 localTempFile = prof->getLocalTempFile();
723 break; 731 break;
724 case (PWMPI): 732 case (PWMPI):
725 preCommand = prof->getPreSyncCommandPWM(); 733 preCommand = prof->getPreSyncCommandPWM();
726 postCommand = prof->getPostSyncCommandPWM(); 734 postCommand = prof->getPostSyncCommandPWM();
727 localTempFile = prof->getLocalTempFilePWM(); 735 localTempFile = prof->getLocalTempFilePWM();
728 break; 736 break;
729 default: 737 default:
730 qDebug("KSM::syncRemote: invalid apptype selected"); 738 qDebug("KSM::syncRemote: invalid apptype selected");
731 break; 739 break;
732 } 740 }
733 741
734 742
735 int fi; 743 int fi;
736 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 744 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
737 QString pwd = getPassword(); 745 QString pwd = getPassword();
738 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 746 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
739 747
740 } 748 }
741 int maxlen = 30; 749 int maxlen = 30;
742 if ( QApplication::desktop()->width() > 320 ) 750 if ( QApplication::desktop()->width() > 320 )
743 maxlen += 25; 751 maxlen += 25;
744 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 752 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
745 int fileSize = 0; 753 int fileSize = 0;
746 int result = system ( preCommand ); 754 int result = system ( preCommand );
747 // 0 : okay 755 // 0 : okay
748 // 256: no such file or dir 756 // 256: no such file or dir
749 // 757 //
750 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 758 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
751 if ( result != 0 ) { 759 if ( result != 0 ) {
752 unsigned int len = maxlen; 760 unsigned int len = maxlen;
753 while ( len < preCommand.length() ) { 761 while ( len < preCommand.length() ) {
754 preCommand.insert( len , "\n" ); 762 preCommand.insert( len , "\n" );
755 len += maxlen +2; 763 len += maxlen +2;
756 } 764 }
757 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 765 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
758 QMessageBox::information( mParent, i18n("Sync - ERROR"), 766 QMessageBox::information( mParent, i18n("Sync - ERROR"),
759 question, 767 question,
760 i18n("Okay!")) ; 768 i18n("Okay!")) ;
761 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 769 mParent->topLevelWidget()->setCaption ("KDE-Pim");
762 return; 770 return;
763 } 771 }
764 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 772 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
765 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 773 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
766 774
767 if ( syncWithFile( localTempFile, true ) ) { 775 if ( syncWithFile( localTempFile, true ) ) {
768 776
769 if ( mWriteBackFile ) { 777 if ( mWriteBackFile ) {
770 int fi; 778 int fi;
771 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 779 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
772 QString pwd = getPassword(); 780 QString pwd = getPassword();
773 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 781 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
774 782
775 } 783 }
776 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 784 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
777 result = system ( postCommand ); 785 result = system ( postCommand );
778 qDebug("KSM::Sync:Writing back file result: %d ", result); 786 qDebug("KSM::Sync:Writing back file result: %d ", result);
779 if ( result != 0 ) { 787 if ( result != 0 ) {
780 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 788 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
781 return; 789 return;
782 } else { 790 } else {
783 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 791 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
784 } 792 }
785 } 793 }
786 } 794 }
787 return; 795 return;
788} 796}
789bool KSyncManager::edit_pisync_options() 797bool KSyncManager::edit_pisync_options()
790{ 798{
791 QDialog dia( mParent, "dia", true ); 799 QDialog dia( mParent, "dia", true );
792 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 800 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
793 QVBoxLayout lay ( &dia ); 801 QVBoxLayout lay ( &dia );
794 lay.setSpacing( 5 ); 802 lay.setSpacing( 5 );
795 lay.setMargin( 3 ); 803 lay.setMargin( 3 );
796 QLabel lab1 ( i18n("Password for remote access:"), &dia); 804 QLabel lab1 ( i18n("Password for remote access:"), &dia);
797 lay.addWidget( &lab1 ); 805 lay.addWidget( &lab1 );
798 QLineEdit le1 (&dia ); 806 QLineEdit le1 (&dia );
799 lay.addWidget( &le1 ); 807 lay.addWidget( &le1 );
800 QLabel lab2 ( i18n("Remote IP address:"), &dia); 808 QLabel lab2 ( i18n("Remote IP address:"), &dia);
801 lay.addWidget( &lab2 ); 809 lay.addWidget( &lab2 );
802 QLineEdit le2 (&dia ); 810 QLineEdit le2 (&dia );
803 lay.addWidget( &le2 ); 811 lay.addWidget( &le2 );
804 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); 812 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia);
805 lay.addWidget( &lab3 ); 813 lay.addWidget( &lab3 );
806 QLineEdit le3 (&dia ); 814 QLineEdit le3 (&dia );
807 lay.addWidget( &le3 ); 815 lay.addWidget( &le3 );
808 QPushButton pb ( "OK", &dia); 816 QPushButton pb ( "OK", &dia);
809 lay.addWidget( &pb ); 817 lay.addWidget( &pb );
810 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 818 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
811 le1.setText( mPassWordPiSync ); 819 le1.setText( mPassWordPiSync );
812 le2.setText( mActiveSyncIP ); 820 le2.setText( mActiveSyncIP );
813 le3.setText( mActiveSyncPort ); 821 le3.setText( mActiveSyncPort );
814 if ( dia.exec() ) { 822 if ( dia.exec() ) {
815 mPassWordPiSync = le1.text(); 823 mPassWordPiSync = le1.text();
816 mActiveSyncPort = le3.text(); 824 mActiveSyncPort = le3.text();
817 mActiveSyncIP = le2.text(); 825 mActiveSyncIP = le2.text();
818 return true; 826 return true;
819 } 827 }
820 return false; 828 return false;
821} 829}
822bool KSyncManager::edit_sync_options() 830bool KSyncManager::edit_sync_options()
823{ 831{
824 832
825 QDialog dia( mParent, "dia", true ); 833 QDialog dia( mParent, "dia", true );
826 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 834 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
827 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 835 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
828 QVBoxLayout lay ( &dia ); 836 QVBoxLayout lay ( &dia );
829 lay.setSpacing( 2 ); 837 lay.setSpacing( 2 );
830 lay.setMargin( 3 ); 838 lay.setMargin( 3 );
831 lay.addWidget(&gr); 839 lay.addWidget(&gr);
832 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 840 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
833 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 841 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
834 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 842 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
835 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 843 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
836 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 844 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
837 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 845 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
838 //QRadioButton both( i18n("Take both on conflict"), &gr ); 846 //QRadioButton both( i18n("Take both on conflict"), &gr );
839 QPushButton pb ( "OK", &dia); 847 QPushButton pb ( "OK", &dia);
840 lay.addWidget( &pb ); 848 lay.addWidget( &pb );
841 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 849 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
842 switch ( mSyncAlgoPrefs ) { 850 switch ( mSyncAlgoPrefs ) {
843 case 0: 851 case 0:
844 loc.setChecked( true); 852 loc.setChecked( true);
845 break; 853 break;
846 case 1: 854 case 1:
847 rem.setChecked( true ); 855 rem.setChecked( true );
848 break; 856 break;
849 case 2: 857 case 2:
@@ -938,748 +946,771 @@ void KSyncManager::syncKDE()
938 QString commandpath = QDir::homeDirPath ()+"/"; 946 QString commandpath = QDir::homeDirPath ()+"/";
939#endif 947#endif
940 if ( ! QFile::exists ( commandpath+commandfile ) ) 948 if ( ! QFile::exists ( commandpath+commandfile ) )
941 command = commandfile; 949 command = commandfile;
942 else 950 else
943 command = commandpath+commandfile; 951 command = commandpath+commandfile;
944 952
945 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 953 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
946 int result = system ( command.latin1()); 954 int result = system ( command.latin1());
947 qDebug("AB dump 33 command call result: %d ", result); 955 qDebug("AB dump 33 command call result: %d ", result);
948 if ( result != 0 ) { 956 if ( result != 0 ) {
949 qDebug("Calling AB dump version 33 failed. Trying 34... "); 957 qDebug("Calling AB dump version 33 failed. Trying 34... ");
950 commandfile = "kdeabdump34"; 958 commandfile = "kdeabdump34";
951 if ( ! QFile::exists ( commandpath+commandfile ) ) 959 if ( ! QFile::exists ( commandpath+commandfile ) )
952 command = commandfile; 960 command = commandfile;
953 else 961 else
954 command = commandpath+commandfile; 962 command = commandpath+commandfile;
955 result = system ( command.latin1()); 963 result = system ( command.latin1());
956 qDebug("AB dump 34 command call result: %d ", result); 964 qDebug("AB dump 34 command call result: %d ", result);
957 if ( result != 0 ) { 965 if ( result != 0 ) {
958 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 966 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
959 return; 967 return;
960 } 968 }
961 } 969 }
962 if ( syncWithFile( fileName,true ) ) { 970 if ( syncWithFile( fileName,true ) ) {
963 if ( mWriteBackFile ) { 971 if ( mWriteBackFile ) {
964 command += " --read"; 972 command += " --read";
965 system ( command.latin1()); 973 system ( command.latin1());
966 } 974 }
967 } 975 }
968 976
969 } 977 }
970 break; 978 break;
971 case (KOPI): 979 case (KOPI):
972 { 980 {
973#ifdef DESKTOP_VERSION 981#ifdef DESKTOP_VERSION
974 QString command = "kdecaldump33"; 982 QString command = "kdecaldump33";
975 QString commandfile = "kdecaldump33"; 983 QString commandfile = "kdecaldump33";
976 QString commandpath = qApp->applicationDirPath () + "/"; 984 QString commandpath = qApp->applicationDirPath () + "/";
977#else 985#else
978 QString command = "kdecaldump33"; 986 QString command = "kdecaldump33";
979 QString commandfile = "kdecaldump33"; 987 QString commandfile = "kdecaldump33";
980 QString commandpath = QDir::homeDirPath ()+"/"; 988 QString commandpath = QDir::homeDirPath ()+"/";
981#endif 989#endif
982 if ( ! QFile::exists ( commandpath+commandfile ) ) 990 if ( ! QFile::exists ( commandpath+commandfile ) )
983 command = commandfile; 991 command = commandfile;
984 else 992 else
985 command = commandpath+commandfile; 993 command = commandpath+commandfile;
986 994
987 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 995 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
988 int result = system ( command.latin1()); 996 int result = system ( command.latin1());
989 qDebug("Cal dump 33 command call result result: %d ", result); 997 qDebug("Cal dump 33 command call result result: %d ", result);
990 if ( result != 0 ) { 998 if ( result != 0 ) {
991 qDebug("Calling CAL dump version 33 failed. Trying 34... "); 999 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
992 commandfile = "kdecaldump34"; 1000 commandfile = "kdecaldump34";
993 if ( ! QFile::exists ( commandpath+commandfile ) ) 1001 if ( ! QFile::exists ( commandpath+commandfile ) )
994 command = commandfile; 1002 command = commandfile;
995 else 1003 else
996 command = commandpath+commandfile; 1004 command = commandpath+commandfile;
997 result = system ( command.latin1()); 1005 result = system ( command.latin1());
998 qDebug("Cal dump 34 command call result result: %d ", result); 1006 qDebug("Cal dump 34 command call result result: %d ", result);
999 if ( result != 0 ) { 1007 if ( result != 0 ) {
1000 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1008 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
1001 return; 1009 return;
1002 } 1010 }
1003 } 1011 }
1004 if ( syncWithFile( fileName,true ) ) { 1012 if ( syncWithFile( fileName,true ) ) {
1005 if ( mWriteBackFile ) { 1013 if ( mWriteBackFile ) {
1006 command += " --read"; 1014 command += " --read";
1007 system ( command.latin1()); 1015 system ( command.latin1());
1008 } 1016 }
1009 } 1017 }
1010 1018
1011 } 1019 }
1012 break; 1020 break;
1013 case (PWMPI): 1021 case (PWMPI):
1014 1022
1015 break; 1023 break;
1016 default: 1024 default:
1017 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 1025 qDebug("KSM::slotSyncMenu: invalid apptype selected");
1018 break; 1026 break;
1019 1027
1020 } 1028 }
1021} 1029}
1022 1030
1023void KSyncManager::syncSharp() 1031void KSyncManager::syncSharp()
1024{ 1032{
1025 1033
1026 if ( ! syncExternalApplication("sharp") ) 1034 if ( ! syncExternalApplication("sharp") )
1027 qDebug("KSM::ERROR sync sharp "); 1035 qDebug("KSM::ERROR sync sharp ");
1028} 1036}
1029 1037
1030bool KSyncManager::syncExternalApplication(QString resource) 1038bool KSyncManager::syncExternalApplication(QString resource)
1031{ 1039{
1032 1040
1033 emit save(); 1041 emit save();
1034 1042
1035 if ( mAskForPreferences ) 1043 if ( mAskForPreferences )
1036 if ( !edit_sync_options()) { 1044 if ( !edit_sync_options()) {
1037 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1045 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1038 return false; 1046 return false;
1039 } 1047 }
1040 1048
1041 qDebug("KSM::Sync extern %s", resource.latin1()); 1049 qDebug("KSM::Sync extern %s", resource.latin1());
1042 1050
1043 bool syncOK = mImplementation->syncExternal(this, resource); 1051 bool syncOK = mImplementation->syncExternal(this, resource);
1044 1052
1045 return syncOK; 1053 return syncOK;
1046 1054
1047} 1055}
1048 1056
1049void KSyncManager::syncPhone() 1057void KSyncManager::syncPhone()
1050{ 1058{
1051 1059
1052 syncExternalApplication("phone"); 1060 syncExternalApplication("phone");
1053 1061
1054} 1062}
1055 1063
1056void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1064void KSyncManager::showProgressBar(int percentage, QString caption, int total)
1057{ 1065{
1058 if (!bar->isVisible()) 1066 if (!bar->isVisible())
1059 { 1067 {
1060 int w = 300; 1068 int w = 300;
1061 if ( QApplication::desktop()->width() < 320 ) 1069 if ( QApplication::desktop()->width() < 320 )
1062 w = 220; 1070 w = 220;
1063 int h = bar->sizeHint().height() ; 1071 int h = bar->sizeHint().height() ;
1064 int dw = QApplication::desktop()->width(); 1072 int dw = QApplication::desktop()->width();
1065 int dh = QApplication::desktop()->height(); 1073 int dh = QApplication::desktop()->height();
1066 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1074 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1067 bar->setCaption (caption); 1075 bar->setCaption (caption);
1068 bar->setTotalSteps ( total ) ; 1076 bar->setTotalSteps ( total ) ;
1069 bar->show(); 1077 bar->show();
1070 } 1078 }
1071 bar->raise(); 1079 bar->raise();
1072 bar->setProgress( percentage ); 1080 bar->setProgress( percentage );
1073 qApp->processEvents(); 1081 qApp->processEvents();
1074} 1082}
1075 1083
1076void KSyncManager::hideProgressBar() 1084void KSyncManager::hideProgressBar()
1077{ 1085{
1078 bar->hide(); 1086 bar->hide();
1079 qApp->processEvents(); 1087 qApp->processEvents();
1080} 1088}
1081 1089
1082bool KSyncManager::isProgressBarCanceled() 1090bool KSyncManager::isProgressBarCanceled()
1083{ 1091{
1084 return !bar->isVisible(); 1092 return !bar->isVisible();
1085} 1093}
1086 1094
1087QString KSyncManager::syncFileName() 1095QString KSyncManager::syncFileName()
1088{ 1096{
1089 1097
1090 QString fn = "tempfile"; 1098 QString fn = "tempfile";
1091 switch(mTargetApp) 1099 switch(mTargetApp)
1092 { 1100 {
1093 case (KAPI): 1101 case (KAPI):
1094 fn = "tempsyncab.vcf"; 1102 fn = "tempsyncab.vcf";
1095 break; 1103 break;
1096 case (KOPI): 1104 case (KOPI):
1097 fn = "tempsynccal.ics"; 1105 fn = "tempsynccal.ics";
1098 break; 1106 break;
1099 case (PWMPI): 1107 case (PWMPI):
1100 fn = "tempsyncpw.pwm"; 1108 fn = "tempsyncpw.pwm";
1101 break; 1109 break;
1102 default: 1110 default:
1103 break; 1111 break;
1104 } 1112 }
1105#ifdef DESKTOP_VERSION 1113#ifdef DESKTOP_VERSION
1106 return locateLocal( "tmp", fn ); 1114 return locateLocal( "tmp", fn );
1107#else 1115#else
1108 return (QString( "/tmp/" )+ fn ); 1116 return (QString( "/tmp/" )+ fn );
1109#endif 1117#endif
1110} 1118}
1111 1119
1112void KSyncManager::syncPi() 1120void KSyncManager::syncPi()
1113{ 1121{
1114 mIsKapiFile = true; 1122 mIsKapiFile = true;
1115 mPisyncFinished = false; 1123 mPisyncFinished = false;
1116 qApp->processEvents(); 1124 qApp->processEvents();
1117 if ( mAskForPreferences ) 1125 if ( mAskForPreferences )
1118 if ( !edit_pisync_options()) { 1126 if ( !edit_pisync_options()) {
1119 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1127 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1120 mPisyncFinished = true; 1128 mPisyncFinished = true;
1121 return; 1129 return;
1122 } 1130 }
1123 bool ok; 1131 bool ok;
1124 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1132 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1125 if ( ! ok ) { 1133 if ( ! ok ) {
1126 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1134 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1127 mPisyncFinished = true; 1135 mPisyncFinished = true;
1128 return; 1136 return;
1129 } 1137 }
1130 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1138 mCurrentResourceLocal = "";
1131 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1139 mCurrentResourceRemote = "";
1132 commandSocket->readFile( syncFileName() ); 1140 if ( mSpecificResources.count() ) {
1141 int startLocal = 0;
1142 int startRemote = mSpecificResources.count()/2;
1143 while ( startLocal < mSpecificResources.count()/2 ) {
1144 mPisyncFinished = false;
1145 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1146 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1147 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1148 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1149 commandSocket->readFile( syncFileName() );
1150 while ( !mPisyncFinished ) {
1151 //qDebug("waiting ");
1152 qApp->processEvents();
1153 }
1154 ++startLocal;
1155 }
1156 } else {
1157 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1159 commandSocket->readFile( syncFileName() );
1160 }
1133} 1161}
1134 1162
1135void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1163void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1136{ 1164{
1137 //enum { success, errorW, errorR, quiet }; 1165 //enum { success, errorW, errorR, quiet };
1138 1166
1139 1167
1140 1168
1141 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1169 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1142 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1170 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1143 if ( state == KCommandSocket::errorPW ) 1171 if ( state == KCommandSocket::errorPW )
1144 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1172 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1145 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1173 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1146 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1174 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1147 else if ( state == KCommandSocket::errorCA ) 1175 else if ( state == KCommandSocket::errorCA )
1148 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1176 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1149 else if ( state == KCommandSocket::errorFI ) 1177 else if ( state == KCommandSocket::errorFI )
1150 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1178 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1151 else if ( state == KCommandSocket::errorED ) 1179 else if ( state == KCommandSocket::errorED )
1152 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1180 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1153 else if ( state == KCommandSocket::errorUN ) 1181 else if ( state == KCommandSocket::errorUN )
1154 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1182 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1155 delete s; 1183 delete s;
1156 if ( state == KCommandSocket::errorR ) { 1184 if ( state == KCommandSocket::errorR ) {
1157 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1185 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1186 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1159 commandSocket->sendStop(); 1187 commandSocket->sendStop();
1160 } 1188 }
1161 mPisyncFinished = true; 1189 mPisyncFinished = true;
1162 return; 1190 return;
1163 1191
1164 } else if ( state == KCommandSocket::errorW ) { 1192 } else if ( state == KCommandSocket::errorW ) {
1165 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1193 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1166 mPisyncFinished = true; 1194 mPisyncFinished = true;
1167 1195
1168 } else if ( state == KCommandSocket::successR ) { 1196 } else if ( state == KCommandSocket::successR ) {
1169 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1197 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1170 1198
1171 } else if ( state == KCommandSocket::successW ) { 1199 } else if ( state == KCommandSocket::successW ) {
1172 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1200 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1173 mPisyncFinished = true; 1201 mPisyncFinished = true;
1174 } else if ( state == KCommandSocket::quiet ){ 1202 } else if ( state == KCommandSocket::quiet ){
1175 qDebug("KSS: quiet "); 1203 qDebug("KSS: quiet ");
1176 mPisyncFinished = true; 1204 mPisyncFinished = true;
1177 } else { 1205 } else {
1178 qDebug("KSS: Error: unknown state: %d ", state); 1206 qDebug("KSS: Error: unknown state: %d ", state);
1179 mPisyncFinished = true; 1207 mPisyncFinished = true;
1180 } 1208 }
1181 1209
1182 delete s; 1210 delete s;
1183} 1211}
1184 1212
1185void KSyncManager::readFileFromSocket() 1213void KSyncManager::readFileFromSocket()
1186{ 1214{
1187 QString fileName = syncFileName(); 1215 QString fileName = syncFileName();
1188 bool syncOK = true; 1216 bool syncOK = true;
1189 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1217 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1190 if ( ! syncWithFile( fileName , true ) ) { 1218 if ( ! syncWithFile( fileName , true ) ) {
1191 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1219 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1192 syncOK = false; 1220 syncOK = false;
1193 } 1221 }
1194 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1222 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1195 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1223 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1196 if ( mWriteBackFile && syncOK ) { 1224 if ( mWriteBackFile && syncOK ) {
1197 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1225 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1198 commandSocket->writeFile( fileName ); 1226 commandSocket->writeFile( fileName );
1199 } 1227 }
1200 else { 1228 else {
1201 commandSocket->sendStop(); 1229 commandSocket->sendStop();
1202 if ( syncOK ) 1230 if ( syncOK )
1203 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1231 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1204 mPisyncFinished = true; 1232 mPisyncFinished = true;
1205 } 1233 }
1206} 1234}
1207 1235
1208KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1236KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1209{ 1237{
1210 mPassWord = pw; 1238 mPassWord = pw;
1211 mSocket = 0; 1239 mSocket = 0;
1212 mSyncActionDialog = 0; 1240 mSyncActionDialog = 0;
1213 blockRC = false; 1241 blockRC = false;
1214 mErrorMessage = 0; 1242 mErrorMessage = 0;
1215} 1243}
1216 1244
1217void KServerSocket::newConnection ( int socket ) 1245void KServerSocket::newConnection ( int socket )
1218{ 1246{
1219 // qDebug("KServerSocket:New connection %d ", socket); 1247 // qDebug("KServerSocket:New connection %d ", socket);
1220 if ( mSocket ) { 1248 if ( mSocket ) {
1221 qDebug("KSS::newConnection Socket deleted! "); 1249 qDebug("KSS::newConnection Socket deleted! ");
1222 delete mSocket; 1250 delete mSocket;
1223 mSocket = 0; 1251 mSocket = 0;
1224 } 1252 }
1225 mSocket = new QSocket( this ); 1253 mSocket = new QSocket( this );
1226 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1254 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1227 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1255 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1228 mSocket->setSocket( socket ); 1256 mSocket->setSocket( socket );
1229} 1257}
1230 1258
1231void KServerSocket::discardClient() 1259void KServerSocket::discardClient()
1232{ 1260{
1233 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1261 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1234} 1262}
1235void KServerSocket::deleteSocket() 1263void KServerSocket::deleteSocket()
1236{ 1264{
1237 qDebug("KSS::deleteSocket"); 1265 qDebug("KSS::deleteSocket");
1238 if ( mSocket ) { 1266 if ( mSocket ) {
1239 delete mSocket; 1267 delete mSocket;
1240 mSocket = 0; 1268 mSocket = 0;
1241 } 1269 }
1242 if ( mErrorMessage ) 1270 if ( mErrorMessage )
1243 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); 1271 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
1244} 1272}
1245void KServerSocket::readClient() 1273void KServerSocket::readClient()
1246{ 1274{
1247 if ( blockRC ) 1275 if ( blockRC )
1248 return; 1276 return;
1249 if ( mSocket == 0 ) { 1277 if ( mSocket == 0 ) {
1250 qDebug("ERROR::KSS::readClient(): mSocket == 0 "); 1278 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1251 return; 1279 return;
1252 } 1280 }
1253 if ( mErrorMessage ) { 1281 if ( mErrorMessage ) {
1254 mErrorMessage = 999; 1282 mErrorMessage = 999;
1255 error_connect("ERROR_ED\r\n\r\n"); 1283 error_connect("ERROR_ED\r\n\r\n");
1256 return; 1284 return;
1257 } 1285 }
1258 mErrorMessage = 0; 1286 mErrorMessage = 0;
1259 //qDebug("KServerSocket::readClient()"); 1287 //qDebug("KServerSocket::readClient()");
1260 if ( mSocket->canReadLine() ) { 1288 if ( mSocket->canReadLine() ) {
1261 QString line = mSocket->readLine(); 1289 QString line = mSocket->readLine();
1262 //qDebug("KServerSocket readline: %s ", line.latin1()); 1290 //qDebug("KServerSocket readline: %s ", line.latin1());
1263 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1291 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1264 if ( tokens[0] == "GET" ) { 1292 if ( tokens[0] == "GET" ) {
1265 if ( tokens[1] == mPassWord ) { 1293 if ( tokens[1] == mPassWord ) {
1266 //emit sendFile( mSocket ); 1294 //emit sendFile( mSocket );
1267 bool ok = false; 1295 bool ok = false;
1268 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1296 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1269 if ( ok ) { 1297 if ( ok ) {
1270 KSyncManager::mRequestedSyncEvent = dt; 1298 KSyncManager::mRequestedSyncEvent = dt;
1271 } 1299 }
1272 else 1300 else
1273 KSyncManager::mRequestedSyncEvent = QDateTime(); 1301 KSyncManager::mRequestedSyncEvent = QDateTime();
1274 send_file(); 1302 send_file();
1275 } 1303 }
1276 else { 1304 else {
1277 mErrorMessage = 1; 1305 mErrorMessage = 1;
1278 error_connect("ERROR_PW\r\n\r\n"); 1306 error_connect("ERROR_PW\r\n\r\n");
1279 } 1307 }
1280 } 1308 }
1281 if ( tokens[0] == "PUT" ) { 1309 if ( tokens[0] == "PUT" ) {
1282 if ( tokens[1] == mPassWord ) { 1310 if ( tokens[1] == mPassWord ) {
1283 //emit getFile( mSocket ); 1311 //emit getFile( mSocket );
1284 blockRC = true; 1312 blockRC = true;
1285 get_file(); 1313 get_file();
1286 } 1314 }
1287 else { 1315 else {
1288 mErrorMessage = 2; 1316 mErrorMessage = 2;
1289 error_connect("ERROR_PW\r\n\r\n"); 1317 error_connect("ERROR_PW\r\n\r\n");
1290 end_connect(); 1318 end_connect();
1291 } 1319 }
1292 } 1320 }
1293 if ( tokens[0] == "STOP" ) { 1321 if ( tokens[0] == "STOP" ) {
1294 //emit endConnect(); 1322 //emit endConnect();
1295 end_connect(); 1323 end_connect();
1296 } 1324 }
1297 } 1325 }
1298} 1326}
1299void KServerSocket::displayErrorMessage() 1327void KServerSocket::displayErrorMessage()
1300{ 1328{
1301 if ( mErrorMessage == 1 ) { 1329 if ( mErrorMessage == 1 ) {
1302 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); 1330 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error"));
1303 mErrorMessage = 0; 1331 mErrorMessage = 0;
1304 } 1332 }
1305 else if ( mErrorMessage == 2 ) { 1333 else if ( mErrorMessage == 2 ) {
1306 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); 1334 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
1307 mErrorMessage = 0; 1335 mErrorMessage = 0;
1308 } 1336 }
1309} 1337}
1310void KServerSocket::error_connect( QString errmess ) 1338void KServerSocket::error_connect( QString errmess )
1311{ 1339{
1312 QTextStream os( mSocket ); 1340 QTextStream os( mSocket );
1313 os.setEncoding( QTextStream::Latin1 ); 1341 os.setEncoding( QTextStream::Latin1 );
1314 os << errmess ; 1342 os << errmess ;
1315 mSocket->close(); 1343 mSocket->close();
1316 if ( mSocket->state() == QSocket::Idle ) { 1344 if ( mSocket->state() == QSocket::Idle ) {
1317 QTimer::singleShot( 0, this , SLOT ( discardClient())); 1345 QTimer::singleShot( 0, this , SLOT ( discardClient()));
1318 } 1346 }
1319} 1347}
1320void KServerSocket::end_connect() 1348void KServerSocket::end_connect()
1321{ 1349{
1322 delete mSyncActionDialog; 1350 delete mSyncActionDialog;
1323 mSyncActionDialog = 0; 1351 mSyncActionDialog = 0;
1324} 1352}
1325void KServerSocket::send_file() 1353void KServerSocket::send_file()
1326{ 1354{
1327 //qDebug("MainWindow::sendFile(QSocket* s) "); 1355 //qDebug("MainWindow::sendFile(QSocket* s) ");
1328 if ( mSyncActionDialog ) 1356 if ( mSyncActionDialog )
1329 delete mSyncActionDialog; 1357 delete mSyncActionDialog;
1330 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1358 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1331 mSyncActionDialog->setCaption(i18n("Received sync request")); 1359 mSyncActionDialog->setCaption(i18n("Received sync request"));
1332 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1360 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1333 label->setAlignment ( Qt::AlignHCenter ); 1361 label->setAlignment ( Qt::AlignHCenter );
1334 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1362 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1335 lay->addWidget( label); 1363 lay->addWidget( label);
1336 lay->setMargin(7); 1364 lay->setMargin(7);
1337 lay->setSpacing(7); 1365 lay->setSpacing(7);
1338 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1366 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1339 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1367 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1340 //secs = 333; 1368 //secs = 333;
1341 if ( secs < 0 ) 1369 if ( secs < 0 )
1342 secs = secs * (-1); 1370 secs = secs * (-1);
1343 if ( secs > 30 ) 1371 if ( secs > 30 )
1344 //if ( true ) 1372 //if ( true )
1345 { 1373 {
1346 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1374 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1347 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1375 QLabel* label = new QLabel( warning, mSyncActionDialog );
1348 label->setAlignment ( Qt::AlignHCenter ); 1376 label->setAlignment ( Qt::AlignHCenter );
1349 lay->addWidget( label); 1377 lay->addWidget( label);
1350 if ( secs > 180 ) 1378 if ( secs > 180 )
1351 { 1379 {
1352 if ( secs > 300 ) { 1380 if ( secs > 300 ) {
1353 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1381 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1354 qDebug("KSS::Sync cancelled ,cs"); 1382 qDebug("KSS::Sync cancelled ,cs");
1355 mErrorMessage = 0; 1383 mErrorMessage = 0;
1356 end_connect(); 1384 end_connect();
1357 error_connect("ERROR_CA\r\n\r\n"); 1385 error_connect("ERROR_CA\r\n\r\n");
1358 return ; 1386 return ;
1359 } 1387 }
1360 } 1388 }
1361 QFont f = label->font(); 1389 QFont f = label->font();
1362 f.setPointSize ( f.pointSize() *2 ); 1390 f.setPointSize ( f.pointSize() *2 );
1363 f. setBold (true ); 1391 f. setBold (true );
1364 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1392 QLabel* label = new QLabel( warning, mSyncActionDialog );
1365 label->setFont( f ); 1393 label->setFont( f );
1366 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1394 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1367 label->setText( warning ); 1395 label->setText( warning );
1368 label->setAlignment ( Qt::AlignHCenter ); 1396 label->setAlignment ( Qt::AlignHCenter );
1369 lay->addWidget( label); 1397 lay->addWidget( label);
1370 mSyncActionDialog->setFixedSize( 230, 300); 1398 mSyncActionDialog->setFixedSize( 230, 300);
1371 } else { 1399 } else {
1372 mSyncActionDialog->setFixedSize( 230, 200); 1400 mSyncActionDialog->setFixedSize( 230, 200);
1373 } 1401 }
1374 } else { 1402 } else {
1375 mSyncActionDialog->setFixedSize( 230, 120); 1403 mSyncActionDialog->setFixedSize( 230, 120);
1376 } 1404 }
1377 } else 1405 } else
1378 mSyncActionDialog->setFixedSize( 230, 120); 1406 mSyncActionDialog->setFixedSize( 230, 120);
1379 mSyncActionDialog->show(); 1407 mSyncActionDialog->show();
1380 mSyncActionDialog->raise(); 1408 mSyncActionDialog->raise();
1381 emit request_file(); 1409 emit request_file();
1382 qApp->processEvents(); 1410 qApp->processEvents();
1383 QString fileName = mFileName; 1411 QString fileName = mFileName;
1384 QFile file( fileName ); 1412 QFile file( fileName );
1385 if (!file.open( IO_ReadOnly ) ) { 1413 if (!file.open( IO_ReadOnly ) ) {
1386 mErrorMessage = 0; 1414 mErrorMessage = 0;
1387 end_connect(); 1415 end_connect();
1388 error_connect("ERROR_FI\r\n\r\n"); 1416 error_connect("ERROR_FI\r\n\r\n");
1389 return ; 1417 return ;
1390 } 1418 }
1391 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1419 mSyncActionDialog->setCaption( i18n("Sending file...") );
1392 QTextStream ts( &file ); 1420 QTextStream ts( &file );
1393 ts.setEncoding( QTextStream::Latin1 ); 1421 ts.setEncoding( QTextStream::Latin1 );
1394 1422
1395 QTextStream os( mSocket ); 1423 QTextStream os( mSocket );
1396 os.setEncoding( QTextStream::Latin1 ); 1424 os.setEncoding( QTextStream::Latin1 );
1397 while ( ! ts.atEnd() ) { 1425 while ( ! ts.atEnd() ) {
1398 os << ts.readLine() << "\r\n"; 1426 os << ts.readLine() << "\r\n";
1399 } 1427 }
1400 os << "\r\n"; 1428 os << "\r\n";
1401 //os << ts.read(); 1429 //os << ts.read();
1402 file.close(); 1430 file.close();
1403 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1431 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1404 mSocket->close(); 1432 mSocket->close();
1405 if ( mSocket->state() == QSocket::Idle ) 1433 if ( mSocket->state() == QSocket::Idle )
1406 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1434 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1407} 1435}
1408void KServerSocket::get_file() 1436void KServerSocket::get_file()
1409{ 1437{
1410 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1438 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1411 1439
1412 piTime.start(); 1440 piTime.start();
1413 piFileString = ""; 1441 piFileString = "";
1414 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1442 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1415} 1443}
1416 1444
1417 1445
1418void KServerSocket::readBackFileFromSocket() 1446void KServerSocket::readBackFileFromSocket()
1419{ 1447{
1420 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1448 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1421 while ( mSocket->canReadLine () ) { 1449 while ( mSocket->canReadLine () ) {
1422 piTime.restart(); 1450 piTime.restart();
1423 QString line = mSocket->readLine (); 1451 QString line = mSocket->readLine ();
1424 piFileString += line; 1452 piFileString += line;
1425 //qDebug("readline: %s ", line.latin1()); 1453 //qDebug("readline: %s ", line.latin1());
1426 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1454 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1427 1455
1428 } 1456 }
1429 if ( piTime.elapsed () < 3000 ) { 1457 if ( piTime.elapsed () < 3000 ) {
1430 // wait for more 1458 // wait for more
1431 //qDebug("waitformore "); 1459 //qDebug("waitformore ");
1432 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1460 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1433 return; 1461 return;
1434 } 1462 }
1435 QString fileName = mFileName; 1463 QString fileName = mFileName;
1436 QFile file ( fileName ); 1464 QFile file ( fileName );
1437 if (!file.open( IO_WriteOnly ) ) { 1465 if (!file.open( IO_WriteOnly ) ) {
1438 delete mSyncActionDialog; 1466 delete mSyncActionDialog;
1439 mSyncActionDialog = 0; 1467 mSyncActionDialog = 0;
1440 qDebug("KSS:Error open read back file "); 1468 qDebug("KSS:Error open read back file ");
1441 piFileString = ""; 1469 piFileString = "";
1442 emit file_received( false ); 1470 emit file_received( false );
1443 blockRC = false; 1471 blockRC = false;
1444 return ; 1472 return ;
1445 1473
1446 } 1474 }
1447 1475
1448 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1476 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1449 QTextStream ts ( &file ); 1477 QTextStream ts ( &file );
1450 ts.setEncoding( QTextStream::Latin1 ); 1478 ts.setEncoding( QTextStream::Latin1 );
1451 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1479 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1452 ts << piFileString; 1480 ts << piFileString;
1453 mSocket->close(); 1481 mSocket->close();
1454 if ( mSocket->state() == QSocket::Idle ) 1482 if ( mSocket->state() == QSocket::Idle )
1455 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1483 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1456 file.close(); 1484 file.close();
1457 piFileString = ""; 1485 piFileString = "";
1458 emit file_received( true ); 1486 emit file_received( true );
1459 delete mSyncActionDialog; 1487 delete mSyncActionDialog;
1460 mSyncActionDialog = 0; 1488 mSyncActionDialog = 0;
1461 blockRC = false; 1489 blockRC = false;
1462 1490
1463} 1491}
1464 1492
1465KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1493KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1466{ 1494{
1495 mRemoteResource = remres;
1496 if ( mRemoteResource.isEmpty() )
1497 mRemoteResource = "ALL";
1467 mPassWord = password; 1498 mPassWord = password;
1468 mSocket = 0; 1499 mSocket = 0;
1469 mFirst = false; 1500 mFirst = false;
1470 mFirstLine = true; 1501 mFirstLine = true;
1471 mPort = port; 1502 mPort = port;
1472 mHost = host; 1503 mHost = host;
1473 tlw = cap; 1504 tlw = cap;
1474 mRetVal = quiet; 1505 mRetVal = quiet;
1475 mTimerSocket = new QTimer ( this ); 1506 mTimerSocket = new QTimer ( this );
1476 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); 1507 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
1477 mConnectProgress.setCaption( i18n("Pi-Sync") ); 1508 mConnectProgress.setCaption( i18n("Pi-Sync") );
1478 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); 1509 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
1479 mConnectCount = -1; 1510 mConnectCount = -1;
1480} 1511}
1481void KCommandSocket::sendFileRequest() 1512void KCommandSocket::sendFileRequest()
1482{ 1513{
1483 if ( tlw ) 1514 if ( tlw )
1484 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1515 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1485 mConnectProgress.hide(); 1516 mConnectProgress.hide();
1486 mConnectCount = 300;mConnectMax = 300; 1517 mConnectCount = 300;mConnectMax = 300;
1487 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1518 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1488 mTimerSocket->start( 100, true ); 1519 mTimerSocket->start( 100, true );
1489 QTextStream os( mSocket ); 1520 QTextStream os( mSocket );
1490 os.setEncoding( QTextStream::Latin1 ); 1521 os.setEncoding( QTextStream::Latin1 );
1491 1522
1492 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1523 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1493 os << "GET " << mPassWord << curDt <<"\r\n\r\n"; 1524 os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n";
1494} 1525}
1495 1526
1496void KCommandSocket::readFile( QString fn ) 1527void KCommandSocket::readFile( QString fn )
1497{ 1528{
1498 if ( !mSocket ) { 1529 if ( !mSocket ) {
1499 mSocket = new QSocket( this ); 1530 mSocket = new QSocket( this );
1500 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1531 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1501 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1532 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1502 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1533 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1503 } 1534 }
1504 mFileString = ""; 1535 mFileString = "";
1505 mFileName = fn; 1536 mFileName = fn;
1506 mFirst = true; 1537 mFirst = true;
1507 if ( tlw ) 1538 if ( tlw )
1508 tlw->setCaption( i18n("Trying to connect to remote...") ); 1539 tlw->setCaption( i18n("Trying to connect to remote...") );
1509 mConnectCount = 30;mConnectMax = 30; 1540 mConnectCount = 30;mConnectMax = 30;
1510 mTimerSocket->start( 1000, true ); 1541 mTimerSocket->start( 1000, true );
1511 mSocket->connectToHost( mHost, mPort ); 1542 mSocket->connectToHost( mHost, mPort );
1512 qDebug("KSS: Waiting for connection"); 1543 qDebug("KSS: Waiting for connection");
1513} 1544}
1514void KCommandSocket::updateConnectDialog() 1545void KCommandSocket::updateConnectDialog()
1515{ 1546{
1516 1547
1517 if ( mConnectCount == mConnectMax ) { 1548 if ( mConnectCount == mConnectMax ) {
1518 //qDebug("MAXX %d", mConnectMax); 1549 //qDebug("MAXX %d", mConnectMax);
1519 mConnectProgress.setTotalSteps ( 30 ); 1550 mConnectProgress.setTotalSteps ( 30 );
1520 mConnectProgress.show(); 1551 mConnectProgress.show();
1521 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); 1552 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") );
1522 } 1553 }
1523 //qDebug("updateConnectDialog() %d", mConnectCount); 1554 //qDebug("updateConnectDialog() %d", mConnectCount);
1524 mConnectProgress.raise(); 1555 mConnectProgress.raise();
1525 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); 1556 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 );
1526 --mConnectCount; 1557 --mConnectCount;
1527 if ( mConnectCount > 0 ) 1558 if ( mConnectCount > 0 )
1528 mTimerSocket->start( 1000, true ); 1559 mTimerSocket->start( 1000, true );
1529 else 1560 else
1530 deleteSocket(); 1561 deleteSocket();
1531 1562
1532} 1563}
1533void KCommandSocket::writeFile( QString fileName ) 1564void KCommandSocket::writeFile( QString fileName )
1534{ 1565{
1535 if ( !mSocket ) { 1566 if ( !mSocket ) {
1536 mSocket = new QSocket( this ); 1567 mSocket = new QSocket( this );
1537 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1568 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1538 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1569 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1539 } 1570 }
1540 mFileName = fileName ; 1571 mFileName = fileName ;
1541 mConnectCount = 30;mConnectMax = 30; 1572 mConnectCount = 30;mConnectMax = 30;
1542 mTimerSocket->start( 1000, true ); 1573 mTimerSocket->start( 1000, true );
1543 mSocket->connectToHost( mHost, mPort ); 1574 mSocket->connectToHost( mHost, mPort );
1544} 1575}
1545void KCommandSocket::writeFileToSocket() 1576void KCommandSocket::writeFileToSocket()
1546{ 1577{
1547 mTimerSocket->stop(); 1578 mTimerSocket->stop();
1548 QFile file2( mFileName ); 1579 QFile file2( mFileName );
1549 if (!file2.open( IO_ReadOnly ) ) { 1580 if (!file2.open( IO_ReadOnly ) ) {
1550 mConnectProgress.hide(); 1581 mConnectProgress.hide();
1551 mConnectCount = -1; 1582 mConnectCount = -1;
1552 mRetVal= errorW; 1583 mRetVal= errorW;
1553 mSocket->close(); 1584 mSocket->close();
1554 if ( mSocket->state() == QSocket::Idle ) 1585 if ( mSocket->state() == QSocket::Idle )
1555 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1586 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1556 return ; 1587 return ;
1557 } 1588 }
1558 mConnectProgress.setTotalSteps ( file2.size() ); 1589 mConnectProgress.setTotalSteps ( file2.size() );
1559 mConnectProgress.show(); 1590 mConnectProgress.show();
1560 int count = 0; 1591 int count = 0;
1561 mConnectProgress.setLabelText( i18n("Sending back synced file...") ); 1592 mConnectProgress.setLabelText( i18n("Sending back synced file...") );
1562 mConnectProgress.setProgress( count ); 1593 mConnectProgress.setProgress( count );
1563 mConnectProgress.blockSignals( true ); 1594 mConnectProgress.blockSignals( true );
1564 QTextStream ts2( &file2 ); 1595 QTextStream ts2( &file2 );
1565 ts2.setEncoding( QTextStream::Latin1 ); 1596 ts2.setEncoding( QTextStream::Latin1 );
1566 QTextStream os2( mSocket ); 1597 QTextStream os2( mSocket );
1567 os2.setEncoding( QTextStream::Latin1 ); 1598 os2.setEncoding( QTextStream::Latin1 );
1568 os2 << "PUT " << mPassWord << "\r\n\r\n";; 1599 os2 << "PUT " << mPassWord << "\r\n\r\n";;
1569 int byteCount = 0; 1600 int byteCount = 0;
1570 int byteMax = file2.size()/53; 1601 int byteMax = file2.size()/53;
1571 while ( ! ts2.atEnd() ) { 1602 while ( ! ts2.atEnd() ) {
1572 qApp->processEvents(); 1603 qApp->processEvents();
1573 if ( byteCount > byteMax ) { 1604 if ( byteCount > byteMax ) {
1574 byteCount = 0; 1605 byteCount = 0;
1575 mConnectProgress.setProgress( count ); 1606 mConnectProgress.setProgress( count );
1576 } 1607 }
1577 QString temp = ts2.readLine(); 1608 QString temp = ts2.readLine();
1578 count += temp.length(); 1609 count += temp.length();
1579 byteCount += temp.length(); 1610 byteCount += temp.length();
1580 os2 << temp << "\r\n"; 1611 os2 << temp << "\r\n";
1581 } 1612 }
1582 file2.close(); 1613 file2.close();
1583 mConnectProgress.hide(); 1614 mConnectProgress.hide();
1584 mConnectCount = -1; 1615 mConnectCount = -1;
1585 os2 << "\r\n"; 1616 os2 << "\r\n";
1586 mRetVal= successW; 1617 mRetVal= successW;
1587 mSocket->close(); 1618 mSocket->close();
1588 if ( mSocket->state() == QSocket::Idle ) 1619 if ( mSocket->state() == QSocket::Idle )
1589 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1620 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1590 mConnectProgress.blockSignals( false ); 1621 mConnectProgress.blockSignals( false );
1591} 1622}
1592void KCommandSocket::sendStop() 1623void KCommandSocket::sendStop()
1593{ 1624{
1594 if ( !mSocket ) { 1625 if ( !mSocket ) {
1595 mSocket = new QSocket( this ); 1626 mSocket = new QSocket( this );
1596 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1627 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1597 } 1628 }
1598 mSocket->connectToHost( mHost, mPort ); 1629 mSocket->connectToHost( mHost, mPort );
1599 QTextStream os2( mSocket ); 1630 QTextStream os2( mSocket );
1600 os2.setEncoding( QTextStream::Latin1 ); 1631 os2.setEncoding( QTextStream::Latin1 );
1601 os2 << "STOP\r\n\r\n"; 1632 os2 << "STOP\r\n\r\n";
1602 mSocket->close(); 1633 mSocket->close();
1603 if ( mSocket->state() == QSocket::Idle ) 1634 if ( mSocket->state() == QSocket::Idle )
1604 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1635 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1605} 1636}
1606 1637
1607void KCommandSocket::startReadFileFromSocket() 1638void KCommandSocket::startReadFileFromSocket()
1608{ 1639{
1609 if ( ! mFirst ) 1640 if ( ! mFirst )
1610 return; 1641 return;
1611 mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); 1642 mConnectProgress.setLabelText( i18n("Receiving file from remote...") );
1612 mFirst = false; 1643 mFirst = false;
1613 mFileString = ""; 1644 mFileString = "";
1614 mTime.start(); 1645 mTime.start();
1615 mFirstLine = true; 1646 mFirstLine = true;
1616 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1647 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1617 1648
1618} 1649}
1619void KCommandSocket::readFileFromSocket() 1650void KCommandSocket::readFileFromSocket()
1620{ 1651{
1621 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1652 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1622 while ( mSocket->canReadLine () ) { 1653 while ( mSocket->canReadLine () ) {
1623 mTime.restart(); 1654 mTime.restart();
1624 QString line = mSocket->readLine (); 1655 QString line = mSocket->readLine ();
1625 if ( mFirstLine ) { 1656 if ( mFirstLine ) {
1626 mFirstLine = false; 1657 mFirstLine = false;
1627 if ( line.left( 6 ) == "ERROR_" ) { 1658 if ( line.left( 6 ) == "ERROR_" ) {
1628 mTimerSocket->stop(); 1659 mTimerSocket->stop();
1629 mConnectCount = -1; 1660 mConnectCount = -1;
1630 if ( line.left( 8 ) == "ERROR_PW" ) { 1661 if ( line.left( 8 ) == "ERROR_PW" ) {
1631 mRetVal = errorPW; 1662 mRetVal = errorPW;
1632 deleteSocket(); 1663 deleteSocket();
1633 return ; 1664 return ;
1634 } 1665 }
1635 if ( line.left( 8 ) == "ERROR_CA" ) { 1666 if ( line.left( 8 ) == "ERROR_CA" ) {
1636 mRetVal = errorCA; 1667 mRetVal = errorCA;
1637 deleteSocket(); 1668 deleteSocket();
1638 return ; 1669 return ;
1639 } 1670 }
1640 if ( line.left( 8 ) == "ERROR_FI" ) { 1671 if ( line.left( 8 ) == "ERROR_FI" ) {
1641 mRetVal = errorFI; 1672 mRetVal = errorFI;
1642 deleteSocket(); 1673 deleteSocket();
1643 return ; 1674 return ;
1644 } 1675 }
1645 if ( line.left( 8 ) == "ERROR_ED" ) { 1676 if ( line.left( 8 ) == "ERROR_ED" ) {
1646 mRetVal = errorED; 1677 mRetVal = errorED;
1647 deleteSocket(); 1678 deleteSocket();
1648 return ; 1679 return ;
1649 } 1680 }
1650 mRetVal = errorUN; 1681 mRetVal = errorUN;
1651 deleteSocket(); 1682 deleteSocket();
1652 return ; 1683 return ;
1653 } 1684 }
1654 } 1685 }
1655 mFileString += line; 1686 mFileString += line;
1656 //qDebug("readline: %s ", line.latin1()); 1687 //qDebug("readline: %s ", line.latin1());
1657 } 1688 }
1658 if ( mTime.elapsed () < 3000 ) { 1689 if ( mTime.elapsed () < 3000 ) {
1659 // wait for more 1690 // wait for more
1660 //qDebug("waitformore "); 1691 //qDebug("waitformore ");
1661 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1692 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1662 return; 1693 return;
1663 } 1694 }
1664 mTimerSocket->stop(); 1695 mTimerSocket->stop();
1665 mConnectCount = -1; 1696 mConnectCount = -1;
1666 mConnectProgress.hide(); 1697 mConnectProgress.hide();
1667 QString fileName = mFileName; 1698 QString fileName = mFileName;
1668 QFile file ( fileName ); 1699 QFile file ( fileName );
1669 if (!file.open( IO_WriteOnly ) ) { 1700 if (!file.open( IO_WriteOnly ) ) {
1670 mFileString = ""; 1701 mFileString = "";
1671 mRetVal = errorR; 1702 mRetVal = errorR;
1672 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1703 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1673 deleteSocket(); 1704 deleteSocket();
1674 return ; 1705 return ;
1675 1706
1676 } 1707 }
1677 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1708 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1678 QTextStream ts ( &file ); 1709 QTextStream ts ( &file );
1679 ts.setEncoding( QTextStream::Latin1 ); 1710 ts.setEncoding( QTextStream::Latin1 );
1680 ts << mFileString; 1711 ts << mFileString;
1681 file.close(); 1712 file.close();
1682 mFileString = ""; 1713 mFileString = "";
1683 mRetVal = successR; 1714 mRetVal = successR;
1684 mSocket->close(); 1715 mSocket->close();
1685 // if state is not idle, deleteSocket(); is called via 1716 // if state is not idle, deleteSocket(); is called via
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index d3734da..f4654ce 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,237 +1,241 @@
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> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qprogressdialog.h> 32#include <qprogressdialog.h>
33#include <kdialog.h> 33#include <kdialog.h>
34 34
35class QPopupMenu; 35class QPopupMenu;
36class KSyncProfile; 36class KSyncProfile;
37class KPimPrefs; 37class KPimPrefs;
38class QWidget; 38class QWidget;
39class KSyncManager; 39class KSyncManager;
40class KSyncInterface; 40class KSyncInterface;
41class QProgressBar; 41class QProgressBar;
42 42
43 43
44class KServerSocket : public QServerSocket 44class KServerSocket : public QServerSocket
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 47
48 public: 48 public:
49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
50 50
51 void newConnection ( int socket ) ; 51 void newConnection ( int socket ) ;
52 void setFileName( QString fn ) {mFileName = fn;}; 52 void setFileName( QString fn ) {mFileName = fn;};
53 signals: 53 signals:
54 void file_received( bool ); 54 void file_received( bool );
55 void request_file(); 55 void request_file();
56 void saveFile(); 56 void saveFile();
57 void endConnect(); 57 void endConnect();
58 private slots: 58 private slots:
59 void discardClient(); 59 void discardClient();
60 void deleteSocket(); 60 void deleteSocket();
61 void readClient(); 61 void readClient();
62 void displayErrorMessage(); 62 void displayErrorMessage();
63 void readBackFileFromSocket(); 63 void readBackFileFromSocket();
64 private : 64 private :
65 int mErrorMessage; 65 int mErrorMessage;
66 bool blockRC; 66 bool blockRC;
67 void send_file(); 67 void send_file();
68 void get_file(); 68 void get_file();
69 void end_connect(); 69 void end_connect();
70 void error_connect( QString ); 70 void error_connect( QString );
71 QDialog* mSyncActionDialog; 71 QDialog* mSyncActionDialog;
72 QSocket* mSocket; 72 QSocket* mSocket;
73 QString mPassWord; 73 QString mPassWord;
74 QString mFileName; 74 QString mFileName;
75 QTime piTime; 75 QTime piTime;
76 QString piFileString; 76 QString piFileString;
77}; 77};
78 78
79class KCommandSocket : public QObject 79class KCommandSocket : public QObject
80{ 80{
81 Q_OBJECT 81 Q_OBJECT
82 public: 82 public:
83 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; 83 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet };
84 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); 84 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
85 void readFile( QString ); 85 void readFile( QString );
86 void writeFile( QString ); 86 void writeFile( QString );
87 void sendStop(); 87 void sendStop();
88 88
89 private slots : 89 private slots :
90 void sendFileRequest(); 90 void sendFileRequest();
91 void updateConnectDialog(); 91 void updateConnectDialog();
92 92
93 signals: 93 signals:
94 void commandFinished( KCommandSocket*, int ); 94 void commandFinished( KCommandSocket*, int );
95 private slots: 95 private slots:
96 void startReadFileFromSocket(); 96 void startReadFileFromSocket();
97 void readFileFromSocket(); 97 void readFileFromSocket();
98 void deleteSocket(); 98 void deleteSocket();
99 void writeFileToSocket(); 99 void writeFileToSocket();
100 private : 100 private :
101 QString mRemoteResource;
101 int mConnectCount; 102 int mConnectCount;
102 int mConnectMax; 103 int mConnectMax;
103 KProgressDialog mConnectProgress; 104 KProgressDialog mConnectProgress;
104 QWidget* tlw; 105 QWidget* tlw;
105 QSocket* mSocket; 106 QSocket* mSocket;
106 QString mPassWord; 107 QString mPassWord;
107 Q_UINT16 mPort; 108 Q_UINT16 mPort;
108 QString mHost; 109 QString mHost;
109 QString mFileName; 110 QString mFileName;
110 QTimer* mTimerSocket; 111 QTimer* mTimerSocket;
111 int mRetVal; 112 int mRetVal;
112 QTime mTime; 113 QTime mTime;
113 QString mFileString; 114 QString mFileString;
114 bool mFirst; 115 bool mFirst;
115 bool mFirstLine; 116 bool mFirstLine;
116}; 117};
117 118
118 119
119class KSyncManager : public QObject 120class KSyncManager : public QObject
120{ 121{
121 Q_OBJECT 122 Q_OBJECT
122 123
123 public: 124 public:
124 enum TargetApp { 125 enum TargetApp {
125 KOPI = 0, 126 KOPI = 0,
126 KAPI = 1, 127 KAPI = 1,
127 PWMPI = 2 }; 128 PWMPI = 2 };
128 129
129 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 130 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
130 ~KSyncManager() ; 131 ~KSyncManager() ;
131 132
132 void multiSync( bool askforPrefs ); 133 void multiSync( bool askforPrefs );
133 bool blockSave() { return mBlockSaveFlag; } 134 bool blockSave() { return mBlockSaveFlag; }
134 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 135 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
135 void setDefaultFileName( QString s) ; 136 void setDefaultFileName( QString s) ;
136 QString defaultFileName() { return mDefFileName ;} 137 QString defaultFileName() { return mDefFileName ;}
137 QString syncFileName(); 138 QString syncFileName();
138 void enableQuick( bool ask = true); 139 void enableQuick( bool ask = true);
139 140
140 bool syncWithDesktop () { return mSyncWithDesktop;} 141 bool syncWithDesktop () { return mSyncWithDesktop;}
141 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 142 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
142 QString getCurrentSyncName() { return mCurrentSyncName; } 143 QString getCurrentSyncName() { return mCurrentSyncName; }
143 144
144 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 145 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
145 void hideProgressBar(); 146 void hideProgressBar();
146 bool isProgressBarCanceled(); 147 bool isProgressBarCanceled();
147 148
148 // sync stuff 149 // sync stuff
149 QString mLocalMachineName; 150 QString mLocalMachineName;
150 QStringList mExternSyncProfiles; 151 QStringList mExternSyncProfiles;
151 QStringList mSyncProfileNames; 152 QStringList mSyncProfileNames;
152 bool mAskForPreferences; 153 bool mAskForPreferences;
153 bool mShowSyncSummary; 154 bool mShowSyncSummary;
154 bool mIsKapiFile; 155 bool mIsKapiFile;
155 bool mWriteBackExistingOnly; 156 bool mWriteBackExistingOnly;
156 int mSyncAlgoPrefs; 157 int mSyncAlgoPrefs;
157 bool mWriteBackFile; 158 bool mWriteBackFile;
158 int mWriteBackInFuture; 159 int mWriteBackInFuture;
159 int mWriteBackInPast; 160 int mWriteBackInPast;
160 QString mPhoneDevice; 161 QString mPhoneDevice;
161 QString mPhoneConnection; 162 QString mPhoneConnection;
162 QString mPhoneModel; 163 QString mPhoneModel;
163 QString mPassWordPiSync; 164 QString mPassWordPiSync;
164 QString mActiveSyncPort; 165 QString mActiveSyncPort;
165 QString mActiveSyncIP ; 166 QString mActiveSyncIP ;
166 QString mFilterInCal; 167 QString mFilterInCal;
167 QString mFilterOutCal; 168 QString mFilterOutCal;
168 QString mFilterInAB; 169 QString mFilterInAB;
169 QString mFilterOutAB; 170 QString mFilterOutAB;
170 static QDateTime mRequestedSyncEvent; 171 static QDateTime mRequestedSyncEvent;
171 172
172 signals: 173 signals:
173 void save(); 174 void save();
174 void request_file(); 175 void request_file();
175 void getFile( bool ); 176 void getFile( bool );
176 177
177 public slots: 178 public slots:
178 void slotSyncMenu( int ); 179 void slotSyncMenu( int );
179 void slotClearMenu( int action ); 180 void slotClearMenu( int action );
180 void deleteCommandSocket(KCommandSocket*s, int state); 181 void deleteCommandSocket(KCommandSocket*s, int state);
181 void readFileFromSocket(); 182 void readFileFromSocket();
182 void fillSyncMenu(); 183 void fillSyncMenu();
183 184
184 private: 185 private:
185 void syncPi(); 186 void syncPi();
186 KServerSocket * mServerSocket; 187 KServerSocket * mServerSocket;
187 KPimPrefs* mPrefs; 188 KPimPrefs* mPrefs;
188 QString mDefFileName; 189 QString mDefFileName;
189 QString mCurrentSyncDevice; 190 QString mCurrentSyncDevice;
190 QString mCurrentSyncName; 191 QString mCurrentSyncName;
191 void quickSyncLocalFile(); 192 void quickSyncLocalFile();
192 bool syncWithFile( QString fn , bool quick ); 193 bool syncWithFile( QString fn , bool quick );
193 void syncLocalFile(); 194 void syncLocalFile();
194 void syncPhone(); 195 void syncPhone();
195 void syncSharp(); 196 void syncSharp();
196 void syncKDE(); 197 void syncKDE();
197 bool syncExternalApplication(QString); 198 bool syncExternalApplication(QString);
198 int mCurrentSyncProfile ; 199 int mCurrentSyncProfile ;
199 void syncRemote( KSyncProfile* prof, bool ask = true); 200 void syncRemote( KSyncProfile* prof, bool ask = true);
200 bool edit_sync_options(); 201 bool edit_sync_options();
201 bool edit_pisync_options(); 202 bool edit_pisync_options();
202 int ringSync(); 203 int ringSync();
203 QString getPassword( ); 204 QString getPassword( );
204 bool mPisyncFinished; 205 bool mPisyncFinished;
206 QStringList mSpecificResources;
207 QString mCurrentResourceLocal;
208 QString mCurrentResourceRemote;
205 bool mBlockSaveFlag; 209 bool mBlockSaveFlag;
206 QWidget* mParent; 210 QWidget* mParent;
207 KSyncInterface* mImplementation; 211 KSyncInterface* mImplementation;
208 TargetApp mTargetApp; 212 TargetApp mTargetApp;
209 QPopupMenu* mSyncMenu; 213 QPopupMenu* mSyncMenu;
210 QProgressBar* bar; 214 QProgressBar* bar;
211 bool mSyncWithDesktop; 215 bool mSyncWithDesktop;
212 216
213private slots: 217private slots:
214 void displayErrorPort(); 218 void displayErrorPort();
215 void confSync(); 219 void confSync();
216 220
217 221
218}; 222};
219 223
220 224
221class KSyncInterface 225class KSyncInterface
222{ 226{
223 public : 227 public :
224 virtual void removeSyncInfo( QString syncProfile) = 0; 228 virtual void removeSyncInfo( QString syncProfile) = 0;
225 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 229 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
226 virtual bool syncExternal(KSyncManager* manager, QString resource) 230 virtual bool syncExternal(KSyncManager* manager, QString resource)
227 { 231 {
228 // empty implementation, because some syncable applications do not 232 // empty implementation, because some syncable applications do not
229 // have an external(sharpdtm) syncmode, like pwmanager. 233 // have an external(sharpdtm) syncmode, like pwmanager.
230 return false; 234 return false;
231 } 235 }
232 236
233 237
234}; 238};
235 239
236 240
237#endif 241#endif
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 292cde1..27f7932 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -403,501 +403,501 @@ void KSyncPrefsDialog::readResources()
403 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 403 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
404 mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] ); 404 mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] );
405 } 405 }
406} 406}
407void KSyncPrefsDialog::readFilter() 407void KSyncPrefsDialog::readFilter()
408{ 408{
409 mFilterKapi.clear(); 409 mFilterKapi.clear();
410 mFilterKopi.clear(); 410 mFilterKopi.clear();
411 KConfig cfgko(locateLocal("config","korganizerrc")); 411 KConfig cfgko(locateLocal("config","korganizerrc"));
412 KConfig cfgka(locateLocal("config","kaddressbookrc")); 412 KConfig cfgka(locateLocal("config","kaddressbookrc"));
413 cfgko.setGroup("General"); 413 cfgko.setGroup("General");
414 mFilterKopi = cfgko.readListEntry("CalendarFilters"); 414 mFilterKopi = cfgko.readListEntry("CalendarFilters");
415 cfgka.setGroup("Filter"); 415 cfgka.setGroup("Filter");
416 int count = cfgka.readNumEntry( "Count", 0 ); 416 int count = cfgka.readNumEntry( "Count", 0 );
417 for ( int i = 0; i < count; i++ ) { 417 for ( int i = 0; i < count; i++ ) {
418 cfgka.setGroup("Filter_"+QString::number( i ) ); 418 cfgka.setGroup("Filter_"+QString::number( i ) );
419 mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); 419 mFilterKapi.append( cfgka.readEntry("Name", "internal error") );
420 } 420 }
421 mFilterOutCal->clear(); 421 mFilterOutCal->clear();
422 mFilterInCal->clear(); 422 mFilterInCal->clear();
423 mFilterOutAB->clear(); 423 mFilterOutAB->clear();
424 mFilterInAB->clear(); 424 mFilterInAB->clear();
425 QStringList temp = mFilterKopi; 425 QStringList temp = mFilterKopi;
426 temp.prepend(i18n("No Filter") ); 426 temp.prepend(i18n("No Filter") );
427 mFilterOutCal->insertStringList( temp ); 427 mFilterOutCal->insertStringList( temp );
428 mFilterInCal->insertStringList( temp ); 428 mFilterInCal->insertStringList( temp );
429 temp = mFilterKapi; 429 temp = mFilterKapi;
430 temp.prepend(i18n("No Filter") ); 430 temp.prepend(i18n("No Filter") );
431 mFilterOutAB->insertStringList( temp ); 431 mFilterOutAB->insertStringList( temp );
432 mFilterInAB->insertStringList( temp ); 432 mFilterInAB->insertStringList( temp );
433} 433}
434 434
435void KSyncPrefsDialog::slotOK() 435void KSyncPrefsDialog::slotOK()
436{ 436{
437 if ( mMyMachineName->text() == "undefined" ) { 437 if ( mMyMachineName->text() == "undefined" ) {
438 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 438 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
439 return; 439 return;
440 } 440 }
441 int i; 441 int i;
442 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 442 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
443 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 443 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
444 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 444 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
445 return; 445 return;
446 } 446 }
447 } 447 }
448 usrWriteConfig(); 448 usrWriteConfig();
449 QDialog::accept(); 449 QDialog::accept();
450} 450}
451void KSyncPrefsDialog::accept() 451void KSyncPrefsDialog::accept()
452{ 452{
453 slotOK(); 453 slotOK();
454} 454}
455void KSyncPrefsDialog::chooseFile() 455void KSyncPrefsDialog::chooseFile()
456{ 456{
457 QString fn = QDir::homeDirPath(); 457 QString fn = QDir::homeDirPath();
458 458
459 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 459 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
460 if ( fn == "" ) 460 if ( fn == "" )
461 return; 461 return;
462 mRemoteFile->setText( fn ); 462 mRemoteFile->setText( fn );
463} 463}
464 464
465void KSyncPrefsDialog::chooseFileAB() 465void KSyncPrefsDialog::chooseFileAB()
466{ 466{
467 QString fn = QDir::homeDirPath(); 467 QString fn = QDir::homeDirPath();
468 468
469 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 469 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
470 if ( fn == "" ) 470 if ( fn == "" )
471 return; 471 return;
472 mRemoteFileAB->setText( fn ); 472 mRemoteFileAB->setText( fn );
473} 473}
474 474
475void KSyncPrefsDialog::chooseFilePWM() 475void KSyncPrefsDialog::chooseFilePWM()
476{ 476{
477 QString fn = QDir::homeDirPath(); 477 QString fn = QDir::homeDirPath();
478 478
479 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 479 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
480 if ( fn == "" ) 480 if ( fn == "" )
481 return; 481 return;
482 mRemoteFilePWM->setText( fn ); 482 mRemoteFilePWM->setText( fn );
483} 483}
484 484
485void KSyncPrefsDialog::textChanged( const QString & s ) 485void KSyncPrefsDialog::textChanged( const QString & s )
486{ 486{
487 if ( mProfileBox->count() == 0 ) 487 if ( mProfileBox->count() == 0 )
488 return; 488 return;
489 if ( currentSelection < 3 ) { 489 if ( currentSelection < 3 ) {
490 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 490 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
491 mProfileBox->blockSignals( true ); 491 mProfileBox->blockSignals( true );
492 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 492 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
493 mProfileBox->blockSignals( false ); 493 mProfileBox->blockSignals( false );
494 return; 494 return;
495 } 495 }
496 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 496 //qDebug("cur i %d ",mProfileBox-> currentItem () );
497 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 497 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
498 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 498 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
499 prof->setName( s ); 499 prof->setName( s );
500 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 500 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
501} 501}
502void KSyncPrefsDialog::profileChanged( int item ) 502void KSyncPrefsDialog::profileChanged( int item )
503{ 503{
504 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 504 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
505 KSyncProfile* prof; 505 KSyncProfile* prof;
506 saveProfile(); 506 saveProfile();
507 readFilter(); 507 readFilter();
508 readResources(); 508 readResources();
509 currentSelection = item; 509 currentSelection = item;
510 prof = mSyncProfiles.at(item) ; 510 prof = mSyncProfiles.at(item) ;
511 511
512 mRemotePw->setText(prof->getRemotePw()); 512 mRemotePw->setText(prof->getRemotePw());
513 mRemoteIP->setText(prof->getRemoteIP()); 513 mRemoteIP->setText(prof->getRemoteIP());
514 mRemotePort->setText(prof->getRemotePort()); 514 mRemotePort->setText(prof->getRemotePort());
515 515
516 mRemotePwAB->setText(prof->getRemotePwAB()); 516 mRemotePwAB->setText(prof->getRemotePwAB());
517 mRemoteIPAB->setText(prof->getRemoteIPAB()); 517 mRemoteIPAB->setText(prof->getRemoteIPAB());
518 mRemotePortAB->setText(prof->getRemotePortAB()); 518 mRemotePortAB->setText(prof->getRemotePortAB());
519 519
520 mRemotePwPWM->setText(prof->getRemotePwPWM()); 520 mRemotePwPWM->setText(prof->getRemotePwPWM());
521 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 521 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
522 mRemotePortPWM->setText(prof->getRemotePortPWM()); 522 mRemotePortPWM->setText(prof->getRemotePortPWM());
523 523
524 mRemotePrecommand->setText(prof->getPreSyncCommand()); 524 mRemotePrecommand->setText(prof->getPreSyncCommand());
525 mRemotePostcommand->setText(prof->getPostSyncCommand()); 525 mRemotePostcommand->setText(prof->getPostSyncCommand());
526 mLocalTempFile->setText(prof->getLocalTempFile()); 526 mLocalTempFile->setText(prof->getLocalTempFile());
527 mRemoteFile->setText(prof->getRemoteFileName()) ; 527 mRemoteFile->setText(prof->getRemoteFileName()) ;
528 528
529 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 529 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
530 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 530 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
531 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 531 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
532 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 532 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
533 533
534 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 534 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
535 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 535 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
536 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 536 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
537 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 537 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
538 538
539 if ( mWriteContactToSIM ) 539 if ( mWriteContactToSIM )
540 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 540 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
541 mPhoneDevice->setText(prof->getPhoneDevice()); 541 mPhoneDevice->setText(prof->getPhoneDevice());
542 mPhoneConnection->setText(prof->getPhoneConnection()); 542 mPhoneConnection->setText(prof->getPhoneConnection());
543 mPhoneModel->setText(prof->getPhoneModel()); 543 mPhoneModel->setText(prof->getPhoneModel());
544 544
545 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 545 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
546 mAskForPreferences->setChecked( prof->getAskForPreferences()); 546 mAskForPreferences->setChecked( prof->getAskForPreferences());
547 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 547 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
548 mWriteBackFile->setChecked( prof->getWriteBackFile()); 548 mWriteBackFile->setChecked( prof->getWriteBackFile());
549 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 549 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
550 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 550 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
551 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 551 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
552 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 552 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
553 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 553 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
554 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); 554 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() );
555 555
556 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); 556 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 );
557 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); 557 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 );
558 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); 558 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 );
559 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); 559 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 );
560 560
561 switch ( prof->getSyncPrefs() ) { 561 switch ( prof->getSyncPrefs() ) {
562 case 0: 562 case 0:
563 loc->setChecked( true); 563 loc->setChecked( true);
564 break; 564 break;
565 case 1: 565 case 1:
566 rem->setChecked( true ); 566 rem->setChecked( true );
567 break; 567 break;
568 case 2: 568 case 2:
569 newest->setChecked( true); 569 newest->setChecked( true);
570 break; 570 break;
571 case 3: 571 case 3:
572 ask->setChecked( true); 572 ask->setChecked( true);
573 break; 573 break;
574 case 4: 574 case 4:
575 f_loc->setChecked( true); 575 f_loc->setChecked( true);
576 break; 576 break;
577 case 5: 577 case 5:
578 f_rem->setChecked( true); 578 f_rem->setChecked( true);
579 break; 579 break;
580 case 6: 580 case 6:
581 //both->setChecked( true); 581 //both->setChecked( true);
582 break; 582 break;
583 default: 583 default:
584 break; 584 break;
585 } 585 }
586 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 586 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
587 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 587 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
588 mIsPi->setChecked(prof->getIsPiSync()) ; 588 mIsPi->setChecked(prof->getIsPiSync()) ;
589 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ; 589 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ;
590 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; 590 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
591 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; 591 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
592 592
593 593
594 QStringList res = QStringList::split( ":",prof->getResSpecKopi()); 594 QStringList res = QStringList::split( ":",prof->getResSpecKopi());
595 int i; 595 int i= res.count()/2;
596 for ( i = 0;i < res.count(); ++i ) { 596 for ( ;i < res.count(); ++i ) {
597 mResTableKopi->setText( i, 0, res[i] ); 597 mResTableKopi->setText( i, 0, res[i] );
598 } 598 }
599 res = QStringList::split( ":",prof->getResSpecKapi()); 599 res = QStringList::split( ":",prof->getResSpecKapi());
600 for ( i = 0;i < res.count(); ++i ) { 600 for ( i = 0;i < res.count(); ++i ) {
601 mResTableKapi->setText( i, 0, res[i] ); 601 mResTableKapi->setText( i, 0, res[i] );
602 } 602 }
603 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec()); 603 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec());
604 proGr->setEnabled( item > 2 ); 604 proGr->setEnabled( item > 2 );
605 if ( item < 3 ) { 605 if ( item < 3 ) {
606 localFileWidget->hide(); 606 localFileWidget->hide();
607 remoteFileWidget->hide(); 607 remoteFileWidget->hide();
608 phoneWidget->hide(); 608 phoneWidget->hide();
609 piWidget->hide(); 609 piWidget->hide();
610 610
611 } else 611 } else
612 kindChanged( prof->getIsLocalFileSync() ); 612 kindChanged( prof->getIsLocalFileSync() );
613} 613}
614 614
615void KSyncPrefsDialog::fillSSH() 615void KSyncPrefsDialog::fillSSH()
616{ 616{
617 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 617 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
618 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 618 mLocalTempFile->setText("/tmp/mycalendar.ics" );
619 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 619 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
620 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 620 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
621 mLocalTempFileAB->setText("/tmp/std.vcf" ); 621 mLocalTempFileAB->setText("/tmp/std.vcf" );
622 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 622 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
623 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 623 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
624 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 624 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
625 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 625 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
626} 626}
627void KSyncPrefsDialog::fillFTP() 627void KSyncPrefsDialog::fillFTP()
628{ 628{
629 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 629 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
630 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 630 mLocalTempFile->setText("/tmp/mycalendar.ics" );
631 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 631 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
632 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 632 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
633 mLocalTempFileAB->setText("/tmp/std.vcf" ); 633 mLocalTempFileAB->setText("/tmp/std.vcf" );
634 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 634 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
635 635
636 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 636 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
637 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 637 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
638 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 638 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
639 639
640} 640}
641void KSyncPrefsDialog::kindChanged( bool b ) 641void KSyncPrefsDialog::kindChanged( bool b )
642{ 642{
643 643
644 if ( mIsLocal->isChecked () ) { 644 if ( mIsLocal->isChecked () ) {
645 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); 645 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() );
646 } else { 646 } else {
647 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); 647 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() );
648 } 648 }
649 649
650 if ( mIsLocal->isChecked () ) 650 if ( mIsLocal->isChecked () )
651 localFileWidget->show(); 651 localFileWidget->show();
652 else 652 else
653 localFileWidget->hide(); 653 localFileWidget->hide();
654 654
655 if ( mIsNotLocal->isChecked () ) 655 if ( mIsNotLocal->isChecked () )
656 remoteFileWidget->show(); 656 remoteFileWidget->show();
657 else 657 else
658 remoteFileWidget->hide(); 658 remoteFileWidget->hide();
659 659
660 if ( mIsPhone->isChecked () ) { 660 if ( mIsPhone->isChecked () ) {
661 phoneWidget->show(); 661 phoneWidget->show();
662 } 662 }
663 else { 663 else {
664 phoneWidget->hide(); 664 phoneWidget->hide();
665 } 665 }
666 666
667 if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) { 667 if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) {
668 piWidget->show(); 668 piWidget->show();
669 if (mIsPiSpecific->isChecked () ) { 669 if (mIsPiSpecific->isChecked () ) {
670 mTableBox->show(); 670 mTableBox->show();
671 } 671 }
672 else { 672 else {
673 mTableBox->hide(); 673 mTableBox->hide();
674 } 674 }
675 } 675 }
676 else { 676 else {
677 piWidget->hide(); 677 piWidget->hide();
678 } 678 }
679 679
680 680
681} 681}
682void KSyncPrefsDialog::deleteProfile() 682void KSyncPrefsDialog::deleteProfile()
683{ 683{
684 //qDebug("KSyncPrefsDialog::deleteProfile() "); 684 //qDebug("KSyncPrefsDialog::deleteProfile() ");
685 if ( currentSelection >= 0 ) { 685 if ( currentSelection >= 0 ) {
686 if ( currentSelection < 3 ) { 686 if ( currentSelection < 3 ) {
687 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 687 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
688 return; 688 return;
689 } 689 }
690 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 690 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
691 mSyncProfiles.remove( temp ); 691 mSyncProfiles.remove( temp );
692 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 692 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
693 insertProfiles(); 693 insertProfiles();
694 } 694 }
695} 695}
696 696
697void KSyncPrefsDialog::saveProfile() 697void KSyncPrefsDialog::saveProfile()
698{ 698{
699 KSyncProfile* prof; 699 KSyncProfile* prof;
700 if ( currentSelection >= 0 ) { 700 if ( currentSelection >= 0 ) {
701 prof = mSyncProfiles.at(currentSelection) ; 701 prof = mSyncProfiles.at(currentSelection) ;
702 702
703 prof->setRemotePw( mRemotePw->text()); 703 prof->setRemotePw( mRemotePw->text());
704 prof->setRemoteIP( mRemoteIP->text()); 704 prof->setRemoteIP( mRemoteIP->text());
705 prof->setRemotePort( mRemotePort->text()); 705 prof->setRemotePort( mRemotePort->text());
706 706
707 prof->setRemotePwAB( mRemotePwAB->text()); 707 prof->setRemotePwAB( mRemotePwAB->text());
708 prof->setRemoteIPAB( mRemoteIPAB->text()); 708 prof->setRemoteIPAB( mRemoteIPAB->text());
709 prof->setRemotePortAB( mRemotePortAB->text()); 709 prof->setRemotePortAB( mRemotePortAB->text());
710 710
711 prof->setRemotePwPWM( mRemotePwPWM->text()); 711 prof->setRemotePwPWM( mRemotePwPWM->text());
712 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 712 prof->setRemoteIPPWM( mRemoteIPPWM->text());
713 prof->setRemotePortPWM( mRemotePortPWM->text()); 713 prof->setRemotePortPWM( mRemotePortPWM->text());
714 714
715 prof->setPreSyncCommand( mRemotePrecommand->text()); 715 prof->setPreSyncCommand( mRemotePrecommand->text());
716 prof->setPostSyncCommand( mRemotePostcommand->text() ); 716 prof->setPostSyncCommand( mRemotePostcommand->text() );
717 prof->setLocalTempFile( mLocalTempFile->text()); 717 prof->setLocalTempFile( mLocalTempFile->text());
718 prof->setRemoteFileName( mRemoteFile->text() ); 718 prof->setRemoteFileName( mRemoteFile->text() );
719 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 719 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
720 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 720 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
721 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 721 prof->setLocalTempFileAB( mLocalTempFileAB->text());
722 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 722 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
723 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 723 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
724 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 724 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
725 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 725 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
726 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 726 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
727 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 727 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
728 prof->setAskForPreferences( mAskForPreferences->isChecked()); 728 prof->setAskForPreferences( mAskForPreferences->isChecked());
729 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 729 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
730 prof->setWriteBackFile( mWriteBackFile->isChecked()); 730 prof->setWriteBackFile( mWriteBackFile->isChecked());
731 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 731 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
732 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 732 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
733 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 733 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
734 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 734 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
735 prof->setSyncPrefs( syncprefs); 735 prof->setSyncPrefs( syncprefs);
736 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 736 prof->setIsLocalFileSync( mIsLocal->isChecked() );
737 prof->setIsPhoneSync( mIsPhone->isChecked() ); 737 prof->setIsPhoneSync( mIsPhone->isChecked() );
738 prof->setIsPiSync( mIsPi->isChecked() ); 738 prof->setIsPiSync( mIsPi->isChecked() );
739 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() ); 739 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() );
740 prof->setIsKapiFile( mIsKapiFileL->isChecked() ); 740 prof->setIsKapiFile( mIsKapiFileL->isChecked() );
741 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 741 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
742 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 742 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
743 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); 743 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value());
744 if ( mWriteContactToSIM ) 744 if ( mWriteContactToSIM )
745 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 745 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
746 prof->setPhoneDevice( mPhoneDevice->text() ); 746 prof->setPhoneDevice( mPhoneDevice->text() );
747 prof->setPhoneConnection( mPhoneConnection->text() ); 747 prof->setPhoneConnection( mPhoneConnection->text() );
748 prof->setPhoneModel( mPhoneModel->text() ); 748 prof->setPhoneModel( mPhoneModel->text() );
749 prof->setFilterInCal ( mFilterInCal->currentText ()); 749 prof->setFilterInCal ( mFilterInCal->currentText ());
750 prof->setFilterOutCal ( mFilterOutCal ->currentText ()); 750 prof->setFilterOutCal ( mFilterOutCal ->currentText ());
751 prof->setFilterInAB ( mFilterInAB ->currentText ()); 751 prof->setFilterInAB ( mFilterInAB ->currentText ());
752 prof->setFilterOutAB ( mFilterOutAB ->currentText ()); 752 prof->setFilterOutAB ( mFilterOutAB ->currentText ());
753 if ( mIsPiSpecific->isChecked() ) { 753 if ( mIsPiSpecific->isChecked() ) {
754 754
755 QStringList res; 755 QStringList res = mResourcesKopi;
756 int i; 756 int i;
757 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 757 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
758 res.append( mResTableKopi->text( i, 0 )); 758 res.append( mResTableKopi->text( i, 0 ));
759 } 759 }
760 prof->setResSpecKopi( res.join(":")); 760 prof->setResSpecKopi( res.join(":"));
761 } 761 }
762 } 762 }
763} 763}
764 764
765void KSyncPrefsDialog::insertProfiles() 765void KSyncPrefsDialog::insertProfiles()
766{ 766{
767 int curItem = mProfileBox->currentItem(); 767 int curItem = mProfileBox->currentItem();
768 mProfileBox->blockSignals( true ); 768 mProfileBox->blockSignals( true );
769 mProfileBox->clear(); 769 mProfileBox->clear();
770 mProfileBox->insertStringList (mSyncProfileNames ); 770 mProfileBox->insertStringList (mSyncProfileNames );
771 int item = mSyncProfileNames.count() -1; 771 int item = mSyncProfileNames.count() -1;
772 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 772 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
773 mProfileBox->setCurrentItem( curItem ); 773 mProfileBox->setCurrentItem( curItem );
774 else if ( item >= 0 ) { 774 else if ( item >= 0 ) {
775 mProfileBox->setCurrentItem( item ); 775 mProfileBox->setCurrentItem( item );
776 } 776 }
777 currentSelection = -1; 777 currentSelection = -1;
778 if ( mSyncProfileNames.count() > 0 ) { 778 if ( mSyncProfileNames.count() > 0 ) {
779 //qDebug(" profileChanged( mProfileBox->currentItem() "); 779 //qDebug(" profileChanged( mProfileBox->currentItem() ");
780 profileChanged( mProfileBox->currentItem() ); 780 profileChanged( mProfileBox->currentItem() );
781 currentSelection = mProfileBox->currentItem(); 781 currentSelection = mProfileBox->currentItem();
782 } 782 }
783 mProfileBox->blockSignals( false ); 783 mProfileBox->blockSignals( false );
784} 784}
785 785
786void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 786void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
787{ 787{
788 saveProfile(); 788 saveProfile();
789 mSyncProfiles.append( temp ); 789 mSyncProfiles.append( temp );
790 mSyncProfileNames << temp->getName(); 790 mSyncProfileNames << temp->getName();
791 insertProfiles(); 791 insertProfiles();
792 int last = mProfileBox->count() -1; 792 int last = mProfileBox->count() -1;
793 mProfileBox->blockSignals( true ); 793 mProfileBox->blockSignals( true );
794 mProfileBox->setCurrentItem( last ); 794 mProfileBox->setCurrentItem( last );
795 mProfileBox->blockSignals( false ); 795 mProfileBox->blockSignals( false );
796 profileChanged(last); 796 profileChanged(last);
797} 797}
798void KSyncPrefsDialog::newProfile() 798void KSyncPrefsDialog::newProfile()
799{ 799{
800 addProfile ( new KSyncProfile () ); 800 addProfile ( new KSyncProfile () );
801} 801}
802 802
803void KSyncPrefsDialog::cloneProfile() 803void KSyncPrefsDialog::cloneProfile()
804{ 804{
805 if ( currentSelection >= 0 ) 805 if ( currentSelection >= 0 )
806 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 806 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
807 else 807 else
808 newProfile(); 808 newProfile();
809} 809}
810 810
811void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 811void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
812{ 812{
813 mMyMachineName->setText( name ); 813 mMyMachineName->setText( name );
814 814
815} 815}
816QString KSyncPrefsDialog::getLocalMachineName ( ) 816QString KSyncPrefsDialog::getLocalMachineName ( )
817{ 817{
818 return mMyMachineName->text(); 818 return mMyMachineName->text();
819} 819}
820 820
821QStringList KSyncPrefsDialog::getSyncProfileNames() 821QStringList KSyncPrefsDialog::getSyncProfileNames()
822{ 822{
823 return mSyncProfileNames; 823 return mSyncProfileNames;
824} 824}
825void KSyncPrefsDialog::usrReadConfig() 825void KSyncPrefsDialog::usrReadConfig()
826{ 826{
827 //KConfig *config = KOGlobals::config(); 827 //KConfig *config = KOGlobals::config();
828 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 828 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
829 config.setGroup("General"); 829 config.setGroup("General");
830 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 830 mSyncProfileNames =config.readListEntry("SyncProfileNames");
831 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 831 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
832 int i; 832 int i;
833 KSyncProfile* temp ; 833 KSyncProfile* temp ;
834 mSyncProfiles.clear(); 834 mSyncProfiles.clear();
835 for ( i = 0; i < mSyncProfileNames.count();++i ) { 835 for ( i = 0; i < mSyncProfileNames.count();++i ) {
836 temp = new KSyncProfile (); 836 temp = new KSyncProfile ();
837 temp->setName( mSyncProfileNames[i] ); 837 temp->setName( mSyncProfileNames[i] );
838 temp->readConfig( &config ); 838 temp->readConfig( &config );
839 mSyncProfiles.append( temp ); 839 mSyncProfiles.append( temp );
840 } 840 }
841 insertProfiles(); 841 insertProfiles();
842 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 842 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
843} 843}
844 844
845 845
846void KSyncPrefsDialog::usrWriteConfig() 846void KSyncPrefsDialog::usrWriteConfig()
847{ 847{
848 saveProfile(); 848 saveProfile();
849 if ( currentSelection >= 0 ) 849 if ( currentSelection >= 0 )
850 profileChanged(currentSelection); 850 profileChanged(currentSelection);
851 //KConfig *config = KOGlobals::config(); 851 //KConfig *config = KOGlobals::config();
852 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 852 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
853 KSyncProfile* prof = mSyncProfiles.first(); 853 KSyncProfile* prof = mSyncProfiles.first();
854 QStringList externalSyncProfileNames; 854 QStringList externalSyncProfileNames;
855 externalSyncProfileNames.append("Sharp_DTM");; 855 externalSyncProfileNames.append("Sharp_DTM");;
856 while ( prof ) { 856 while ( prof ) {
857 prof->writeConfig(&config); 857 prof->writeConfig(&config);
858 if ( prof->getIsPhoneSync( ) ) 858 if ( prof->getIsPhoneSync( ) )
859 externalSyncProfileNames.append(prof->getName( ) ); 859 externalSyncProfileNames.append(prof->getName( ) );
860 prof = mSyncProfiles.next(); 860 prof = mSyncProfiles.next();
861 } 861 }
862 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 862 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
863 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 863 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
864 config.setGroup("General"); 864 config.setGroup("General");
865 config.writeEntry("SyncProfileNames",mSyncProfileNames); 865 config.writeEntry("SyncProfileNames",mSyncProfileNames);
866 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 866 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
867 config.writeEntry("LocalMachineName",mMyMachineName->text()); 867 config.writeEntry("LocalMachineName",mMyMachineName->text());
868 config.sync(); 868 config.sync();
869} 869}
870 870
871void KSyncPrefsDialog::helpDevice() 871void KSyncPrefsDialog::helpDevice()
872{ 872{
873 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 873 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
874#ifdef _WIN32_ 874#ifdef _WIN32_
875 hint += "Leave empty for Irda.\n" 875 hint += "Leave empty for Irda.\n"
876 "com1:\n(first serial port)\n" 876 "com1:\n(first serial port)\n"
877 "usb not supported\n" 877 "usb not supported\n"
878 "???\n(bluetooth device address)\n"; 878 "???\n(bluetooth device address)\n";
879 879
880#else 880#else
881 hint += "/dev/ircomm\n(Irda)\n" 881 hint += "/dev/ircomm\n(Irda)\n"
882 "/dev/ttyS0\n(first serial port)\n" 882 "/dev/ttyS0\n(first serial port)\n"
883 "/dev/ttyUSB0\n(first device usb port)\n" 883 "/dev/ttyUSB0\n(first device usb port)\n"
884 "???\n(bluetooth device address)\n"; 884 "???\n(bluetooth device address)\n";
885#endif 885#endif
886 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 886 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
887} 887}
888void KSyncPrefsDialog::helpModel() 888void KSyncPrefsDialog::helpModel()
889{ 889{
890 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); 890 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n");
891 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 891 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
892 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 892 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
893 893
894} 894}
895void KSyncPrefsDialog::helpConnection() 895void KSyncPrefsDialog::helpConnection()
896{ 896{
897 QString hint = i18n("Insert kind of connection,e.g.:\n"); 897 QString hint = i18n("Insert kind of connection,e.g.:\n");
898 hint += "irda | Nokia FBUS over infrared\n" 898 hint += "irda | Nokia FBUS over infrared\n"
899 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 899 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
900 "irdaobex | set also model as obex\n" 900 "irdaobex | set also model as obex\n"
901 "fbus | Nokia FBUS2 serial\n"; 901 "fbus | Nokia FBUS2 serial\n";
902 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 902 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
903} 903}