summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp14
-rw-r--r--korganizer/calendarview.cpp14
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/mainwindow.cpp1
-rw-r--r--libkdepim/kpimprefs.h18
-rw-r--r--libkdepim/ksyncmanager.cpp100
-rw-r--r--libkdepim/ksyncmanager.h20
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp6
8 files changed, 79 insertions, 96 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index b014cba..9041e45 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2096,712 +2096,712 @@ void KABCore::updateActionMenu()
2096{ 2096{
2097 UndoStack *undo = UndoStack::instance(); 2097 UndoStack *undo = UndoStack::instance();
2098 RedoStack *redo = RedoStack::instance(); 2098 RedoStack *redo = RedoStack::instance();
2099 2099
2100 if ( undo->isEmpty() ) 2100 if ( undo->isEmpty() )
2101 mActionUndo->setText( i18n( "Undo" ) ); 2101 mActionUndo->setText( i18n( "Undo" ) );
2102 else 2102 else
2103 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2103 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2104 2104
2105 mActionUndo->setEnabled( !undo->isEmpty() ); 2105 mActionUndo->setEnabled( !undo->isEmpty() );
2106 2106
2107 if ( !redo->top() ) 2107 if ( !redo->top() )
2108 mActionRedo->setText( i18n( "Redo" ) ); 2108 mActionRedo->setText( i18n( "Redo" ) );
2109 else 2109 else
2110 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2110 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2111 2111
2112 mActionRedo->setEnabled( !redo->isEmpty() ); 2112 mActionRedo->setEnabled( !redo->isEmpty() );
2113} 2113}
2114 2114
2115void KABCore::configureKeyBindings() 2115void KABCore::configureKeyBindings()
2116{ 2116{
2117#ifndef KAB_EMBEDDED 2117#ifndef KAB_EMBEDDED
2118 KKeyDialog::configure( actionCollection(), true ); 2118 KKeyDialog::configure( actionCollection(), true );
2119#else //KAB_EMBEDDED 2119#else //KAB_EMBEDDED
2120 qDebug("KABCore::configureKeyBindings() not implemented"); 2120 qDebug("KABCore::configureKeyBindings() not implemented");
2121#endif //KAB_EMBEDDED 2121#endif //KAB_EMBEDDED
2122} 2122}
2123 2123
2124#ifdef KAB_EMBEDDED 2124#ifdef KAB_EMBEDDED
2125void KABCore::configureResources() 2125void KABCore::configureResources()
2126{ 2126{
2127 KRES::KCMKResources dlg( this, "" , 0 ); 2127 KRES::KCMKResources dlg( this, "" , 0 );
2128 2128
2129 if ( !dlg.exec() ) 2129 if ( !dlg.exec() )
2130 return; 2130 return;
2131 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2131 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2132} 2132}
2133#endif //KAB_EMBEDDED 2133#endif //KAB_EMBEDDED
2134 2134
2135 2135
2136/* this method will be called through the QCop interface from Ko/Pi to select addresses 2136/* this method will be called through the QCop interface from Ko/Pi to select addresses
2137 * for the attendees list of an event. 2137 * for the attendees list of an event.
2138 */ 2138 */
2139void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2139void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2140{ 2140{
2141 QStringList nameList; 2141 QStringList nameList;
2142 QStringList emailList; 2142 QStringList emailList;
2143 QStringList uidList; 2143 QStringList uidList;
2144 2144
2145 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2145 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2146 uint i=0; 2146 uint i=0;
2147 for (i=0; i < list.count(); i++) 2147 for (i=0; i < list.count(); i++)
2148 { 2148 {
2149 nameList.append(list[i].realName()); 2149 nameList.append(list[i].realName());
2150 emailList.append(list[i].preferredEmail()); 2150 emailList.append(list[i].preferredEmail());
2151 uidList.append(list[i].uid()); 2151 uidList.append(list[i].uid());
2152 } 2152 }
2153 2153
2154 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2154 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2155 2155
2156} 2156}
2157 2157
2158/* this method will be called through the QCop interface from other apps to show details of a contact. 2158/* this method will be called through the QCop interface from other apps to show details of a contact.
2159 */ 2159 */
2160void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2160void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2161{ 2161{
2162 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2162 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2163 2163
2164 QString foundUid = QString::null; 2164 QString foundUid = QString::null;
2165 if ( ! uid.isEmpty() ) { 2165 if ( ! uid.isEmpty() ) {
2166 Addressee adrr = mAddressBook->findByUid( uid ); 2166 Addressee adrr = mAddressBook->findByUid( uid );
2167 if ( !adrr.isEmpty() ) { 2167 if ( !adrr.isEmpty() ) {
2168 foundUid = uid; 2168 foundUid = uid;
2169 } 2169 }
2170 if ( email == "sendbacklist" ) { 2170 if ( email == "sendbacklist" ) {
2171 //qDebug("ssssssssssssssssssssssend "); 2171 //qDebug("ssssssssssssssssssssssend ");
2172 QStringList nameList; 2172 QStringList nameList;
2173 QStringList emailList; 2173 QStringList emailList;
2174 QStringList uidList; 2174 QStringList uidList;
2175 nameList.append(adrr.realName()); 2175 nameList.append(adrr.realName());
2176 emailList = adrr.emails(); 2176 emailList = adrr.emails();
2177 uidList.append( adrr.preferredEmail()); 2177 uidList.append( adrr.preferredEmail());
2178 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2178 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2179 return; 2179 return;
2180 } 2180 }
2181 2181
2182 } 2182 }
2183 2183
2184 if ( email == "sendbacklist" ) 2184 if ( email == "sendbacklist" )
2185 return; 2185 return;
2186 if (foundUid.isEmpty()) 2186 if (foundUid.isEmpty())
2187 { 2187 {
2188 //find the uid of the person first 2188 //find the uid of the person first
2189 Addressee::List namelist; 2189 Addressee::List namelist;
2190 Addressee::List emaillist; 2190 Addressee::List emaillist;
2191 2191
2192 if (!name.isEmpty()) 2192 if (!name.isEmpty())
2193 namelist = mAddressBook->findByName( name ); 2193 namelist = mAddressBook->findByName( name );
2194 2194
2195 if (!email.isEmpty()) 2195 if (!email.isEmpty())
2196 emaillist = mAddressBook->findByEmail( email ); 2196 emaillist = mAddressBook->findByEmail( email );
2197 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2197 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2198 //check if we have a match in Namelist and Emaillist 2198 //check if we have a match in Namelist and Emaillist
2199 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2199 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2200 foundUid = emaillist[0].uid(); 2200 foundUid = emaillist[0].uid();
2201 } 2201 }
2202 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2202 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2203 foundUid = namelist[0].uid(); 2203 foundUid = namelist[0].uid();
2204 else 2204 else
2205 { 2205 {
2206 for (int i = 0; i < namelist.count(); i++) 2206 for (int i = 0; i < namelist.count(); i++)
2207 { 2207 {
2208 for (int j = 0; j < emaillist.count(); j++) 2208 for (int j = 0; j < emaillist.count(); j++)
2209 { 2209 {
2210 if (namelist[i] == emaillist[j]) 2210 if (namelist[i] == emaillist[j])
2211 { 2211 {
2212 foundUid = namelist[i].uid(); 2212 foundUid = namelist[i].uid();
2213 } 2213 }
2214 } 2214 }
2215 } 2215 }
2216 } 2216 }
2217 } 2217 }
2218 else 2218 else
2219 { 2219 {
2220 foundUid = uid; 2220 foundUid = uid;
2221 } 2221 }
2222 2222
2223 if (!foundUid.isEmpty()) 2223 if (!foundUid.isEmpty())
2224 { 2224 {
2225 2225
2226 // raise Ka/Pi if it is in the background 2226 // raise Ka/Pi if it is in the background
2227#ifndef DESKTOP_VERSION 2227#ifndef DESKTOP_VERSION
2228#ifndef KORG_NODCOP 2228#ifndef KORG_NODCOP
2229 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2229 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2230#endif 2230#endif
2231#endif 2231#endif
2232 2232
2233 mMainWindow->showMaximized(); 2233 mMainWindow->showMaximized();
2234 mMainWindow-> raise(); 2234 mMainWindow-> raise();
2235 2235
2236 mViewManager->setSelected( "", false); 2236 mViewManager->setSelected( "", false);
2237 mViewManager->refreshView( "" ); 2237 mViewManager->refreshView( "" );
2238 mViewManager->setSelected( foundUid, true ); 2238 mViewManager->setSelected( foundUid, true );
2239 mViewManager->refreshView( foundUid ); 2239 mViewManager->refreshView( foundUid );
2240 2240
2241 if ( !mMultipleViewsAtOnce ) 2241 if ( !mMultipleViewsAtOnce )
2242 { 2242 {
2243 setDetailsVisible( true ); 2243 setDetailsVisible( true );
2244 mActionDetails->setChecked(true); 2244 mActionDetails->setChecked(true);
2245 } 2245 }
2246 } 2246 }
2247} 2247}
2248 2248
2249 2249
2250void KABCore::faq() 2250void KABCore::faq()
2251{ 2251{
2252 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2252 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2253} 2253}
2254 2254
2255#include <libkcal/syncdefines.h> 2255#include <libkcal/syncdefines.h>
2256 2256
2257KABC::Addressee KABCore::getLastSyncAddressee() 2257KABC::Addressee KABCore::getLastSyncAddressee()
2258{ 2258{
2259 Addressee lse; 2259 Addressee lse;
2260 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2260 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2261 2261
2262 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2262 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2263 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2263 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2264 if (lse.isEmpty()) { 2264 if (lse.isEmpty()) {
2265 qDebug("Creating new last-syncAddressee "); 2265 qDebug("Creating new last-syncAddressee ");
2266 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2266 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2267 QString sum = ""; 2267 QString sum = "";
2268 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2268 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2269 sum = "E: "; 2269 sum = "E: ";
2270 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2270 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2271 lse.setRevision( mLastAddressbookSync ); 2271 lse.setRevision( mLastAddressbookSync );
2272 lse.setCategories( i18n("SyncEvent") ); 2272 lse.setCategories( i18n("SyncEvent") );
2273 mAddressBook->insertAddressee( lse ); 2273 mAddressBook->insertAddressee( lse );
2274 } 2274 }
2275 return lse; 2275 return lse;
2276} 2276}
2277int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2277int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2278{ 2278{
2279 2279
2280 //void setZaurusId(int id); 2280 //void setZaurusId(int id);
2281 // int zaurusId() const; 2281 // int zaurusId() const;
2282 // void setZaurusUid(int id); 2282 // void setZaurusUid(int id);
2283 // int zaurusUid() const; 2283 // int zaurusUid() const;
2284 // void setZaurusStat(int id); 2284 // void setZaurusStat(int id);
2285 // int zaurusStat() const; 2285 // int zaurusStat() const;
2286 // 0 equal 2286 // 0 equal
2287 // 1 take local 2287 // 1 take local
2288 // 2 take remote 2288 // 2 take remote
2289 // 3 cancel 2289 // 3 cancel
2290 QDateTime lastSync = mLastAddressbookSync; 2290 QDateTime lastSync = mLastAddressbookSync;
2291 QDateTime localMod = local->revision(); 2291 QDateTime localMod = local->revision();
2292 QDateTime remoteMod = remote->revision(); 2292 QDateTime remoteMod = remote->revision();
2293 2293
2294 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2294 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2295 2295
2296 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2296 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2297 bool remCh, locCh; 2297 bool remCh, locCh;
2298 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2298 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2299 2299
2300 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2300 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2301 locCh = ( localMod > mLastAddressbookSync ); 2301 locCh = ( localMod > mLastAddressbookSync );
2302 if ( !remCh && ! locCh ) { 2302 if ( !remCh && ! locCh ) {
2303 //qDebug("both not changed "); 2303 //qDebug("both not changed ");
2304 lastSync = localMod.addDays(1); 2304 lastSync = localMod.addDays(1);
2305 if ( mode <= SYNC_PREF_ASK ) 2305 if ( mode <= SYNC_PREF_ASK )
2306 return 0; 2306 return 0;
2307 } else { 2307 } else {
2308 if ( locCh ) { 2308 if ( locCh ) {
2309 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2309 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2310 lastSync = localMod.addDays( -1 ); 2310 lastSync = localMod.addDays( -1 );
2311 if ( !remCh ) 2311 if ( !remCh )
2312 remoteMod =( lastSync.addDays( -1 ) ); 2312 remoteMod =( lastSync.addDays( -1 ) );
2313 } else { 2313 } else {
2314 //qDebug(" not loc changed "); 2314 //qDebug(" not loc changed ");
2315 lastSync = localMod.addDays( 1 ); 2315 lastSync = localMod.addDays( 1 );
2316 if ( remCh ) 2316 if ( remCh )
2317 remoteMod =( lastSync.addDays( 1 ) ); 2317 remoteMod =( lastSync.addDays( 1 ) );
2318 2318
2319 } 2319 }
2320 } 2320 }
2321 full = true; 2321 full = true;
2322 if ( mode < SYNC_PREF_ASK ) 2322 if ( mode < SYNC_PREF_ASK )
2323 mode = SYNC_PREF_ASK; 2323 mode = SYNC_PREF_ASK;
2324 } else { 2324 } else {
2325 if ( localMod == remoteMod ) 2325 if ( localMod == remoteMod )
2326 return 0; 2326 return 0;
2327 2327
2328 } 2328 }
2329 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2329 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2330 2330
2331 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2331 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2332 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2332 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2333 //full = true; //debug only 2333 //full = true; //debug only
2334 if ( full ) { 2334 if ( full ) {
2335 bool equ = ( (*local) == (*remote) ); 2335 bool equ = ( (*local) == (*remote) );
2336 if ( equ ) { 2336 if ( equ ) {
2337 //qDebug("equal "); 2337 //qDebug("equal ");
2338 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2338 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2339 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2339 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2340 } 2340 }
2341 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2341 if ( mode < SYNC_PREF_FORCE_LOCAL )
2342 return 0; 2342 return 0;
2343 2343
2344 }//else //debug only 2344 }//else //debug only
2345 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2345 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2346 } 2346 }
2347 int result; 2347 int result;
2348 bool localIsNew; 2348 bool localIsNew;
2349 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2349 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2350 2350
2351 if ( full && mode < SYNC_PREF_NEWEST ) 2351 if ( full && mode < SYNC_PREF_NEWEST )
2352 mode = SYNC_PREF_ASK; 2352 mode = SYNC_PREF_ASK;
2353 2353
2354 switch( mode ) { 2354 switch( mode ) {
2355 case SYNC_PREF_LOCAL: 2355 case SYNC_PREF_LOCAL:
2356 if ( lastSync > remoteMod ) 2356 if ( lastSync > remoteMod )
2357 return 1; 2357 return 1;
2358 if ( lastSync > localMod ) 2358 if ( lastSync > localMod )
2359 return 2; 2359 return 2;
2360 return 1; 2360 return 1;
2361 break; 2361 break;
2362 case SYNC_PREF_REMOTE: 2362 case SYNC_PREF_REMOTE:
2363 if ( lastSync > remoteMod ) 2363 if ( lastSync > remoteMod )
2364 return 1; 2364 return 1;
2365 if ( lastSync > localMod ) 2365 if ( lastSync > localMod )
2366 return 2; 2366 return 2;
2367 return 2; 2367 return 2;
2368 break; 2368 break;
2369 case SYNC_PREF_NEWEST: 2369 case SYNC_PREF_NEWEST:
2370 if ( localMod > remoteMod ) 2370 if ( localMod > remoteMod )
2371 return 1; 2371 return 1;
2372 else 2372 else
2373 return 2; 2373 return 2;
2374 break; 2374 break;
2375 case SYNC_PREF_ASK: 2375 case SYNC_PREF_ASK:
2376 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2376 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2377 if ( lastSync > remoteMod ) 2377 if ( lastSync > remoteMod )
2378 return 1; 2378 return 1;
2379 if ( lastSync > localMod ) 2379 if ( lastSync > localMod )
2380 return 2; 2380 return 2;
2381 localIsNew = localMod >= remoteMod; 2381 localIsNew = localMod >= remoteMod;
2382 //qDebug("conflict! ************************************** "); 2382 //qDebug("conflict! ************************************** ");
2383 { 2383 {
2384 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2384 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2385 result = acd.executeD(localIsNew); 2385 result = acd.executeD(localIsNew);
2386 return result; 2386 return result;
2387 } 2387 }
2388 break; 2388 break;
2389 case SYNC_PREF_FORCE_LOCAL: 2389 case SYNC_PREF_FORCE_LOCAL:
2390 return 1; 2390 return 1;
2391 break; 2391 break;
2392 case SYNC_PREF_FORCE_REMOTE: 2392 case SYNC_PREF_FORCE_REMOTE:
2393 return 2; 2393 return 2;
2394 break; 2394 break;
2395 2395
2396 default: 2396 default:
2397 // SYNC_PREF_TAKE_BOTH not implemented 2397 // SYNC_PREF_TAKE_BOTH not implemented
2398 break; 2398 break;
2399 } 2399 }
2400 return 0; 2400 return 0;
2401} 2401}
2402 2402
2403 2403
2404bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2404bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2405{ 2405{
2406 bool syncOK = true; 2406 bool syncOK = true;
2407 int addedAddressee = 0; 2407 int addedAddressee = 0;
2408 int addedAddresseeR = 0; 2408 int addedAddresseeR = 0;
2409 int deletedAddresseeR = 0; 2409 int deletedAddresseeR = 0;
2410 int deletedAddresseeL = 0; 2410 int deletedAddresseeL = 0;
2411 int changedLocal = 0; 2411 int changedLocal = 0;
2412 int changedRemote = 0; 2412 int changedRemote = 0;
2413 2413
2414 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2414 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2415 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2415 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2416 2416
2417 //QPtrList<Addressee> el = local->rawAddressees(); 2417 //QPtrList<Addressee> el = local->rawAddressees();
2418 Addressee addresseeR; 2418 Addressee addresseeR;
2419 QString uid; 2419 QString uid;
2420 int take; 2420 int take;
2421 Addressee addresseeL; 2421 Addressee addresseeL;
2422 Addressee addresseeRSync; 2422 Addressee addresseeRSync;
2423 Addressee addresseeLSync; 2423 Addressee addresseeLSync;
2424 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2424 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2425 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2425 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2426 bool fullDateRange = false; 2426 bool fullDateRange = false;
2427 local->resetTempSyncStat(); 2427 local->resetTempSyncStat();
2428 mLastAddressbookSync = QDateTime::currentDateTime(); 2428 mLastAddressbookSync = QDateTime::currentDateTime();
2429 QDateTime modifiedCalendar = mLastAddressbookSync;; 2429 QDateTime modifiedCalendar = mLastAddressbookSync;;
2430 addresseeLSync = getLastSyncAddressee(); 2430 addresseeLSync = getLastSyncAddressee();
2431 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2431 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2432 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2432 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2433 if ( !addresseeR.isEmpty() ) { 2433 if ( !addresseeR.isEmpty() ) {
2434 addresseeRSync = addresseeR; 2434 addresseeRSync = addresseeR;
2435 remote->removeAddressee(addresseeR ); 2435 remote->removeAddressee(addresseeR );
2436 2436
2437 } else { 2437 } else {
2438 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2438 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2439 addresseeRSync = addresseeLSync ; 2439 addresseeRSync = addresseeLSync ;
2440 } else { 2440 } else {
2441 qDebug("FULLDATE 1"); 2441 qDebug("FULLDATE 1");
2442 fullDateRange = true; 2442 fullDateRange = true;
2443 Addressee newAdd; 2443 Addressee newAdd;
2444 addresseeRSync = newAdd; 2444 addresseeRSync = newAdd;
2445 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2445 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2446 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2446 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2447 addresseeRSync.setRevision( mLastAddressbookSync ); 2447 addresseeRSync.setRevision( mLastAddressbookSync );
2448 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2448 addresseeRSync.setCategories( i18n("SyncAddressee") );
2449 } 2449 }
2450 } 2450 }
2451 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2451 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2452 qDebug("FULLDATE 2"); 2452 qDebug("FULLDATE 2");
2453 fullDateRange = true; 2453 fullDateRange = true;
2454 } 2454 }
2455 if ( ! fullDateRange ) { 2455 if ( ! fullDateRange ) {
2456 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2456 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2457 2457
2458 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2458 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2459 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2459 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2460 fullDateRange = true; 2460 fullDateRange = true;
2461 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2461 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2462 } 2462 }
2463 } 2463 }
2464 // fullDateRange = true; // debug only! 2464 // fullDateRange = true; // debug only!
2465 if ( fullDateRange ) 2465 if ( fullDateRange )
2466 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2466 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2467 else 2467 else
2468 mLastAddressbookSync = addresseeLSync.revision(); 2468 mLastAddressbookSync = addresseeLSync.revision();
2469 // for resyncing if own file has changed 2469 // for resyncing if own file has changed
2470 // PENDING fixme later when implemented 2470 // PENDING fixme later when implemented
2471#if 0 2471#if 0
2472 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2472 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2473 mLastAddressbookSync = loadedFileVersion; 2473 mLastAddressbookSync = loadedFileVersion;
2474 qDebug("setting mLastAddressbookSync "); 2474 qDebug("setting mLastAddressbookSync ");
2475 } 2475 }
2476#endif 2476#endif
2477 2477
2478 //qDebug("*************************** "); 2478 //qDebug("*************************** ");
2479 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2479 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2480 QStringList er = remote->uidList(); 2480 QStringList er = remote->uidList();
2481 Addressee inR ;//= er.first(); 2481 Addressee inR ;//= er.first();
2482 Addressee inL; 2482 Addressee inL;
2483 2483
2484 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2484 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2485 2485
2486 int modulo = (er.count()/10)+1; 2486 int modulo = (er.count()/10)+1;
2487 int incCounter = 0; 2487 int incCounter = 0;
2488 while ( incCounter < er.count()) { 2488 while ( incCounter < er.count()) {
2489 if (syncManager->isProgressBarCanceled()) 2489 if (syncManager->isProgressBarCanceled())
2490 return false; 2490 return false;
2491 if ( incCounter % modulo == 0 ) 2491 if ( incCounter % modulo == 0 )
2492 syncManager->showProgressBar(incCounter); 2492 syncManager->showProgressBar(incCounter);
2493 2493
2494 uid = er[ incCounter ]; 2494 uid = er[ incCounter ];
2495 bool skipIncidence = false; 2495 bool skipIncidence = false;
2496 if ( uid.left(19) == QString("last-syncAddressee-") ) 2496 if ( uid.left(19) == QString("last-syncAddressee-") )
2497 skipIncidence = true; 2497 skipIncidence = true;
2498 QString idS,OidS; 2498 QString idS,OidS;
2499 qApp->processEvents(); 2499 qApp->processEvents();
2500 if ( !skipIncidence ) { 2500 if ( !skipIncidence ) {
2501 inL = local->findByUid( uid ); 2501 inL = local->findByUid( uid );
2502 inR = remote->findByUid( uid ); 2502 inR = remote->findByUid( uid );
2503 //inL.setResource( 0 ); 2503 //inL.setResource( 0 );
2504 //inR.setResource( 0 ); 2504 //inR.setResource( 0 );
2505 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2505 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2506 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2506 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2507 //qDebug("take %d %s ", take, inL.summary().latin1()); 2507 //qDebug("take %d %s ", take, inL.summary().latin1());
2508 if ( take == 3 ) 2508 if ( take == 3 )
2509 return false; 2509 return false;
2510 if ( take == 1 ) {// take local 2510 if ( take == 1 ) {// take local
2511 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2511 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2512 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2512 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2513 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2513 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2514 local->insertAddressee( inL, false ); 2514 local->insertAddressee( inL, false );
2515 idS = inR.externalUID(); 2515 idS = inR.externalUID();
2516 OidS = inR.originalExternalUID(); 2516 OidS = inR.originalExternalUID();
2517 } 2517 }
2518 else 2518 else
2519 idS = inR.IDStr(); 2519 idS = inR.IDStr();
2520 remote->removeAddressee( inR ); 2520 remote->removeAddressee( inR );
2521 inR = inL; 2521 inR = inL;
2522 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2522 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2523 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2523 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2524 inR.setOriginalExternalUID( OidS ); 2524 inR.setOriginalExternalUID( OidS );
2525 inR.setExternalUID( idS ); 2525 inR.setExternalUID( idS );
2526 } else { 2526 } else {
2527 inR.setIDStr( idS ); 2527 inR.setIDStr( idS );
2528 } 2528 }
2529 inR.setResource( 0 ); 2529 inR.setResource( 0 );
2530 remote->insertAddressee( inR , false); 2530 remote->insertAddressee( inR , false);
2531 ++changedRemote; 2531 ++changedRemote;
2532 } else { // take == 2 take remote 2532 } else { // take == 2 take remote
2533 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2533 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2534 if ( inR.revision().date().year() < 2004 ) 2534 if ( inR.revision().date().year() < 2004 )
2535 inR.setRevision( modifiedCalendar ); 2535 inR.setRevision( modifiedCalendar );
2536 } 2536 }
2537 idS = inL.IDStr(); 2537 idS = inL.IDStr();
2538 local->removeAddressee( inL ); 2538 local->removeAddressee( inL );
2539 inL = inR; 2539 inL = inR;
2540 inL.setIDStr( idS ); 2540 inL.setIDStr( idS );
2541 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2541 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2542 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2542 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2543 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2543 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2544 } 2544 }
2545 inL.setResource( 0 ); 2545 inL.setResource( 0 );
2546 local->insertAddressee( inL , false ); 2546 local->insertAddressee( inL , false );
2547 ++changedLocal; 2547 ++changedLocal;
2548 } 2548 }
2549 } 2549 }
2550 } else { // no conflict 2550 } else { // no conflict
2551 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2551 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2552 QString des = addresseeLSync.note(); 2552 QString des = addresseeLSync.note();
2553 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2553 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2554 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2554 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2555 remote->insertAddressee( inR, false ); 2555 remote->insertAddressee( inR, false );
2556 ++deletedAddresseeR; 2556 ++deletedAddresseeR;
2557 } else { 2557 } else {
2558 inR.setRevision( modifiedCalendar ); 2558 inR.setRevision( modifiedCalendar );
2559 remote->insertAddressee( inR, false ); 2559 remote->insertAddressee( inR, false );
2560 inL = inR; 2560 inL = inR;
2561 inL.setResource( 0 ); 2561 inL.setResource( 0 );
2562 local->insertAddressee( inL , false); 2562 local->insertAddressee( inL , false);
2563 ++addedAddressee; 2563 ++addedAddressee;
2564 } 2564 }
2565 } else { 2565 } else {
2566 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2566 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2567 inR.setRevision( modifiedCalendar ); 2567 inR.setRevision( modifiedCalendar );
2568 remote->insertAddressee( inR, false ); 2568 remote->insertAddressee( inR, false );
2569 inR.setResource( 0 ); 2569 inR.setResource( 0 );
2570 local->insertAddressee( inR, false ); 2570 local->insertAddressee( inR, false );
2571 ++addedAddressee; 2571 ++addedAddressee;
2572 } else { 2572 } else {
2573 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2573 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2574 remote->removeAddressee( inR ); 2574 remote->removeAddressee( inR );
2575 ++deletedAddresseeR; 2575 ++deletedAddresseeR;
2576 } 2576 }
2577 } 2577 }
2578 } 2578 }
2579 } 2579 }
2580 ++incCounter; 2580 ++incCounter;
2581 } 2581 }
2582 er.clear(); 2582 er.clear();
2583 QStringList el = local->uidList(); 2583 QStringList el = local->uidList();
2584 modulo = (el.count()/10)+1; 2584 modulo = (el.count()/10)+1;
2585 2585
2586 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2586 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2587 incCounter = 0; 2587 incCounter = 0;
2588 while ( incCounter < el.count()) { 2588 while ( incCounter < el.count()) {
2589 qApp->processEvents(); 2589 qApp->processEvents();
2590 if (syncManager->isProgressBarCanceled()) 2590 if (syncManager->isProgressBarCanceled())
2591 return false; 2591 return false;
2592 if ( incCounter % modulo == 0 ) 2592 if ( incCounter % modulo == 0 )
2593 syncManager->showProgressBar(incCounter); 2593 syncManager->showProgressBar(incCounter);
2594 uid = el[ incCounter ]; 2594 uid = el[ incCounter ];
2595 bool skipIncidence = false; 2595 bool skipIncidence = false;
2596 if ( uid.left(19) == QString("last-syncAddressee-") ) 2596 if ( uid.left(19) == QString("last-syncAddressee-") )
2597 skipIncidence = true; 2597 skipIncidence = true;
2598 if ( !skipIncidence ) { 2598 if ( !skipIncidence ) {
2599 inL = local->findByUid( uid ); 2599 inL = local->findByUid( uid );
2600 inR = remote->findByUid( uid ); 2600 inR = remote->findByUid( uid );
2601 if ( inR.isEmpty() ) { 2601 if ( inR.isEmpty() ) {
2602 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2602 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2603 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2603 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2604 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2604 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2605 local->removeAddressee( inL ); 2605 local->removeAddressee( inL );
2606 ++deletedAddresseeL; 2606 ++deletedAddresseeL;
2607 } else { 2607 } else {
2608 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2608 if ( ! syncManager->mWriteBackExistingOnly ) {
2609 inL.removeID(mCurrentSyncDevice ); 2609 inL.removeID(mCurrentSyncDevice );
2610 ++addedAddresseeR; 2610 ++addedAddresseeR;
2611 inL.setRevision( modifiedCalendar ); 2611 inL.setRevision( modifiedCalendar );
2612 local->insertAddressee( inL, false ); 2612 local->insertAddressee( inL, false );
2613 inR = inL; 2613 inR = inL;
2614 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2614 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2615 inR.setResource( 0 ); 2615 inR.setResource( 0 );
2616 remote->insertAddressee( inR, false ); 2616 remote->insertAddressee( inR, false );
2617 } 2617 }
2618 } 2618 }
2619 } else { 2619 } else {
2620 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2620 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2621 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2621 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2622 local->removeAddressee( inL ); 2622 local->removeAddressee( inL );
2623 ++deletedAddresseeL; 2623 ++deletedAddresseeL;
2624 } else { 2624 } else {
2625 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2625 if ( ! syncManager->mWriteBackExistingOnly ) {
2626 ++addedAddresseeR; 2626 ++addedAddresseeR;
2627 inL.setRevision( modifiedCalendar ); 2627 inL.setRevision( modifiedCalendar );
2628 local->insertAddressee( inL, false ); 2628 local->insertAddressee( inL, false );
2629 inR = inL; 2629 inR = inL;
2630 inR.setResource( 0 ); 2630 inR.setResource( 0 );
2631 remote->insertAddressee( inR, false ); 2631 remote->insertAddressee( inR, false );
2632 } 2632 }
2633 } 2633 }
2634 } 2634 }
2635 } 2635 }
2636 } 2636 }
2637 ++incCounter; 2637 ++incCounter;
2638 } 2638 }
2639 el.clear(); 2639 el.clear();
2640 syncManager->hideProgressBar(); 2640 syncManager->hideProgressBar();
2641 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2641 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2642 // get rid of micro seconds 2642 // get rid of micro seconds
2643 QTime t = mLastAddressbookSync.time(); 2643 QTime t = mLastAddressbookSync.time();
2644 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2644 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2645 addresseeLSync.setRevision( mLastAddressbookSync ); 2645 addresseeLSync.setRevision( mLastAddressbookSync );
2646 addresseeRSync.setRevision( mLastAddressbookSync ); 2646 addresseeRSync.setRevision( mLastAddressbookSync );
2647 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2647 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2648 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2648 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2649 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2649 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2650 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2650 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2651 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2651 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2652 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2652 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2653 addresseeRSync.setNote( "" ) ; 2653 addresseeRSync.setNote( "" ) ;
2654 addresseeLSync.setNote( "" ); 2654 addresseeLSync.setNote( "" );
2655 2655
2656 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2656 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2657 remote->insertAddressee( addresseeRSync, false ); 2657 remote->insertAddressee( addresseeRSync, false );
2658 local->insertAddressee( addresseeLSync, false ); 2658 local->insertAddressee( addresseeLSync, false );
2659 QString mes; 2659 QString mes;
2660 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2660 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2661 if ( KABPrefs::instance()->mShowSyncSummary ) { 2661 if ( syncManager->mShowSyncSummary ) {
2662 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2662 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2663 } 2663 }
2664 qDebug( mes ); 2664 qDebug( mes );
2665 return syncOK; 2665 return syncOK;
2666} 2666}
2667 2667
2668 2668
2669//this is a overwritten callbackmethods from the syncinterface 2669//this is a overwritten callbackmethods from the syncinterface
2670bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2670bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2671{ 2671{
2672 2672
2673 //pending prepare addresseeview for output 2673 //pending prepare addresseeview for output
2674 //pending detect, if remote file has REV field. if not switch to external sync 2674 //pending detect, if remote file has REV field. if not switch to external sync
2675 mGlobalSyncMode = SYNC_MODE_NORMAL; 2675 mGlobalSyncMode = SYNC_MODE_NORMAL;
2676 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2676 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2677 2677
2678 AddressBook abLocal(filename,"syncContact"); 2678 AddressBook abLocal(filename,"syncContact");
2679 bool syncOK = false; 2679 bool syncOK = false;
2680 if ( abLocal.load() ) { 2680 if ( abLocal.load() ) {
2681 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2681 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2682 bool external = false; 2682 bool external = false;
2683 bool isXML = false; 2683 bool isXML = false;
2684 if ( filename.right(4) == ".xml") { 2684 if ( filename.right(4) == ".xml") {
2685 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2685 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2686 isXML = true; 2686 isXML = true;
2687 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2687 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2688 } else { 2688 } else {
2689 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2689 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2690 if ( ! lse.isEmpty() ) { 2690 if ( ! lse.isEmpty() ) {
2691 if ( lse.familyName().left(4) == "!E: " ) 2691 if ( lse.familyName().left(4) == "!E: " )
2692 external = true; 2692 external = true;
2693 } else { 2693 } else {
2694 bool found = false; 2694 bool found = false;
2695 AddressBook::Iterator it; 2695 AddressBook::Iterator it;
2696 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2696 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2697 if ( (*it).revision().date().year() > 2003 ) { 2697 if ( (*it).revision().date().year() > 2003 ) {
2698 found = true; 2698 found = true;
2699 break; 2699 break;
2700 } 2700 }
2701 } 2701 }
2702 external = ! found; 2702 external = ! found;
2703 } 2703 }
2704 2704
2705 if ( external ) { 2705 if ( external ) {
2706 qDebug("Setting vcf mode to external "); 2706 qDebug("Setting vcf mode to external ");
2707 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2707 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2708 AddressBook::Iterator it; 2708 AddressBook::Iterator it;
2709 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2709 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2710 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2710 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2711 (*it).computeCsum( mCurrentSyncDevice ); 2711 (*it).computeCsum( mCurrentSyncDevice );
2712 } 2712 }
2713 } 2713 }
2714 } 2714 }
2715 //AddressBook::Iterator it; 2715 //AddressBook::Iterator it;
2716 //QStringList vcards; 2716 //QStringList vcards;
2717 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2717 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2718 // qDebug("Name %s ", (*it).familyName().latin1()); 2718 // qDebug("Name %s ", (*it).familyName().latin1());
2719 //} 2719 //}
2720 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2720 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2721 if ( syncOK ) { 2721 if ( syncOK ) {
2722 if ( KABPrefs::instance()->mWriteBackFile ) 2722 if ( syncManager->mWriteBackFile )
2723 { 2723 {
2724 if ( external ) 2724 if ( external )
2725 abLocal.removeSyncAddressees( !isXML); 2725 abLocal.removeSyncAddressees( !isXML);
2726 qDebug("Saving remote AB "); 2726 qDebug("Saving remote AB ");
2727 abLocal.saveAB(); 2727 abLocal.saveAB();
2728 if ( isXML ) { 2728 if ( isXML ) {
2729 // afterwrite processing 2729 // afterwrite processing
2730 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2730 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2731 } 2731 }
2732 } 2732 }
2733 } 2733 }
2734 setModified(); 2734 setModified();
2735 2735
2736 } 2736 }
2737 if ( syncOK ) 2737 if ( syncOK )
2738 mViewManager->refreshView(); 2738 mViewManager->refreshView();
2739 return syncOK; 2739 return syncOK;
2740#if 0 2740#if 0
2741 2741
2742 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2742 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2743 getEventViewerDialog()->setSyncMode( true ); 2743 getEventViewerDialog()->setSyncMode( true );
2744 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2744 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2745 getEventViewerDialog()->setSyncMode( false ); 2745 getEventViewerDialog()->setSyncMode( false );
2746 if ( syncOK ) { 2746 if ( syncOK ) {
2747 if ( KOPrefs::instance()->mWriteBackFile ) 2747 if ( KOPrefs::instance()->mWriteBackFile )
2748 { 2748 {
2749 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2749 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2750 storage->save(); 2750 storage->save();
2751 } 2751 }
2752 } 2752 }
2753 setModified(); 2753 setModified();
2754 } 2754 }
2755 2755
2756#endif 2756#endif
2757} 2757}
2758 2758
2759 2759
2760//this is a overwritten callbackmethods from the syncinterface 2760//this is a overwritten callbackmethods from the syncinterface
2761bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2761bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2762{ 2762{
2763 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2763 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2764 2764
2765 AddressBook abLocal( resource,"syncContact"); 2765 AddressBook abLocal( resource,"syncContact");
2766 bool syncOK = false; 2766 bool syncOK = false;
2767 if ( abLocal.load() ) { 2767 if ( abLocal.load() ) {
2768 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2768 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2769 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2769 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2770 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2770 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2771 qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); 2771 qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? ");
2772 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); 2772 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2773 if ( syncOK ) { 2773 if ( syncOK ) {
2774 if ( KABPrefs::instance()->mWriteBackFile ) { 2774 if ( syncManager->mWriteBackFile ) {
2775 abLocal.saveAB(); 2775 abLocal.saveAB();
2776 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2776 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2777 } 2777 }
2778 } 2778 }
2779 setModified(); 2779 setModified();
2780 } 2780 }
2781 if ( syncOK ) 2781 if ( syncOK )
2782 mViewManager->refreshView(); 2782 mViewManager->refreshView();
2783 return syncOK; 2783 return syncOK;
2784 2784
2785} 2785}
2786 2786
2787//called by the syncmanager to indicate that the work has to marked as dirty. 2787//called by the syncmanager to indicate that the work has to marked as dirty.
2788void KABCore::sync_setModified() 2788void KABCore::sync_setModified()
2789{ 2789{
2790 setModified(); 2790 setModified();
2791} 2791}
2792 2792
2793//called by the syncmanager to ask if the dirty flag is set. 2793//called by the syncmanager to ask if the dirty flag is set.
2794bool KABCore::sync_isModified() 2794bool KABCore::sync_isModified()
2795{ 2795{
2796 return mModified; 2796 return mModified;
2797} 2797}
2798 2798
2799 2799
2800//called by the syncmanager to indicate that the work has to be saved. 2800//called by the syncmanager to indicate that the work has to be saved.
2801void KABCore::sync_save() 2801void KABCore::sync_save()
2802{ 2802{
2803 save(); 2803 save();
2804} 2804}
2805 2805
2806 2806
2807 2807
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 38b55f7..1de2759 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -368,1039 +368,1025 @@ void CalendarView::init()
368 connect( mDateNavigator, SIGNAL( goPrevious() ), 368 connect( mDateNavigator, SIGNAL( goPrevious() ),
369 mNavigator, SLOT( selectPrevious() ) ); 369 mNavigator, SLOT( selectPrevious() ) );
370 connect( mDateNavigator, SIGNAL( goNext() ), 370 connect( mDateNavigator, SIGNAL( goNext() ),
371 mNavigator, SLOT( selectNext() ) ); 371 mNavigator, SLOT( selectNext() ) );
372 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 372 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) ); 373 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 374 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
375 mNavigator, SLOT( slotMonthSelect( int ) ) ); 375 mNavigator, SLOT( slotMonthSelect( int ) ) );
376 376
377 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 377 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
378 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 378 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
379 379
380 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 380 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
381 SLOT( eventAdded( Event *) ) ); 381 SLOT( eventAdded( Event *) ) );
382 382
383 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 383 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
384 384
385 connect( this, SIGNAL( configChanged() ), 385 connect( this, SIGNAL( configChanged() ),
386 mDateNavigator, SLOT( updateConfig() ) ); 386 mDateNavigator, SLOT( updateConfig() ) );
387 387
388 connect( mTodoList, SIGNAL( newTodoSignal() ), 388 connect( mTodoList, SIGNAL( newTodoSignal() ),
389 SLOT( newTodo() ) ); 389 SLOT( newTodo() ) );
390 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 390 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
391 SLOT( newSubTodo( Todo * ) ) ); 391 SLOT( newSubTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 392 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
393 SLOT( editTodo( Todo * ) ) ); 393 SLOT( editTodo( Todo * ) ) );
394 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 394 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
395 SLOT( showTodo( Todo *) ) ); 395 SLOT( showTodo( Todo *) ) );
396 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 396 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
397 SLOT( deleteTodo( Todo *) ) ); 397 SLOT( deleteTodo( Todo *) ) );
398 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 398 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
399 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 399 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
400 SLOT( purgeCompleted() ) ); 400 SLOT( purgeCompleted() ) );
401 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 401 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
402 SIGNAL( todoModified( Todo *, int ) ) ); 402 SIGNAL( todoModified( Todo *, int ) ) );
403 403
404 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 404 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
405 this, SLOT ( cloneIncidence( Incidence * ) ) ); 405 this, SLOT ( cloneIncidence( Incidence * ) ) );
406 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 406 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
407 this, SLOT (cancelIncidence( Incidence * ) ) ); 407 this, SLOT (cancelIncidence( Incidence * ) ) );
408 408
409 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
410 this, SLOT ( moveIncidence( Incidence * ) ) ); 410 this, SLOT ( moveIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
412 this, SLOT ( beamIncidence( Incidence * ) ) ); 412 this, SLOT ( beamIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 414 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
415 this, SLOT ( todo_unsub( Todo * ) ) ); 415 this, SLOT ( todo_unsub( Todo * ) ) );
416 416
417 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 417 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
418 SLOT( updateTodo( Todo *, int ) ) ); 418 SLOT( updateTodo( Todo *, int ) ) );
419 connect( this, SIGNAL( todoModified( Todo *, int )), this, 419 connect( this, SIGNAL( todoModified( Todo *, int )), this,
420 SLOT( changeTodoDisplay( Todo *, int ) ) ); 420 SLOT( changeTodoDisplay( Todo *, int ) ) );
421 421
422 422
423 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 423 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
424 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 424 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
425 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 425 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
426 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 426 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
427 427
428 428
429 429
430 430
431 431
432 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 432 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
433 SLOT(checkClipboard())); 433 SLOT(checkClipboard()));
434 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 434 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
435 SLOT( processTodoListSelection( Incidence * ) ) ); 435 SLOT( processTodoListSelection( Incidence * ) ) );
436 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 436 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
437 437
438 // kdDebug() << "CalendarView::CalendarView() done" << endl; 438 // kdDebug() << "CalendarView::CalendarView() done" << endl;
439 439
440 mDateFrame = new QVBox(0,0,WType_Popup); 440 mDateFrame = new QVBox(0,0,WType_Popup);
441 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 441 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
442 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 442 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
443 mDateFrame->setLineWidth(3); 443 mDateFrame->setLineWidth(3);
444 mDateFrame->hide(); 444 mDateFrame->hide();
445 mDateFrame->setCaption( i18n( "Pick a date to display")); 445 mDateFrame->setCaption( i18n( "Pick a date to display"));
446 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 446 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
447 447
448 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 448 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
449 449
450 mEventEditor = mDialogManager->getEventEditor(); 450 mEventEditor = mDialogManager->getEventEditor();
451 mTodoEditor = mDialogManager->getTodoEditor(); 451 mTodoEditor = mDialogManager->getTodoEditor();
452 452
453 mFlagEditDescription = false; 453 mFlagEditDescription = false;
454 454
455 mSuspendTimer = new QTimer( this ); 455 mSuspendTimer = new QTimer( this );
456 mAlarmTimer = new QTimer( this ); 456 mAlarmTimer = new QTimer( this );
457 mRecheckAlarmTimer = new QTimer( this ); 457 mRecheckAlarmTimer = new QTimer( this );
458 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 458 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
459 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 459 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
460 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 460 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
461 mAlarmDialog = new AlarmDialog( this ); 461 mAlarmDialog = new AlarmDialog( this );
462 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 462 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
463 mAlarmDialog->setServerNotification( false ); 463 mAlarmDialog->setServerNotification( false );
464 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 464 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
465} 465}
466 466
467 467
468CalendarView::~CalendarView() 468CalendarView::~CalendarView()
469{ 469{
470 // kdDebug() << "~CalendarView()" << endl; 470 // kdDebug() << "~CalendarView()" << endl;
471 //qDebug("CalendarView::~CalendarView() "); 471 //qDebug("CalendarView::~CalendarView() ");
472 delete mDialogManager; 472 delete mDialogManager;
473 delete mViewManager; 473 delete mViewManager;
474 delete mStorage; 474 delete mStorage;
475 delete mDateFrame ; 475 delete mDateFrame ;
476 delete beamDialog; 476 delete beamDialog;
477 //kdDebug() << "~CalendarView() done" << endl; 477 //kdDebug() << "~CalendarView() done" << endl;
478} 478}
479void CalendarView::timerAlarm() 479void CalendarView::timerAlarm()
480{ 480{
481 //qDebug("CalendarView::timerAlarm() "); 481 //qDebug("CalendarView::timerAlarm() ");
482 computeAlarm(mAlarmNotification ); 482 computeAlarm(mAlarmNotification );
483} 483}
484 484
485void CalendarView::suspendAlarm() 485void CalendarView::suspendAlarm()
486{ 486{
487 //qDebug(" CalendarView::suspendAlarm() "); 487 //qDebug(" CalendarView::suspendAlarm() ");
488 computeAlarm(mSuspendAlarmNotification ); 488 computeAlarm(mSuspendAlarmNotification );
489 489
490} 490}
491 491
492void CalendarView::startAlarm( QString mess , QString filename) 492void CalendarView::startAlarm( QString mess , QString filename)
493{ 493{
494 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 494 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
495 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 495 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
496 496
497} 497}
498 498
499void CalendarView::checkNextTimerAlarm() 499void CalendarView::checkNextTimerAlarm()
500{ 500{
501 mCalendar->checkAlarmForIncidence( 0, true ); 501 mCalendar->checkAlarmForIncidence( 0, true );
502} 502}
503 503
504void CalendarView::computeAlarm( QString msg ) 504void CalendarView::computeAlarm( QString msg )
505{ 505{
506 506
507 QString mess = msg; 507 QString mess = msg;
508 QString mAlarmMessage = mess.mid( 9 ); 508 QString mAlarmMessage = mess.mid( 9 );
509 QString filename = MainWindow::resourcePath(); 509 QString filename = MainWindow::resourcePath();
510 filename += "koalarm.wav"; 510 filename += "koalarm.wav";
511 QString tempfilename; 511 QString tempfilename;
512 if ( mess.left( 13 ) == "suspend_alarm") { 512 if ( mess.left( 13 ) == "suspend_alarm") {
513 bool error = false; 513 bool error = false;
514 int len = mess.mid( 13 ).find("+++"); 514 int len = mess.mid( 13 ).find("+++");
515 if ( len < 2 ) 515 if ( len < 2 )
516 error = true; 516 error = true;
517 else { 517 else {
518 tempfilename = mess.mid( 13, len ); 518 tempfilename = mess.mid( 13, len );
519 if ( !QFile::exists( tempfilename ) ) 519 if ( !QFile::exists( tempfilename ) )
520 error = true; 520 error = true;
521 } 521 }
522 if ( ! error ) { 522 if ( ! error ) {
523 filename = tempfilename; 523 filename = tempfilename;
524 } 524 }
525 mAlarmMessage = mess.mid( 13+len+3 ); 525 mAlarmMessage = mess.mid( 13+len+3 );
526 //qDebug("suspend file %s ",tempfilename.latin1() ); 526 //qDebug("suspend file %s ",tempfilename.latin1() );
527 startAlarm( mAlarmMessage, filename); 527 startAlarm( mAlarmMessage, filename);
528 return; 528 return;
529 } 529 }
530 if ( mess.left( 11 ) == "timer_alarm") { 530 if ( mess.left( 11 ) == "timer_alarm") {
531 //mTimerTime = 0; 531 //mTimerTime = 0;
532 startAlarm( mess.mid( 11 ), filename ); 532 startAlarm( mess.mid( 11 ), filename );
533 return; 533 return;
534 } 534 }
535 if ( mess.left( 10 ) == "proc_alarm") { 535 if ( mess.left( 10 ) == "proc_alarm") {
536 bool error = false; 536 bool error = false;
537 int len = mess.mid( 10 ).find("+++"); 537 int len = mess.mid( 10 ).find("+++");
538 if ( len < 2 ) 538 if ( len < 2 )
539 error = true; 539 error = true;
540 else { 540 else {
541 tempfilename = mess.mid( 10, len ); 541 tempfilename = mess.mid( 10, len );
542 if ( !QFile::exists( tempfilename ) ) 542 if ( !QFile::exists( tempfilename ) )
543 error = true; 543 error = true;
544 } 544 }
545 if ( error ) { 545 if ( error ) {
546 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 546 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
547 mAlarmMessage += mess.mid( 10+len+3+9 ); 547 mAlarmMessage += mess.mid( 10+len+3+9 );
548 } else { 548 } else {
549 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 549 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
550 //qDebug("-----system command %s ",tempfilename.latin1() ); 550 //qDebug("-----system command %s ",tempfilename.latin1() );
551#ifndef _WIN32_ 551#ifndef _WIN32_
552 if ( vfork () == 0 ) { 552 if ( vfork () == 0 ) {
553 execl ( tempfilename.latin1(), 0 ); 553 execl ( tempfilename.latin1(), 0 );
554 return; 554 return;
555 } 555 }
556#else 556#else
557 QProcess* p = new QProcess(); 557 QProcess* p = new QProcess();
558 p->addArgument( tempfilename.latin1() ); 558 p->addArgument( tempfilename.latin1() );
559 p->start(); 559 p->start();
560 return; 560 return;
561#endif 561#endif
562 562
563 return; 563 return;
564 } 564 }
565 565
566 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 566 //qDebug("+++++++system command %s ",tempfilename.latin1() );
567 } 567 }
568 if ( mess.left( 11 ) == "audio_alarm") { 568 if ( mess.left( 11 ) == "audio_alarm") {
569 bool error = false; 569 bool error = false;
570 int len = mess.mid( 11 ).find("+++"); 570 int len = mess.mid( 11 ).find("+++");
571 if ( len < 2 ) 571 if ( len < 2 )
572 error = true; 572 error = true;
573 else { 573 else {
574 tempfilename = mess.mid( 11, len ); 574 tempfilename = mess.mid( 11, len );
575 if ( !QFile::exists( tempfilename ) ) 575 if ( !QFile::exists( tempfilename ) )
576 error = true; 576 error = true;
577 } 577 }
578 if ( ! error ) { 578 if ( ! error ) {
579 filename = tempfilename; 579 filename = tempfilename;
580 } 580 }
581 mAlarmMessage = mess.mid( 11+len+3+9 ); 581 mAlarmMessage = mess.mid( 11+len+3+9 );
582 //qDebug("audio file command %s ",tempfilename.latin1() ); 582 //qDebug("audio file command %s ",tempfilename.latin1() );
583 } 583 }
584 if ( mess.left( 9 ) == "cal_alarm") { 584 if ( mess.left( 9 ) == "cal_alarm") {
585 mAlarmMessage = mess.mid( 9 ) ; 585 mAlarmMessage = mess.mid( 9 ) ;
586 } 586 }
587 587
588 startAlarm( mAlarmMessage, filename ); 588 startAlarm( mAlarmMessage, filename );
589 589
590 590
591} 591}
592 592
593void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 593void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
594{ 594{
595 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 595 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
596 596
597 mSuspendAlarmNotification = noti; 597 mSuspendAlarmNotification = noti;
598 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 598 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
599 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 599 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
600 mSuspendTimer->start( ms , true ); 600 mSuspendTimer->start( ms , true );
601 601
602} 602}
603 603
604void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 604void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
605{ 605{
606 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 606 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
607 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 607 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
608#ifndef DESKTOP_VERSION 608#ifndef DESKTOP_VERSION
609 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 609 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
610#endif 610#endif
611 return; 611 return;
612 } 612 }
613 int maxSec; 613 int maxSec;
614 //maxSec = 5; //testing only 614 //maxSec = 5; //testing only
615 maxSec = 86400+3600; // one day+1hour 615 maxSec = 86400+3600; // one day+1hour
616 mAlarmNotification = noti; 616 mAlarmNotification = noti;
617 int sec = QDateTime::currentDateTime().secsTo( qdt ); 617 int sec = QDateTime::currentDateTime().secsTo( qdt );
618 if ( sec > maxSec ) { 618 if ( sec > maxSec ) {
619 mRecheckAlarmTimer->start( maxSec * 1000 ); 619 mRecheckAlarmTimer->start( maxSec * 1000 );
620 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 620 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
621 return; 621 return;
622 } else { 622 } else {
623 mRecheckAlarmTimer->stop(); 623 mRecheckAlarmTimer->stop();
624 } 624 }
625 //qDebug("Alarm timer started with secs: %d ", sec); 625 //qDebug("Alarm timer started with secs: %d ", sec);
626 mAlarmTimer->start( sec *1000 , true ); 626 mAlarmTimer->start( sec *1000 , true );
627 627
628} 628}
629// called by mRecheckAlarmTimer to get next alarm 629// called by mRecheckAlarmTimer to get next alarm
630// we need this, because a QTimer has only a max range of 25 days 630// we need this, because a QTimer has only a max range of 25 days
631void CalendarView::recheckTimerAlarm() 631void CalendarView::recheckTimerAlarm()
632{ 632{
633 mAlarmTimer->stop(); 633 mAlarmTimer->stop();
634 mRecheckAlarmTimer->stop(); 634 mRecheckAlarmTimer->stop();
635 mCalendar->checkAlarmForIncidence( 0, true ); 635 mCalendar->checkAlarmForIncidence( 0, true );
636} 636}
637void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 637void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
638{ 638{
639 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 639 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
640 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 640 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
641#ifndef DESKTOP_VERSION 641#ifndef DESKTOP_VERSION
642 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 642 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
643#endif 643#endif
644 return; 644 return;
645 } 645 }
646 mAlarmTimer->stop(); 646 mAlarmTimer->stop();
647} 647}
648void CalendarView::selectWeekNum ( int num ) 648void CalendarView::selectWeekNum ( int num )
649{ 649{
650 dateNavigator()->selectWeek( num ); 650 dateNavigator()->selectWeek( num );
651 mViewManager->showWeekView(); 651 mViewManager->showWeekView();
652} 652}
653KOViewManager *CalendarView::viewManager() 653KOViewManager *CalendarView::viewManager()
654{ 654{
655 return mViewManager; 655 return mViewManager;
656} 656}
657 657
658KODialogManager *CalendarView::dialogManager() 658KODialogManager *CalendarView::dialogManager()
659{ 659{
660 return mDialogManager; 660 return mDialogManager;
661} 661}
662 662
663QDate CalendarView::startDate() 663QDate CalendarView::startDate()
664{ 664{
665 DateList dates = mNavigator->selectedDates(); 665 DateList dates = mNavigator->selectedDates();
666 666
667 return dates.first(); 667 return dates.first();
668} 668}
669 669
670QDate CalendarView::endDate() 670QDate CalendarView::endDate()
671{ 671{
672 DateList dates = mNavigator->selectedDates(); 672 DateList dates = mNavigator->selectedDates();
673 673
674 return dates.last(); 674 return dates.last();
675} 675}
676 676
677 677
678void CalendarView::createPrinter() 678void CalendarView::createPrinter()
679{ 679{
680#ifndef KORG_NOPRINTER 680#ifndef KORG_NOPRINTER
681 if (!mCalPrinter) { 681 if (!mCalPrinter) {
682 mCalPrinter = new CalPrinter(this, mCalendar); 682 mCalPrinter = new CalPrinter(this, mCalendar);
683 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 683 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
684 } 684 }
685#endif 685#endif
686} 686}
687 687
688void CalendarView::confSync() 688void CalendarView::confSync()
689{ 689{
690 static KSyncPrefsDialog* sp = 0; 690 static KSyncPrefsDialog* sp = 0;
691 if ( ! sp ) { 691 if ( ! sp ) {
692 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 692 sp = new KSyncPrefsDialog( this, "syncprefs", true );
693 } 693 }
694 sp->usrReadConfig(); 694 sp->usrReadConfig();
695#ifndef DESKTOP_VERSION 695#ifndef DESKTOP_VERSION
696 sp->showMaximized(); 696 sp->showMaximized();
697#else 697#else
698 sp->show(); 698 sp->show();
699#endif 699#endif
700 sp->exec(); 700 sp->exec();
701 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 701 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
702 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 702 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
703} 703}
704 704
705 705
706//KOPrefs::instance()->mWriteBackFile 706//KOPrefs::instance()->mWriteBackFile
707//KOPrefs::instance()->mWriteBackExistingOnly 707//KOPrefs::instance()->mWriteBackExistingOnly
708 708
709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
715 715
716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
717{ 717{
718 718
719 //void setZaurusId(int id); 719 //void setZaurusId(int id);
720 // int zaurusId() const; 720 // int zaurusId() const;
721 // void setZaurusUid(int id); 721 // void setZaurusUid(int id);
722 // int zaurusUid() const; 722 // int zaurusUid() const;
723 // void setZaurusStat(int id); 723 // void setZaurusStat(int id);
724 // int zaurusStat() const; 724 // int zaurusStat() const;
725 // 0 equal 725 // 0 equal
726 // 1 take local 726 // 1 take local
727 // 2 take remote 727 // 2 take remote
728 // 3 cancel 728 // 3 cancel
729 QDateTime lastSync = mLastCalendarSync; 729 QDateTime lastSync = mLastCalendarSync;
730 QDateTime localMod = local->lastModified(); 730 QDateTime localMod = local->lastModified();
731 QDateTime remoteMod = remote->lastModified(); 731 QDateTime remoteMod = remote->lastModified();
732 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 732 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
733 bool remCh, locCh; 733 bool remCh, locCh;
734 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 734 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
735 //if ( remCh ) 735 //if ( remCh )
736 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 736 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
737 locCh = ( localMod > mLastCalendarSync ); 737 locCh = ( localMod > mLastCalendarSync );
738 if ( !remCh && ! locCh ) { 738 if ( !remCh && ! locCh ) {
739 //qDebug("both not changed "); 739 //qDebug("both not changed ");
740 lastSync = localMod.addDays(1); 740 lastSync = localMod.addDays(1);
741 if ( mode <= SYNC_PREF_ASK ) 741 if ( mode <= SYNC_PREF_ASK )
742 return 0; 742 return 0;
743 } else { 743 } else {
744 if ( locCh ) { 744 if ( locCh ) {
745 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 745 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
746 lastSync = localMod.addDays( -1 ); 746 lastSync = localMod.addDays( -1 );
747 if ( !remCh ) 747 if ( !remCh )
748 remoteMod = ( lastSync.addDays( -1 ) ); 748 remoteMod = ( lastSync.addDays( -1 ) );
749 } else { 749 } else {
750 //qDebug(" not loc changed "); 750 //qDebug(" not loc changed ");
751 lastSync = localMod.addDays( 1 ); 751 lastSync = localMod.addDays( 1 );
752 if ( remCh ) 752 if ( remCh )
753 remoteMod =( lastSync.addDays( 1 ) ); 753 remoteMod =( lastSync.addDays( 1 ) );
754 754
755 } 755 }
756 } 756 }
757 full = true; 757 full = true;
758 if ( mode < SYNC_PREF_ASK ) 758 if ( mode < SYNC_PREF_ASK )
759 mode = SYNC_PREF_ASK; 759 mode = SYNC_PREF_ASK;
760 } else { 760 } else {
761 if ( localMod == remoteMod ) 761 if ( localMod == remoteMod )
762 if ( local->revision() == remote->revision() ) 762 if ( local->revision() == remote->revision() )
763 return 0; 763 return 0;
764 764
765 } 765 }
766 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 766 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
767 767
768 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 768 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
769 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 769 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
770 //full = true; //debug only 770 //full = true; //debug only
771 if ( full ) { 771 if ( full ) {
772 bool equ = false; 772 bool equ = false;
773 if ( local->type() == "Event" ) { 773 if ( local->type() == "Event" ) {
774 equ = (*((Event*) local) == *((Event*) remote)); 774 equ = (*((Event*) local) == *((Event*) remote));
775 } 775 }
776 else if ( local->type() =="Todo" ) 776 else if ( local->type() =="Todo" )
777 equ = (*((Todo*) local) == (*(Todo*) remote)); 777 equ = (*((Todo*) local) == (*(Todo*) remote));
778 else if ( local->type() =="Journal" ) 778 else if ( local->type() =="Journal" )
779 equ = (*((Journal*) local) == *((Journal*) remote)); 779 equ = (*((Journal*) local) == *((Journal*) remote));
780 if ( equ ) { 780 if ( equ ) {
781 //qDebug("equal "); 781 //qDebug("equal ");
782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
783 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 783 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
784 } 784 }
785 if ( mode < SYNC_PREF_FORCE_LOCAL ) 785 if ( mode < SYNC_PREF_FORCE_LOCAL )
786 return 0; 786 return 0;
787 787
788 }//else //debug only 788 }//else //debug only
789 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 789 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
790 } 790 }
791 int result; 791 int result;
792 bool localIsNew; 792 bool localIsNew;
793 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 793 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
794 794
795 if ( full && mode < SYNC_PREF_NEWEST ) 795 if ( full && mode < SYNC_PREF_NEWEST )
796 mode = SYNC_PREF_ASK; 796 mode = SYNC_PREF_ASK;
797 797
798 switch( mode ) { 798 switch( mode ) {
799 case SYNC_PREF_LOCAL: 799 case SYNC_PREF_LOCAL:
800 if ( lastSync > remoteMod ) 800 if ( lastSync > remoteMod )
801 return 1; 801 return 1;
802 if ( lastSync > localMod ) 802 if ( lastSync > localMod )
803 return 2; 803 return 2;
804 return 1; 804 return 1;
805 break; 805 break;
806 case SYNC_PREF_REMOTE: 806 case SYNC_PREF_REMOTE:
807 if ( lastSync > remoteMod ) 807 if ( lastSync > remoteMod )
808 return 1; 808 return 1;
809 if ( lastSync > localMod ) 809 if ( lastSync > localMod )
810 return 2; 810 return 2;
811 return 2; 811 return 2;
812 break; 812 break;
813 case SYNC_PREF_NEWEST: 813 case SYNC_PREF_NEWEST:
814 if ( localMod > remoteMod ) 814 if ( localMod > remoteMod )
815 return 1; 815 return 1;
816 else 816 else
817 return 2; 817 return 2;
818 break; 818 break;
819 case SYNC_PREF_ASK: 819 case SYNC_PREF_ASK:
820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
821 if ( lastSync > remoteMod ) 821 if ( lastSync > remoteMod )
822 return 1; 822 return 1;
823 if ( lastSync > localMod ) 823 if ( lastSync > localMod )
824 return 2; 824 return 2;
825 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 825 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
826 localIsNew = localMod >= remoteMod; 826 localIsNew = localMod >= remoteMod;
827 if ( localIsNew ) 827 if ( localIsNew )
828 getEventViewerDialog()->setColorMode( 1 ); 828 getEventViewerDialog()->setColorMode( 1 );
829 else 829 else
830 getEventViewerDialog()->setColorMode( 2 ); 830 getEventViewerDialog()->setColorMode( 2 );
831 getEventViewerDialog()->setIncidence(local); 831 getEventViewerDialog()->setIncidence(local);
832 if ( localIsNew ) 832 if ( localIsNew )
833 getEventViewerDialog()->setColorMode( 2 ); 833 getEventViewerDialog()->setColorMode( 2 );
834 else 834 else
835 getEventViewerDialog()->setColorMode( 1 ); 835 getEventViewerDialog()->setColorMode( 1 );
836 getEventViewerDialog()->addIncidence(remote); 836 getEventViewerDialog()->addIncidence(remote);
837 getEventViewerDialog()->setColorMode( 0 ); 837 getEventViewerDialog()->setColorMode( 0 );
838 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 838 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
839 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 839 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
840 getEventViewerDialog()->showMe(); 840 getEventViewerDialog()->showMe();
841 result = getEventViewerDialog()->executeS( localIsNew ); 841 result = getEventViewerDialog()->executeS( localIsNew );
842 return result; 842 return result;
843 843
844 break; 844 break;
845 case SYNC_PREF_FORCE_LOCAL: 845 case SYNC_PREF_FORCE_LOCAL:
846 return 1; 846 return 1;
847 break; 847 break;
848 case SYNC_PREF_FORCE_REMOTE: 848 case SYNC_PREF_FORCE_REMOTE:
849 return 2; 849 return 2;
850 break; 850 break;
851 851
852 default: 852 default:
853 // SYNC_PREF_TAKE_BOTH not implemented 853 // SYNC_PREF_TAKE_BOTH not implemented
854 break; 854 break;
855 } 855 }
856 return 0; 856 return 0;
857} 857}
858Event* CalendarView::getLastSyncEvent() 858Event* CalendarView::getLastSyncEvent()
859{ 859{
860 Event* lse; 860 Event* lse;
861 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 861 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
862 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 862 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
863 if (!lse) { 863 if (!lse) {
864 lse = new Event(); 864 lse = new Event();
865 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 865 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
866 QString sum = ""; 866 QString sum = "";
867 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 867 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
868 sum = "E: "; 868 sum = "E: ";
869 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 869 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
870 lse->setDtStart( mLastCalendarSync ); 870 lse->setDtStart( mLastCalendarSync );
871 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 871 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
872 lse->setCategories( i18n("SyncEvent") ); 872 lse->setCategories( i18n("SyncEvent") );
873 lse->setReadOnly( true ); 873 lse->setReadOnly( true );
874 mCalendar->addEvent( lse ); 874 mCalendar->addEvent( lse );
875 } 875 }
876 876
877 return lse; 877 return lse;
878 878
879} 879}
880// probaly useless
881void CalendarView::setupExternSyncProfiles()
882{
883 Event* lse;
884 mExternLastSyncEvent.clear();
885 int i;
886 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
887 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
888 if ( lse )
889 mExternLastSyncEvent.append( lse );
890 else
891 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
892 }
893 880
894}
895// we check, if the to delete event has a id for a profile 881// we check, if the to delete event has a id for a profile
896// if yes, we set this id in the profile to delete 882// if yes, we set this id in the profile to delete
897void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 883void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
898{ 884{
899 if ( lastSync.count() == 0 ) { 885 if ( lastSync.count() == 0 ) {
900 //qDebug(" lastSync.count() == 0"); 886 //qDebug(" lastSync.count() == 0");
901 return; 887 return;
902 } 888 }
903 if ( toDelete->type() == "Journal" ) 889 if ( toDelete->type() == "Journal" )
904 return; 890 return;
905 891
906 Event* eve = lastSync.first(); 892 Event* eve = lastSync.first();
907 893
908 while ( eve ) { 894 while ( eve ) {
909 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 895 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
910 if ( !id.isEmpty() ) { 896 if ( !id.isEmpty() ) {
911 QString des = eve->description(); 897 QString des = eve->description();
912 QString pref = "e"; 898 QString pref = "e";
913 if ( toDelete->type() == "Todo" ) 899 if ( toDelete->type() == "Todo" )
914 pref = "t"; 900 pref = "t";
915 des += pref+ id + ","; 901 des += pref+ id + ",";
916 eve->setReadOnly( false ); 902 eve->setReadOnly( false );
917 eve->setDescription( des ); 903 eve->setDescription( des );
918 //qDebug("setdes %s ", des.latin1()); 904 //qDebug("setdes %s ", des.latin1());
919 eve->setReadOnly( true ); 905 eve->setReadOnly( true );
920 } 906 }
921 eve = lastSync.next(); 907 eve = lastSync.next();
922 } 908 }
923 909
924} 910}
925void CalendarView::checkExternalId( Incidence * inc ) 911void CalendarView::checkExternalId( Incidence * inc )
926{ 912{
927 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 913 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
928 checkExternSyncEvent( lastSync, inc ); 914 checkExternSyncEvent( lastSync, inc );
929 915
930} 916}
931bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 917bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
932{ 918{
933 bool syncOK = true; 919 bool syncOK = true;
934 int addedEvent = 0; 920 int addedEvent = 0;
935 int addedEventR = 0; 921 int addedEventR = 0;
936 int deletedEventR = 0; 922 int deletedEventR = 0;
937 int deletedEventL = 0; 923 int deletedEventL = 0;
938 int changedLocal = 0; 924 int changedLocal = 0;
939 int changedRemote = 0; 925 int changedRemote = 0;
940 //QPtrList<Event> el = local->rawEvents(); 926 //QPtrList<Event> el = local->rawEvents();
941 Event* eventR; 927 Event* eventR;
942 QString uid; 928 QString uid;
943 int take; 929 int take;
944 Event* eventL; 930 Event* eventL;
945 Event* eventRSync; 931 Event* eventRSync;
946 Event* eventLSync; 932 Event* eventLSync;
947 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 933 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
948 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 934 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
949 bool fullDateRange = false; 935 bool fullDateRange = false;
950 local->resetTempSyncStat(); 936 local->resetTempSyncStat();
951 mLastCalendarSync = QDateTime::currentDateTime(); 937 mLastCalendarSync = QDateTime::currentDateTime();
952 QDateTime modifiedCalendar = mLastCalendarSync;; 938 QDateTime modifiedCalendar = mLastCalendarSync;;
953 eventLSync = getLastSyncEvent(); 939 eventLSync = getLastSyncEvent();
954 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 940 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
955 if ( eventR ) { 941 if ( eventR ) {
956 eventRSync = (Event*) eventR->clone(); 942 eventRSync = (Event*) eventR->clone();
957 remote->deleteEvent(eventR ); 943 remote->deleteEvent(eventR );
958 944
959 } else { 945 } else {
960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 946 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
961 eventRSync = (Event*)eventLSync->clone(); 947 eventRSync = (Event*)eventLSync->clone();
962 } else { 948 } else {
963 fullDateRange = true; 949 fullDateRange = true;
964 eventRSync = new Event(); 950 eventRSync = new Event();
965 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 951 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
966 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 952 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
967 eventRSync->setDtStart( mLastCalendarSync ); 953 eventRSync->setDtStart( mLastCalendarSync );
968 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 954 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
969 eventRSync->setCategories( i18n("SyncEvent") ); 955 eventRSync->setCategories( i18n("SyncEvent") );
970 } 956 }
971 } 957 }
972 if ( eventLSync->dtStart() == mLastCalendarSync ) 958 if ( eventLSync->dtStart() == mLastCalendarSync )
973 fullDateRange = true; 959 fullDateRange = true;
974 960
975 if ( ! fullDateRange ) { 961 if ( ! fullDateRange ) {
976 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 962 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
977 963
978 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 964 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
979 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 965 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
980 fullDateRange = true; 966 fullDateRange = true;
981 } 967 }
982 } 968 }
983 if ( fullDateRange ) 969 if ( fullDateRange )
984 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 970 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
985 else 971 else
986 mLastCalendarSync = eventLSync->dtStart(); 972 mLastCalendarSync = eventLSync->dtStart();
987 // for resyncing if own file has changed 973 // for resyncing if own file has changed
988 if ( mCurrentSyncDevice == "deleteaftersync" ) { 974 if ( mCurrentSyncDevice == "deleteaftersync" ) {
989 mLastCalendarSync = loadedFileVersion; 975 mLastCalendarSync = loadedFileVersion;
990 qDebug("setting mLastCalendarSync "); 976 qDebug("setting mLastCalendarSync ");
991 } 977 }
992 //qDebug("*************************** "); 978 //qDebug("*************************** ");
993 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 979 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
994 QPtrList<Incidence> er = remote->rawIncidences(); 980 QPtrList<Incidence> er = remote->rawIncidences();
995 Incidence* inR = er.first(); 981 Incidence* inR = er.first();
996 Incidence* inL; 982 Incidence* inL;
997 QProgressBar bar( er.count(),0 ); 983 QProgressBar bar( er.count(),0 );
998 bar.setCaption (i18n("Syncing - close to abort!") ); 984 bar.setCaption (i18n("Syncing - close to abort!") );
999 985
1000 int w = 300; 986 int w = 300;
1001 if ( QApplication::desktop()->width() < 320 ) 987 if ( QApplication::desktop()->width() < 320 )
1002 w = 220; 988 w = 220;
1003 int h = bar.sizeHint().height() ; 989 int h = bar.sizeHint().height() ;
1004 int dw = QApplication::desktop()->width(); 990 int dw = QApplication::desktop()->width();
1005 int dh = QApplication::desktop()->height(); 991 int dh = QApplication::desktop()->height();
1006 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 992 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1007 bar.show(); 993 bar.show();
1008 int modulo = (er.count()/10)+1; 994 int modulo = (er.count()/10)+1;
1009 int incCounter = 0; 995 int incCounter = 0;
1010 while ( inR ) { 996 while ( inR ) {
1011 if ( ! bar.isVisible() ) 997 if ( ! bar.isVisible() )
1012 return false; 998 return false;
1013 if ( incCounter % modulo == 0 ) 999 if ( incCounter % modulo == 0 )
1014 bar.setProgress( incCounter ); 1000 bar.setProgress( incCounter );
1015 ++incCounter; 1001 ++incCounter;
1016 uid = inR->uid(); 1002 uid = inR->uid();
1017 bool skipIncidence = false; 1003 bool skipIncidence = false;
1018 if ( uid.left(15) == QString("last-syncEvent-") ) 1004 if ( uid.left(15) == QString("last-syncEvent-") )
1019 skipIncidence = true; 1005 skipIncidence = true;
1020 QString idS; 1006 QString idS;
1021 qApp->processEvents(); 1007 qApp->processEvents();
1022 if ( !skipIncidence ) { 1008 if ( !skipIncidence ) {
1023 inL = local->incidence( uid ); 1009 inL = local->incidence( uid );
1024 if ( inL ) { // maybe conflict - same uid in both calendars 1010 if ( inL ) { // maybe conflict - same uid in both calendars
1025 int maxrev = inL->revision(); 1011 int maxrev = inL->revision();
1026 if ( maxrev < inR->revision() ) 1012 if ( maxrev < inR->revision() )
1027 maxrev = inR->revision(); 1013 maxrev = inR->revision();
1028 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1014 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1029 //qDebug("take %d %s ", take, inL->summary().latin1()); 1015 //qDebug("take %d %s ", take, inL->summary().latin1());
1030 if ( take == 3 ) 1016 if ( take == 3 )
1031 return false; 1017 return false;
1032 if ( take == 1 ) {// take local 1018 if ( take == 1 ) {// take local
1033 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1019 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1034 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1020 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1035 else 1021 else
1036 idS = inR->IDStr(); 1022 idS = inR->IDStr();
1037 remote->deleteIncidence( inR ); 1023 remote->deleteIncidence( inR );
1038 if ( inL->revision() < maxrev ) 1024 if ( inL->revision() < maxrev )
1039 inL->setRevision( maxrev ); 1025 inL->setRevision( maxrev );
1040 inR = inL->clone(); 1026 inR = inL->clone();
1041 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1027 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1042 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1028 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1043 inR->setIDStr( idS ); 1029 inR->setIDStr( idS );
1044 remote->addIncidence( inR ); 1030 remote->addIncidence( inR );
1045 ++changedRemote; 1031 ++changedRemote;
1046 } else { 1032 } else {
1047 if ( inR->revision() < maxrev ) 1033 if ( inR->revision() < maxrev )
1048 inR->setRevision( maxrev ); 1034 inR->setRevision( maxrev );
1049 idS = inL->IDStr(); 1035 idS = inL->IDStr();
1050 local->deleteIncidence( inL ); 1036 local->deleteIncidence( inL );
1051 inL = inR->clone(); 1037 inL = inR->clone();
1052 inL->setIDStr( idS ); 1038 inL->setIDStr( idS );
1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1039 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1040 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1055 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1041 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1056 } 1042 }
1057 local->addIncidence( inL ); 1043 local->addIncidence( inL );
1058 ++changedLocal; 1044 ++changedLocal;
1059 } 1045 }
1060 } 1046 }
1061 } else { // no conflict 1047 } else { // no conflict
1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1063 QString des = eventLSync->description(); 1049 QString des = eventLSync->description();
1064 QString pref = "e"; 1050 QString pref = "e";
1065 if ( inR->type() == "Todo" ) 1051 if ( inR->type() == "Todo" )
1066 pref = "t"; 1052 pref = "t";
1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1053 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1054 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1069 //remote->deleteIncidence( inR ); 1055 //remote->deleteIncidence( inR );
1070 ++deletedEventR; 1056 ++deletedEventR;
1071 } else { 1057 } else {
1072 inR->setLastModified( modifiedCalendar ); 1058 inR->setLastModified( modifiedCalendar );
1073 inL = inR->clone(); 1059 inL = inR->clone();
1074 local->addIncidence( inL ); 1060 local->addIncidence( inL );
1075 ++addedEvent; 1061 ++addedEvent;
1076 } 1062 }
1077 } else { 1063 } else {
1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1064 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1079 inR->setLastModified( modifiedCalendar ); 1065 inR->setLastModified( modifiedCalendar );
1080 local->addIncidence( inR->clone() ); 1066 local->addIncidence( inR->clone() );
1081 ++addedEvent; 1067 ++addedEvent;
1082 } else { 1068 } else {
1083 checkExternSyncEvent(eventRSyncSharp, inR); 1069 checkExternSyncEvent(eventRSyncSharp, inR);
1084 remote->deleteIncidence( inR ); 1070 remote->deleteIncidence( inR );
1085 ++deletedEventR; 1071 ++deletedEventR;
1086 } 1072 }
1087 } 1073 }
1088 } 1074 }
1089 } 1075 }
1090 inR = er.next(); 1076 inR = er.next();
1091 } 1077 }
1092 QPtrList<Incidence> el = local->rawIncidences(); 1078 QPtrList<Incidence> el = local->rawIncidences();
1093 inL = el.first(); 1079 inL = el.first();
1094 modulo = (el.count()/10)+1; 1080 modulo = (el.count()/10)+1;
1095 bar.setCaption (i18n("Add / remove events") ); 1081 bar.setCaption (i18n("Add / remove events") );
1096 bar.setTotalSteps ( el.count() ) ; 1082 bar.setTotalSteps ( el.count() ) ;
1097 bar.show(); 1083 bar.show();
1098 incCounter = 0; 1084 incCounter = 0;
1099 1085
1100 while ( inL ) { 1086 while ( inL ) {
1101 1087
1102 qApp->processEvents(); 1088 qApp->processEvents();
1103 if ( ! bar.isVisible() ) 1089 if ( ! bar.isVisible() )
1104 return false; 1090 return false;
1105 if ( incCounter % modulo == 0 ) 1091 if ( incCounter % modulo == 0 )
1106 bar.setProgress( incCounter ); 1092 bar.setProgress( incCounter );
1107 ++incCounter; 1093 ++incCounter;
1108 uid = inL->uid(); 1094 uid = inL->uid();
1109 bool skipIncidence = false; 1095 bool skipIncidence = false;
1110 if ( uid.left(15) == QString("last-syncEvent-") ) 1096 if ( uid.left(15) == QString("last-syncEvent-") )
1111 skipIncidence = true; 1097 skipIncidence = true;
1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1098 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1113 skipIncidence = true; 1099 skipIncidence = true;
1114 if ( !skipIncidence ) { 1100 if ( !skipIncidence ) {
1115 inR = remote->incidence( uid ); 1101 inR = remote->incidence( uid );
1116 if ( ! inR ) { 1102 if ( ! inR ) {
1117 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1103 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1118 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1104 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1119 checkExternSyncEvent(eventLSyncSharp, inL); 1105 checkExternSyncEvent(eventLSyncSharp, inL);
1120 local->deleteIncidence( inL ); 1106 local->deleteIncidence( inL );
1121 ++deletedEventL; 1107 ++deletedEventL;
1122 } else { 1108 } else {
1123 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1109 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1124 inL->removeID(mCurrentSyncDevice ); 1110 inL->removeID(mCurrentSyncDevice );
1125 ++addedEventR; 1111 ++addedEventR;
1126 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1112 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1127 inL->setLastModified( modifiedCalendar ); 1113 inL->setLastModified( modifiedCalendar );
1128 inR = inL->clone(); 1114 inR = inL->clone();
1129 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1115 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1130 remote->addIncidence( inR ); 1116 remote->addIncidence( inR );
1131 } 1117 }
1132 } 1118 }
1133 } else { 1119 } else {
1134 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1120 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1135 checkExternSyncEvent(eventLSyncSharp, inL); 1121 checkExternSyncEvent(eventLSyncSharp, inL);
1136 local->deleteIncidence( inL ); 1122 local->deleteIncidence( inL );
1137 ++deletedEventL; 1123 ++deletedEventL;
1138 } else { 1124 } else {
1139 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1125 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1140 ++addedEventR; 1126 ++addedEventR;
1141 inL->setLastModified( modifiedCalendar ); 1127 inL->setLastModified( modifiedCalendar );
1142 remote->addIncidence( inL->clone() ); 1128 remote->addIncidence( inL->clone() );
1143 } 1129 }
1144 } 1130 }
1145 } 1131 }
1146 } 1132 }
1147 } 1133 }
1148 inL = el.next(); 1134 inL = el.next();
1149 } 1135 }
1150 int delFut = 0; 1136 int delFut = 0;
1151 if ( KOPrefs::instance()->mWriteBackInFuture ) { 1137 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1152 er = remote->rawIncidences(); 1138 er = remote->rawIncidences();
1153 inR = er.first(); 1139 inR = er.first();
1154 QDateTime dt; 1140 QDateTime dt;
1155 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1141 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1156 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); 1142 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 );
1157 while ( inR ) { 1143 while ( inR ) {
1158 if ( inR->type() == "Todo" ) { 1144 if ( inR->type() == "Todo" ) {
1159 Todo * t = (Todo*)inR; 1145 Todo * t = (Todo*)inR;
1160 if ( t->hasDueDate() ) 1146 if ( t->hasDueDate() )
1161 dt = t->dtDue(); 1147 dt = t->dtDue();
1162 else 1148 else
1163 dt = cur.addSecs( 62 ); 1149 dt = cur.addSecs( 62 );
1164 } 1150 }
1165 else if (inR->type() == "Event" ) { 1151 else if (inR->type() == "Event" ) {
1166 bool ok; 1152 bool ok;
1167 dt = inR->getNextOccurence( cur, &ok ); 1153 dt = inR->getNextOccurence( cur, &ok );
1168 if ( !ok ) 1154 if ( !ok )
1169 dt = cur.addSecs( -62 ); 1155 dt = cur.addSecs( -62 );
1170 } 1156 }
1171 else 1157 else
1172 dt = inR->dtStart(); 1158 dt = inR->dtStart();
1173 if ( dt < cur || dt > end ) { 1159 if ( dt < cur || dt > end ) {
1174 remote->deleteIncidence( inR ); 1160 remote->deleteIncidence( inR );
1175 ++delFut; 1161 ++delFut;
1176 } 1162 }
1177 inR = er.next(); 1163 inR = er.next();
1178 } 1164 }
1179 } 1165 }
1180 bar.hide(); 1166 bar.hide();
1181 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1167 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1182 eventLSync->setReadOnly( false ); 1168 eventLSync->setReadOnly( false );
1183 eventLSync->setDtStart( mLastCalendarSync ); 1169 eventLSync->setDtStart( mLastCalendarSync );
1184 eventRSync->setDtStart( mLastCalendarSync ); 1170 eventRSync->setDtStart( mLastCalendarSync );
1185 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1171 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1186 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1172 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1187 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1173 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1188 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1174 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1189 eventLSync->setReadOnly( true ); 1175 eventLSync->setReadOnly( true );
1190 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1176 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1191 remote->addEvent( eventRSync ); 1177 remote->addEvent( eventRSync );
1192 QString mes; 1178 QString mes;
1193 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1179 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1194 QString delmess; 1180 QString delmess;
1195 if ( delFut ) { 1181 if ( delFut ) {
1196 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); 1182 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
1197 mes += delmess; 1183 mes += delmess;
1198 } 1184 }
1199 if ( KOPrefs::instance()->mShowSyncSummary ) { 1185 if ( KOPrefs::instance()->mShowSyncSummary ) {
1200 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1186 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1201 } 1187 }
1202 qDebug( mes ); 1188 qDebug( mes );
1203 mCalendar->checkAlarmForIncidence( 0, true ); 1189 mCalendar->checkAlarmForIncidence( 0, true );
1204 return syncOK; 1190 return syncOK;
1205} 1191}
1206 1192
1207void CalendarView::setSyncDevice( QString s ) 1193void CalendarView::setSyncDevice( QString s )
1208{ 1194{
1209 mCurrentSyncDevice= s; 1195 mCurrentSyncDevice= s;
1210} 1196}
1211void CalendarView::setSyncName( QString s ) 1197void CalendarView::setSyncName( QString s )
1212{ 1198{
1213 mCurrentSyncName= s; 1199 mCurrentSyncName= s;
1214} 1200}
1215bool CalendarView::syncCalendar(QString filename, int mode) 1201bool CalendarView::syncCalendar(QString filename, int mode)
1216{ 1202{
1217 mGlobalSyncMode = SYNC_MODE_NORMAL; 1203 mGlobalSyncMode = SYNC_MODE_NORMAL;
1218 CalendarLocal* calendar = new CalendarLocal(); 1204 CalendarLocal* calendar = new CalendarLocal();
1219 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1205 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1220 FileStorage* storage = new FileStorage( calendar ); 1206 FileStorage* storage = new FileStorage( calendar );
1221 bool syncOK = false; 1207 bool syncOK = false;
1222 storage->setFileName( filename ); 1208 storage->setFileName( filename );
1223 // qDebug("loading ... "); 1209 // qDebug("loading ... ");
1224 if ( storage->load() ) { 1210 if ( storage->load() ) {
1225 getEventViewerDialog()->setSyncMode( true ); 1211 getEventViewerDialog()->setSyncMode( true );
1226 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1212 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1227 getEventViewerDialog()->setSyncMode( false ); 1213 getEventViewerDialog()->setSyncMode( false );
1228 if ( syncOK ) { 1214 if ( syncOK ) {
1229 if ( KOPrefs::instance()->mWriteBackFile ) 1215 if ( KOPrefs::instance()->mWriteBackFile )
1230 { 1216 {
1231 storage->setSaveFormat( new ICalFormat() ); 1217 storage->setSaveFormat( new ICalFormat() );
1232 storage->save(); 1218 storage->save();
1233 } 1219 }
1234 } 1220 }
1235 setModified( true ); 1221 setModified( true );
1236 } 1222 }
1237 delete storage; 1223 delete storage;
1238 delete calendar; 1224 delete calendar;
1239 if ( syncOK ) 1225 if ( syncOK )
1240 updateView(); 1226 updateView();
1241 return syncOK; 1227 return syncOK;
1242} 1228}
1243void CalendarView::syncPhone() 1229void CalendarView::syncPhone()
1244{ 1230{
1245 syncExternal( 1 ); 1231 syncExternal( 1 );
1246} 1232}
1247void CalendarView::syncExternal( int mode ) 1233void CalendarView::syncExternal( int mode )
1248{ 1234{
1249 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1235 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1250 //mCurrentSyncDevice = "sharp-DTM"; 1236 //mCurrentSyncDevice = "sharp-DTM";
1251 if ( KOPrefs::instance()->mAskForPreferences ) 1237 if ( KOPrefs::instance()->mAskForPreferences )
1252 edit_sync_options(); 1238 edit_sync_options();
1253 qApp->processEvents(); 1239 qApp->processEvents();
1254 CalendarLocal* calendar = new CalendarLocal(); 1240 CalendarLocal* calendar = new CalendarLocal();
1255 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1241 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1256 bool syncOK = false; 1242 bool syncOK = false;
1257 bool loadSuccess = false; 1243 bool loadSuccess = false;
1258 PhoneFormat* phoneFormat = 0; 1244 PhoneFormat* phoneFormat = 0;
1259#ifndef DESKTOP_VERSION 1245#ifndef DESKTOP_VERSION
1260 SharpFormat* sharpFormat = 0; 1246 SharpFormat* sharpFormat = 0;
1261 if ( mode == 0 ) { // sharp 1247 if ( mode == 0 ) { // sharp
1262 sharpFormat = new SharpFormat () ; 1248 sharpFormat = new SharpFormat () ;
1263 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1249 loadSuccess = sharpFormat->load( calendar, mCalendar );
1264 1250
1265 } else 1251 } else
1266#endif 1252#endif
1267 if ( mode == 1 ) { // phone 1253 if ( mode == 1 ) { // phone
1268 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1254 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1269 KOPrefs::instance()->mPhoneDevice, 1255 KOPrefs::instance()->mPhoneDevice,
1270 KOPrefs::instance()->mPhoneConnection, 1256 KOPrefs::instance()->mPhoneConnection,
1271 KOPrefs::instance()->mPhoneModel); 1257 KOPrefs::instance()->mPhoneModel);
1272 loadSuccess = phoneFormat->load( calendar,mCalendar); 1258 loadSuccess = phoneFormat->load( calendar,mCalendar);
1273 1259
1274 } else 1260 } else
1275 return; 1261 return;
1276 if ( loadSuccess ) { 1262 if ( loadSuccess ) {
1277 getEventViewerDialog()->setSyncMode( true ); 1263 getEventViewerDialog()->setSyncMode( true );
1278 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1264 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1279 getEventViewerDialog()->setSyncMode( false ); 1265 getEventViewerDialog()->setSyncMode( false );
1280 qApp->processEvents(); 1266 qApp->processEvents();
1281 if ( syncOK ) { 1267 if ( syncOK ) {
1282 if ( KOPrefs::instance()->mWriteBackFile ) 1268 if ( KOPrefs::instance()->mWriteBackFile )
1283 { 1269 {
1284 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1270 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1285 Incidence* inc = iL.first(); 1271 Incidence* inc = iL.first();
1286 if ( phoneFormat ) { 1272 if ( phoneFormat ) {
1287 while ( inc ) { 1273 while ( inc ) {
1288 inc->removeID(mCurrentSyncDevice); 1274 inc->removeID(mCurrentSyncDevice);
1289 inc = iL.next(); 1275 inc = iL.next();
1290 } 1276 }
1291 } 1277 }
1292#ifndef DESKTOP_VERSION 1278#ifndef DESKTOP_VERSION
1293 if ( sharpFormat ) 1279 if ( sharpFormat )
1294 sharpFormat->save(calendar); 1280 sharpFormat->save(calendar);
1295#endif 1281#endif
1296 if ( phoneFormat ) 1282 if ( phoneFormat )
1297 phoneFormat->save(calendar); 1283 phoneFormat->save(calendar);
1298 iL = calendar->rawIncidences(); 1284 iL = calendar->rawIncidences();
1299 inc = iL.first(); 1285 inc = iL.first();
1300 Incidence* loc; 1286 Incidence* loc;
1301 while ( inc ) { 1287 while ( inc ) {
1302 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1288 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1303 loc = mCalendar->incidence(inc->uid() ); 1289 loc = mCalendar->incidence(inc->uid() );
1304 if ( loc ) { 1290 if ( loc ) {
1305 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1291 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1306 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1292 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1307 } 1293 }
1308 } 1294 }
1309 inc = iL.next(); 1295 inc = iL.next();
1310 } 1296 }
1311 Incidence* lse = getLastSyncEvent(); 1297 Incidence* lse = getLastSyncEvent();
1312 if ( lse ) { 1298 if ( lse ) {
1313 lse->setReadOnly( false ); 1299 lse->setReadOnly( false );
1314 lse->setDescription( "" ); 1300 lse->setDescription( "" );
1315 lse->setReadOnly( true ); 1301 lse->setReadOnly( true );
1316 } 1302 }
1317 } 1303 }
1318 } 1304 }
1319 setModified( true ); 1305 setModified( true );
1320 } else { 1306 } else {
1321 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1307 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1322 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1308 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1323 question, i18n("Ok")) ; 1309 question, i18n("Ok")) ;
1324 1310
1325 } 1311 }
1326 delete calendar; 1312 delete calendar;
1327 updateView(); 1313 updateView();
1328 return ;//syncOK; 1314 return ;//syncOK;
1329 1315
1330} 1316}
1331void CalendarView::syncSharp() 1317void CalendarView::syncSharp()
1332{ 1318{
1333 syncExternal( 0 ); 1319 syncExternal( 0 );
1334 1320
1335} 1321}
1336 1322
1337 1323
1338//#include <kabc/stdaddressbook.h> 1324//#include <kabc/stdaddressbook.h>
1339bool CalendarView::importBday() 1325bool CalendarView::importBday()
1340{ 1326{
1341#if 0 1327#if 0
1342 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1328 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1343 KABC::AddressBook::Iterator it; 1329 KABC::AddressBook::Iterator it;
1344 int count = 0; 1330 int count = 0;
1345 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1331 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1346 ++count; 1332 ++count;
1347 } 1333 }
1348 QProgressBar bar(count,0 ); 1334 QProgressBar bar(count,0 );
1349 int w = 300; 1335 int w = 300;
1350 if ( QApplication::desktop()->width() < 320 ) 1336 if ( QApplication::desktop()->width() < 320 )
1351 w = 220; 1337 w = 220;
1352 int h = bar.sizeHint().height() ; 1338 int h = bar.sizeHint().height() ;
1353 int dw = QApplication::desktop()->width(); 1339 int dw = QApplication::desktop()->width();
1354 int dh = QApplication::desktop()->height(); 1340 int dh = QApplication::desktop()->height();
1355 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1341 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1356 bar.show(); 1342 bar.show();
1357 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1343 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1358 qApp->processEvents(); 1344 qApp->processEvents();
1359 count = 0; 1345 count = 0;
1360 int addCount = 0; 1346 int addCount = 0;
1361 KCal::Attendee* a = 0; 1347 KCal::Attendee* a = 0;
1362 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1348 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1363 if ( ! bar.isVisible() ) 1349 if ( ! bar.isVisible() )
1364 return false; 1350 return false;
1365 bar.setProgress( count++ ); 1351 bar.setProgress( count++ );
1366 qApp->processEvents(); 1352 qApp->processEvents();
1367 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1353 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1368 if ( (*it).birthday().date().isValid() ){ 1354 if ( (*it).birthday().date().isValid() ){
1369 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1355 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1370 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1356 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1371 ++addCount; 1357 ++addCount;
1372 } 1358 }
1373 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1359 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1374 if ( anni.isValid() ){ 1360 if ( anni.isValid() ){
1375 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1361 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1376 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1362 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1377 ++addCount; 1363 ++addCount;
1378 } 1364 }
1379 } 1365 }
1380 updateView(); 1366 updateView();
1381 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1367 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1382#endif 1368#endif
1383 return true; 1369 return true;
1384} 1370}
1385 1371
1386bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1372bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1387{ 1373{
1388 //qDebug("addAnni "); 1374 //qDebug("addAnni ");
1389 Event * ev = new Event(); 1375 Event * ev = new Event();
1390 if ( a ) { 1376 if ( a ) {
1391 ev->addAttendee( a ); 1377 ev->addAttendee( a );
1392 } 1378 }
1393 QString kind; 1379 QString kind;
1394 if ( birthday ) 1380 if ( birthday )
1395 kind = i18n( "Birthday" ); 1381 kind = i18n( "Birthday" );
1396 else 1382 else
1397 kind = i18n( "Anniversary" ); 1383 kind = i18n( "Anniversary" );
1398 ev->setSummary( name + " - " + kind ); 1384 ev->setSummary( name + " - " + kind );
1399 ev->setOrganizer( "nobody@nowhere" ); 1385 ev->setOrganizer( "nobody@nowhere" );
1400 ev->setCategories( kind ); 1386 ev->setCategories( kind );
1401 ev->setDtStart( QDateTime(date) ); 1387 ev->setDtStart( QDateTime(date) );
1402 ev->setDtEnd( QDateTime(date) ); 1388 ev->setDtEnd( QDateTime(date) );
1403 ev->setFloats( true ); 1389 ev->setFloats( true );
1404 Recurrence * rec = ev->recurrence(); 1390 Recurrence * rec = ev->recurrence();
1405 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1391 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1406 rec->addYearlyNum( date.month() ); 1392 rec->addYearlyNum( date.month() );
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index a713c91..0f7e696 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,596 +1,594 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45class QWidgetStack; 45class QWidgetStack;
46class QSplitter; 46class QSplitter;
47 47
48class CalPrinter; 48class CalPrinter;
49class KOFilterView; 49class KOFilterView;
50class KOViewManager; 50class KOViewManager;
51class KODialogManager; 51class KODialogManager;
52class KOTodoView; 52class KOTodoView;
53class KDateNavigator; 53class KDateNavigator;
54class DateNavigator; 54class DateNavigator;
55class KOIncidenceEditor; 55class KOIncidenceEditor;
56class KDatePicker; 56class KDatePicker;
57class ResourceView; 57class ResourceView;
58class NavigatorBar; 58class NavigatorBar;
59class KOEventEditor; 59class KOEventEditor;
60class KOTodoEditor ; 60class KOTodoEditor ;
61class KOEventViewerDialog; 61class KOEventViewerDialog;
62class KOBeamPrefs; 62class KOBeamPrefs;
63class KSyncProfile; 63class KSyncProfile;
64class AlarmDialog; 64class AlarmDialog;
65class KCal::Attendee; 65class KCal::Attendee;
66 66
67namespace KCal { class FileStorage; } 67namespace KCal { class FileStorage; }
68 68
69using namespace KCal; 69using namespace KCal;
70 70
71/** 71/**
72 This is the main calendar widget. It provides the different vies on t he 72 This is the main calendar widget. It provides the different vies on t he
73 calendar data as well as the date navigator. It also handles synchronisation 73 calendar data as well as the date navigator. It also handles synchronisation
74 of the different views and controls the different dialogs like preferences, 74 of the different views and controls the different dialogs like preferences,
75 event editor, search dialog etc. 75 event editor, search dialog etc.
76 76
77 @short main calendar view widget 77 @short main calendar view widget
78 @author Cornelius Schumacher 78 @author Cornelius Schumacher
79*/ 79*/
80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer 80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer
81{ 81{
82 Q_OBJECT 82 Q_OBJECT
83 public: 83 public:
84 /** 84 /**
85 Constructs a new calendar view widget. 85 Constructs a new calendar view widget.
86 86
87 @param calendar calendar document 87 @param calendar calendar document
88 @param parent parent window 88 @param parent parent window
89 @param name Qt internal widget object name 89 @param name Qt internal widget object name
90 */ 90 */
91 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 91 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
92 const char *name = 0 ); 92 const char *name = 0 );
93 CalendarView( Calendar *calendar, QWidget *parent = 0, 93 CalendarView( Calendar *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 virtual ~CalendarView(); 95 virtual ~CalendarView();
96 96
97 Calendar *calendar() { return mCalendar; } 97 Calendar *calendar() { return mCalendar; }
98 98
99 KOViewManager *viewManager(); 99 KOViewManager *viewManager();
100 KODialogManager *dialogManager(); 100 KODialogManager *dialogManager();
101 101
102 QDate startDate(); 102 QDate startDate();
103 QDate endDate(); 103 QDate endDate();
104 104
105 QWidgetStack *viewStack(); 105 QWidgetStack *viewStack();
106 QWidget *leftFrame(); 106 QWidget *leftFrame();
107 NavigatorBar *navigatorBar(); 107 NavigatorBar *navigatorBar();
108 108
109 DateNavigator *dateNavigator(); 109 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget(); 110 KDateNavigator *dateNavigatorWidget();
111 111
112 void addView(KOrg::BaseView *); 112 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *); 113 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog(); 114 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection(); 115 Incidence *currentSelection();
116 void setupExternSyncProfiles();
117 116
118 signals: 117 signals:
119 /** This todo has been modified */ 118 /** This todo has been modified */
120 void todoModified(Todo *, int); 119 void todoModified(Todo *, int);
121 120
122 /** when change is made to options dialog, the topwidget will catch this 121 /** when change is made to options dialog, the topwidget will catch this
123 * and emit this signal which notifies all widgets which have registered 122 * and emit this signal which notifies all widgets which have registered
124 * for notification to update their settings. */ 123 * for notification to update their settings. */
125 void configChanged(); 124 void configChanged();
126 /** emitted when the topwidget is closing down, so that any attached 125 /** emitted when the topwidget is closing down, so that any attached
127 child windows can also close. */ 126 child windows can also close. */
128 void closingDown(); 127 void closingDown();
129 /** emitted right before we die */ 128 /** emitted right before we die */
130 void closed(QWidget *); 129 void closed(QWidget *);
131 130
132 /** Emitted when state of modified flag changes */ 131 /** Emitted when state of modified flag changes */
133 void modifiedChanged(bool); 132 void modifiedChanged(bool);
134 void signalmodified(); 133 void signalmodified();
135 134
136 /** Emitted when state of read-only flag changes */ 135 /** Emitted when state of read-only flag changes */
137 void readOnlyChanged(bool); 136 void readOnlyChanged(bool);
138 137
139 /** Emitted when the unit of navigation changes */ 138 /** Emitted when the unit of navigation changes */
140 void changeNavStringPrev(const QString &); 139 void changeNavStringPrev(const QString &);
141 void changeNavStringNext(const QString &); 140 void changeNavStringNext(const QString &);
142 141
143 /** Emitted when state of events selection has changed and user is organizer*/ 142 /** Emitted when state of events selection has changed and user is organizer*/
144 void organizerEventsSelected(bool); 143 void organizerEventsSelected(bool);
145 /** Emitted when state of events selection has changed and user is attendee*/ 144 /** Emitted when state of events selection has changed and user is attendee*/
146 void groupEventsSelected(bool); 145 void groupEventsSelected(bool);
147 /** 146 /**
148 Emitted when an incidence gets selected. If the selection is cleared the 147 Emitted when an incidence gets selected. If the selection is cleared the
149 signal is emitted with 0 as argument. 148 signal is emitted with 0 as argument.
150 */ 149 */
151 void incidenceSelected( Incidence * ); 150 void incidenceSelected( Incidence * );
152 /** Emitted, when a todoitem is selected or deselected. */ 151 /** Emitted, when a todoitem is selected or deselected. */
153 void todoSelected( bool ); 152 void todoSelected( bool );
154 153
155 /** 154 /**
156 Emitted, when clipboard content changes. Parameter indicates if paste 155 Emitted, when clipboard content changes. Parameter indicates if paste
157 is possible or not. 156 is possible or not.
158 */ 157 */
159 void pasteEnabled(bool); 158 void pasteEnabled(bool);
160 159
161 /** Emitted, when the number of incoming messages has changed. */ 160 /** Emitted, when the number of incoming messages has changed. */
162 void numIncomingChanged(int); 161 void numIncomingChanged(int);
163 162
164 /** Emitted, when the number of outgoing messages has changed. */ 163 /** Emitted, when the number of outgoing messages has changed. */
165 void numOutgoingChanged(int); 164 void numOutgoingChanged(int);
166 165
167 /** Send status message, which can e.g. be displayed in the status bar. */ 166 /** Send status message, which can e.g. be displayed in the status bar. */
168 void statusMessage(const QString &); 167 void statusMessage(const QString &);
169 168
170 void calendarViewExpanded( bool ); 169 void calendarViewExpanded( bool );
171 void updateSearchDialog(); 170 void updateSearchDialog();
172 171
173 172
174 public slots: 173 public slots:
175 void showOpenError(); 174 void showOpenError();
176 void watchSavedFile(); 175 void watchSavedFile();
177 void recheckTimerAlarm(); 176 void recheckTimerAlarm();
178 void checkNextTimerAlarm(); 177 void checkNextTimerAlarm();
179 void addAlarm(const QDateTime &qdt, const QString &noti ); 178 void addAlarm(const QDateTime &qdt, const QString &noti );
180 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 179 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
181 void removeAlarm(const QDateTime &qdt, const QString &noti ); 180 void removeAlarm(const QDateTime &qdt, const QString &noti );
182 181
183 /** options dialog made a changed to the configuration. we catch this 182 /** options dialog made a changed to the configuration. we catch this
184 * and notify all widgets which need to update their configuration. */ 183 * and notify all widgets which need to update their configuration. */
185 void updateConfig(); 184 void updateConfig();
186 185
187 /** 186 /**
188 Load calendar from file \a filename. If \a merge is true, load 187 Load calendar from file \a filename. If \a merge is true, load
189 calendar into existing one, if it is false, clear calendar, before 188 calendar into existing one, if it is false, clear calendar, before
190 loading. Return true, if calendar could be successfully loaded. 189 loading. Return true, if calendar could be successfully loaded.
191 */ 190 */
192 bool openCalendar(QString filename, bool merge=false); 191 bool openCalendar(QString filename, bool merge=false);
193 bool syncCalendar(QString filename,int mode = 0 ); 192 bool syncCalendar(QString filename,int mode = 0 );
194 193
195 /** 194 /**
196 Save calendar data to file. Return true if calendar could be 195 Save calendar data to file. Return true if calendar could be
197 successfully saved. 196 successfully saved.
198 */ 197 */
199 bool saveCalendar(QString filename); 198 bool saveCalendar(QString filename);
200 199
201 /** 200 /**
202 Close calendar. Clear calendar data and reset views to display an empty 201 Close calendar. Clear calendar data and reset views to display an empty
203 calendar. 202 calendar.
204 */ 203 */
205 void closeCalendar(); 204 void closeCalendar();
206 205
207 /** Archive old events of calendar */ 206 /** Archive old events of calendar */
208 void archiveCalendar(); 207 void archiveCalendar();
209 208
210 void showIncidence(); 209 void showIncidence();
211 void editIncidence(); 210 void editIncidence();
212 void editIncidenceDescription(); 211 void editIncidenceDescription();
213 void deleteIncidence(); 212 void deleteIncidence();
214 void cloneIncidence(); 213 void cloneIncidence();
215 void moveIncidence(); 214 void moveIncidence();
216 void beamIncidence(); 215 void beamIncidence();
217 void toggleCancelIncidence(); 216 void toggleCancelIncidence();
218 217
219 /** create an editeventwin with supplied date/time, and if bool is true, 218 /** create an editeventwin with supplied date/time, and if bool is true,
220 * make the event take all day. */ 219 * make the event take all day. */
221 void newEvent(QDateTime, QDateTime, bool allDay = false); 220 void newEvent(QDateTime, QDateTime, bool allDay = false);
222 void newEvent(QDateTime fh); 221 void newEvent(QDateTime fh);
223 void newEvent(QDate dt); 222 void newEvent(QDate dt);
224 /** create new event without having a date hint. Takes current date as 223 /** create new event without having a date hint. Takes current date as
225 default hint. */ 224 default hint. */
226 void newEvent(); 225 void newEvent();
227 void newFloatingEvent(); 226 void newFloatingEvent();
228 227
229 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 228 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
230 void showIncidence(Incidence *); 229 void showIncidence(Incidence *);
231 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 230 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
232 void editIncidence(Incidence *); 231 void editIncidence(Incidence *);
233 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 232 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
234 void deleteIncidence(Incidence *); 233 void deleteIncidence(Incidence *);
235 void cloneIncidence(Incidence *); 234 void cloneIncidence(Incidence *);
236 void cancelIncidence(Incidence *); 235 void cancelIncidence(Incidence *);
237 /** Create an editor for the supplied event. */ 236 /** Create an editor for the supplied event. */
238 void editEvent(Event *); 237 void editEvent(Event *);
239 /** Delete the supplied event. */ 238 /** Delete the supplied event. */
240 void deleteEvent(Event *); 239 void deleteEvent(Event *);
241 /** Delete the event with the given unique ID. Returns false, if event wasn't 240 /** Delete the event with the given unique ID. Returns false, if event wasn't
242 found. */ 241 found. */
243 bool deleteEvent(const QString &uid); 242 bool deleteEvent(const QString &uid);
244 /** Create a read-only viewer dialog for the supplied event. */ 243 /** Create a read-only viewer dialog for the supplied event. */
245 void showEvent(Event *); 244 void showEvent(Event *);
246 245
247 void editJournal(Journal *); 246 void editJournal(Journal *);
248 void showJournal(Journal *); 247 void showJournal(Journal *);
249 void deleteJournal(Journal *); 248 void deleteJournal(Journal *);
250 /** Create an editor dialog for a todo */ 249 /** Create an editor dialog for a todo */
251 void editTodo(Todo *); 250 void editTodo(Todo *);
252 /** Create a read-only viewer dialog for the supplied todo */ 251 /** Create a read-only viewer dialog for the supplied todo */
253 void showTodo(Todo *); 252 void showTodo(Todo *);
254 /** create new todo */ 253 /** create new todo */
255 void newTodo(); 254 void newTodo();
256 /** create new todo with a parent todo */ 255 /** create new todo with a parent todo */
257 void newSubTodo(); 256 void newSubTodo();
258 /** create new todo with a parent todo */ 257 /** create new todo with a parent todo */
259 void newSubTodo(Todo *); 258 void newSubTodo(Todo *);
260 /** Delete todo */ 259 /** Delete todo */
261 void deleteTodo(Todo *); 260 void deleteTodo(Todo *);
262 261
263 262
264 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 263 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
265 * emitted as result. */ 264 * emitted as result. */
266 void checkClipboard(); 265 void checkClipboard();
267 266
268 /** using the KConfig associated with the kapp variable, read in the 267 /** using the KConfig associated with the kapp variable, read in the
269 * settings from the config file. 268 * settings from the config file.
270 */ 269 */
271 void readSettings(); 270 void readSettings();
272 271
273 /** write current state to config file. */ 272 /** write current state to config file. */
274 void writeSettings(); 273 void writeSettings();
275 274
276 /** read settings for calendar filters */ 275 /** read settings for calendar filters */
277 void readFilterSettings(KConfig *config); 276 void readFilterSettings(KConfig *config);
278 277
279 /** write settings for calendar filters */ 278 /** write settings for calendar filters */
280 void writeFilterSettings(KConfig *config); 279 void writeFilterSettings(KConfig *config);
281 280
282 /** passes on the message that an event has changed to the currently 281 /** passes on the message that an event has changed to the currently
283 * activated view so that it can make appropriate display changes. */ 282 * activated view so that it can make appropriate display changes. */
284 void changeEventDisplay(Event *, int); 283 void changeEventDisplay(Event *, int);
285 void changeIncidenceDisplay(Incidence *, int); 284 void changeIncidenceDisplay(Incidence *, int);
286 void changeTodoDisplay(Todo *, int); 285 void changeTodoDisplay(Todo *, int);
287 286
288 void eventAdded(Event *); 287 void eventAdded(Event *);
289 void eventChanged(Event *); 288 void eventChanged(Event *);
290 void eventToBeDeleted(Event *); 289 void eventToBeDeleted(Event *);
291 void eventDeleted(); 290 void eventDeleted();
292 291
293 void todoAdded(Todo *); 292 void todoAdded(Todo *);
294 void todoChanged(Todo *); 293 void todoChanged(Todo *);
295 void todoToBeDeleted(Todo *); 294 void todoToBeDeleted(Todo *);
296 void todoDeleted(); 295 void todoDeleted();
297 296
298 void updateView(const QDate &start, const QDate &end); 297 void updateView(const QDate &start, const QDate &end);
299 void updateView(); 298 void updateView();
300 299
301 /** Full update of visible todo views */ 300 /** Full update of visible todo views */
302 void updateTodoViews(); 301 void updateTodoViews();
303 302
304 void updateUnmanagedViews(); 303 void updateUnmanagedViews();
305 304
306 /** cut the current appointment to the clipboard */ 305 /** cut the current appointment to the clipboard */
307 void edit_cut(); 306 void edit_cut();
308 307
309 /** copy the current appointment(s) to the clipboard */ 308 /** copy the current appointment(s) to the clipboard */
310 void edit_copy(); 309 void edit_copy();
311 310
312 /** paste the current vobject(s) in the clipboard buffer into calendar */ 311 /** paste the current vobject(s) in the clipboard buffer into calendar */
313 void edit_paste(); 312 void edit_paste();
314 313
315 /** edit viewing and configuration options. */ 314 /** edit viewing and configuration options. */
316 void edit_options(); 315 void edit_options();
317 void edit_sync_options(); 316 void edit_sync_options();
318 /** 317 /**
319 Functions for printing, previewing a print, and setting up printing 318 Functions for printing, previewing a print, and setting up printing
320 parameters. 319 parameters.
321 */ 320 */
322 void print(); 321 void print();
323 void printSetup(); 322 void printSetup();
324 void printPreview(); 323 void printPreview();
325 324
326 /** Export as iCalendar file */ 325 /** Export as iCalendar file */
327 void exportICalendar(); 326 void exportICalendar();
328 327
329 /** Export as vCalendar file */ 328 /** Export as vCalendar file */
330 bool exportVCalendar( QString fn); 329 bool exportVCalendar( QString fn);
331 330
332 /** pop up a dialog to show an existing appointment. */ 331 /** pop up a dialog to show an existing appointment. */
333 void appointment_show(); 332 void appointment_show();
334 /** 333 /**
335 * pop up an Appointment Dialog to edit an existing appointment.Get 334 * pop up an Appointment Dialog to edit an existing appointment.Get
336 * information on the appointment from the list of unique IDs that is 335 * information on the appointment from the list of unique IDs that is
337 * currently in the View, called currIds. 336 * currently in the View, called currIds.
338 */ 337 */
339 void appointment_edit(); 338 void appointment_edit();
340 /** 339 /**
341 * pop up dialog confirming deletion of currently selected event in the 340 * pop up dialog confirming deletion of currently selected event in the
342 * View. 341 * View.
343 */ 342 */
344 void appointment_delete(); 343 void appointment_delete();
345 344
346 /** mails the currently selected event to a particular user as a vCalendar 345 /** mails the currently selected event to a particular user as a vCalendar
347 attachment. */ 346 attachment. */
348 void action_mail(); 347 void action_mail();
349 348
350 /* frees a subtodo from it's relation */ 349 /* frees a subtodo from it's relation */
351 void todo_unsub( Todo * ); 350 void todo_unsub( Todo * );
352 351
353 /** Take ownership of selected event. */ 352 /** Take ownership of selected event. */
354 void takeOverEvent(); 353 void takeOverEvent();
355 354
356 /** Take ownership of all events in calendar. */ 355 /** Take ownership of all events in calendar. */
357 void takeOverCalendar(); 356 void takeOverCalendar();
358 357
359 /** query whether or not the calendar is "dirty". */ 358 /** query whether or not the calendar is "dirty". */
360 bool isModified(); 359 bool isModified();
361 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 360 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
362 void setModified(bool modified=true); 361 void setModified(bool modified=true);
363 362
364 /** query if the calendar is read-only. */ 363 /** query if the calendar is read-only. */
365 bool isReadOnly(); 364 bool isReadOnly();
366 /** set state of calendar to read-only */ 365 /** set state of calendar to read-only */
367 void setReadOnly(bool readOnly=true); 366 void setReadOnly(bool readOnly=true);
368 367
369 void eventUpdated(Incidence *); 368 void eventUpdated(Incidence *);
370 369
371 /* iTIP scheduling actions */ 370 /* iTIP scheduling actions */
372 void schedule_publish(Incidence *incidence = 0); 371 void schedule_publish(Incidence *incidence = 0);
373 void schedule_request(Incidence *incidence = 0); 372 void schedule_request(Incidence *incidence = 0);
374 void schedule_refresh(Incidence *incidence = 0); 373 void schedule_refresh(Incidence *incidence = 0);
375 void schedule_cancel(Incidence *incidence = 0); 374 void schedule_cancel(Incidence *incidence = 0);
376 void schedule_add(Incidence *incidence = 0); 375 void schedule_add(Incidence *incidence = 0);
377 void schedule_reply(Incidence *incidence = 0); 376 void schedule_reply(Incidence *incidence = 0);
378 void schedule_counter(Incidence *incidence = 0); 377 void schedule_counter(Incidence *incidence = 0);
379 void schedule_declinecounter(Incidence *incidence = 0); 378 void schedule_declinecounter(Incidence *incidence = 0);
380 void schedule_publish_freebusy(int daysToPublish = 30); 379 void schedule_publish_freebusy(int daysToPublish = 30);
381 380
382 void openAddressbook(); 381 void openAddressbook();
383 382
384 void editFilters(); 383 void editFilters();
385 void toggleFilerEnabled(); 384 void toggleFilerEnabled();
386 QPtrList<CalFilter> filters(); 385 QPtrList<CalFilter> filters();
387 void toggleFilter(); 386 void toggleFilter();
388 void showFilter(bool visible); 387 void showFilter(bool visible);
389 void updateFilter(); 388 void updateFilter();
390 void filterEdited(); 389 void filterEdited();
391 void selectFilter( int ); 390 void selectFilter( int );
392 KOFilterView *filterView(); 391 KOFilterView *filterView();
393 392
394 void showIntro(); 393 void showIntro();
395 394
396 /** Move the curdatepient view date to today */ 395 /** Move the curdatepient view date to today */
397 void goToday(); 396 void goToday();
398 397
399 /** Move to the next date(s) in the current view */ 398 /** Move to the next date(s) in the current view */
400 void goNext(); 399 void goNext();
401 400
402 /** Move to the previous date(s) in the current view */ 401 /** Move to the previous date(s) in the current view */
403 void goPrevious(); 402 void goPrevious();
404 /** Move to the next date(s) in the current view */ 403 /** Move to the next date(s) in the current view */
405 void goNextMonth(); 404 void goNextMonth();
406 405
407 /** Move to the previous date(s) in the current view */ 406 /** Move to the previous date(s) in the current view */
408 void goPreviousMonth(); 407 void goPreviousMonth();
409 408
410 void toggleExpand(); 409 void toggleExpand();
411 void toggleDateNavigatorWidget(); 410 void toggleDateNavigatorWidget();
412 void toggleAllDaySize(); 411 void toggleAllDaySize();
413 void dialogClosing(Incidence *); 412 void dialogClosing(Incidence *);
414 413
415 /** Look for new messages in the inbox */ 414 /** Look for new messages in the inbox */
416 void lookForIncomingMessages(); 415 void lookForIncomingMessages();
417 /** Look for new messages in the outbox */ 416 /** Look for new messages in the outbox */
418 void lookForOutgoingMessages(); 417 void lookForOutgoingMessages();
419 418
420 void processMainViewSelection( Incidence * ); 419 void processMainViewSelection( Incidence * );
421 void processTodoListSelection( Incidence * ); 420 void processTodoListSelection( Incidence * );
422 421
423 void processIncidenceSelection( Incidence * ); 422 void processIncidenceSelection( Incidence * );
424 423
425 void purgeCompleted(); 424 void purgeCompleted();
426 bool removeCompletedSubTodos( Todo* ); 425 bool removeCompletedSubTodos( Todo* );
427 void slotCalendarChanged(); 426 void slotCalendarChanged();
428 bool importBday(); 427 bool importBday();
429 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 428 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
430 bool importQtopia( const QString &categoriesFile, 429 bool importQtopia( const QString &categoriesFile,
431 const QString &datebookFile, 430 const QString &datebookFile,
432 const QString &tasklistFile ); 431 const QString &tasklistFile );
433 void syncSharp( ); 432 void syncSharp( );
434 void syncPhone( ); 433 void syncPhone( );
435 void syncExternal( int mode ); 434 void syncExternal( int mode );
436 void slotSelectPickerDate( QDate ) ; 435 void slotSelectPickerDate( QDate ) ;
437 void showDatePicker( ) ; 436 void showDatePicker( ) ;
438 void moveIncidence(Incidence *) ; 437 void moveIncidence(Incidence *) ;
439 void beamIncidence(Incidence *) ; 438 void beamIncidence(Incidence *) ;
440 void beamCalendar() ; 439 void beamCalendar() ;
441 void beamFilteredCalendar() ; 440 void beamFilteredCalendar() ;
442 void beamIncidenceList(QPtrList<Incidence>) ; 441 void beamIncidenceList(QPtrList<Incidence>) ;
443 void manageCategories(); 442 void manageCategories();
444 int addCategories(); 443 int addCategories();
445 void removeCategories(); 444 void removeCategories();
446 void setSyncDevice( QString ); 445 void setSyncDevice( QString );
447 void setSyncName( QString ); 446 void setSyncName( QString );
448 protected slots: 447 protected slots:
449 void timerAlarm(); 448 void timerAlarm();
450 void suspendAlarm(); 449 void suspendAlarm();
451 void beamDone( Ir *ir ); 450 void beamDone( Ir *ir );
452 /** Select a view or adapt the current view to display the specified dates. */ 451 /** Select a view or adapt the current view to display the specified dates. */
453 void showDates( const KCal::DateList & ); 452 void showDates( const KCal::DateList & );
454 void selectWeekNum ( int ); 453 void selectWeekNum ( int );
455 454
456 public: 455 public:
457 // show a standard warning 456 // show a standard warning
458 // returns KMsgBox::yesNoCancel() 457 // returns KMsgBox::yesNoCancel()
459 int msgCalModified(); 458 int msgCalModified();
460 void confSync(); 459 void confSync();
461 void setLoadedFileVersion(QDateTime); 460 void setLoadedFileVersion(QDateTime);
462 bool checkFileVersion(QString fn); 461 bool checkFileVersion(QString fn);
463 bool checkFileChanged(QString fn); 462 bool checkFileChanged(QString fn);
464 Event* getLastSyncEvent(); 463 Event* getLastSyncEvent();
465 /** Adapt navigation units correpsonding to step size of navigation of the 464 /** Adapt navigation units correpsonding to step size of navigation of the
466 * current view. 465 * current view.
467 */ 466 */
468 void adaptNavigationUnits(); 467 void adaptNavigationUnits();
469 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 468 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
470 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 469 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
471 //Attendee* getYourAttendee(Event *event); 470 //Attendee* getYourAttendee(Event *event);
472 protected: 471 protected:
473 void schedule(Scheduler::Method, Incidence *incidence = 0); 472 void schedule(Scheduler::Method, Incidence *incidence = 0);
474 473
475 // returns KMsgBox::OKCandel() 474 // returns KMsgBox::OKCandel()
476 int msgItemDelete(); 475 int msgItemDelete();
477 void showEventEditor(); 476 void showEventEditor();
478 void showTodoEditor(); 477 void showTodoEditor();
479 void writeLocale(); 478 void writeLocale();
480 Todo *selectedTodo(); 479 Todo *selectedTodo();
481 480
482 private: 481 private:
483 AlarmDialog * mAlarmDialog; 482 AlarmDialog * mAlarmDialog;
484 QString mAlarmNotification; 483 QString mAlarmNotification;
485 QString mSuspendAlarmNotification; 484 QString mSuspendAlarmNotification;
486 QTimer* mSuspendTimer; 485 QTimer* mSuspendTimer;
487 QTimer* mAlarmTimer; 486 QTimer* mAlarmTimer;
488 QTimer* mRecheckAlarmTimer; 487 QTimer* mRecheckAlarmTimer;
489 void computeAlarm( QString ); 488 void computeAlarm( QString );
490 void startAlarm( QString, QString ); 489 void startAlarm( QString, QString );
491 void setSyncEventsReadOnly(); 490 void setSyncEventsReadOnly();
492 491
493 QDateTime loadedFileVersion; 492 QDateTime loadedFileVersion;
494 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 493 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
495 void checkExternalId( Incidence * inc ); 494 void checkExternalId( Incidence * inc );
496 int mGlobalSyncMode; 495 int mGlobalSyncMode;
497 QString mCurrentSyncDevice; 496 QString mCurrentSyncDevice;
498 QString mCurrentSyncName; 497 QString mCurrentSyncName;
499 KOBeamPrefs* beamDialog; 498 KOBeamPrefs* beamDialog;
500 void init(); 499 void init();
501 int mDatePickerMode; 500 int mDatePickerMode;
502 bool mFlagEditDescription; 501 bool mFlagEditDescription;
503 QDateTime mLastCalendarSync; 502 QDateTime mLastCalendarSync;
504 void createPrinter(); 503 void createPrinter();
505 504
506 void calendarModified( bool, Calendar * ); 505 void calendarModified( bool, Calendar * );
507 506
508 CalPrinter *mCalPrinter; 507 CalPrinter *mCalPrinter;
509 508
510 QSplitter *mPanner; 509 QSplitter *mPanner;
511 QSplitter *mLeftSplitter; 510 QSplitter *mLeftSplitter;
512 QWidget *mLeftFrame; 511 QWidget *mLeftFrame;
513 QWidgetStack *mRightFrame; 512 QWidgetStack *mRightFrame;
514 513
515 KDatePicker* mDatePicker; 514 KDatePicker* mDatePicker;
516 QVBox* mDateFrame; 515 QVBox* mDateFrame;
517 NavigatorBar *mNavigatorBar; 516 NavigatorBar *mNavigatorBar;
518 517
519 KDateNavigator *mDateNavigator; // widget showing small month view. 518 KDateNavigator *mDateNavigator; // widget showing small month view.
520 519
521 KOFilterView *mFilterView; 520 KOFilterView *mFilterView;
522 521
523 ResourceView *mResourceView; 522 ResourceView *mResourceView;
524 523
525 // calendar object for this viewing instance 524 // calendar object for this viewing instance
526 Calendar *mCalendar; 525 Calendar *mCalendar;
527 526
528 CalendarResourceManager *mResourceManager; 527 CalendarResourceManager *mResourceManager;
529 528
530 FileStorage *mStorage; 529 FileStorage *mStorage;
531 530
532 DateNavigator *mNavigator; 531 DateNavigator *mNavigator;
533 532
534 KOViewManager *mViewManager; 533 KOViewManager *mViewManager;
535 KODialogManager *mDialogManager; 534 KODialogManager *mDialogManager;
536 535
537 // Calendar filters 536 // Calendar filters
538 QPtrList<CalFilter> mFilters; 537 QPtrList<CalFilter> mFilters;
539 538
540 // various housekeeping variables. 539 // various housekeeping variables.
541 bool mModified; // flag indicating if calendar is modified 540 bool mModified; // flag indicating if calendar is modified
542 bool mReadOnly; // flag indicating if calendar is read-only 541 bool mReadOnly; // flag indicating if calendar is read-only
543 QDate mSaveSingleDate; 542 QDate mSaveSingleDate;
544 543
545 Incidence *mSelectedIncidence; 544 Incidence *mSelectedIncidence;
546 Incidence *mMoveIncidence; 545 Incidence *mMoveIncidence;
547 QPtrList<Event> mExternLastSyncEvent;
548 KOTodoView *mTodoList; 546 KOTodoView *mTodoList;
549 KOEventEditor * mEventEditor; 547 KOEventEditor * mEventEditor;
550 KOTodoEditor * mTodoEditor; 548 KOTodoEditor * mTodoEditor;
551 KOEventViewerDialog * mEventViewerDialog; 549 KOEventViewerDialog * mEventViewerDialog;
552 void keyPressEvent ( QKeyEvent *e) ; 550 void keyPressEvent ( QKeyEvent *e) ;
553 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 551 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
554}; 552};
555 553
556 554
557class CalendarViewVisitor : public Incidence::Visitor 555class CalendarViewVisitor : public Incidence::Visitor
558{ 556{
559 public: 557 public:
560 CalendarViewVisitor() : mView( 0 ) {} 558 CalendarViewVisitor() : mView( 0 ) {}
561 559
562 bool act( Incidence *incidence, CalendarView *view ) 560 bool act( Incidence *incidence, CalendarView *view )
563 { 561 {
564 mView = view; 562 mView = view;
565 return incidence->accept( *this ); 563 return incidence->accept( *this );
566 } 564 }
567 565
568 protected: 566 protected:
569 CalendarView *mView; 567 CalendarView *mView;
570}; 568};
571 569
572class ShowIncidenceVisitor : public CalendarViewVisitor 570class ShowIncidenceVisitor : public CalendarViewVisitor
573{ 571{
574 protected: 572 protected:
575 bool visit( Event *event ) { mView->showEvent( event ); return true; } 573 bool visit( Event *event ) { mView->showEvent( event ); return true; }
576 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 574 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
577 bool visit( Journal * j ) { mView->showJournal( j );return true; } 575 bool visit( Journal * j ) { mView->showJournal( j );return true; }
578}; 576};
579 577
580class EditIncidenceVisitor : public CalendarViewVisitor 578class EditIncidenceVisitor : public CalendarViewVisitor
581{ 579{
582 protected: 580 protected:
583 bool visit( Event *event ) { mView->editEvent( event ); return true; } 581 bool visit( Event *event ) { mView->editEvent( event ); return true; }
584 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 582 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
585 bool visit( Journal *j ) { mView->editJournal( j); return true; } 583 bool visit( Journal *j ) { mView->editJournal( j); return true; }
586}; 584};
587 585
588class DeleteIncidenceVisitor : public CalendarViewVisitor 586class DeleteIncidenceVisitor : public CalendarViewVisitor
589{ 587{
590 protected: 588 protected:
591 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 589 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
592 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 590 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
593 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 591 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
594}; 592};
595 593
596#endif 594#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index ec69b11..9104347 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -481,1025 +481,1024 @@ void MainWindow::initActions()
481 // ****************** 481 // ******************
482 QAction *action; 482 QAction *action;
483 QIconSet icon; 483 QIconSet icon;
484 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 484 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
485 configureToolBarMenu->setCheckable( true ); 485 configureToolBarMenu->setCheckable( true );
486 486
487 QString pathString = ""; 487 QString pathString = "";
488 if ( !p->mToolBarMiniIcons ) { 488 if ( !p->mToolBarMiniIcons ) {
489 if ( QApplication::desktop()->width() < 480 ) 489 if ( QApplication::desktop()->width() < 480 )
490 pathString += "icons16/"; 490 pathString += "icons16/";
491 } else 491 } else
492 pathString += "iconsmini/"; 492 pathString += "iconsmini/";
493 configureAgendaMenu->setCheckable( true ); 493 configureAgendaMenu->setCheckable( true );
494 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 494 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
495 configureAgendaMenu->insertSeparator(); 495 configureAgendaMenu->insertSeparator();
496 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 496 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
497 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 497 configureAgendaMenu->insertItem(i18n("Small"), 6 );
498 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 498 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
499 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 499 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
500 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 500 configureAgendaMenu->insertItem(i18n("Large"), 12 );
501 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 501 configureAgendaMenu->insertItem(i18n("Big"), 14 );
502 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 502 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
503 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 503 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
504 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 504 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
505 505
506 icon = loadPixmap( pathString + "configure" ); 506 icon = loadPixmap( pathString + "configure" );
507 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 507 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
508 action->addTo( actionMenu ); 508 action->addTo( actionMenu );
509 connect( action, SIGNAL( activated() ), 509 connect( action, SIGNAL( activated() ),
510 mView, SLOT( edit_options() ) ); 510 mView, SLOT( edit_options() ) );
511 actionMenu->insertSeparator(); 511 actionMenu->insertSeparator();
512 icon = loadPixmap( pathString + "newevent" ); 512 icon = loadPixmap( pathString + "newevent" );
513 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 513 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
514 configureToolBarMenu->insertSeparator(); 514 configureToolBarMenu->insertSeparator();
515 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 515 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
516 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 516 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
517 ne_action->addTo( actionMenu ); 517 ne_action->addTo( actionMenu );
518 connect( ne_action, SIGNAL( activated() ), 518 connect( ne_action, SIGNAL( activated() ),
519 mView, SLOT( newEvent() ) ); 519 mView, SLOT( newEvent() ) );
520 icon = loadPixmap( pathString + "newtodo" ); 520 icon = loadPixmap( pathString + "newtodo" );
521 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 521 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
522 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 522 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
523 nt_action->addTo( actionMenu ); 523 nt_action->addTo( actionMenu );
524 connect( nt_action, SIGNAL( activated() ), 524 connect( nt_action, SIGNAL( activated() ),
525 mView, SLOT( newTodo() ) ); 525 mView, SLOT( newTodo() ) );
526 icon = loadPixmap( pathString + "navi" ); 526 icon = loadPixmap( pathString + "navi" );
527 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 527 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
528 action->addTo( viewMenu ); 528 action->addTo( viewMenu );
529 connect( action, SIGNAL( activated() ), 529 connect( action, SIGNAL( activated() ),
530 mView, SLOT( toggleDateNavigatorWidget() ) ); 530 mView, SLOT( toggleDateNavigatorWidget() ) );
531 icon = loadPixmap( pathString + "filter" ); 531 icon = loadPixmap( pathString + "filter" );
532 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 532 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
533 action->addTo( viewMenu ); 533 action->addTo( viewMenu );
534 connect( action, SIGNAL( activated() ), 534 connect( action, SIGNAL( activated() ),
535 mView, SLOT( toggleFilter() ) ); 535 mView, SLOT( toggleFilter() ) );
536 536
537 537
538 viewMenu->insertSeparator(); 538 viewMenu->insertSeparator();
539 icon = loadPixmap( pathString + "picker" ); 539 icon = loadPixmap( pathString + "picker" );
540 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 540 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
541 action->addTo( viewMenu ); 541 action->addTo( viewMenu );
542 connect( action, SIGNAL( activated() ), 542 connect( action, SIGNAL( activated() ),
543 mView, SLOT( showDatePicker() ) ); 543 mView, SLOT( showDatePicker() ) );
544 action->addTo( iconToolBar ); 544 action->addTo( iconToolBar );
545 viewMenu->insertSeparator(); 545 viewMenu->insertSeparator();
546 icon = loadPixmap( pathString + "list" ); 546 icon = loadPixmap( pathString + "list" );
547 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 547 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
548 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 548 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
549 showlist_action->addTo( viewMenu ); 549 showlist_action->addTo( viewMenu );
550 connect( showlist_action, SIGNAL( activated() ), 550 connect( showlist_action, SIGNAL( activated() ),
551 mView->viewManager(), SLOT( showListView() ) ); 551 mView->viewManager(), SLOT( showListView() ) );
552 552
553 553
554 icon = loadPixmap( pathString + "day" ); 554 icon = loadPixmap( pathString + "day" );
555 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 555 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
556 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 556 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
557 day1_action->addTo( viewMenu ); 557 day1_action->addTo( viewMenu );
558 // action->addTo( toolBar ); 558 // action->addTo( toolBar );
559 connect( day1_action, SIGNAL( activated() ), 559 connect( day1_action, SIGNAL( activated() ),
560 mView->viewManager(), SLOT( showDayView() ) ); 560 mView->viewManager(), SLOT( showDayView() ) );
561 561
562 icon = loadPixmap( pathString + "workweek" ); 562 icon = loadPixmap( pathString + "workweek" );
563 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 563 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
564 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 564 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
565 day5_action->addTo( viewMenu ); 565 day5_action->addTo( viewMenu );
566 connect( day5_action, SIGNAL( activated() ), 566 connect( day5_action, SIGNAL( activated() ),
567 mView->viewManager(), SLOT( showWorkWeekView() ) ); 567 mView->viewManager(), SLOT( showWorkWeekView() ) );
568 568
569 icon = loadPixmap( pathString + "week" ); 569 icon = loadPixmap( pathString + "week" );
570 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 570 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
571 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 571 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
572 day7_action->addTo( viewMenu ); 572 day7_action->addTo( viewMenu );
573 connect( day7_action, SIGNAL( activated() ), 573 connect( day7_action, SIGNAL( activated() ),
574 mView->viewManager(), SLOT( showWeekView() ) ); 574 mView->viewManager(), SLOT( showWeekView() ) );
575 575
576 icon = loadPixmap( pathString + "month" ); 576 icon = loadPixmap( pathString + "month" );
577 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 577 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
578 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 578 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
579 month_action->addTo( viewMenu ); 579 month_action->addTo( viewMenu );
580 connect( month_action, SIGNAL( activated() ), 580 connect( month_action, SIGNAL( activated() ),
581 mView->viewManager(), SLOT( showMonthView() ) ); 581 mView->viewManager(), SLOT( showMonthView() ) );
582 582
583 icon = loadPixmap( pathString + "todo" ); 583 icon = loadPixmap( pathString + "todo" );
584 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 584 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
585 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 585 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
586 todoview_action->addTo( viewMenu ); 586 todoview_action->addTo( viewMenu );
587 connect( todoview_action, SIGNAL( activated() ), 587 connect( todoview_action, SIGNAL( activated() ),
588 mView->viewManager(), SLOT( showTodoView() ) ); 588 mView->viewManager(), SLOT( showTodoView() ) );
589 589
590 icon = loadPixmap( pathString + "journal" ); 590 icon = loadPixmap( pathString + "journal" );
591 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 591 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
592 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 592 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
593 viewjournal_action->addTo( viewMenu ); 593 viewjournal_action->addTo( viewMenu );
594 connect( viewjournal_action, SIGNAL( activated() ), 594 connect( viewjournal_action, SIGNAL( activated() ),
595 mView->viewManager(), SLOT( showJournalView() ) ); 595 mView->viewManager(), SLOT( showJournalView() ) );
596 596
597 icon = loadPixmap( pathString + "xdays" ); 597 icon = loadPixmap( pathString + "xdays" );
598 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 598 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
599 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 599 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
600 xdays_action->addTo( viewMenu ); 600 xdays_action->addTo( viewMenu );
601 connect( xdays_action, SIGNAL( activated() ), 601 connect( xdays_action, SIGNAL( activated() ),
602 mView->viewManager(), SLOT( showNextXView() ) ); 602 mView->viewManager(), SLOT( showNextXView() ) );
603 603
604 icon = loadPixmap( pathString + "whatsnext" ); 604 icon = loadPixmap( pathString + "whatsnext" );
605 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 605 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
606 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 606 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
607 whatsnext_action->addTo( viewMenu ); 607 whatsnext_action->addTo( viewMenu );
608 connect( whatsnext_action, SIGNAL( activated() ), 608 connect( whatsnext_action, SIGNAL( activated() ),
609 mView->viewManager(), SLOT( showWhatsNextView() ) ); 609 mView->viewManager(), SLOT( showWhatsNextView() ) );
610 610
611#if 0 611#if 0
612 action = new QAction( "view_timespan", "Time Span", 0, this ); 612 action = new QAction( "view_timespan", "Time Span", 0, this );
613 action->addTo( viewMenu ); 613 action->addTo( viewMenu );
614 connect( action, SIGNAL( activated() ), 614 connect( action, SIGNAL( activated() ),
615 mView->viewManager(), SLOT( showTimeSpanView() ) ); 615 mView->viewManager(), SLOT( showTimeSpanView() ) );
616#endif 616#endif
617 617
618 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 618 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
619 this ); 619 this );
620 mNewSubTodoAction->addTo( actionMenu ); 620 mNewSubTodoAction->addTo( actionMenu );
621 connect( mNewSubTodoAction, SIGNAL( activated() ), 621 connect( mNewSubTodoAction, SIGNAL( activated() ),
622 mView, SLOT( newSubTodo() ) ); 622 mView, SLOT( newSubTodo() ) );
623 623
624 actionMenu->insertSeparator(); 624 actionMenu->insertSeparator();
625 625
626 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 626 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
627 mShowAction->addTo( actionMenu ); 627 mShowAction->addTo( actionMenu );
628 connect( mShowAction, SIGNAL( activated() ), 628 connect( mShowAction, SIGNAL( activated() ),
629 mView, SLOT( showIncidence() ) ); 629 mView, SLOT( showIncidence() ) );
630 630
631 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 631 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
632 mEditAction->addTo( actionMenu ); 632 mEditAction->addTo( actionMenu );
633 connect( mEditAction, SIGNAL( activated() ), 633 connect( mEditAction, SIGNAL( activated() ),
634 mView, SLOT( editIncidence() ) ); 634 mView, SLOT( editIncidence() ) );
635 635
636 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 636 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
637 mDeleteAction->addTo( actionMenu ); 637 mDeleteAction->addTo( actionMenu );
638 connect( mDeleteAction, SIGNAL( activated() ), 638 connect( mDeleteAction, SIGNAL( activated() ),
639 mView, SLOT( deleteIncidence() ) ); 639 mView, SLOT( deleteIncidence() ) );
640 640
641 641
642 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 642 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
643 mCloneAction->addTo( actionMenu ); 643 mCloneAction->addTo( actionMenu );
644 connect( mCloneAction, SIGNAL( activated() ), 644 connect( mCloneAction, SIGNAL( activated() ),
645 mView, SLOT( cloneIncidence() ) ); 645 mView, SLOT( cloneIncidence() ) );
646 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 646 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
647 mMoveAction->addTo( actionMenu ); 647 mMoveAction->addTo( actionMenu );
648 connect( mMoveAction, SIGNAL( activated() ), 648 connect( mMoveAction, SIGNAL( activated() ),
649 mView, SLOT( moveIncidence() ) ); 649 mView, SLOT( moveIncidence() ) );
650 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 650 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
651 mBeamAction->addTo( actionMenu ); 651 mBeamAction->addTo( actionMenu );
652 connect( mBeamAction, SIGNAL( activated() ), 652 connect( mBeamAction, SIGNAL( activated() ),
653 mView, SLOT( beamIncidence() ) ); 653 mView, SLOT( beamIncidence() ) );
654 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 654 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
655 mCancelAction->addTo( actionMenu ); 655 mCancelAction->addTo( actionMenu );
656 connect( mCancelAction, SIGNAL( activated() ), 656 connect( mCancelAction, SIGNAL( activated() ),
657 mView, SLOT( toggleCancelIncidence() ) ); 657 mView, SLOT( toggleCancelIncidence() ) );
658 658
659 actionMenu->insertSeparator(); 659 actionMenu->insertSeparator();
660 660
661 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 661 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
662 this ); 662 this );
663 action->addTo( actionMenu ); 663 action->addTo( actionMenu );
664 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 664 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
665 665
666 icon = loadPixmap( pathString + "search" ); 666 icon = loadPixmap( pathString + "search" );
667 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 667 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
668 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 668 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
669 search_action->addTo( actionMenu ); 669 search_action->addTo( actionMenu );
670 connect( search_action, SIGNAL( activated() ), 670 connect( search_action, SIGNAL( activated() ),
671 mView->dialogManager(), SLOT( showSearchDialog() ) ); 671 mView->dialogManager(), SLOT( showSearchDialog() ) );
672 672
673 icon = loadPixmap( pathString + "today" ); 673 icon = loadPixmap( pathString + "today" );
674 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 674 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
675 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 675 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
676 today_action->addTo( actionMenu ); 676 today_action->addTo( actionMenu );
677 connect( today_action, SIGNAL( activated() ), 677 connect( today_action, SIGNAL( activated() ),
678 mView, SLOT( goToday() ) ); 678 mView, SLOT( goToday() ) );
679 679
680 if ( KOPrefs::instance()->mShowFullMenu ) { 680 if ( KOPrefs::instance()->mShowFullMenu ) {
681 actionMenu->insertSeparator(); 681 actionMenu->insertSeparator();
682 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 682 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
683 683
684 } 684 }
685 // actionMenu->insertSeparator(); 685 // actionMenu->insertSeparator();
686 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 686 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
687 this ); 687 this );
688 action->addTo( importMenu ); 688 action->addTo( importMenu );
689 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 689 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
690 action = new QAction( "import_quick", i18n("Import last file"), 0, 690 action = new QAction( "import_quick", i18n("Import last file"), 0,
691 this ); 691 this );
692 action->addTo( importMenu ); 692 action->addTo( importMenu );
693 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 693 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
694 importMenu->insertSeparator(); 694 importMenu->insertSeparator();
695 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 695 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
696 this ); 696 this );
697 action->addTo( importMenu ); 697 action->addTo( importMenu );
698 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 698 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
699#ifndef DESKTOP_VERSION 699#ifndef DESKTOP_VERSION
700 importMenu->insertSeparator(); 700 importMenu->insertSeparator();
701 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 701 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
702 this ); 702 this );
703 action->addTo( importMenu ); 703 action->addTo( importMenu );
704 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 704 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
705#else 705#else
706#ifdef _WIN32_ 706#ifdef _WIN32_
707 importMenu->insertSeparator(); 707 importMenu->insertSeparator();
708 action = new QAction( "import_ol", i18n("Import from OL"), 0, 708 action = new QAction( "import_ol", i18n("Import from OL"), 0,
709 this ); 709 this );
710 action->addTo( importMenu ); 710 action->addTo( importMenu );
711 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 711 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
712#endif 712#endif
713#endif 713#endif
714 714
715 importMenu->insertSeparator(); 715 importMenu->insertSeparator();
716 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 716 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
717 this ); 717 this );
718 action->addTo( importMenu ); 718 action->addTo( importMenu );
719 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 719 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
720 720
721 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 721 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
722 this ); 722 this );
723 action->addTo( importMenu ); 723 action->addTo( importMenu );
724 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 724 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
725 725
726 importMenu->insertSeparator(); 726 importMenu->insertSeparator();
727 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 727 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
728 this ); 728 this );
729 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 729 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
730 730
731 731
732 //LR 732 //LR
733 QPopupMenu *ex2phone = new QPopupMenu( this ); 733 QPopupMenu *ex2phone = new QPopupMenu( this );
734 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 734 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
735 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 735 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
736 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 736 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
737 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 737 importMenu->insertItem( i18n("Export to phone"), ex2phone );
738 738
739 importMenu->insertSeparator(); 739 importMenu->insertSeparator();
740 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 740 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
741 this ); 741 this );
742 action->addTo( importMenu ); 742 action->addTo( importMenu );
743 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 743 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
744#ifndef DESKTOP_VERSION 744#ifndef DESKTOP_VERSION
745 importMenu->insertSeparator(); 745 importMenu->insertSeparator();
746 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 746 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
747 this ); 747 this );
748 action->addTo( importMenu ); 748 action->addTo( importMenu );
749 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 749 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
750 750
751 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 751 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
752 this ); 752 this );
753 action->addTo( importMenu ); 753 action->addTo( importMenu );
754 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 754 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
755#else 755#else
756 importMenu->insertSeparator(); 756 importMenu->insertSeparator();
757 icon = loadPixmap( pathString + "print" ); 757 icon = loadPixmap( pathString + "print" );
758 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 758 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
759 action->addTo( importMenu ); 759 action->addTo( importMenu );
760 connect( action, SIGNAL( activated() ), 760 connect( action, SIGNAL( activated() ),
761 this, SLOT( printCal() ) ); 761 this, SLOT( printCal() ) );
762 762
763 icon = loadPixmap( pathString + "print" ); 763 icon = loadPixmap( pathString + "print" );
764 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 764 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
765 action->addTo( importMenu ); 765 action->addTo( importMenu );
766 connect( action, SIGNAL( activated() ), 766 connect( action, SIGNAL( activated() ),
767 this, SLOT( printSel() ) ); 767 this, SLOT( printSel() ) );
768#endif 768#endif
769 importMenu->insertSeparator(); 769 importMenu->insertSeparator();
770 action = new QAction( "beam all", i18n("Save"), 0, 770 action = new QAction( "beam all", i18n("Save"), 0,
771 this ); 771 this );
772 action->addTo( importMenu ); 772 action->addTo( importMenu );
773 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 773 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
774 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 774 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
775 this ); 775 this );
776 action->addTo( importMenu ); 776 action->addTo( importMenu );
777 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 777 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
778 778
779 //menuBar->insertItem( "Configure",configureMenu ); 779 //menuBar->insertItem( "Configure",configureMenu );
780 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 780 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
781 icon = loadPixmap( "korganizer/korganizer" ); 781 icon = loadPixmap( "korganizer/korganizer" );
782 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 782 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
783 action->addTo( helpMenu ); 783 action->addTo( helpMenu );
784 connect( action, SIGNAL( activated() ), 784 connect( action, SIGNAL( activated() ),
785 SLOT( keyBindings() ) ); 785 SLOT( keyBindings() ) );
786 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 786 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
787 action->addTo( helpMenu ); 787 action->addTo( helpMenu );
788 connect( action, SIGNAL( activated() ), 788 connect( action, SIGNAL( activated() ),
789 SLOT( features() ) ); 789 SLOT( features() ) );
790 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 790 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
791 action->addTo( helpMenu ); 791 action->addTo( helpMenu );
792 connect( action, SIGNAL( activated() ), 792 connect( action, SIGNAL( activated() ),
793 SLOT( aboutAutoSaving() ) ); 793 SLOT( aboutAutoSaving() ) );
794 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 794 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
795 action->addTo( helpMenu ); 795 action->addTo( helpMenu );
796 connect( action, SIGNAL( activated() ), 796 connect( action, SIGNAL( activated() ),
797 SLOT( aboutKnownBugs() ) ); 797 SLOT( aboutKnownBugs() ) );
798 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 798 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
799 action->addTo( helpMenu ); 799 action->addTo( helpMenu );
800 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
801 SLOT( usertrans() ) ); 801 SLOT( usertrans() ) );
802 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 802 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
803 action->addTo( helpMenu ); 803 action->addTo( helpMenu );
804 connect( action, SIGNAL( activated() ), 804 connect( action, SIGNAL( activated() ),
805 SLOT( synchowto() ) ); 805 SLOT( synchowto() ) );
806 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 806 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
807 action->addTo( helpMenu ); 807 action->addTo( helpMenu );
808 connect( action, SIGNAL( activated() ), 808 connect( action, SIGNAL( activated() ),
809 SLOT( whatsNew() ) ); 809 SLOT( whatsNew() ) );
810 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 810 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
811 action->addTo( helpMenu ); 811 action->addTo( helpMenu );
812 connect( action, SIGNAL( activated() ), 812 connect( action, SIGNAL( activated() ),
813 SLOT( faq() ) ); 813 SLOT( faq() ) );
814 814
815 815
816 action = new QAction( "about", i18n("About..."), 0, this ); 816 action = new QAction( "about", i18n("About..."), 0, this );
817 action->addTo( helpMenu ); 817 action->addTo( helpMenu );
818 connect( action, SIGNAL( activated() ), 818 connect( action, SIGNAL( activated() ),
819 SLOT( about() ) ); 819 SLOT( about() ) );
820 action = new QAction( "licence", i18n("Licence..."), 0, this ); 820 action = new QAction( "licence", i18n("Licence..."), 0, this );
821 action->addTo( helpMenu ); 821 action->addTo( helpMenu );
822 connect( action, SIGNAL( activated() ), 822 connect( action, SIGNAL( activated() ),
823 SLOT( licence() ) ); 823 SLOT( licence() ) );
824 //menuBar->insertSeparator(); 824 //menuBar->insertSeparator();
825 825
826 // ****************************************************** 826 // ******************************************************
827 // menubar icons 827 // menubar icons
828 828
829 829
830 iconToolBar->setHorizontalStretchable (true ); 830 iconToolBar->setHorizontalStretchable (true );
831 //menuBar->insertItem( iconToolBar ); 831 //menuBar->insertItem( iconToolBar );
832 //xdays_action 832 //xdays_action
833 if (p-> mShowIconNewEvent) 833 if (p-> mShowIconNewEvent)
834 ne_action->addTo( iconToolBar ); 834 ne_action->addTo( iconToolBar );
835 if (p->mShowIconNewTodo ) 835 if (p->mShowIconNewTodo )
836 nt_action->addTo( iconToolBar ); 836 nt_action->addTo( iconToolBar );
837 if (p-> mShowIconSearch) 837 if (p-> mShowIconSearch)
838 search_action->addTo( iconToolBar ); 838 search_action->addTo( iconToolBar );
839 if (p-> mShowIconNext) 839 if (p-> mShowIconNext)
840 whatsnext_action->addTo( iconToolBar ); 840 whatsnext_action->addTo( iconToolBar );
841 if (p-> mShowIconNextDays) 841 if (p-> mShowIconNextDays)
842 xdays_action->addTo( iconToolBar ); 842 xdays_action->addTo( iconToolBar );
843 if (p-> mShowIconList) 843 if (p-> mShowIconList)
844 showlist_action->addTo( iconToolBar ); 844 showlist_action->addTo( iconToolBar );
845 if (p-> mShowIconDay1) 845 if (p-> mShowIconDay1)
846 day1_action->addTo( iconToolBar ); 846 day1_action->addTo( iconToolBar );
847 if (p-> mShowIconDay5) 847 if (p-> mShowIconDay5)
848 day5_action->addTo( iconToolBar ); 848 day5_action->addTo( iconToolBar );
849 if (p-> mShowIconDay7) 849 if (p-> mShowIconDay7)
850 day7_action->addTo( iconToolBar ); 850 day7_action->addTo( iconToolBar );
851 if (p-> mShowIconMonth) 851 if (p-> mShowIconMonth)
852 month_action->addTo( iconToolBar ); 852 month_action->addTo( iconToolBar );
853 if (p-> mShowIconTodoview) 853 if (p-> mShowIconTodoview)
854 todoview_action->addTo( iconToolBar ); 854 todoview_action->addTo( iconToolBar );
855 if (p-> mShowIconJournal) 855 if (p-> mShowIconJournal)
856 viewjournal_action->addTo( iconToolBar ); 856 viewjournal_action->addTo( iconToolBar );
857 icon = loadPixmap( pathString + "2leftarrowB" ); 857 icon = loadPixmap( pathString + "2leftarrowB" );
858 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 858 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
859 if (p-> mShowIconBackFast) { 859 if (p-> mShowIconBackFast) {
860 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 860 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
861 connect( action, SIGNAL( activated() ), 861 connect( action, SIGNAL( activated() ),
862 mView, SLOT( goPreviousMonth() ) ); 862 mView, SLOT( goPreviousMonth() ) );
863 action->addTo( iconToolBar ); 863 action->addTo( iconToolBar );
864 } 864 }
865 icon = loadPixmap( pathString + "1leftarrowB" ); 865 icon = loadPixmap( pathString + "1leftarrowB" );
866 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 866 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
867 if (p-> mShowIconBack) { 867 if (p-> mShowIconBack) {
868 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 868 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
869 connect( action, SIGNAL( activated() ), 869 connect( action, SIGNAL( activated() ),
870 mView, SLOT( goPrevious() ) ); 870 mView, SLOT( goPrevious() ) );
871 action->addTo( iconToolBar ); 871 action->addTo( iconToolBar );
872 } 872 }
873 if (p-> mShowIconToday) 873 if (p-> mShowIconToday)
874 today_action->addTo( iconToolBar ); 874 today_action->addTo( iconToolBar );
875 icon = loadPixmap( pathString + "1rightarrowB" ); 875 icon = loadPixmap( pathString + "1rightarrowB" );
876 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 876 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
877 if (p-> mShowIconForward) { 877 if (p-> mShowIconForward) {
878 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 878 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
879 connect( action, SIGNAL( activated() ), 879 connect( action, SIGNAL( activated() ),
880 mView, SLOT( goNext() ) ); 880 mView, SLOT( goNext() ) );
881 action->addTo( iconToolBar ); 881 action->addTo( iconToolBar );
882 } 882 }
883 icon = loadPixmap( pathString + "2rightarrowB" ); 883 icon = loadPixmap( pathString + "2rightarrowB" );
884 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 884 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
885 if (p-> mShowIconForwardFast) { 885 if (p-> mShowIconForwardFast) {
886 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 886 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
887 connect( action, SIGNAL( activated() ), 887 connect( action, SIGNAL( activated() ),
888 mView, SLOT( goNextMonth() ) ); 888 mView, SLOT( goNextMonth() ) );
889 action->addTo( iconToolBar ); 889 action->addTo( iconToolBar );
890 } 890 }
891 891
892 892
893 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 893 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
894 894
895 if (p-> mShowIconNewEvent) 895 if (p-> mShowIconNewEvent)
896 configureToolBarMenu->setItemChecked( 10, true ); 896 configureToolBarMenu->setItemChecked( 10, true );
897 if (p->mShowIconNewTodo ) 897 if (p->mShowIconNewTodo )
898 configureToolBarMenu->setItemChecked( 20, true ); 898 configureToolBarMenu->setItemChecked( 20, true );
899 if (p-> mShowIconSearch) 899 if (p-> mShowIconSearch)
900 configureToolBarMenu->setItemChecked( 120, true ); 900 configureToolBarMenu->setItemChecked( 120, true );
901 if (p-> mShowIconList) 901 if (p-> mShowIconList)
902 configureToolBarMenu->setItemChecked( 30, true ); 902 configureToolBarMenu->setItemChecked( 30, true );
903 if (p-> mShowIconDay1) 903 if (p-> mShowIconDay1)
904 configureToolBarMenu->setItemChecked( 40, true ); 904 configureToolBarMenu->setItemChecked( 40, true );
905 if (p-> mShowIconDay5) 905 if (p-> mShowIconDay5)
906 configureToolBarMenu->setItemChecked( 50, true ); 906 configureToolBarMenu->setItemChecked( 50, true );
907 if (p-> mShowIconDay7) 907 if (p-> mShowIconDay7)
908 configureToolBarMenu->setItemChecked( 60, true ); 908 configureToolBarMenu->setItemChecked( 60, true );
909 if (p-> mShowIconMonth) 909 if (p-> mShowIconMonth)
910 configureToolBarMenu->setItemChecked( 70, true ); 910 configureToolBarMenu->setItemChecked( 70, true );
911 if (p-> mShowIconTodoview) 911 if (p-> mShowIconTodoview)
912 configureToolBarMenu->setItemChecked( 80, true ); 912 configureToolBarMenu->setItemChecked( 80, true );
913 if (p-> mShowIconBackFast) 913 if (p-> mShowIconBackFast)
914 configureToolBarMenu->setItemChecked( 200, true ); 914 configureToolBarMenu->setItemChecked( 200, true );
915 if (p-> mShowIconBack) 915 if (p-> mShowIconBack)
916 configureToolBarMenu->setItemChecked( 210, true ); 916 configureToolBarMenu->setItemChecked( 210, true );
917 if (p-> mShowIconToday) 917 if (p-> mShowIconToday)
918 configureToolBarMenu->setItemChecked( 130, true ); 918 configureToolBarMenu->setItemChecked( 130, true );
919 if (p-> mShowIconForward) 919 if (p-> mShowIconForward)
920 configureToolBarMenu->setItemChecked( 220, true ); 920 configureToolBarMenu->setItemChecked( 220, true );
921 if (p-> mShowIconForwardFast) 921 if (p-> mShowIconForwardFast)
922 configureToolBarMenu->setItemChecked( 230, true ); 922 configureToolBarMenu->setItemChecked( 230, true );
923 if (p-> mShowIconNextDays) 923 if (p-> mShowIconNextDays)
924 configureToolBarMenu->setItemChecked( 100, true ); 924 configureToolBarMenu->setItemChecked( 100, true );
925 if (p-> mShowIconNext) 925 if (p-> mShowIconNext)
926 configureToolBarMenu->setItemChecked( 110, true ); 926 configureToolBarMenu->setItemChecked( 110, true );
927 if (p-> mShowIconJournal) 927 if (p-> mShowIconJournal)
928 configureToolBarMenu->setItemChecked( 90, true ); 928 configureToolBarMenu->setItemChecked( 90, true );
929 if (p-> mShowIconWhatsThis) 929 if (p-> mShowIconWhatsThis)
930 configureToolBarMenu->setItemChecked( 300, true ); 930 configureToolBarMenu->setItemChecked( 300, true );
931 931
932 QLabel* dummy = new QLabel( iconToolBar ); 932 QLabel* dummy = new QLabel( iconToolBar );
933 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 933 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
934 if (!p-> mShowIconStretch) 934 if (!p-> mShowIconStretch)
935 iconToolBar->setStretchableWidget ( dummy ) ; 935 iconToolBar->setStretchableWidget ( dummy ) ;
936 else 936 else
937 configureToolBarMenu->setItemChecked( 5, true ); 937 configureToolBarMenu->setItemChecked( 5, true );
938 if (p-> mShowIconWhatsThis) 938 if (p-> mShowIconWhatsThis)
939 QWhatsThis::whatsThisButton ( iconToolBar ); 939 QWhatsThis::whatsThisButton ( iconToolBar );
940 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 940 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
941 configureAgenda( p->mHourSize ); 941 configureAgenda( p->mHourSize );
942 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 942 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
943} 943}
944void MainWindow::fillSyncMenu() 944void MainWindow::fillSyncMenu()
945{ 945{
946 if ( syncMenu->count() ) 946 if ( syncMenu->count() )
947 syncMenu->clear(); 947 syncMenu->clear();
948 syncMenu->insertItem( i18n("Configure..."), 0 ); 948 syncMenu->insertItem( i18n("Configure..."), 0 );
949 syncMenu->insertSeparator(); 949 syncMenu->insertSeparator();
950 if ( mServerSocket == 0 ) { 950 if ( mServerSocket == 0 ) {
951 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 951 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
952 } else { 952 } else {
953 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 953 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
954 } 954 }
955 syncMenu->insertSeparator(); 955 syncMenu->insertSeparator();
956 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 956 syncMenu->insertItem( i18n("Multiple sync"), 1 );
957 syncMenu->insertSeparator(); 957 syncMenu->insertSeparator();
958 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 958 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
959 config.setGroup("General"); 959 config.setGroup("General");
960 QStringList prof = config.readListEntry("SyncProfileNames"); 960 QStringList prof = config.readListEntry("SyncProfileNames");
961 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 961 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
962 if ( prof.count() < 3 ) { 962 if ( prof.count() < 3 ) {
963 prof.clear(); 963 prof.clear();
964 prof << i18n("Sharp_DTM"); 964 prof << i18n("Sharp_DTM");
965 prof << i18n("Local_file"); 965 prof << i18n("Local_file");
966 prof << i18n("Last_file"); 966 prof << i18n("Last_file");
967 KSyncProfile* temp = new KSyncProfile (); 967 KSyncProfile* temp = new KSyncProfile ();
968 temp->setName( prof[0] ); 968 temp->setName( prof[0] );
969 temp->writeConfig(&config); 969 temp->writeConfig(&config);
970 temp->setName( prof[1] ); 970 temp->setName( prof[1] );
971 temp->writeConfig(&config); 971 temp->writeConfig(&config);
972 temp->setName( prof[2] ); 972 temp->setName( prof[2] );
973 temp->writeConfig(&config); 973 temp->writeConfig(&config);
974 config.setGroup("General"); 974 config.setGroup("General");
975 config.writeEntry("SyncProfileNames",prof); 975 config.writeEntry("SyncProfileNames",prof);
976 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 976 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
977 config.sync(); 977 config.sync();
978 delete temp; 978 delete temp;
979 } 979 }
980 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 980 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
981 KOPrefs::instance()->mSyncProfileNames = prof; 981 KOPrefs::instance()->mSyncProfileNames = prof;
982 int i; 982 int i;
983 for ( i = 0; i < prof.count(); ++i ) { 983 for ( i = 0; i < prof.count(); ++i ) {
984 984
985 syncMenu->insertItem( prof[i], 1000+i ); 985 syncMenu->insertItem( prof[i], 1000+i );
986 if ( i == 2 ) 986 if ( i == 2 )
987 syncMenu->insertSeparator(); 987 syncMenu->insertSeparator();
988 } 988 }
989 QDir app_dir; 989 QDir app_dir;
990 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 990 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
991 syncMenu->setItemEnabled( false , 1000 ); 991 syncMenu->setItemEnabled( false , 1000 );
992 } 992 }
993 mView->setupExternSyncProfiles();
994} 993}
995 994
996int MainWindow::ringSync() 995int MainWindow::ringSync()
997{ 996{
998 int syncedProfiles = 0; 997 int syncedProfiles = 0;
999 int i; 998 int i;
1000 QTime timer; 999 QTime timer;
1001 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1000 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1002 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 1001 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
1003 KSyncProfile* temp = new KSyncProfile (); 1002 KSyncProfile* temp = new KSyncProfile ();
1004 KOPrefs::instance()->mAskForPreferences = false; 1003 KOPrefs::instance()->mAskForPreferences = false;
1005 for ( i = 0; i < syncProfileNames.count(); ++i ) { 1004 for ( i = 0; i < syncProfileNames.count(); ++i ) {
1006 mCurrentSyncProfile = i; 1005 mCurrentSyncProfile = i;
1007 temp->setName(syncProfileNames[mCurrentSyncProfile]); 1006 temp->setName(syncProfileNames[mCurrentSyncProfile]);
1008 temp->readConfig(&config); 1007 temp->readConfig(&config);
1009 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 1008 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
1010 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 1009 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
1011 ++syncedProfiles; 1010 ++syncedProfiles;
1012 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1011 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1013 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1012 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1014 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1013 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1015 KOPrefs::instance()->mWriteBackInFuture = 0; 1014 KOPrefs::instance()->mWriteBackInFuture = 0;
1016 if ( temp->getWriteBackFuture() ) 1015 if ( temp->getWriteBackFuture() )
1017 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1016 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1018 KOPrefs::instance()->mShowSyncSummary = false; 1017 KOPrefs::instance()->mShowSyncSummary = false;
1019 mView->setSyncDevice(syncProfileNames[i] ); 1018 mView->setSyncDevice(syncProfileNames[i] );
1020 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1019 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1021 if ( i == 0 ) { 1020 if ( i == 0 ) {
1022 syncSharp(); 1021 syncSharp();
1023 } else { 1022 } else {
1024 if ( temp->getIsLocalFileSync() ) { 1023 if ( temp->getIsLocalFileSync() ) {
1025 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 1024 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
1026 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1025 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1027 } else { 1026 } else {
1028 if ( temp->getIsPhoneSync() ) { 1027 if ( temp->getIsPhoneSync() ) {
1029 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1028 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1030 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1029 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1031 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1030 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1032 syncPhone(); 1031 syncPhone();
1033 } else if ( temp->getIsPiSync() ) { 1032 } else if ( temp->getIsPiSync() ) {
1034 mPassWordPiSync = temp->getRemotePw(); 1033 mPassWordPiSync = temp->getRemotePw();
1035 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1034 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1036 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1035 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1037 syncPi(); 1036 syncPi();
1038 } else 1037 } else
1039 syncRemote( temp, false ); 1038 syncRemote( temp, false );
1040 1039
1041 } 1040 }
1042 } 1041 }
1043 timer.start(); 1042 timer.start();
1044 setCaption(i18n("Multiple sync in progress ... please wait!") ); 1043 setCaption(i18n("Multiple sync in progress ... please wait!") );
1045 while ( timer.elapsed () < 2000 ) { 1044 while ( timer.elapsed () < 2000 ) {
1046 qApp->processEvents(); 1045 qApp->processEvents();
1047#ifndef _WIN32_ 1046#ifndef _WIN32_
1048 sleep (1); 1047 sleep (1);
1049#endif 1048#endif
1050 } 1049 }
1051 1050
1052 } 1051 }
1053 1052
1054 } 1053 }
1055 delete temp; 1054 delete temp;
1056 return syncedProfiles; 1055 return syncedProfiles;
1057} 1056}
1058 1057
1059void MainWindow::multiSync( bool askforPrefs ) 1058void MainWindow::multiSync( bool askforPrefs )
1060{ 1059{
1061 if (mBlockSaveFlag) 1060 if (mBlockSaveFlag)
1062 return; 1061 return;
1063 mBlockSaveFlag = true; 1062 mBlockSaveFlag = true;
1064 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 1063 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
1065 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1064 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1066 question, 1065 question,
1067 i18n("Yes"), i18n("No"), 1066 i18n("Yes"), i18n("No"),
1068 0, 0 ) != 0 ) { 1067 0, 0 ) != 0 ) {
1069 mBlockSaveFlag = false; 1068 mBlockSaveFlag = false;
1070 setCaption(i18n("Aborted! Nothing synced!")); 1069 setCaption(i18n("Aborted! Nothing synced!"));
1071 return; 1070 return;
1072 } 1071 }
1073 mView->setSyncDevice(i18n("Multiple profiles") ); 1072 mView->setSyncDevice(i18n("Multiple profiles") );
1074 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 1073 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
1075 if ( askforPrefs ) { 1074 if ( askforPrefs ) {
1076 mView->edit_sync_options(); 1075 mView->edit_sync_options();
1077 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 1076 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
1078 } 1077 }
1079 setCaption(i18n("Multiple sync started.") ); 1078 setCaption(i18n("Multiple sync started.") );
1080 qApp->processEvents(); 1079 qApp->processEvents();
1081 int num = ringSync() ; 1080 int num = ringSync() ;
1082 if ( num > 1 ) 1081 if ( num > 1 )
1083 ringSync(); 1082 ringSync();
1084 mBlockSaveFlag = false; 1083 mBlockSaveFlag = false;
1085 if ( num ) 1084 if ( num )
1086 save(); 1085 save();
1087 if ( num ) 1086 if ( num )
1088 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1087 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
1089 else 1088 else
1090 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1089 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
1091 return; 1090 return;
1092} 1091}
1093void MainWindow::slotSyncMenu( int action ) 1092void MainWindow::slotSyncMenu( int action )
1094{ 1093{
1095 qDebug("syncaction %d ", action); 1094 qDebug("syncaction %d ", action);
1096 if ( action == 0 ) { 1095 if ( action == 0 ) {
1097 1096
1098 // seems to be a Qt2 event handling bug 1097 // seems to be a Qt2 event handling bug
1099 // syncmenu.clear causes a segfault at first time 1098 // syncmenu.clear causes a segfault at first time
1100 // when we call it after the main event loop, it is ok 1099 // when we call it after the main event loop, it is ok
1101 // same behaviour when calling OM/Pi via QCOP for the first time 1100 // same behaviour when calling OM/Pi via QCOP for the first time
1102 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1101 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1103 //confSync(); 1102 //confSync();
1104 1103
1105 return; 1104 return;
1106 } 1105 }
1107 if ( action == 1 ) { 1106 if ( action == 1 ) {
1108 multiSync( true ); 1107 multiSync( true );
1109 return; 1108 return;
1110 } 1109 }
1111 if ( action == 2 ) { 1110 if ( action == 2 ) {
1112 enableQuick(); 1111 enableQuick();
1113 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1112 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1114 return; 1113 return;
1115 } 1114 }
1116 if ( action == 3 ) { 1115 if ( action == 3 ) {
1117 delete mServerSocket; 1116 delete mServerSocket;
1118 mServerSocket = 0; 1117 mServerSocket = 0;
1119 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1118 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1120 return; 1119 return;
1121 } 1120 }
1122 1121
1123 if (mBlockSaveFlag) 1122 if (mBlockSaveFlag)
1124 return; 1123 return;
1125 mBlockSaveFlag = true; 1124 mBlockSaveFlag = true;
1126 mCurrentSyncProfile = action - 1000 ; 1125 mCurrentSyncProfile = action - 1000 ;
1127 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1126 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1128 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1127 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1129 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1128 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1130 KSyncProfile* temp = new KSyncProfile (); 1129 KSyncProfile* temp = new KSyncProfile ();
1131 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1130 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1132 temp->readConfig(&config); 1131 temp->readConfig(&config);
1133 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1132 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1134 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1133 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1135 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1134 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1136 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1135 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1137 KOPrefs::instance()->mWriteBackInFuture = 0; 1136 KOPrefs::instance()->mWriteBackInFuture = 0;
1138 if ( temp->getWriteBackFuture() ) 1137 if ( temp->getWriteBackFuture() )
1139 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1138 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1140 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1139 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1141 if ( action == 1000 ) { 1140 if ( action == 1000 ) {
1142 syncSharp(); 1141 syncSharp();
1143 1142
1144 } else if ( action == 1001 ) { 1143 } else if ( action == 1001 ) {
1145 syncLocalFile(); 1144 syncLocalFile();
1146 1145
1147 } else if ( action == 1002 ) { 1146 } else if ( action == 1002 ) {
1148 quickSyncLocalFile(); 1147 quickSyncLocalFile();
1149 1148
1150 } else if ( action >= 1003 ) { 1149 } else if ( action >= 1003 ) {
1151 if ( temp->getIsLocalFileSync() ) { 1150 if ( temp->getIsLocalFileSync() ) {
1152 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1151 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1153 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1152 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1154 } else { 1153 } else {
1155 if ( temp->getIsPhoneSync() ) { 1154 if ( temp->getIsPhoneSync() ) {
1156 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1155 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1157 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1156 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1158 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1157 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1159 syncPhone(); 1158 syncPhone();
1160 } else if ( temp->getIsPiSync() ) { 1159 } else if ( temp->getIsPiSync() ) {
1161 mPassWordPiSync = temp->getRemotePw(); 1160 mPassWordPiSync = temp->getRemotePw();
1162 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1161 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1163 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1162 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1164 syncPi(); 1163 syncPi();
1165 } else 1164 } else
1166 syncRemote( temp ); 1165 syncRemote( temp );
1167 1166
1168 } 1167 }
1169 } 1168 }
1170 delete temp; 1169 delete temp;
1171 mBlockSaveFlag = false; 1170 mBlockSaveFlag = false;
1172} 1171}
1173void MainWindow::exportToPhone( int mode ) 1172void MainWindow::exportToPhone( int mode )
1174{ 1173{
1175 1174
1176 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1175 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1177 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1176 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1178 KOex2phonePrefs ex2phone; 1177 KOex2phonePrefs ex2phone;
1179 1178
1180 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1179 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1181 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1180 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1182 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1181 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1183 if ( mode == 1 ) 1182 if ( mode == 1 )
1184 ex2phone.setCaption(i18n("Export complete calendar")); 1183 ex2phone.setCaption(i18n("Export complete calendar"));
1185 if ( mode == 2 ) 1184 if ( mode == 2 )
1186 ex2phone.setCaption(i18n("Export filtered calendar")); 1185 ex2phone.setCaption(i18n("Export filtered calendar"));
1187 1186
1188 if ( !ex2phone.exec() ) { 1187 if ( !ex2phone.exec() ) {
1189 return; 1188 return;
1190 } 1189 }
1191 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1190 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1192 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1191 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1193 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1192 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1194 1193
1195 int inFuture = 0; 1194 int inFuture = 0;
1196 if ( ex2phone.mWriteBackFuture->isChecked() ) 1195 if ( ex2phone.mWriteBackFuture->isChecked() )
1197 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1196 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1198 QPtrList<Incidence> delSel; 1197 QPtrList<Incidence> delSel;
1199 if ( mode == 1 ) 1198 if ( mode == 1 )
1200 delSel = mCalendar->rawIncidences(); 1199 delSel = mCalendar->rawIncidences();
1201 if ( mode == 2 ) 1200 if ( mode == 2 )
1202 delSel = mCalendar->incidences(); 1201 delSel = mCalendar->incidences();
1203 CalendarLocal* cal = new CalendarLocal(); 1202 CalendarLocal* cal = new CalendarLocal();
1204 cal->setLocalTime(); 1203 cal->setLocalTime();
1205 Incidence *incidence = delSel.first(); 1204 Incidence *incidence = delSel.first();
1206 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1205 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1207 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1206 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1208 while ( incidence ) { 1207 while ( incidence ) {
1209 if ( incidence->type() != "Journal" ) { 1208 if ( incidence->type() != "Journal" ) {
1210 bool add = true; 1209 bool add = true;
1211 if ( inFuture ) { 1210 if ( inFuture ) {
1212 QDateTime dt; 1211 QDateTime dt;
1213 if ( incidence->type() == "Todo" ) { 1212 if ( incidence->type() == "Todo" ) {
1214 Todo * t = (Todo*)incidence; 1213 Todo * t = (Todo*)incidence;
1215 if ( t->hasDueDate() ) 1214 if ( t->hasDueDate() )
1216 dt = t->dtDue(); 1215 dt = t->dtDue();
1217 else 1216 else
1218 dt = cur.addSecs( 62 ); 1217 dt = cur.addSecs( 62 );
1219 } 1218 }
1220 else { 1219 else {
1221 bool ok; 1220 bool ok;
1222 dt = incidence->getNextOccurence( cur, &ok ); 1221 dt = incidence->getNextOccurence( cur, &ok );
1223 if ( !ok ) 1222 if ( !ok )
1224 dt = cur.addSecs( -62 ); 1223 dt = cur.addSecs( -62 );
1225 } 1224 }
1226 if ( dt < cur || dt > end ) { 1225 if ( dt < cur || dt > end ) {
1227 add = false; 1226 add = false;
1228 } 1227 }
1229 } 1228 }
1230 if ( add ) { 1229 if ( add ) {
1231 Incidence *in = incidence->clone(); 1230 Incidence *in = incidence->clone();
1232 cal->addIncidence( in ); 1231 cal->addIncidence( in );
1233 } 1232 }
1234 } 1233 }
1235 incidence = delSel.next(); 1234 incidence = delSel.next();
1236 } 1235 }
1237 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1236 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1238 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1237 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1239 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1238 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1240 1239
1241 setCaption( i18n("Writing to phone...")); 1240 setCaption( i18n("Writing to phone..."));
1242 if ( PhoneFormat::writeToPhone( cal ) ) 1241 if ( PhoneFormat::writeToPhone( cal ) )
1243 setCaption( i18n("Export to phone successful!")); 1242 setCaption( i18n("Export to phone successful!"));
1244 else 1243 else
1245 setCaption( i18n("Error exporting to phone!")); 1244 setCaption( i18n("Error exporting to phone!"));
1246 delete cal; 1245 delete cal;
1247} 1246}
1248 1247
1249 1248
1250void MainWindow::setDefaultPreferences() 1249void MainWindow::setDefaultPreferences()
1251{ 1250{
1252 KOPrefs *p = KOPrefs::instance(); 1251 KOPrefs *p = KOPrefs::instance();
1253 1252
1254 p->mCompactDialogs = true; 1253 p->mCompactDialogs = true;
1255 p->mConfirm = true; 1254 p->mConfirm = true;
1256 // p->mEnableQuickTodo = false; 1255 // p->mEnableQuickTodo = false;
1257 1256
1258} 1257}
1259 1258
1260QString MainWindow::resourcePath() 1259QString MainWindow::resourcePath()
1261{ 1260{
1262 return KGlobal::iconLoader()->iconPath(); 1261 return KGlobal::iconLoader()->iconPath();
1263} 1262}
1264 1263
1265void MainWindow::displayText( QString text ,QString cap ) 1264void MainWindow::displayText( QString text ,QString cap )
1266{ 1265{
1267 QDialog dia( this, "name", true ); ; 1266 QDialog dia( this, "name", true ); ;
1268 dia.setCaption( cap ); 1267 dia.setCaption( cap );
1269 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1268 QVBoxLayout* lay = new QVBoxLayout( &dia );
1270 lay->setSpacing( 3 ); 1269 lay->setSpacing( 3 );
1271 lay->setMargin( 3 ); 1270 lay->setMargin( 3 );
1272 QTextBrowser tb ( &dia ); 1271 QTextBrowser tb ( &dia );
1273 lay->addWidget( &tb ); 1272 lay->addWidget( &tb );
1274 tb.setText( text ); 1273 tb.setText( text );
1275#ifdef DESKTOP_VERSION 1274#ifdef DESKTOP_VERSION
1276 dia.resize( 640, 480); 1275 dia.resize( 640, 480);
1277#else 1276#else
1278 dia.showMaximized(); 1277 dia.showMaximized();
1279#endif 1278#endif
1280 dia.exec(); 1279 dia.exec();
1281} 1280}
1282void MainWindow::displayFile( QString fn, QString cap ) 1281void MainWindow::displayFile( QString fn, QString cap )
1283{ 1282{
1284 QString fileName = resourcePath() + fn; 1283 QString fileName = resourcePath() + fn;
1285 QString text; 1284 QString text;
1286 QFile file( fileName ); 1285 QFile file( fileName );
1287 if (!file.open( IO_ReadOnly ) ) { 1286 if (!file.open( IO_ReadOnly ) ) {
1288 return ; 1287 return ;
1289 1288
1290 } 1289 }
1291 QTextStream ts( &file ); 1290 QTextStream ts( &file );
1292 text = ts.read(); 1291 text = ts.read();
1293 file.close(); 1292 file.close();
1294 displayText( text, cap); 1293 displayText( text, cap);
1295} 1294}
1296void MainWindow::features() 1295void MainWindow::features()
1297{ 1296{
1298 1297
1299 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1298 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1300} 1299}
1301 1300
1302void MainWindow::usertrans() 1301void MainWindow::usertrans()
1303{ 1302{
1304 1303
1305 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1304 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1306} 1305}
1307 1306
1308void MainWindow::synchowto() 1307void MainWindow::synchowto()
1309{ 1308{
1310#if 0 1309#if 0
1311 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1310 QPtrList<Incidence> er = mCalendar->rawIncidences();
1312 Incidence* inR = er.first(); 1311 Incidence* inR = er.first();
1313 VCalFormat vf; 1312 VCalFormat vf;
1314 QString strout; 1313 QString strout;
1315 while ( inR ) { 1314 while ( inR ) {
1316 if ( inR->type() == "Todo" ) 1315 if ( inR->type() == "Todo" )
1317 strout = vf.todoToString( (Todo *) inR ); 1316 strout = vf.todoToString( (Todo *) inR );
1318 if ( inR->type() == "Event" ) 1317 if ( inR->type() == "Event" )
1319 strout = vf.eventToString( (Event *) inR ); 1318 strout = vf.eventToString( (Event *) inR );
1320 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1319 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1321 inR = er.next(); 1320 inR = er.next();
1322 } 1321 }
1323#endif 1322#endif
1324 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1323 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1325} 1324}
1326void MainWindow::faq() 1325void MainWindow::faq()
1327{ 1326{
1328 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1327 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1329 1328
1330} 1329}
1331void MainWindow::whatsNew() 1330void MainWindow::whatsNew()
1332{ 1331{
1333 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1332 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1334 1333
1335} 1334}
1336void MainWindow::licence() 1335void MainWindow::licence()
1337{ 1336{
1338 KApplication::showLicence(); 1337 KApplication::showLicence();
1339 1338
1340} 1339}
1341void MainWindow::about() 1340void MainWindow::about()
1342{ 1341{
1343 QString version; 1342 QString version;
1344#include <../version> 1343#include <../version>
1345 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1344 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1346 i18n("KOrganizer/Platform-independent\n") + 1345 i18n("KOrganizer/Platform-independent\n") +
1347 "(KO/Pi) " + version + " - " + 1346 "(KO/Pi) " + version + " - " +
1348 1347
1349#ifdef DESKTOP_VERSION 1348#ifdef DESKTOP_VERSION
1350 i18n("Desktop Edition\n") + 1349 i18n("Desktop Edition\n") +
1351#else 1350#else
1352 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1351 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1353#endif 1352#endif
1354 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1353 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1355} 1354}
1356void MainWindow::keyBindings() 1355void MainWindow::keyBindings()
1357{ 1356{
1358 QString cap = i18n("Key bindings KOrganizer/Pi"); 1357 QString cap = i18n("Key bindings KOrganizer/Pi");
1359 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1358 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1360 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1359 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1361 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1360 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1362 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1361 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1363 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1362 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1364 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1363 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1365 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1364 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1366 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1365 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1367 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1366 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1368 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1367 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1369 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1368 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1370 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1369 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1371 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1370 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1372 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1371 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1373 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1372 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1374 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1373 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1375 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1374 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1376 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1375 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1377 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1376 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1378 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1377 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1379 i18n("<p><h3>In agenda view:</h3></p>\n") + 1378 i18n("<p><h3>In agenda view:</h3></p>\n") +
1380 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1379 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1381 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1380 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1382 i18n("<p><h3>In todo view:</h3></p>\n") + 1381 i18n("<p><h3>In todo view:</h3></p>\n") +
1383 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1382 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1384 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1383 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1385 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1384 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1386 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1385 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1387 i18n("<p><h3>In list view:</h3></p>\n") + 1386 i18n("<p><h3>In list view:</h3></p>\n") +
1388 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1387 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1389 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1388 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1390 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1389 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1391 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1390 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1392 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1391 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1393 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1392 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1394 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1393 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1395 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1394 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1396 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1395 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1397 i18n("<p><b>E</b>: Edit item</p>\n") + 1396 i18n("<p><b>E</b>: Edit item</p>\n") +
1398 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1397 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1399 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1398 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1400 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1399 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1401 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1400 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1402 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1401 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1403 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1402 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1404 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1403 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1405 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1404 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1406 i18n("<p><b>White</b>: Item readonly</p>\n"); 1405 i18n("<p><b>White</b>: Item readonly</p>\n");
1407 displayText( text, cap); 1406 displayText( text, cap);
1408 1407
1409} 1408}
1410void MainWindow::aboutAutoSaving() 1409void MainWindow::aboutAutoSaving()
1411{ 1410{
1412 QMessageBox* msg; 1411 QMessageBox* msg;
1413 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1412 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1414 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1413 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1415 QMessageBox::Ok, 1414 QMessageBox::Ok,
1416 QMessageBox::NoButton, 1415 QMessageBox::NoButton,
1417 QMessageBox::NoButton); 1416 QMessageBox::NoButton);
1418 msg->exec(); 1417 msg->exec();
1419 delete msg; 1418 delete msg;
1420 1419
1421 1420
1422} 1421}
1423void MainWindow::aboutKnownBugs() 1422void MainWindow::aboutKnownBugs()
1424{ 1423{
1425 QMessageBox* msg; 1424 QMessageBox* msg;
1426 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1425 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1427 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1426 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1428 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1427 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1429 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1428 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1430 i18n("\nor report them in the bugtracker on\n") + 1429 i18n("\nor report them in the bugtracker on\n") +
1431 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1430 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1432 QMessageBox::NoIcon, 1431 QMessageBox::NoIcon,
1433 QMessageBox::Ok, 1432 QMessageBox::Ok,
1434 QMessageBox::NoButton, 1433 QMessageBox::NoButton,
1435 QMessageBox::NoButton); 1434 QMessageBox::NoButton);
1436 msg->exec(); 1435 msg->exec();
1437 delete msg; 1436 delete msg;
1438 1437
1439} 1438}
1440 1439
1441QString MainWindow::defaultFileName() 1440QString MainWindow::defaultFileName()
1442{ 1441{
1443 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1442 return locateLocal( "data", "korganizer/mycalendar.ics" );
1444} 1443}
1445QString MainWindow::syncFileName() 1444QString MainWindow::syncFileName()
1446{ 1445{
1447#ifdef _WIN32_ 1446#ifdef _WIN32_
1448 return locateLocal( "tmp", "synccalendar.ics" ); 1447 return locateLocal( "tmp", "synccalendar.ics" );
1449#else 1448#else
1450 return QString( "/tmp/kopitempfile.ics" ); 1449 return QString( "/tmp/kopitempfile.ics" );
1451#endif 1450#endif
1452} 1451}
1453 1452
1454void MainWindow::processIncidenceSelection( Incidence *incidence ) 1453void MainWindow::processIncidenceSelection( Incidence *incidence )
1455{ 1454{
1456 if ( !incidence ) { 1455 if ( !incidence ) {
1457 enableIncidenceActions( false ); 1456 enableIncidenceActions( false );
1458 1457
1459 mNewSubTodoAction->setEnabled( false ); 1458 mNewSubTodoAction->setEnabled( false );
1460 setCaptionToDates(); 1459 setCaptionToDates();
1461 return; 1460 return;
1462 1461
1463 } 1462 }
1464 1463
1465 //KGlobal::locale()->formatDateTime(nextA, true); 1464 //KGlobal::locale()->formatDateTime(nextA, true);
1466 QString startString = ""; 1465 QString startString = "";
1467 if ( incidence->type() != "Todo" ) { 1466 if ( incidence->type() != "Todo" ) {
1468 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1467 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1469 if ( incidence->doesFloat() ) { 1468 if ( incidence->doesFloat() ) {
1470 startString += ": "+incidence->dtStartDateStr( true ); 1469 startString += ": "+incidence->dtStartDateStr( true );
1471 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1470 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1472 1471
1473 } else { 1472 } else {
1474 startString = ": "+incidence->dtStartStr(true); 1473 startString = ": "+incidence->dtStartStr(true);
1475 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1474 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1476 1475
1477 } 1476 }
1478 1477
1479 } else { 1478 } else {
1480 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1479 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1481 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1480 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1482 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1481 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1483 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1482 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1484 } 1483 }
1485 1484
1486 } 1485 }
1487 else 1486 else
1488 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1487 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1489 if ( !incidence->location().isEmpty() ) 1488 if ( !incidence->location().isEmpty() )
1490 startString += " (" +incidence->location()+")"; 1489 startString += " (" +incidence->location()+")";
1491 setCaption( incidence->summary()+startString); 1490 setCaption( incidence->summary()+startString);
1492 1491
1493 enableIncidenceActions( true ); 1492 enableIncidenceActions( true );
1494 1493
1495 if ( incidence->type() == "Event" ) { 1494 if ( incidence->type() == "Event" ) {
1496 mShowAction->setText( i18n("Show Event...") ); 1495 mShowAction->setText( i18n("Show Event...") );
1497 mEditAction->setText( i18n("Edit Event...") ); 1496 mEditAction->setText( i18n("Edit Event...") );
1498 mDeleteAction->setText( i18n("Delete Event...") ); 1497 mDeleteAction->setText( i18n("Delete Event...") );
1499 1498
1500 mNewSubTodoAction->setEnabled( false ); 1499 mNewSubTodoAction->setEnabled( false );
1501 } else if ( incidence->type() == "Todo" ) { 1500 } else if ( incidence->type() == "Todo" ) {
1502 mShowAction->setText( i18n("Show Todo...") ); 1501 mShowAction->setText( i18n("Show Todo...") );
1503 mEditAction->setText( i18n("Edit Todo...") ); 1502 mEditAction->setText( i18n("Edit Todo...") );
1504 mDeleteAction->setText( i18n("Delete Todo...") ); 1503 mDeleteAction->setText( i18n("Delete Todo...") );
1505 1504
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index 01c57a3..6f92919 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -1,85 +1,69 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 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 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KPIMPREFS_H 31#ifndef KPIMPREFS_H
32#define KPIMPREFS_H 32#define KPIMPREFS_H
33 33
34#include <qstringlist.h> 34#include <qstringlist.h>
35 35
36#include "kprefs.h" 36#include "kprefs.h"
37 37
38class KPimPrefs : public KPrefs 38class KPimPrefs : public KPrefs
39{ 39{
40 public: 40 public:
41 41
42 KPimPrefs( const QString &name = QString::null ); 42 KPimPrefs( const QString &name = QString::null );
43 43
44 virtual ~KPimPrefs(); 44 virtual ~KPimPrefs();
45 45
46 /** Set preferences to default values */ 46 /** Set preferences to default values */
47 void usrSetDefaults(); 47 void usrSetDefaults();
48 48
49 /** Read preferences from config file */ 49 /** Read preferences from config file */
50 void usrReadConfig(); 50 void usrReadConfig();
51 51
52 /** Write preferences to config file */ 52 /** Write preferences to config file */
53 void usrWriteConfig(); 53 void usrWriteConfig();
54 54
55 55
56 public: 56 public:
57 QStringList mCustomCategories; 57 QStringList mCustomCategories;
58 58
59 // sync stuff 59
60 QString mLocalMachineName;
61 QStringList mExternSyncProfiles;
62 QStringList mSyncProfileNames;
63 bool mAskForPreferences;
64 bool mShowSyncSummary;
65 bool mShowSyncEvents;
66 bool mShowTodoInAgenda;
67 bool mWriteBackExistingOnly;
68 int mSyncAlgoPrefs;
69 int mRingSyncAlgoPrefs;
70 bool mWriteBackFile;
71 int mWriteBackInFuture;
72 QString mPhoneDevice;
73 QString mPhoneConnection;
74 QString mPhoneModel;
75 QString mLastSyncedLocalFile; // save!
76 60
77 61
78 protected: 62 protected:
79 virtual void setCategoryDefaults(); 63 virtual void setCategoryDefaults();
80 64
81 65
82 66
83}; 67};
84 68
85#endif 69#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 07e6761..c0cc840 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,665 +1,663 @@
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 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 35
36#include <qdir.h> 36#include <qdir.h>
37#include <qprogressbar.h> 37#include <qprogressbar.h>
38#include <qpopupmenu.h> 38#include <qpopupmenu.h>
39#include <qpushbutton.h> 39#include <qpushbutton.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qbuttongroup.h> 41#include <qbuttongroup.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qmessagebox.h> 43#include <qmessagebox.h>
44#include <qapplication.h> 44#include <qapplication.h>
45#include <qlineedit.h> 45#include <qlineedit.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <qlayout.h> 47#include <qlayout.h>
48 48
49#include <klocale.h> 49#include <klocale.h>
50#include <kglobal.h> 50#include <kglobal.h>
51#include <kconfig.h> 51#include <kconfig.h>
52#include <kfiledialog.h> 52#include <kfiledialog.h>
53 53
54KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 54KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
55 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs), mSyncMenu(syncmenu) 55 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
56{ 56{
57 bar = new QProgressBar ( 1, 0 ); 57 bar = new QProgressBar ( 1, 0 );
58 bar->setCaption (""); 58 bar->setCaption ("");
59 59
60 int w = 300; 60 int w = 300;
61 if ( QApplication::desktop()->width() < 320 ) 61 if ( QApplication::desktop()->width() < 320 )
62 w = 220; 62 w = 220;
63 int h = bar->sizeHint().height() ; 63 int h = bar->sizeHint().height() ;
64 int dw = QApplication::desktop()->width(); 64 int dw = QApplication::desktop()->width();
65 int dh = QApplication::desktop()->height(); 65 int dh = QApplication::desktop()->height();
66 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 66 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
67 67
68} 68}
69 69
70KSyncManager::~KSyncManager() 70KSyncManager::~KSyncManager()
71{ 71{
72 delete bar; 72 delete bar;
73} 73}
74 74
75 75
76void KSyncManager::fillSyncMenu() 76void KSyncManager::fillSyncMenu()
77{ 77{
78 if ( mSyncMenu->count() ) 78 if ( mSyncMenu->count() )
79 mSyncMenu->clear(); 79 mSyncMenu->clear();
80 80
81 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 81 mSyncMenu->insertItem( i18n("Configure..."), 0 );
82 mSyncMenu->insertSeparator(); 82 mSyncMenu->insertSeparator();
83 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 83 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
84 mSyncMenu->insertSeparator(); 84 mSyncMenu->insertSeparator();
85 85
86 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 86 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
87 config.setGroup("General"); 87 config.setGroup("General");
88 QStringList prof = config.readListEntry("SyncProfileNames"); 88 QStringList prof = config.readListEntry("SyncProfileNames");
89 mPrefs->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 89 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
90 if ( prof.count() < 3 ) { 90 if ( prof.count() < 3 ) {
91 prof.clear(); 91 prof.clear();
92 prof << i18n("Sharp_DTM"); 92 prof << i18n("Sharp_DTM");
93 prof << i18n("Local_file"); 93 prof << i18n("Local_file");
94 prof << i18n("Last_file"); 94 prof << i18n("Last_file");
95 KSyncProfile* temp = new KSyncProfile (); 95 KSyncProfile* temp = new KSyncProfile ();
96 temp->setName( prof[0] ); 96 temp->setName( prof[0] );
97 temp->writeConfig(&config); 97 temp->writeConfig(&config);
98 temp->setName( prof[1] ); 98 temp->setName( prof[1] );
99 temp->writeConfig(&config); 99 temp->writeConfig(&config);
100 temp->setName( prof[2] ); 100 temp->setName( prof[2] );
101 temp->writeConfig(&config); 101 temp->writeConfig(&config);
102 config.setGroup("General"); 102 config.setGroup("General");
103 config.writeEntry("SyncProfileNames",prof); 103 config.writeEntry("SyncProfileNames",prof);
104 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 104 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
105 config.sync(); 105 config.sync();
106 delete temp; 106 delete temp;
107 } 107 }
108 mPrefs->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 108 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
109 mPrefs->mSyncProfileNames = prof; 109 mSyncProfileNames = prof;
110 unsigned int i; 110 unsigned int i;
111 for ( i = 0; i < prof.count(); ++i ) { 111 for ( i = 0; i < prof.count(); ++i ) {
112 mSyncMenu->insertItem( prof[i], 1000+i ); 112 mSyncMenu->insertItem( prof[i], 1000+i );
113 if ( i == 2 ) 113 if ( i == 2 )
114 mSyncMenu->insertSeparator(); 114 mSyncMenu->insertSeparator();
115 } 115 }
116 QDir app_dir; 116 QDir app_dir;
117 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 117 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
118 if ( mTargetApp == PWMPI) { 118 if ( mTargetApp == PWMPI) {
119 mSyncMenu->removeItem( 1000 ); 119 mSyncMenu->removeItem( 1000 );
120 } 120 }
121 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 121 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
122 mSyncMenu->setItemEnabled( 1000, false ); 122 mSyncMenu->setItemEnabled( 1000, false );
123 } 123 }
124 //probaly useless
125 //mView->setupExternSyncProfiles();
126} 124}
127 125
128void KSyncManager::slotSyncMenu( int action ) 126void KSyncManager::slotSyncMenu( int action )
129{ 127{
130 //qDebug("syncaction %d ", action); 128 //qDebug("syncaction %d ", action);
131 if ( action == 0 ) { 129 if ( action == 0 ) {
132 130
133 // seems to be a Qt2 event handling bug 131 // seems to be a Qt2 event handling bug
134 // syncmenu.clear causes a segfault at first time 132 // syncmenu.clear causes a segfault at first time
135 // when we call it after the main event loop, it is ok 133 // when we call it after the main event loop, it is ok
136 // same behaviour when calling OM/Pi via QCOP for the first time 134 // same behaviour when calling OM/Pi via QCOP for the first time
137 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 135 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
138 //confSync(); 136 //confSync();
139 137
140 return; 138 return;
141 } 139 }
142 if ( action == 1 ) { 140 if ( action == 1 ) {
143 multiSync( true ); 141 multiSync( true );
144 return; 142 return;
145 } 143 }
146 144
147 if (blockSave()) 145 if (blockSave())
148 return; 146 return;
149 147
150 setBlockSave(true); 148 setBlockSave(true);
151 149
152 mCurrentSyncProfile = action - 1000 ; 150 mCurrentSyncProfile = action - 1000 ;
153 mCurrentSyncDevice = mPrefs->mSyncProfileNames[mCurrentSyncProfile] ; 151 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
154 mCurrentSyncName = mPrefs->mLocalMachineName ; 152 mCurrentSyncName = mLocalMachineName ;
155 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 153 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
156 KSyncProfile* temp = new KSyncProfile (); 154 KSyncProfile* temp = new KSyncProfile ();
157 temp->setName(mPrefs->mSyncProfileNames[mCurrentSyncProfile]); 155 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
158 temp->readConfig(&config); 156 temp->readConfig(&config);
159 mPrefs->mAskForPreferences = temp->getAskForPreferences(); 157 mAskForPreferences = temp->getAskForPreferences();
160 mPrefs->mSyncAlgoPrefs = temp->getSyncPrefs(); 158 mSyncAlgoPrefs = temp->getSyncPrefs();
161 mPrefs->mWriteBackFile = temp->getWriteBackFile(); 159 mWriteBackFile = temp->getWriteBackFile();
162 mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); 160 mWriteBackExistingOnly = temp->getWriteBackExisting();
163 mPrefs->mWriteBackInFuture = 0; 161 mWriteBackInFuture = 0;
164 if ( temp->getWriteBackFuture() ) 162 if ( temp->getWriteBackFuture() )
165 mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 163 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
166 mPrefs->mShowSyncSummary = temp->getShowSummaryAfterSync(); 164 mShowSyncSummary = temp->getShowSummaryAfterSync();
167 if ( action == 1000 ) { 165 if ( action == 1000 ) {
168 syncSharp(); 166 syncSharp();
169 167
170 } else if ( action == 1001 ) { 168 } else if ( action == 1001 ) {
171 syncLocalFile(); 169 syncLocalFile();
172 170
173 } else if ( action == 1002 ) { 171 } else if ( action == 1002 ) {
174 quickSyncLocalFile(); 172 quickSyncLocalFile();
175 173
176 } else if ( action >= 1003 ) { 174 } else if ( action >= 1003 ) {
177 if ( temp->getIsLocalFileSync() ) { 175 if ( temp->getIsLocalFileSync() ) {
178 switch(mTargetApp) 176 switch(mTargetApp)
179 { 177 {
180 case (KAPI): 178 case (KAPI):
181 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 179 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
182 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 180 mLastSyncedLocalFile = temp->getRemoteFileNameAB();
183 break; 181 break;
184 case (KOPI): 182 case (KOPI):
185 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 183 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
186 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 184 mLastSyncedLocalFile = temp->getRemoteFileName();
187 break; 185 break;
188 case (PWMPI): 186 case (PWMPI):
189 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 187 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
190 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 188 mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
191 break; 189 break;
192 default: 190 default:
193 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 191 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
194 break; 192 break;
195 193
196 } 194 }
197 } else { 195 } else {
198 if ( temp->getIsPhoneSync() ) { 196 if ( temp->getIsPhoneSync() ) {
199 mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; 197 mPhoneDevice = temp->getPhoneDevice( ) ;
200 mPrefs->mPhoneConnection = temp->getPhoneConnection( ); 198 mPhoneConnection = temp->getPhoneConnection( );
201 mPrefs->mPhoneModel = temp->getPhoneModel( ); 199 mPhoneModel = temp->getPhoneModel( );
202 syncPhone(); 200 syncPhone();
203 } else 201 } else
204 syncRemote( temp ); 202 syncRemote( temp );
205 203
206 } 204 }
207 } 205 }
208 delete temp; 206 delete temp;
209 setBlockSave(false); 207 setBlockSave(false);
210} 208}
211 209
212void KSyncManager::syncLocalFile() 210void KSyncManager::syncLocalFile()
213{ 211{
214 212
215 QString fn =mPrefs->mLastSyncedLocalFile; 213 QString fn =mLastSyncedLocalFile;
216 QString ext; 214 QString ext;
217 215
218 switch(mTargetApp) 216 switch(mTargetApp)
219 { 217 {
220 case (KAPI): 218 case (KAPI):
221 ext = "(*.vcf)"; 219 ext = "(*.vcf)";
222 break; 220 break;
223 case (KOPI): 221 case (KOPI):
224 ext = "(*.ics/*.vcs)"; 222 ext = "(*.ics/*.vcs)";
225 break; 223 break;
226 case (PWMPI): 224 case (PWMPI):
227 ext = "(*.pwm)"; 225 ext = "(*.pwm)";
228 break; 226 break;
229 default: 227 default:
230 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 228 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
231 break; 229 break;
232 230
233 } 231 }
234 232
235 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 233 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
236 if ( fn == "" ) 234 if ( fn == "" )
237 return; 235 return;
238 if ( syncWithFile( fn, false ) ) { 236 if ( syncWithFile( fn, false ) ) {
239 qDebug("syncLocalFile() successful "); 237 qDebug("syncLocalFile() successful ");
240 } 238 }
241 239
242} 240}
243bool KSyncManager::syncWithFile( QString fn , bool quick ) 241bool KSyncManager::syncWithFile( QString fn , bool quick )
244{ 242{
245 bool ret = false; 243 bool ret = false;
246 QFileInfo info; 244 QFileInfo info;
247 info.setFile( fn ); 245 info.setFile( fn );
248 QString mess; 246 QString mess;
249 bool loadbup = true; 247 bool loadbup = true;
250 if ( !info. exists() ) { 248 if ( !info. exists() ) {
251 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 249 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
252 int result = QMessageBox::warning( mParent, i18n("Warning!"), 250 int result = QMessageBox::warning( mParent, i18n("Warning!"),
253 mess ); 251 mess );
254 return ret; 252 return ret;
255 } 253 }
256 int result = 0; 254 int result = 0;
257 if ( !quick ) { 255 if ( !quick ) {
258 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 256 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
259 result = QMessageBox::warning( mParent, i18n("Warning!"), 257 result = QMessageBox::warning( mParent, i18n("Warning!"),
260 mess, 258 mess,
261 i18n("Sync"), i18n("Cancel"), 0, 259 i18n("Sync"), i18n("Cancel"), 0,
262 0, 1 ); 260 0, 1 );
263 if ( result ) 261 if ( result )
264 return false; 262 return false;
265 } 263 }
266 if ( mPrefs->mAskForPreferences ) 264 if ( mAskForPreferences )
267 edit_sync_options(); 265 edit_sync_options();
268 if ( result == 0 ) { 266 if ( result == 0 ) {
269 //qDebug("Now sycing ... "); 267 //qDebug("Now sycing ... ");
270 if ( ret = mImplementation->sync( this, fn, mPrefs->mSyncAlgoPrefs ) ) 268 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
271 mParent->setCaption( i18n("Synchronization successful") ); 269 mParent->setCaption( i18n("Synchronization successful") );
272 else 270 else
273 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 271 mParent->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
274 if ( ! quick ) 272 if ( ! quick )
275 mPrefs->mLastSyncedLocalFile = fn; 273 mLastSyncedLocalFile = fn;
276 mImplementation->sync_setModified(); 274 mImplementation->sync_setModified();
277 } 275 }
278 return ret; 276 return ret;
279} 277}
280void KSyncManager::quickSyncLocalFile() 278void KSyncManager::quickSyncLocalFile()
281{ 279{
282 280
283 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) { 281 if ( syncWithFile( mLastSyncedLocalFile, false ) ) {
284 qDebug("quick syncLocalFile() successful "); 282 qDebug("quick syncLocalFile() successful ");
285 283
286 } 284 }
287} 285}
288void KSyncManager::multiSync( bool askforPrefs ) 286void KSyncManager::multiSync( bool askforPrefs )
289{ 287{
290 if (blockSave()) 288 if (blockSave())
291 return; 289 return;
292 setBlockSave(true); 290 setBlockSave(true);
293 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 291 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
294 if ( QMessageBox::information( mParent, i18n("Sync"), 292 if ( QMessageBox::information( mParent, i18n("Sync"),
295 question, 293 question,
296 i18n("Yes"), i18n("No"), 294 i18n("Yes"), i18n("No"),
297 0, 0 ) != 0 ) { 295 0, 0 ) != 0 ) {
298 setBlockSave(false); 296 setBlockSave(false);
299 mParent->setCaption(i18n("Aborted! Nothing synced!")); 297 mParent->setCaption(i18n("Aborted! Nothing synced!"));
300 return; 298 return;
301 } 299 }
302 mCurrentSyncDevice = i18n("Multiple profiles") ; 300 mCurrentSyncDevice = i18n("Multiple profiles") ;
303 mPrefs->mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 301 mSyncAlgoPrefs = mRingSyncAlgoPrefs;
304 if ( askforPrefs ) { 302 if ( askforPrefs ) {
305 edit_sync_options(); 303 edit_sync_options();
306 mPrefs->mRingSyncAlgoPrefs = mPrefs->mSyncAlgoPrefs; 304 mRingSyncAlgoPrefs = mSyncAlgoPrefs;
307 } 305 }
308 mParent->setCaption(i18n("Multiple sync started.") ); 306 mParent->setCaption(i18n("Multiple sync started.") );
309 qApp->processEvents(); 307 qApp->processEvents();
310 int num = ringSync() ; 308 int num = ringSync() ;
311 if ( num > 1 ) 309 if ( num > 1 )
312 ringSync(); 310 ringSync();
313 setBlockSave(false); 311 setBlockSave(false);
314 if ( num ) 312 if ( num )
315 mImplementation->sync_save(); 313 mImplementation->sync_save();
316 if ( num ) 314 if ( num )
317 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 315 mParent->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
318 else 316 else
319 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 317 mParent->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
320 return; 318 return;
321} 319}
322int KSyncManager::ringSync() 320int KSyncManager::ringSync()
323{ 321{
324 int syncedProfiles = 0; 322 int syncedProfiles = 0;
325 unsigned int i; 323 unsigned int i;
326 QTime timer; 324 QTime timer;
327 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 325 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
328 QStringList syncProfileNames = mPrefs->mSyncProfileNames; 326 QStringList syncProfileNames = mSyncProfileNames;
329 KSyncProfile* temp = new KSyncProfile (); 327 KSyncProfile* temp = new KSyncProfile ();
330 mPrefs->mAskForPreferences = false; 328 mAskForPreferences = false;
331 for ( i = 0; i < syncProfileNames.count(); ++i ) { 329 for ( i = 0; i < syncProfileNames.count(); ++i ) {
332 mCurrentSyncProfile = i; 330 mCurrentSyncProfile = i;
333 temp->setName(syncProfileNames[mCurrentSyncProfile]); 331 temp->setName(syncProfileNames[mCurrentSyncProfile]);
334 temp->readConfig(&config); 332 temp->readConfig(&config);
335 333
336 QString includeInRingSync; 334 QString includeInRingSync;
337 switch(mTargetApp) 335 switch(mTargetApp)
338 { 336 {
339 case (KAPI): 337 case (KAPI):
340 includeInRingSync = temp->getIncludeInRingSyncAB(); 338 includeInRingSync = temp->getIncludeInRingSyncAB();
341 break; 339 break;
342 case (KOPI): 340 case (KOPI):
343 includeInRingSync = temp->getIncludeInRingSync(); 341 includeInRingSync = temp->getIncludeInRingSync();
344 break; 342 break;
345 case (PWMPI): 343 case (PWMPI):
346 includeInRingSync = temp->getIncludeInRingSyncPWM(); 344 includeInRingSync = temp->getIncludeInRingSyncPWM();
347 break; 345 break;
348 default: 346 default:
349 qDebug("KSyncManager::ringSync: invalid apptype selected"); 347 qDebug("KSyncManager::ringSync: invalid apptype selected");
350 break; 348 break;
351 349
352 } 350 }
353 351
354 352
355 if ( includeInRingSync && ( i < 1 || i > 2 )) { 353 if ( includeInRingSync && ( i < 1 || i > 2 )) {
356 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 354 mParent->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
357 ++syncedProfiles; 355 ++syncedProfiles;
358 // mPrefs->mAskForPreferences = temp->getAskForPreferences(); 356 // mAskForPreferences = temp->getAskForPreferences();
359 mPrefs->mWriteBackFile = temp->getWriteBackFile(); 357 mWriteBackFile = temp->getWriteBackFile();
360 mPrefs->mWriteBackExistingOnly = temp->getWriteBackExisting(); 358 mWriteBackExistingOnly = temp->getWriteBackExisting();
361 mPrefs->mWriteBackInFuture = 0; 359 mWriteBackInFuture = 0;
362 if ( temp->getWriteBackFuture() ) 360 if ( temp->getWriteBackFuture() )
363 mPrefs->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 361 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
364 mPrefs->mShowSyncSummary = false; 362 mShowSyncSummary = false;
365 mCurrentSyncDevice = syncProfileNames[i] ; 363 mCurrentSyncDevice = syncProfileNames[i] ;
366 mCurrentSyncName = mPrefs->mLocalMachineName; 364 mCurrentSyncName = mLocalMachineName;
367 if ( i == 0 ) { 365 if ( i == 0 ) {
368 syncSharp(); 366 syncSharp();
369 } else { 367 } else {
370 if ( temp->getIsLocalFileSync() ) { 368 if ( temp->getIsLocalFileSync() ) {
371 switch(mTargetApp) 369 switch(mTargetApp)
372 { 370 {
373 case (KAPI): 371 case (KAPI):
374 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 372 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
375 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 373 mLastSyncedLocalFile = temp->getRemoteFileNameAB();
376 break; 374 break;
377 case (KOPI): 375 case (KOPI):
378 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 376 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
379 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 377 mLastSyncedLocalFile = temp->getRemoteFileName();
380 break; 378 break;
381 case (PWMPI): 379 case (PWMPI):
382 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 380 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
383 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 381 mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
384 break; 382 break;
385 default: 383 default:
386 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 384 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
387 break; 385 break;
388 } 386 }
389 } else { 387 } else {
390 if ( temp->getIsPhoneSync() ) { 388 if ( temp->getIsPhoneSync() ) {
391 mPrefs->mPhoneDevice = temp->getPhoneDevice( ) ; 389 mPhoneDevice = temp->getPhoneDevice( ) ;
392 mPrefs->mPhoneConnection = temp->getPhoneConnection( ); 390 mPhoneConnection = temp->getPhoneConnection( );
393 mPrefs->mPhoneModel = temp->getPhoneModel( ); 391 mPhoneModel = temp->getPhoneModel( );
394 syncPhone(); 392 syncPhone();
395 } else 393 } else
396 syncRemote( temp, false ); 394 syncRemote( temp, false );
397 395
398 } 396 }
399 } 397 }
400 timer.start(); 398 timer.start();
401 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") ); 399 mParent->setCaption(i18n("Multiple sync in progress ... please wait!") );
402 while ( timer.elapsed () < 2000 ) { 400 while ( timer.elapsed () < 2000 ) {
403 qApp->processEvents(); 401 qApp->processEvents();
404#ifndef _WIN32_ 402#ifndef _WIN32_
405 sleep (1); 403 sleep (1);
406#endif 404#endif
407 } 405 }
408 406
409 } 407 }
410 408
411 } 409 }
412 delete temp; 410 delete temp;
413 return syncedProfiles; 411 return syncedProfiles;
414} 412}
415 413
416void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 414void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
417{ 415{
418 QString question; 416 QString question;
419 if ( ask ) { 417 if ( ask ) {
420 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 418 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
421 if ( QMessageBox::information( mParent, i18n("Sync"), 419 if ( QMessageBox::information( mParent, i18n("Sync"),
422 question, 420 question,
423 i18n("Yes"), i18n("No"), 421 i18n("Yes"), i18n("No"),
424 0, 0 ) != 0 ) 422 0, 0 ) != 0 )
425 return; 423 return;
426 } 424 }
427 425
428 QString preCommand; 426 QString preCommand;
429 QString localTempFile; 427 QString localTempFile;
430 QString postCommand; 428 QString postCommand;
431 429
432 switch(mTargetApp) 430 switch(mTargetApp)
433 { 431 {
434 case (KAPI): 432 case (KAPI):
435 preCommand = prof->getPreSyncCommandAB(); 433 preCommand = prof->getPreSyncCommandAB();
436 postCommand = prof->getPostSyncCommandAB(); 434 postCommand = prof->getPostSyncCommandAB();
437 localTempFile = prof->getLocalTempFileAB(); 435 localTempFile = prof->getLocalTempFileAB();
438 break; 436 break;
439 case (KOPI): 437 case (KOPI):
440 preCommand = prof->getPreSyncCommand(); 438 preCommand = prof->getPreSyncCommand();
441 postCommand = prof->getPostSyncCommand(); 439 postCommand = prof->getPostSyncCommand();
442 localTempFile = prof->getLocalTempFile(); 440 localTempFile = prof->getLocalTempFile();
443 break; 441 break;
444 case (PWMPI): 442 case (PWMPI):
445 preCommand = prof->getPreSyncCommandPWM(); 443 preCommand = prof->getPreSyncCommandPWM();
446 postCommand = prof->getPostSyncCommandPWM(); 444 postCommand = prof->getPostSyncCommandPWM();
447 localTempFile = prof->getLocalTempFilePWM(); 445 localTempFile = prof->getLocalTempFilePWM();
448 break; 446 break;
449 default: 447 default:
450 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 448 qDebug("KSyncManager::syncRemote: invalid apptype selected");
451 break; 449 break;
452 } 450 }
453 451
454 452
455 int fi; 453 int fi;
456 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 454 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
457 QString pwd = getPassword(); 455 QString pwd = getPassword();
458 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 456 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
459 457
460 } 458 }
461 int maxlen = 30; 459 int maxlen = 30;
462 if ( QApplication::desktop()->width() > 320 ) 460 if ( QApplication::desktop()->width() > 320 )
463 maxlen += 25; 461 maxlen += 25;
464 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) ); 462 mParent->setCaption ( i18n( "Copy remote file to local machine..." ) );
465 int fileSize = 0; 463 int fileSize = 0;
466 int result = system ( preCommand ); 464 int result = system ( preCommand );
467 // 0 : okay 465 // 0 : okay
468 // 256: no such file or dir 466 // 256: no such file or dir
469 // 467 //
470 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 468 qDebug("KO: Remote copy result(0 = okay): %d ",result );
471 if ( result != 0 ) { 469 if ( result != 0 ) {
472 unsigned int len = maxlen; 470 unsigned int len = maxlen;
473 while ( len < preCommand.length() ) { 471 while ( len < preCommand.length() ) {
474 preCommand.insert( len , "\n" ); 472 preCommand.insert( len , "\n" );
475 len += maxlen +2; 473 len += maxlen +2;
476 } 474 }
477 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) ; 475 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) ;
478 QMessageBox::information( mParent, i18n("Sync - ERROR"), 476 QMessageBox::information( mParent, i18n("Sync - ERROR"),
479 question, 477 question,
480 i18n("Okay!")) ; 478 i18n("Okay!")) ;
481 mParent->setCaption (""); 479 mParent->setCaption ("");
482 return; 480 return;
483 } 481 }
484 mParent->setCaption ( i18n( "Copying succeed." ) ); 482 mParent->setCaption ( i18n( "Copying succeed." ) );
485 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 483 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
486 484
487 485
488 486
489 if ( syncWithFile( localTempFile, true ) ) { 487 if ( syncWithFile( localTempFile, true ) ) {
490// Event* e = mView->getLastSyncEvent(); 488// Event* e = mView->getLastSyncEvent();
491// e->setReadOnly( false ); 489// e->setReadOnly( false );
492// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 490// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
493// e->setReadOnly( true ); 491// e->setReadOnly( true );
494 if ( mPrefs->mWriteBackFile ) { 492 if ( mWriteBackFile ) {
495 int fi; 493 int fi;
496 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 494 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
497 QString pwd = getPassword(); 495 QString pwd = getPassword();
498 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 496 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
499 497
500 } 498 }
501 mParent->setCaption ( i18n( "Writing back file ..." ) ); 499 mParent->setCaption ( i18n( "Writing back file ..." ) );
502 result = system ( postCommand ); 500 result = system ( postCommand );
503 qDebug("Writing back file result: %d ", result); 501 qDebug("Writing back file result: %d ", result);
504 if ( result != 0 ) { 502 if ( result != 0 ) {
505 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 503 mParent->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
506 return; 504 return;
507 } else { 505 } else {
508 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 506 mParent->setCaption ( i18n( "Syncronization sucessfully completed" ) );
509 } 507 }
510 } 508 }
511 } 509 }
512 return; 510 return;
513} 511}
514 512
515void KSyncManager::edit_sync_options() 513void KSyncManager::edit_sync_options()
516{ 514{
517 //mDialogManager->showSyncOptions(); 515 //mDialogManager->showSyncOptions();
518 //mPrefs->mSyncAlgoPrefs 516 //mSyncAlgoPrefs
519 QDialog dia( mParent, "dia", true ); 517 QDialog dia( mParent, "dia", true );
520 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 518 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
521 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 519 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
522 QVBoxLayout lay ( &dia ); 520 QVBoxLayout lay ( &dia );
523 lay.setSpacing( 2 ); 521 lay.setSpacing( 2 );
524 lay.setMargin( 3 ); 522 lay.setMargin( 3 );
525 lay.addWidget(&gr); 523 lay.addWidget(&gr);
526 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 524 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
527 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 525 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
528 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 526 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
529 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 527 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
530 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 528 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
531 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 529 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
532 //QRadioButton both( i18n("Take both on conflict"), &gr ); 530 //QRadioButton both( i18n("Take both on conflict"), &gr );
533 QPushButton pb ( "OK", &dia); 531 QPushButton pb ( "OK", &dia);
534 lay.addWidget( &pb ); 532 lay.addWidget( &pb );
535 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 533 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
536 switch ( mPrefs->mSyncAlgoPrefs ) { 534 switch ( mSyncAlgoPrefs ) {
537 case 0: 535 case 0:
538 loc.setChecked( true); 536 loc.setChecked( true);
539 break; 537 break;
540 case 1: 538 case 1:
541 rem.setChecked( true ); 539 rem.setChecked( true );
542 break; 540 break;
543 case 2: 541 case 2:
544 newest.setChecked( true); 542 newest.setChecked( true);
545 break; 543 break;
546 case 3: 544 case 3:
547 ask.setChecked( true); 545 ask.setChecked( true);
548 break; 546 break;
549 case 4: 547 case 4:
550 f_loc.setChecked( true); 548 f_loc.setChecked( true);
551 break; 549 break;
552 case 5: 550 case 5:
553 f_rem.setChecked( true); 551 f_rem.setChecked( true);
554 break; 552 break;
555 case 6: 553 case 6:
556 // both.setChecked( true); 554 // both.setChecked( true);
557 break; 555 break;
558 default: 556 default:
559 break; 557 break;
560 } 558 }
561 if ( dia.exec() ) { 559 if ( dia.exec() ) {
562 mPrefs->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 560 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
563 } 561 }
564 562
565 563
566} 564}
567QString KSyncManager::getPassword( ) 565QString KSyncManager::getPassword( )
568{ 566{
569 QString retfile = ""; 567 QString retfile = "";
570 QDialog dia ( mParent, "input-dialog", true ); 568 QDialog dia ( mParent, "input-dialog", true );
571 QLineEdit lab ( &dia ); 569 QLineEdit lab ( &dia );
572 lab.setEchoMode( QLineEdit::Password ); 570 lab.setEchoMode( QLineEdit::Password );
573 QVBoxLayout lay( &dia ); 571 QVBoxLayout lay( &dia );
574 lay.setMargin(7); 572 lay.setMargin(7);
575 lay.setSpacing(7); 573 lay.setSpacing(7);
576 lay.addWidget( &lab); 574 lay.addWidget( &lab);
577 dia.setFixedSize( 230,50 ); 575 dia.setFixedSize( 230,50 );
578 dia.setCaption( i18n("Enter password") ); 576 dia.setCaption( i18n("Enter password") );
579 QPushButton pb ( "OK", &dia); 577 QPushButton pb ( "OK", &dia);
580 lay.addWidget( &pb ); 578 lay.addWidget( &pb );
581 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 579 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
582 dia.show(); 580 dia.show();
583 int res = dia.exec(); 581 int res = dia.exec();
584 if ( res ) 582 if ( res )
585 retfile = lab.text(); 583 retfile = lab.text();
586 dia.hide(); 584 dia.hide();
587 qApp->processEvents(); 585 qApp->processEvents();
588 return retfile; 586 return retfile;
589 587
590} 588}
591 589
592 590
593void KSyncManager::confSync() 591void KSyncManager::confSync()
594{ 592{
595 static KSyncPrefsDialog* sp = 0; 593 static KSyncPrefsDialog* sp = 0;
596 if ( ! sp ) { 594 if ( ! sp ) {
597 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 595 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
598 } 596 }
599 sp->usrReadConfig(); 597 sp->usrReadConfig();
600#ifndef DESKTOP_VERSION 598#ifndef DESKTOP_VERSION
601 sp->showMaximized(); 599 sp->showMaximized();
602#else 600#else
603 sp->show(); 601 sp->show();
604#endif 602#endif
605 sp->exec(); 603 sp->exec();
606 mPrefs->mSyncProfileNames = sp->getSyncProfileNames(); 604 mSyncProfileNames = sp->getSyncProfileNames();
607 mPrefs->mLocalMachineName = sp->getLocalMachineName (); 605 mLocalMachineName = sp->getLocalMachineName ();
608 fillSyncMenu(); 606 fillSyncMenu();
609} 607}
610 608
611void KSyncManager::syncSharp() 609void KSyncManager::syncSharp()
612{ 610{
613 if ( ! syncExternalApplication("sharp") ) 611 if ( ! syncExternalApplication("sharp") )
614 qDebug("ERROR sync sharp ");; 612 qDebug("ERROR sync sharp ");;
615} 613}
616 614
617bool KSyncManager::syncExternalApplication(QString resource) 615bool KSyncManager::syncExternalApplication(QString resource)
618{ 616{
619 if ( mImplementation->sync_isModified() ) 617 if ( mImplementation->sync_isModified() )
620 mImplementation->sync_save(); 618 mImplementation->sync_save();
621 619
622 if ( mPrefs->mAskForPreferences ) 620 if ( mAskForPreferences )
623 edit_sync_options(); 621 edit_sync_options();
624 622
625 qDebug("sync %s", resource.latin1()); 623 qDebug("sync %s", resource.latin1());
626 624
627 bool syncOK = mImplementation->syncExternal(this, resource); 625 bool syncOK = mImplementation->syncExternal(this, resource);
628 626
629 return syncOK; 627 return syncOK;
630 628
631} 629}
632 630
633void KSyncManager::syncPhone() 631void KSyncManager::syncPhone()
634{ 632{
635 if ( mImplementation->sync_isModified() ) 633 if ( mImplementation->sync_isModified() )
636 mImplementation->sync_save(); 634 mImplementation->sync_save();
637 635
638 qDebug("pending syncPhone(); "); 636 qDebug("pending syncPhone(); ");
639 //mView->syncPhone(); 637 //mView->syncPhone();
640 mImplementation->sync_setModified(); 638 mImplementation->sync_setModified();
641 639
642} 640}
643 641
644void KSyncManager::showProgressBar(int percentage, QString caption, int total) 642void KSyncManager::showProgressBar(int percentage, QString caption, int total)
645{ 643{
646 if (!bar->isVisible()) 644 if (!bar->isVisible())
647 { 645 {
648 bar->setCaption (caption); 646 bar->setCaption (caption);
649 bar->setTotalSteps ( total ) ; 647 bar->setTotalSteps ( total ) ;
650 648
651 bar->show(); 649 bar->show();
652 } 650 }
653 651
654 bar->setProgress( percentage ); 652 bar->setProgress( percentage );
655} 653}
656 654
657void KSyncManager::hideProgressBar() 655void KSyncManager::hideProgressBar()
658{ 656{
659 bar->hide(); 657 bar->hide();
660} 658}
661 659
662bool KSyncManager::isProgressBarCanceled() 660bool KSyncManager::isProgressBarCanceled()
663{ 661{
664 return !bar->isVisible(); 662 return !bar->isVisible();
665} 663}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 9761107..6b10016 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,129 +1,147 @@
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 27
28class QPopupMenu; 28class QPopupMenu;
29class KSyncProfile; 29class KSyncProfile;
30class KPimPrefs; 30class KPimPrefs;
31class QWidget; 31class QWidget;
32class KSyncManager; 32class KSyncManager;
33class KSyncInterface; 33class KSyncInterface;
34class QProgressBar; 34class QProgressBar;
35 35
36class KSyncManager : public QObject 36class KSyncManager : public QObject
37{ 37{
38 Q_OBJECT 38 Q_OBJECT
39 39
40 public: 40 public:
41 enum TargetApp { 41 enum TargetApp {
42 KOPI = 0, 42 KOPI = 0,
43 KAPI = 1, 43 KAPI = 1,
44 PWMPI = 2 }; 44 PWMPI = 2 };
45 45
46 46
47 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 47 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
48 ~KSyncManager() ; 48 ~KSyncManager() ;
49 49
50 bool blockSave() { return mBlockSaveFlag; } 50 bool blockSave() { return mBlockSaveFlag; }
51 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 51 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
52 52
53 void fillSyncMenu(); 53 void fillSyncMenu();
54 54
55 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 55 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
56 QString getCurrentSyncName() { return mCurrentSyncName; } 56 QString getCurrentSyncName() { return mCurrentSyncName; }
57 57
58 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 58 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
59 void hideProgressBar(); 59 void hideProgressBar();
60 bool isProgressBarCanceled(); 60 bool isProgressBarCanceled();
61 61
62 // sync stuff
63 QString mLocalMachineName;
64 QStringList mExternSyncProfiles;
65 QStringList mSyncProfileNames;
66 bool mAskForPreferences;
67 bool mShowSyncSummary;
68 bool mShowSyncEvents;
69 bool mShowTodoInAgenda;
70 bool mWriteBackExistingOnly;
71 int mSyncAlgoPrefs;
72 int mRingSyncAlgoPrefs;
73 bool mWriteBackFile;
74 int mWriteBackInFuture;
75 QString mPhoneDevice;
76 QString mPhoneConnection;
77 QString mPhoneModel;
78 QString mLastSyncedLocalFile; // save!
79
80
62 81
63 public slots: 82 public slots:
64 void slotSyncMenu( int ); 83 void slotSyncMenu( int );
65 84
66 private: 85 private:
67 // LR ******************************* 86 // LR *******************************
68 // sync stuff! 87 // sync stuff!
69 QString mCurrentSyncDevice; 88 QString mCurrentSyncDevice;
70 QString mCurrentSyncName; 89 QString mCurrentSyncName;
71 void quickSyncLocalFile(); 90 void quickSyncLocalFile();
72 bool syncWithFile( QString fn , bool quick ); 91 bool syncWithFile( QString fn , bool quick );
73 void syncLocalFile(); 92 void syncLocalFile();
74 void syncPhone(); 93 void syncPhone();
75 void syncSharp(); 94 void syncSharp();
76 bool syncExternalApplication(QString); 95 bool syncExternalApplication(QString);
77 void multiSync( bool askforPrefs ); 96 void multiSync( bool askforPrefs );
78 int mCurrentSyncProfile ; 97 int mCurrentSyncProfile ;
79 void syncRemote( KSyncProfile* prof, bool ask = true); 98 void syncRemote( KSyncProfile* prof, bool ask = true);
80 void edit_sync_options(); 99 void edit_sync_options();
81 int ringSync(); 100 int ringSync();
82 QString getPassword( ); 101 QString getPassword( );
83 102
84 private slots: 103 private slots:
85 void confSync(); 104 void confSync();
86 // ********************* 105 // *********************
87 106
88 private: 107 private:
89 bool mBlockSaveFlag; 108 bool mBlockSaveFlag;
90 109
91 110
92 QWidget* mParent; 111 QWidget* mParent;
93 KSyncInterface* mImplementation; 112 KSyncInterface* mImplementation;
94 TargetApp mTargetApp; 113 TargetApp mTargetApp;
95 KPimPrefs* mPrefs;
96 QPopupMenu* mSyncMenu; 114 QPopupMenu* mSyncMenu;
97 115
98 QProgressBar* bar; 116 QProgressBar* bar;
99 117
100 118
101 119
102 120
103 121
104}; 122};
105 123
106 124
107class KSyncInterface 125class KSyncInterface
108{ 126{
109 public: 127 public:
110 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 128 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
111 129
112 virtual bool syncExternal(KSyncManager* manager, QString resource) 130 virtual bool syncExternal(KSyncManager* manager, QString resource)
113 { 131 {
114 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager. 132 // empty implementation, because some syncable applications do not have an external(sharpdtm) syncmode, like pwmanager.
115 return false; 133 return false;
116 } 134 }
117 135
118 //called by the syncmanager to indicate that the work has to be marked as dirty. 136 //called by the syncmanager to indicate that the work has to be marked as dirty.
119 virtual void sync_setModified() = 0; 137 virtual void sync_setModified() = 0;
120 138
121 //called by the syncmanager to ask if the dirty flag is set. 139 //called by the syncmanager to ask if the dirty flag is set.
122 virtual bool sync_isModified() = 0; 140 virtual bool sync_isModified() = 0;
123 141
124 //called by the syncmanager to indicate that the work has to be saved. 142 //called by the syncmanager to indicate that the work has to be saved.
125 virtual void sync_save() = 0; 143 virtual void sync_save() = 0;
126}; 144};
127 145
128 146
129#endif 147#endif
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 6c1a9c0..76a45f4 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -2451,850 +2451,850 @@ PwMerror PwMDoc::importText_PwM(const QString *file)
2451 return e_outOfMem; 2451 return e_outOfMem;
2452 } 2452 }
2453 2453
2454 // - check header 2454 // - check header
2455 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line. 2455 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) // skip first line.
2456 goto formatError; 2456 goto formatError;
2457 // check version-string and return version in "ch_tmp". 2457 // check version-string and return version in "ch_tmp".
2458 if (fscanf(f, "PwM v%s", ch_tmp) != 1) { 2458 if (fscanf(f, "PwM v%s", ch_tmp) != 1) {
2459 // header not recognized as PwM generated header 2459 // header not recognized as PwM generated header
2460 goto formatError; 2460 goto formatError;
2461 } 2461 }
2462 // set filepointer behind version-string-line previously checked 2462 // set filepointer behind version-string-line previously checked
2463 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2463 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2464 goto formatError; 2464 goto formatError;
2465 // skip next line containing the build-date 2465 // skip next line containing the build-date
2466 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2466 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2467 goto formatError; 2467 goto formatError;
2468 // read header termination line 2468 // read header termination line
2469 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2469 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2470 goto formatError; 2470 goto formatError;
2471 if (strcmp(ch_tmp, "==============================\n")) 2471 if (strcmp(ch_tmp, "==============================\n"))
2472 goto formatError; 2472 goto formatError;
2473 2473
2474 // - read entries 2474 // - read entries
2475 do { 2475 do {
2476 // find beginning of next category 2476 // find beginning of next category
2477 do { 2477 do {
2478 tmp = fgetc(f); 2478 tmp = fgetc(f);
2479 } while (tmp == '\n' && tmp != EOF); 2479 } while (tmp == '\n' && tmp != EOF);
2480 if (tmp == EOF) 2480 if (tmp == EOF)
2481 break; 2481 break;
2482 2482
2483 // decrement filepos by one 2483 // decrement filepos by one
2484 fseek(f, -1, SEEK_CUR); 2484 fseek(f, -1, SEEK_CUR);
2485 // read cat-name 2485 // read cat-name
2486 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2486 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2487 goto formatError; 2487 goto formatError;
2488 // check cat-name format 2488 // check cat-name format
2489 if (memcmp(ch_tmp, "== Category: ", 13) != 0) 2489 if (memcmp(ch_tmp, "== Category: ", 13) != 0)
2490 goto formatError; 2490 goto formatError;
2491 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0) 2491 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " ==", 3) != 0)
2492 goto formatError; 2492 goto formatError;
2493 // copy cat-name 2493 // copy cat-name
2494 curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16); 2494 curCat.assign(ch_tmp + 13, strlen(ch_tmp) - 1 - 16);
2495 2495
2496 do { 2496 do {
2497 // find beginning of next entry 2497 // find beginning of next entry
2498 do { 2498 do {
2499 tmp = fgetc(f); 2499 tmp = fgetc(f);
2500 } while (tmp == '\n' && tmp != EOF && tmp != '='); 2500 } while (tmp == '\n' && tmp != EOF && tmp != '=');
2501 if (tmp == EOF) 2501 if (tmp == EOF)
2502 break; 2502 break;
2503 if (tmp == '=') { 2503 if (tmp == '=') {
2504 fseek(f, -1, SEEK_CUR); 2504 fseek(f, -1, SEEK_CUR);
2505 break; 2505 break;
2506 } 2506 }
2507 // decrement filepos by one 2507 // decrement filepos by one
2508 fseek(f, -1, SEEK_CUR); 2508 fseek(f, -1, SEEK_CUR);
2509 // read desc-line 2509 // read desc-line
2510 if (getline(&ch_tmp, &ch_tmp_size, f) == -1) 2510 if (getline(&ch_tmp, &ch_tmp_size, f) == -1)
2511 goto formatError; 2511 goto formatError;
2512 // check desc-line format 2512 // check desc-line format
2513 if (memcmp(ch_tmp, "-- ", 3) != 0) 2513 if (memcmp(ch_tmp, "-- ", 3) != 0)
2514 goto formatError; 2514 goto formatError;
2515 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0) 2515 if (memcmp(ch_tmp + (strlen(ch_tmp) - 1 - 3), " --", 3) != 0)
2516 goto formatError; 2516 goto formatError;
2517 // add desc-line 2517 // add desc-line
2518 currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6); 2518 currItem.desc.assign(ch_tmp + 3, strlen(ch_tmp) - 1 - 6);
2519 2519
2520 // read username-line 2520 // read username-line
2521 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2521 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2522 goto formatError; 2522 goto formatError;
2523 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name)) 2523 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.name))
2524 goto formatError; 2524 goto formatError;
2525 2525
2526 // read pw-line 2526 // read pw-line
2527 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2527 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2528 goto formatError; 2528 goto formatError;
2529 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw)) 2529 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.pw))
2530 goto formatError; 2530 goto formatError;
2531 2531
2532 // read comment-line 2532 // read comment-line
2533 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2533 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2534 goto formatError; 2534 goto formatError;
2535 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment)) 2535 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.comment))
2536 goto formatError; 2536 goto formatError;
2537 2537
2538 // read URL-line 2538 // read URL-line
2539 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2539 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2540 goto formatError; 2540 goto formatError;
2541 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url)) 2541 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.url))
2542 goto formatError; 2542 goto formatError;
2543 2543
2544 // read launcher-line 2544 // read launcher-line
2545 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1) 2545 if ((ret = getline(&ch_tmp, &ch_tmp_size, f)) == -1)
2546 goto formatError; 2546 goto formatError;
2547 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher)) 2547 if (!textExtractEntry_PwM(ch_tmp, ret, &currItem.launcher))
2548 goto formatError; 2548 goto formatError;
2549 2549
2550 currItem.lockStat = true; 2550 currItem.lockStat = true;
2551 currItem.listViewPos = -1; 2551 currItem.listViewPos = -1;
2552 addEntry(curCat.c_str(), &currItem, true); 2552 addEntry(curCat.c_str(), &currItem, true);
2553 ++entriesRead; 2553 ++entriesRead;
2554 } while (1); 2554 } while (1);
2555 } while (1); 2555 } while (1);
2556 if (!entriesRead) 2556 if (!entriesRead)
2557 goto formatError; 2557 goto formatError;
2558 2558
2559 free(ch_tmp); 2559 free(ch_tmp);
2560 fclose(f); 2560 fclose(f);
2561 flagDirty(); 2561 flagDirty();
2562 return e_success; 2562 return e_success;
2563 2563
2564 formatError: 2564 formatError:
2565 free(ch_tmp); 2565 free(ch_tmp);
2566 fclose(f); 2566 fclose(f);
2567 return e_fileFormat; 2567 return e_fileFormat;
2568} 2568}
2569 2569
2570bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out) 2570bool PwMDoc::textExtractEntry_PwM(const char *in, ssize_t in_size, string *out)
2571{ 2571{
2572 PWM_ASSERT(in && out); 2572 PWM_ASSERT(in && out);
2573 ssize_t i = 0, len = in_size - 1; 2573 ssize_t i = 0, len = in_size - 1;
2574 while (i < len) { 2574 while (i < len) {
2575 if (in[i] == ':') 2575 if (in[i] == ':')
2576 break; 2576 break;
2577 ++i; 2577 ++i;
2578 } 2578 }
2579 i += 2; 2579 i += 2;
2580 *out = ""; 2580 *out = "";
2581 out->append(in + i, in_size - i - 1); 2581 out->append(in + i, in_size - i - 1);
2582 return true; 2582 return true;
2583} 2583}
2584 2584
2585PwMerror PwMDoc::exportToGpasman(const QString *file) 2585PwMerror PwMDoc::exportToGpasman(const QString *file)
2586{ 2586{
2587 PWM_ASSERT(file); 2587 PWM_ASSERT(file);
2588 GpasmanFile gp; 2588 GpasmanFile gp;
2589 int ret; 2589 int ret;
2590 2590
2591 if (!unlockAll_tempoary()) 2591 if (!unlockAll_tempoary())
2592 return e_lock; 2592 return e_lock;
2593 2593
2594 QString gpmPassword; 2594 QString gpmPassword;
2595 while (1) { 2595 while (1) {
2596 gpmPassword = requestNewMpw(0); 2596 gpmPassword = requestNewMpw(0);
2597 if (gpmPassword == "") { 2597 if (gpmPassword == "") {
2598 unlockAll_tempoary(true); 2598 unlockAll_tempoary(true);
2599 return e_noPw; 2599 return e_noPw;
2600 } 2600 }
2601 if (gpmPassword.length() < 4) { 2601 if (gpmPassword.length() < 4) {
2602 gpmPwLenErrMsgBox(); 2602 gpmPwLenErrMsgBox();
2603 } else { 2603 } else {
2604 break; 2604 break;
2605 } 2605 }
2606 } 2606 }
2607 2607
2608 ret = gp.save_init(file->latin1(), gpmPassword.latin1()); 2608 ret = gp.save_init(file->latin1(), gpmPassword.latin1());
2609 if (ret != 1) { 2609 if (ret != 1) {
2610 unlockAll_tempoary(true); 2610 unlockAll_tempoary(true);
2611 return e_accessFile; 2611 return e_accessFile;
2612 } 2612 }
2613 2613
2614 char *entry[4]; 2614 char *entry[4];
2615 unsigned int numCat = numCategories(), i; 2615 unsigned int numCat = numCategories(), i;
2616 unsigned int numEntr, j; 2616 unsigned int numEntr, j;
2617 int descLen, nameLen, pwLen, commentLen; 2617 int descLen, nameLen, pwLen, commentLen;
2618 for (i = 0; i < numCat; ++i) { 2618 for (i = 0; i < numCat; ++i) {
2619 numEntr = numEntries(i); 2619 numEntr = numEntries(i);
2620 for (j = 0; j < numEntr; ++j) { 2620 for (j = 0; j < numEntr; ++j) {
2621 descLen = dti.dta[i].d[j].desc.length(); 2621 descLen = dti.dta[i].d[j].desc.length();
2622 nameLen = dti.dta[i].d[j].name.length(); 2622 nameLen = dti.dta[i].d[j].name.length();
2623 pwLen = dti.dta[i].d[j].pw.length(); 2623 pwLen = dti.dta[i].d[j].pw.length();
2624 commentLen = dti.dta[i].d[j].comment.length(); 2624 commentLen = dti.dta[i].d[j].comment.length();
2625 entry[0] = new char[descLen + 1]; 2625 entry[0] = new char[descLen + 1];
2626 entry[1] = new char[nameLen + 1]; 2626 entry[1] = new char[nameLen + 1];
2627 entry[2] = new char[pwLen + 1]; 2627 entry[2] = new char[pwLen + 1];
2628 entry[3] = new char[commentLen + 1]; 2628 entry[3] = new char[commentLen + 1];
2629 strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str()); 2629 strcpy(entry[0], descLen == 0 ? " " : dti.dta[i].d[j].desc.c_str());
2630 strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str()); 2630 strcpy(entry[1], nameLen == 0 ? " " : dti.dta[i].d[j].name.c_str());
2631 strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str()); 2631 strcpy(entry[2], pwLen == 0 ? " " : dti.dta[i].d[j].pw.c_str());
2632 strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str()); 2632 strcpy(entry[3], commentLen == 0 ? " " : dti.dta[i].d[j].comment.c_str());
2633 entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0'; 2633 entry[0][descLen == 0 ? descLen + 1 : descLen] = '\0';
2634 entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0'; 2634 entry[1][nameLen == 0 ? nameLen + 1 : nameLen] = '\0';
2635 entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0'; 2635 entry[2][pwLen == 0 ? pwLen + 1 : pwLen] = '\0';
2636 entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0'; 2636 entry[3][commentLen == 0 ? commentLen + 1 : commentLen] = '\0';
2637 2637
2638 ret = gp.save_entry(entry); 2638 ret = gp.save_entry(entry);
2639 if (ret == -1){ 2639 if (ret == -1){
2640 delete [] entry[0]; 2640 delete [] entry[0];
2641 delete [] entry[1]; 2641 delete [] entry[1];
2642 delete [] entry[2]; 2642 delete [] entry[2];
2643 delete [] entry[3]; 2643 delete [] entry[3];
2644 gp.save_finalize(); 2644 gp.save_finalize();
2645 unlockAll_tempoary(true); 2645 unlockAll_tempoary(true);
2646 return e_writeFile; 2646 return e_writeFile;
2647 } 2647 }
2648 2648
2649 delete [] entry[0]; 2649 delete [] entry[0];
2650 delete [] entry[1]; 2650 delete [] entry[1];
2651 delete [] entry[2]; 2651 delete [] entry[2];
2652 delete [] entry[3]; 2652 delete [] entry[3];
2653 } 2653 }
2654 } 2654 }
2655 unlockAll_tempoary(true); 2655 unlockAll_tempoary(true);
2656 if (gp.save_finalize() == -1) 2656 if (gp.save_finalize() == -1)
2657 return e_writeFile; 2657 return e_writeFile;
2658 2658
2659 return e_success; 2659 return e_success;
2660} 2660}
2661 2661
2662PwMerror PwMDoc::importFromGpasman(const QString *file) 2662PwMerror PwMDoc::importFromGpasman(const QString *file)
2663{ 2663{
2664 PWM_ASSERT(file); 2664 PWM_ASSERT(file);
2665 QString pw = requestMpw(false); 2665 QString pw = requestMpw(false);
2666 if (pw == "") 2666 if (pw == "")
2667 return e_noPw; 2667 return e_noPw;
2668 GpasmanFile gp; 2668 GpasmanFile gp;
2669 int ret, i; 2669 int ret, i;
2670 PwMerror ret2; 2670 PwMerror ret2;
2671 char *entry[4]; 2671 char *entry[4];
2672 PwMDataItem tmpData; 2672 PwMDataItem tmpData;
2673 ret = gp.load_init(file->latin1(), pw.latin1()); 2673 ret = gp.load_init(file->latin1(), pw.latin1());
2674 if (ret != 1) 2674 if (ret != 1)
2675 return e_accessFile; 2675 return e_accessFile;
2676 2676
2677 do { 2677 do {
2678 ret = gp.load_entry(entry); 2678 ret = gp.load_entry(entry);
2679 if(ret != 1) 2679 if(ret != 1)
2680 break; 2680 break;
2681 tmpData.desc = entry[0]; 2681 tmpData.desc = entry[0];
2682 tmpData.name = entry[1]; 2682 tmpData.name = entry[1];
2683 tmpData.pw = entry[2]; 2683 tmpData.pw = entry[2];
2684 tmpData.comment = entry[3]; 2684 tmpData.comment = entry[3];
2685 tmpData.lockStat = true; 2685 tmpData.lockStat = true;
2686 tmpData.listViewPos = -1; 2686 tmpData.listViewPos = -1;
2687 ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true); 2687 ret2 = addEntry(DEFAULT_CATEGORY, &tmpData, true);
2688 for (i = 0; i < 4; ++i) 2688 for (i = 0; i < 4; ++i)
2689 free(entry[i]); 2689 free(entry[i]);
2690 if (ret2 == e_maxAllowedEntr) { 2690 if (ret2 == e_maxAllowedEntr) {
2691 gp.load_finalize(); 2691 gp.load_finalize();
2692 return e_maxAllowedEntr; 2692 return e_maxAllowedEntr;
2693 } 2693 }
2694 } while (1); 2694 } while (1);
2695 gp.load_finalize(); 2695 gp.load_finalize();
2696 if (isDocEmpty()) 2696 if (isDocEmpty())
2697 return e_wrongPw; // we assume this. 2697 return e_wrongPw; // we assume this.
2698 2698
2699 flagDirty(); 2699 flagDirty();
2700 return e_success; 2700 return e_success;
2701} 2701}
2702 2702
2703void PwMDoc::ensureLvp() 2703void PwMDoc::ensureLvp()
2704{ 2704{
2705 if (isDocEmpty()) 2705 if (isDocEmpty())
2706 return; 2706 return;
2707 2707
2708 vector< vector<PwMDataItem>::iterator > undefined; 2708 vector< vector<PwMDataItem>::iterator > undefined;
2709 vector< vector<PwMDataItem>::iterator >::iterator undefBegin, 2709 vector< vector<PwMDataItem>::iterator >::iterator undefBegin,
2710 undefEnd, 2710 undefEnd,
2711 undefI; 2711 undefI;
2712 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(), 2712 vector<PwMCategoryItem>::iterator catBegin = dti.dta.begin(),
2713 catEnd = dti.dta.end(), 2713 catEnd = dti.dta.end(),
2714 catI = catBegin; 2714 catI = catBegin;
2715 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 2715 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
2716 int lvpTop, tmpLvp; 2716 int lvpTop, tmpLvp;
2717 2717
2718 while (catI != catEnd) { 2718 while (catI != catEnd) {
2719 lvpTop = -1; 2719 lvpTop = -1;
2720 undefined.clear(); 2720 undefined.clear();
2721 2721
2722 entrBegin = catI->d.begin(); 2722 entrBegin = catI->d.begin();
2723 entrEnd = catI->d.end(); 2723 entrEnd = catI->d.end();
2724 entrI = entrBegin; 2724 entrI = entrBegin;
2725 2725
2726 while (entrI != entrEnd) { 2726 while (entrI != entrEnd) {
2727 tmpLvp = entrI->listViewPos; 2727 tmpLvp = entrI->listViewPos;
2728 if (tmpLvp == -1) 2728 if (tmpLvp == -1)
2729 undefined.push_back(entrI); 2729 undefined.push_back(entrI);
2730 else if (tmpLvp > lvpTop) 2730 else if (tmpLvp > lvpTop)
2731 lvpTop = tmpLvp; 2731 lvpTop = tmpLvp;
2732 ++entrI; 2732 ++entrI;
2733 } 2733 }
2734 undefBegin = undefined.begin(); 2734 undefBegin = undefined.begin();
2735 undefEnd = undefined.end(); 2735 undefEnd = undefined.end();
2736 undefI = undefBegin; 2736 undefI = undefBegin;
2737 while (undefI != undefEnd) { 2737 while (undefI != undefEnd) {
2738 (*undefI)->listViewPos = ++lvpTop; 2738 (*undefI)->listViewPos = ++lvpTop;
2739 ++undefI; 2739 ++undefI;
2740 } 2740 }
2741 ++catI; 2741 ++catI;
2742 } 2742 }
2743} 2743}
2744 2744
2745QString PwMDoc::getTitle() 2745QString PwMDoc::getTitle()
2746{ 2746{
2747 /* NOTE: We have to ensure, that the returned title 2747 /* NOTE: We have to ensure, that the returned title
2748 * is unique and not reused somewhere else while 2748 * is unique and not reused somewhere else while
2749 * this document is valid (open). 2749 * this document is valid (open).
2750 */ 2750 */
2751 QString title(getFilename()); 2751 QString title(getFilename());
2752 if (title.isEmpty()) { 2752 if (title.isEmpty()) {
2753 if (unnamedNum == 0) { 2753 if (unnamedNum == 0) {
2754 unnamedNum = PwMDocList::getNewUnnamedNumber(); 2754 unnamedNum = PwMDocList::getNewUnnamedNumber();
2755 PWM_ASSERT(unnamedNum != 0); 2755 PWM_ASSERT(unnamedNum != 0);
2756 } 2756 }
2757 title = DEFAULT_TITLE; 2757 title = DEFAULT_TITLE;
2758 title += " "; 2758 title += " ";
2759 title += tostr(unnamedNum).c_str(); 2759 title += tostr(unnamedNum).c_str();
2760 } 2760 }
2761 return title; 2761 return title;
2762} 2762}
2763 2763
2764bool PwMDoc::tryDelete() 2764bool PwMDoc::tryDelete()
2765{ 2765{
2766 if (deleted) 2766 if (deleted)
2767 return true; 2767 return true;
2768 int ret; 2768 int ret;
2769 if (isDirty()) { 2769 if (isDirty()) {
2770 ret = dirtyAskSave(getTitle()); 2770 ret = dirtyAskSave(getTitle());
2771 if (ret == 0) { // save to disk 2771 if (ret == 0) { // save to disk
2772 if (!saveDocUi(this)) 2772 if (!saveDocUi(this))
2773 goto out_ignore; 2773 goto out_ignore;
2774 } else if (ret == 1) { // don't save and delete 2774 } else if (ret == 1) { // don't save and delete
2775 goto out_accept; 2775 goto out_accept;
2776 } else { // cancel operation 2776 } else { // cancel operation
2777 goto out_ignore; 2777 goto out_ignore;
2778 } 2778 }
2779 } 2779 }
2780out_accept: 2780out_accept:
2781 deleted = true; 2781 deleted = true;
2782 delete this; 2782 delete this;
2783 return true; 2783 return true;
2784out_ignore: 2784out_ignore:
2785 return false; 2785 return false;
2786} 2786}
2787 2787
2788 2788
2789 2789
2790#ifdef PWM_EMBEDDED 2790#ifdef PWM_EMBEDDED
2791//US ENH: this is the magic function that syncronizes the this doc with the remote doc 2791//US ENH: this is the magic function that syncronizes the this doc with the remote doc
2792//US it could have been defined as static, but I did not want to. 2792//US it could have been defined as static, but I did not want to.
2793PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode ) 2793PwMerror PwMDoc::syncronize(KSyncManager* manager, PwMDoc* syncLocal , PwMDoc* syncRemote, int mode )
2794{ 2794{
2795 int addedPasswordsLocal = 0; 2795 int addedPasswordsLocal = 0;
2796 int addedPasswordsRemote = 0; 2796 int addedPasswordsRemote = 0;
2797 int deletedPasswordsRemote = 0; 2797 int deletedPasswordsRemote = 0;
2798 int deletedPasswordsLocal = 0; 2798 int deletedPasswordsLocal = 0;
2799 int changedLocal = 0; 2799 int changedLocal = 0;
2800 int changedRemote = 0; 2800 int changedRemote = 0;
2801 2801
2802 PwMSyncItem* syncItemLocal; 2802 PwMSyncItem* syncItemLocal;
2803 PwMSyncItem* syncItemRemote; 2803 PwMSyncItem* syncItemRemote;
2804 2804
2805 QString mCurrentSyncName = manager->getCurrentSyncName(); 2805 QString mCurrentSyncName = manager->getCurrentSyncName();
2806 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2806 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2807 2807
2808 bool fullDateRange = false; 2808 bool fullDateRange = false;
2809 int take; 2809 int take;
2810 // local->resetTempSyncStat(); 2810 // local->resetTempSyncStat();
2811 QDateTime mLastSync = QDateTime::currentDateTime(); 2811 QDateTime mLastSync = QDateTime::currentDateTime();
2812 QDateTime modifiedSync = mLastSync; 2812 QDateTime modifiedSync = mLastSync;
2813 2813
2814 unsigned int index; 2814 unsigned int index;
2815 //Step 1. Find syncinfo in Local file and create if not existent. 2815 //Step 1. Find syncinfo in Local file and create if not existent.
2816 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 2816 bool found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
2817 if (found == false) 2817 if (found == false)
2818 { 2818 {
2819 PwMSyncItem newSyncItemLocal; 2819 PwMSyncItem newSyncItemLocal;
2820 newSyncItemLocal.syncName = mCurrentSyncDevice; 2820 newSyncItemLocal.syncName = mCurrentSyncDevice;
2821 newSyncItemLocal.lastSyncDate = mLastSync; 2821 newSyncItemLocal.lastSyncDate = mLastSync;
2822 syncLocal->addSyncDataEntry(&newSyncItemLocal, true); 2822 syncLocal->addSyncDataEntry(&newSyncItemLocal, true);
2823 found = syncLocal->findSyncData(mCurrentSyncDevice, &index); 2823 found = syncLocal->findSyncData(mCurrentSyncDevice, &index);
2824 if (found == false) { 2824 if (found == false) {
2825 qDebug("PwMDoc::syncronize : newly created local sync data could not be found"); 2825 qDebug("PwMDoc::syncronize : newly created local sync data could not be found");
2826 return e_syncError; 2826 return e_syncError;
2827 } 2827 }
2828 } 2828 }
2829 2829
2830 syncItemLocal = syncLocal->getSyncDataEntry(index); 2830 syncItemLocal = syncLocal->getSyncDataEntry(index);
2831 qDebug("Last Sync %s ", syncItemLocal->lastSyncDate.toString().latin1()); 2831 qDebug("Last Sync %s ", syncItemLocal->lastSyncDate.toString().latin1());
2832 2832
2833 //Step 2. Find syncinfo in remote file and create if not existent. 2833 //Step 2. Find syncinfo in remote file and create if not existent.
2834 found = syncRemote->findSyncData(mCurrentSyncName, &index); 2834 found = syncRemote->findSyncData(mCurrentSyncName, &index);
2835 if (found == false) 2835 if (found == false)
2836 { 2836 {
2837 qDebug("FULLDATE 1"); 2837 qDebug("FULLDATE 1");
2838 fullDateRange = true; 2838 fullDateRange = true;
2839 PwMSyncItem newSyncItemRemote; 2839 PwMSyncItem newSyncItemRemote;
2840 newSyncItemRemote.syncName = mCurrentSyncName; 2840 newSyncItemRemote.syncName = mCurrentSyncName;
2841 newSyncItemRemote.lastSyncDate = mLastSync; 2841 newSyncItemRemote.lastSyncDate = mLastSync;
2842 syncRemote->addSyncDataEntry(&newSyncItemRemote, true); 2842 syncRemote->addSyncDataEntry(&newSyncItemRemote, true);
2843 found = syncRemote->findSyncData(mCurrentSyncName, &index); 2843 found = syncRemote->findSyncData(mCurrentSyncName, &index);
2844 if (found == false) { 2844 if (found == false) {
2845 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found"); 2845 qDebug("PwMDoc::syncronize : newly created remote sync data could not be found");
2846 return e_syncError; 2846 return e_syncError;
2847 } 2847 }
2848 } 2848 }
2849 2849
2850 syncItemRemote = syncRemote->getSyncDataEntry(index); 2850 syncItemRemote = syncRemote->getSyncDataEntry(index);
2851 //and remove the found entry here. We will reenter it later again. 2851 //and remove the found entry here. We will reenter it later again.
2852 syncRemote->delSyncDataEntry(index, true); 2852 syncRemote->delSyncDataEntry(index, true);
2853 2853
2854 2854
2855 if ( syncItemLocal->lastSyncDate == mLastSync ) { 2855 if ( syncItemLocal->lastSyncDate == mLastSync ) {
2856 qDebug("FULLDATE 2"); 2856 qDebug("FULLDATE 2");
2857 fullDateRange = true; 2857 fullDateRange = true;
2858 } 2858 }
2859 2859
2860 if ( ! fullDateRange ) { 2860 if ( ! fullDateRange ) {
2861 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) { 2861 if ( syncItemLocal->lastSyncDate != syncItemRemote->lastSyncDate ) {
2862 2862
2863 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2863 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2864 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2864 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2865 fullDateRange = true; 2865 fullDateRange = true;
2866 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() ); 2866 qDebug("FULLDATE 3 %s %s", syncItemLocal->lastSyncDate.toString().latin1() , syncItemRemote->lastSyncDate.toString().latin1() );
2867 } 2867 }
2868 } 2868 }
2869 // fullDateRange = true; // debug only! 2869 // fullDateRange = true; // debug only!
2870 if ( fullDateRange ) 2870 if ( fullDateRange )
2871 mLastSync = QDateTime::currentDateTime().addDays( -100*365); 2871 mLastSync = QDateTime::currentDateTime().addDays( -100*365);
2872 else 2872 else
2873 mLastSync = syncItemLocal->lastSyncDate; 2873 mLastSync = syncItemLocal->lastSyncDate;
2874 2874
2875 2875
2876 qDebug("*************************** "); 2876 qDebug("*************************** ");
2877 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2877 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2878 QStringList er = syncRemote->getIDEntryList(); 2878 QStringList er = syncRemote->getIDEntryList();
2879 PwMDataItem* inRemote ;//= er.first(); 2879 PwMDataItem* inRemote ;//= er.first();
2880 PwMDataItem* inLocal; 2880 PwMDataItem* inLocal;
2881 unsigned int catLocal, indexLocal; 2881 unsigned int catLocal, indexLocal;
2882 unsigned int catRemote, indexRemote; 2882 unsigned int catRemote, indexRemote;
2883 2883
2884 QString uid; 2884 QString uid;
2885 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2885 manager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2886 2886
2887 int modulo = (er.count()/10)+1; 2887 int modulo = (er.count()/10)+1;
2888 unsigned int incCounter = 0; 2888 unsigned int incCounter = 0;
2889 while ( incCounter < er.count()) { 2889 while ( incCounter < er.count()) {
2890 if (manager->isProgressBarCanceled()) 2890 if (manager->isProgressBarCanceled())
2891 return e_syncError; 2891 return e_syncError;
2892 if ( incCounter % modulo == 0 ) 2892 if ( incCounter % modulo == 0 )
2893 manager->showProgressBar(incCounter); 2893 manager->showProgressBar(incCounter);
2894 2894
2895 uid = er[ incCounter ]; 2895 uid = er[ incCounter ];
2896 qDebug("sync uid %s from remote file", uid.latin1()); 2896 qDebug("sync uid %s from remote file", uid.latin1());
2897 2897
2898 qApp->processEvents(); 2898 qApp->processEvents();
2899 2899
2900 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 2900 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
2901 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 2901 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
2902 PWM_ASSERT(inRemote); 2902 PWM_ASSERT(inRemote);
2903 if ( inLocal != 0 ) { // maybe conflict - same uid in both files 2903 if ( inLocal != 0 ) { // maybe conflict - same uid in both files
2904 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) { 2904 if ( (take = takePwMDataItem( inLocal, inRemote, mLastSync, mode, fullDateRange) ) ) {
2905 //qDebug("take %d %s ", take, inL.summary().latin1()); 2905 //qDebug("take %d %s ", take, inL.summary().latin1());
2906 if ( take == 3 ) 2906 if ( take == 3 )
2907 return e_syncError; 2907 return e_syncError;
2908 if ( take == 1 ) {// take local 2908 if ( take == 1 ) {// take local
2909 //US syncRemote->removeAddressee( inRemote ); 2909 //US syncRemote->removeAddressee( inRemote );
2910 (*inRemote) = (*inLocal); 2910 (*inRemote) = (*inLocal);
2911 //US syncRemote->insertAddressee( inRemote , false); 2911 //US syncRemote->insertAddressee( inRemote , false);
2912 ++changedRemote; 2912 ++changedRemote;
2913 } else { // take == 2 take remote 2913 } else { // take == 2 take remote
2914 //US syncLocal->removeAddressee( inLocal ); 2914 //US syncLocal->removeAddressee( inLocal );
2915 (*inLocal) = (*inRemote); 2915 (*inLocal) = (*inRemote);
2916 //US syncLocal->insertAddressee( inLocal , false ); 2916 //US syncLocal->insertAddressee( inLocal , false );
2917 ++changedLocal; 2917 ++changedLocal;
2918 } 2918 }
2919 } 2919 }
2920 } else { // no conflict 2920 } else { // no conflict
2921 if ( inRemote->meta.update > mLastSync || mode == 5 ) { 2921 if ( inRemote->meta.update > mLastSync || mode == 5 ) {
2922 inRemote->meta.update = modifiedSync; 2922 inRemote->meta.update = modifiedSync;
2923 //US syncRemote->insertAddressee( inRemote, false ); 2923 //US syncRemote->insertAddressee( inRemote, false );
2924 //US syncLocal->insertAddressee( inRemote, false ); 2924 //US syncLocal->insertAddressee( inRemote, false );
2925 syncLocal->addEntry("newcategory", inRemote, true, false); 2925 syncLocal->addEntry("newcategory", inRemote, true, false);
2926 2926
2927 ++addedPasswordsLocal; 2927 ++addedPasswordsLocal;
2928 } else { 2928 } else {
2929 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2929 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2930 syncRemote->delEntry(catRemote, indexRemote, true); 2930 syncRemote->delEntry(catRemote, indexRemote, true);
2931 //USsyncRemote->removeAddressee( inRemote ); 2931 //USsyncRemote->removeAddressee( inRemote );
2932 ++deletedPasswordsRemote; 2932 ++deletedPasswordsRemote;
2933 } 2933 }
2934 } 2934 }
2935 2935
2936 ++incCounter; 2936 ++incCounter;
2937 } 2937 }
2938 2938
2939 2939
2940 er.clear(); 2940 er.clear();
2941 QStringList el = syncLocal->getIDEntryList(); 2941 QStringList el = syncLocal->getIDEntryList();
2942 modulo = (el.count()/10)+1; 2942 modulo = (el.count()/10)+1;
2943 2943
2944 manager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2944 manager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2945 incCounter = 0; 2945 incCounter = 0;
2946 while ( incCounter < el.count()) { 2946 while ( incCounter < el.count()) {
2947 qApp->processEvents(); 2947 qApp->processEvents();
2948 if (manager->isProgressBarCanceled()) 2948 if (manager->isProgressBarCanceled())
2949 return e_syncError; 2949 return e_syncError;
2950 if ( incCounter % modulo == 0 ) 2950 if ( incCounter % modulo == 0 )
2951 manager->showProgressBar(incCounter); 2951 manager->showProgressBar(incCounter);
2952 uid = el[ incCounter ]; 2952 uid = el[ incCounter ];
2953 2953
2954 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal ); 2954 inLocal = syncLocal->findEntryByID( uid, &catLocal, &indexLocal );
2955 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote ); 2955 inRemote = syncRemote->findEntryByID( uid, &catRemote, &indexRemote );
2956 if ( inRemote == 0 ) { 2956 if ( inRemote == 0 ) {
2957 if ( inLocal->meta.update < mLastSync && mode != 4 ) { 2957 if ( inLocal->meta.update < mLastSync && mode != 4 ) {
2958 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2958 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2959 syncLocal->delEntry(catLocal, indexLocal, true); 2959 syncLocal->delEntry(catLocal, indexLocal, true);
2960 //USsyncLocal->removeAddressee( inLocal ); 2960 //USsyncLocal->removeAddressee( inLocal );
2961 ++deletedPasswordsLocal; 2961 ++deletedPasswordsLocal;
2962 } else { 2962 } else {
2963 if ( ! PWMPrefs::instance()->mWriteBackExistingOnly ) { 2963 if ( ! manager->mWriteBackExistingOnly ) {
2964 ++addedPasswordsRemote; 2964 ++addedPasswordsRemote;
2965 inLocal->meta.update = modifiedSync; 2965 inLocal->meta.update = modifiedSync;
2966 //USsyncLocal->insertAddressee( inLocal, false ); 2966 //USsyncLocal->insertAddressee( inLocal, false );
2967 (*inRemote) = (*inLocal); 2967 (*inRemote) = (*inLocal);
2968 //USsyncRemote->insertAddressee( inRemote, false ); 2968 //USsyncRemote->insertAddressee( inRemote, false );
2969 syncRemote->addEntry("newcategory", inRemote, true, false); 2969 syncRemote->addEntry("newcategory", inRemote, true, false);
2970 2970
2971 } 2971 }
2972 } 2972 }
2973 2973
2974 } 2974 }
2975 ++incCounter; 2975 ++incCounter;
2976 } 2976 }
2977 el.clear(); 2977 el.clear();
2978 manager->hideProgressBar(); 2978 manager->hideProgressBar();
2979 2979
2980 // Now write the info back into the sync data space of the files 2980 // Now write the info back into the sync data space of the files
2981 2981
2982 mLastSync = QDateTime::currentDateTime().addSecs( 1 ); 2982 mLastSync = QDateTime::currentDateTime().addSecs( 1 );
2983 // get rid of micro seconds 2983 // get rid of micro seconds
2984 QTime t = mLastSync.time(); 2984 QTime t = mLastSync.time();
2985 mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2985 mLastSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2986 2986
2987 2987
2988 syncItemLocal->lastSyncDate = mLastSync; 2988 syncItemLocal->lastSyncDate = mLastSync;
2989 syncItemRemote->lastSyncDate = mLastSync; 2989 syncItemRemote->lastSyncDate = mLastSync;
2990 2990
2991 // addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2991 // addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2992 // addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2992 // addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2993 2993
2994 syncRemote->addSyncDataEntry( syncItemRemote, false ); 2994 syncRemote->addSyncDataEntry( syncItemRemote, false );
2995 syncLocal->addSyncDataEntry( syncItemLocal, false ); 2995 syncLocal->addSyncDataEntry( syncItemLocal, false );
2996 QString mes; 2996 QString mes;
2997 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"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote ); 2997 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"),addedPasswordsLocal, addedPasswordsRemote, changedLocal, changedRemote, deletedPasswordsLocal, deletedPasswordsRemote );
2998 if ( PWMPrefs::instance()->mShowSyncSummary ) { 2998 if ( manager->mShowSyncSummary ) {
2999 KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") ); 2999 KMessageBox::information(0, mes, i18n("PWM/Pi Synchronization") );
3000 } 3000 }
3001 qDebug( mes ); 3001 qDebug( mes );
3002 return e_success; 3002 return e_success;
3003} 3003}
3004 3004
3005 3005
3006int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full ) 3006int PwMDoc::takePwMDataItem( PwMDataItem* local, PwMDataItem* remote, QDateTime lastSync, int mode , bool full )
3007{ 3007{
3008 // 0 equal 3008 // 0 equal
3009 // 1 take local 3009 // 1 take local
3010 // 2 take remote 3010 // 2 take remote
3011 // 3 cancel 3011 // 3 cancel
3012 QDateTime localMod = local->meta.update; 3012 QDateTime localMod = local->meta.update;
3013 QDateTime remoteMod = remote->meta.update; 3013 QDateTime remoteMod = remote->meta.update;
3014 3014
3015 //US QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3015 //US QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3016 3016
3017 if ( localMod == remoteMod ) 3017 if ( localMod == remoteMod )
3018 return 0; 3018 return 0;
3019 3019
3020 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() ); 3020 qDebug(" %d %d conflict on %s %s ", mode, full, local->desc.c_str(), remote->desc.c_str() );
3021 3021
3022 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 3022 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
3023 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 3023 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
3024 //full = true; //debug only 3024 //full = true; //debug only
3025 if ( full ) { 3025 if ( full ) {
3026 bool equ = true;//US ( (*local) == (*remote) ); 3026 bool equ = true;//US ( (*local) == (*remote) );
3027 if ( equ ) { 3027 if ( equ ) {
3028 //qDebug("equal "); 3028 //qDebug("equal ");
3029 if ( mode < SYNC_PREF_FORCE_LOCAL ) 3029 if ( mode < SYNC_PREF_FORCE_LOCAL )
3030 return 0; 3030 return 0;
3031 3031
3032 }//else //debug only 3032 }//else //debug only
3033 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 3033 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
3034 } 3034 }
3035 3035
3036 int result; 3036 int result;
3037 bool localIsNew; 3037 bool localIsNew;
3038 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 3038 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
3039 3039
3040 if ( full && mode < SYNC_PREF_NEWEST ) 3040 if ( full && mode < SYNC_PREF_NEWEST )
3041 mode = SYNC_PREF_ASK; 3041 mode = SYNC_PREF_ASK;
3042 3042
3043 switch( mode ) { 3043 switch( mode ) {
3044 case SYNC_PREF_LOCAL: 3044 case SYNC_PREF_LOCAL:
3045 if ( lastSync > remoteMod ) 3045 if ( lastSync > remoteMod )
3046 return 1; 3046 return 1;
3047 if ( lastSync > localMod ) 3047 if ( lastSync > localMod )
3048 return 2; 3048 return 2;
3049 return 1; 3049 return 1;
3050 break; 3050 break;
3051 case SYNC_PREF_REMOTE: 3051 case SYNC_PREF_REMOTE:
3052 if ( lastSync > remoteMod ) 3052 if ( lastSync > remoteMod )
3053 return 1; 3053 return 1;
3054 if ( lastSync > localMod ) 3054 if ( lastSync > localMod )
3055 return 2; 3055 return 2;
3056 return 2; 3056 return 2;
3057 break; 3057 break;
3058 case SYNC_PREF_NEWEST: 3058 case SYNC_PREF_NEWEST:
3059 if ( localMod > remoteMod ) 3059 if ( localMod > remoteMod )
3060 return 1; 3060 return 1;
3061 else 3061 else
3062 return 2; 3062 return 2;
3063 break; 3063 break;
3064 case SYNC_PREF_ASK: 3064 case SYNC_PREF_ASK:
3065 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 3065 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
3066 if ( lastSync > remoteMod ) 3066 if ( lastSync > remoteMod )
3067 return 1; 3067 return 1;
3068 if ( lastSync > localMod ) 3068 if ( lastSync > localMod )
3069 return 2; 3069 return 2;
3070 localIsNew = localMod >= remoteMod; 3070 localIsNew = localMod >= remoteMod;
3071 //qDebug("conflict! ************************************** "); 3071 //qDebug("conflict! ************************************** ");
3072 { 3072 {
3073 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ ); 3073 PwMDataItemChooser acd ( *local,*remote, localIsNew , 0/*this*/ );
3074 result = acd.executeD(localIsNew); 3074 result = acd.executeD(localIsNew);
3075 return result; 3075 return result;
3076 } 3076 }
3077 break; 3077 break;
3078 case SYNC_PREF_FORCE_LOCAL: 3078 case SYNC_PREF_FORCE_LOCAL:
3079 return 1; 3079 return 1;
3080 break; 3080 break;
3081 case SYNC_PREF_FORCE_REMOTE: 3081 case SYNC_PREF_FORCE_REMOTE:
3082 return 2; 3082 return 2;
3083 break; 3083 break;
3084 3084
3085 default: 3085 default:
3086 // SYNC_PREF_TAKE_BOTH not implemented 3086 // SYNC_PREF_TAKE_BOTH not implemented
3087 break; 3087 break;
3088 } 3088 }
3089 return 0; 3089 return 0;
3090} 3090}
3091 3091
3092 3092
3093 3093
3094 3094
3095//this are the overwritten callbackmethods from the syncinterface 3095//this are the overwritten callbackmethods from the syncinterface
3096bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode) 3096bool PwMDoc::sync(KSyncManager* manager, QString filename, int mode)
3097{ 3097{
3098 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3098 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3099 3099
3100 //1) unlock local file first if necessary (ask for password) 3100 //1) unlock local file first if necessary (ask for password)
3101 if (this->isDeepLocked()) { 3101 if (this->isDeepLocked()) {
3102 PwMerror ret = this->deepLock(false); 3102 PwMerror ret = this->deepLock(false);
3103 if (ret != e_success) 3103 if (ret != e_success)
3104 return false; 3104 return false;
3105 } 3105 }
3106 3106
3107 //2) construct and open a new doc on the stack(automatic cleanup) for remote file. 3107 //2) construct and open a new doc on the stack(automatic cleanup) for remote file.
3108 PwMDoc syncTarget(this, "synctarget"); 3108 PwMDoc syncTarget(this, "synctarget");
3109 PwMDoc* pSyncTarget = &syncTarget; 3109 PwMDoc* pSyncTarget = &syncTarget;
3110 3110
3111 3111
3112 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/); 3112 PwMerror err = pSyncTarget->openDoc(&filename, 1 /*== open with all entries locked*/);
3113 3113
3114 if (err == e_alreadyOpen) { 3114 if (err == e_alreadyOpen) {
3115 PwMDocList::listItem li; 3115 PwMDocList::listItem li;
3116 if (getOpenDocList()->find(filename.latin1(), &li)) 3116 if (getOpenDocList()->find(filename.latin1(), &li))
3117 pSyncTarget = li.doc; 3117 pSyncTarget = li.doc;
3118 else { 3118 else {
3119 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3119 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3120 return false; 3120 return false;
3121 } 3121 }
3122 } 3122 }
3123 else if (err != e_success) { 3123 else if (err != e_success) {
3124 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1()); 3124 qDebug("PwmDoc::sync: sync failed. Error %i while opening file %s",err, filename.latin1());
3125 return false; 3125 return false;
3126 } 3126 }
3127 3127
3128 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode ); 3128 qDebug("PWM file loaded %s,sync mode %d",filename.latin1(), mode );
3129 3129
3130 3130
3131 //3) unlock remote file first if necessary (ask for password) 3131 //3) unlock remote file first if necessary (ask for password)
3132 if (pSyncTarget->isDeepLocked()) { 3132 if (pSyncTarget->isDeepLocked()) {
3133 PwMerror ret = pSyncTarget->deepLock(false); 3133 PwMerror ret = pSyncTarget->deepLock(false);
3134 if (ret != e_success) 3134 if (ret != e_success)
3135 return false; 3135 return false;
3136 } 3136 }
3137 3137
3138 3138
3139 err = syncronize(manager, this, pSyncTarget, mode ); 3139 err = syncronize(manager, this, pSyncTarget, mode );
3140 3140
3141 if (err == e_success) { 3141 if (err == e_success) {
3142 if ( PWMPrefs::instance()->mWriteBackFile ){ 3142 if ( manager->mWriteBackFile ){
3143 qDebug("Saving remote PWManager file"); 3143 qDebug("Saving remote PWManager file");
3144 err = pSyncTarget->saveDoc(conf()->confGlobCompression()); 3144 err = pSyncTarget->saveDoc(conf()->confGlobCompression());
3145 if (err != e_success) { 3145 if (err != e_success) {
3146 qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1()); 3146 qDebug("PwmDoc::sync: Sync failed. Error %i while storing file %s",err, filename.latin1());
3147 return false; 3147 return false;
3148 } 3148 }
3149 } 3149 }
3150 3150
3151 flagDirty(); 3151 flagDirty();
3152 return true; 3152 return true;
3153 } 3153 }
3154 else { 3154 else {
3155 return false; 3155 return false;
3156 } 3156 }
3157} 3157}
3158 3158
3159//called by the syncmanager to indicate that the work has to marked as dirty. 3159//called by the syncmanager to indicate that the work has to marked as dirty.
3160void PwMDoc::sync_setModified() 3160void PwMDoc::sync_setModified()
3161{ 3161{
3162 flagDirty(); 3162 flagDirty();
3163} 3163}
3164 3164
3165//called by the syncmanager to ask if the dirty flag is set. 3165//called by the syncmanager to ask if the dirty flag is set.
3166bool PwMDoc::sync_isModified() 3166bool PwMDoc::sync_isModified()
3167{ 3167{
3168 return isDirty(); 3168 return isDirty();
3169} 3169}
3170 3170
3171//called by the syncmanager to indicate that the work has to be saved. 3171//called by the syncmanager to indicate that the work has to be saved.
3172void PwMDoc::sync_save() 3172void PwMDoc::sync_save()
3173{ 3173{
3174 saveDoc(conf()->confGlobCompression()); 3174 saveDoc(conf()->confGlobCompression());
3175} 3175}
3176#endif 3176#endif
3177 3177
3178 3178
3179bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index) 3179bool PwMDoc::findSyncData(const QString &syncname, unsigned int *index)
3180{ 3180{
3181 vector<PwMSyncItem>::iterator i = dti.syncDta.begin(), 3181 vector<PwMSyncItem>::iterator i = dti.syncDta.begin(),
3182 end = dti.syncDta.end(); 3182 end = dti.syncDta.end();
3183 3183
3184 while (i != end) { 3184 while (i != end) {
3185 if ((*i).syncName == syncname.latin1()) { 3185 if ((*i).syncName == syncname.latin1()) {
3186 if (index) { 3186 if (index) {
3187 *index = i - dti.syncDta.begin(); 3187 *index = i - dti.syncDta.begin();
3188 } 3188 }
3189 return true; 3189 return true;
3190 } 3190 }
3191 ++i; 3191 ++i;
3192 } 3192 }
3193 return false; 3193 return false;
3194}; 3194};
3195 3195
3196/** add new syncdataentry */ 3196/** add new syncdataentry */
3197PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty) 3197PwMerror PwMDoc::addSyncDataEntry(PwMSyncItem *d, bool dontFlagDirty)
3198{ 3198{
3199 PWM_ASSERT(d); 3199 PWM_ASSERT(d);
3200 3200
3201 if (isDeepLocked()) { 3201 if (isDeepLocked()) {
3202 PwMerror ret; 3202 PwMerror ret;
3203 ret = deepLock(false); 3203 ret = deepLock(false);
3204 if (ret != e_success) 3204 if (ret != e_success)
3205 return e_lock; 3205 return e_lock;
3206 } 3206 }
3207 unsigned int index; 3207 unsigned int index;
3208 3208
3209 const QString tmp = d->syncName.c_str(); 3209 const QString tmp = d->syncName.c_str();
3210 bool exists = findSyncData(d->syncName.c_str(), &index); 3210 bool exists = findSyncData(d->syncName.c_str(), &index);
3211 3211
3212 if (exists == true) { 3212 if (exists == true) {
3213 // DOH! We found this entry. 3213 // DOH! We found this entry.
3214 return e_entryExists; 3214 return e_entryExists;
3215 } 3215 }
3216 3216
3217 dti.syncDta.push_back(*d); 3217 dti.syncDta.push_back(*d);
3218 3218
3219 if (!dontFlagDirty) 3219 if (!dontFlagDirty)
3220 flagDirty(); 3220 flagDirty();
3221 return e_success; 3221 return e_success;
3222} 3222}
3223 3223
3224 3224
3225 3225
3226/** delete syncdata entry */ 3226/** delete syncdata entry */
3227bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty) 3227bool PwMDoc::delSyncDataEntry(unsigned int index, bool dontFlagDirty)
3228{ 3228{
3229 if (isDeepLocked()) 3229 if (isDeepLocked())
3230 return false; 3230 return false;
3231 if (index > dti.syncDta.size() - 1) 3231 if (index > dti.syncDta.size() - 1)
3232 return false; 3232 return false;
3233 3233
3234 // delete entry 3234 // delete entry
3235 dti.syncDta.erase(dti.syncDta.begin() + index); 3235 dti.syncDta.erase(dti.syncDta.begin() + index);
3236 3236
3237 if (!dontFlagDirty) 3237 if (!dontFlagDirty)
3238 flagDirty(); 3238 flagDirty();
3239 return true; 3239 return true;
3240} 3240}
3241 3241
3242 3242
3243PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index) 3243PwMDataItem* PwMDoc::findEntryByID(const QString &uid, unsigned int *category, unsigned int *index)
3244{ 3244{
3245 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), 3245 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(),
3246 catend = dti.dta.end(); 3246 catend = dti.dta.end();
3247 3247
3248 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 3248 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
3249 3249
3250 while (catcounter != catend) { 3250 while (catcounter != catend) {
3251 entrBegin = catcounter->d.begin(); 3251 entrBegin = catcounter->d.begin();
3252 entrEnd = catcounter->d.end(); 3252 entrEnd = catcounter->d.end();
3253 entrI = entrBegin; 3253 entrI = entrBegin;
3254 while (entrI != entrEnd) { 3254 while (entrI != entrEnd) {
3255 if ((*entrI).meta.uniqueid == uid.latin1()) { 3255 if ((*entrI).meta.uniqueid == uid.latin1()) {
3256 if (category) 3256 if (category)
3257 *category = catcounter - dti.dta.begin(); 3257 *category = catcounter - dti.dta.begin();
3258 if (index) 3258 if (index)
3259 *index = entrI - entrBegin; 3259 *index = entrI - entrBegin;
3260 3260
3261 return &(*entrI); 3261 return &(*entrI);
3262 } 3262 }
3263 ++entrI; 3263 ++entrI;
3264 } 3264 }
3265 ++catcounter; 3265 ++catcounter;
3266 } 3266 }
3267 3267
3268 return 0; 3268 return 0;
3269} 3269}
3270 3270
3271QStringList PwMDoc::getIDEntryList() 3271QStringList PwMDoc::getIDEntryList()
3272{ 3272{
3273 QStringList results; 3273 QStringList results;
3274 3274
3275 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(), 3275 vector<PwMCategoryItem>::iterator catcounter = dti.dta.begin(),
3276 catend = dti.dta.end(); 3276 catend = dti.dta.end();
3277 3277
3278 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI; 3278 vector<PwMDataItem>::iterator entrBegin, entrEnd, entrI;
3279 3279
3280 while (catcounter != catend) { 3280 while (catcounter != catend) {
3281 entrBegin = catcounter->d.begin(); 3281 entrBegin = catcounter->d.begin();
3282 entrEnd = catcounter->d.end(); 3282 entrEnd = catcounter->d.end();
3283 entrI = entrBegin; 3283 entrI = entrBegin;
3284 while (entrI != entrEnd) { 3284 while (entrI != entrEnd) {
3285 results.append( (*entrI).meta.uniqueid ); 3285 results.append( (*entrI).meta.uniqueid );
3286 ++entrI; 3286 ++entrI;
3287 } 3287 }
3288 ++catcounter; 3288 ++catcounter;
3289 } 3289 }
3290 3290
3291 return results; 3291 return results;
3292} 3292}
3293 3293
3294 3294
3295 3295
3296 3296
3297 3297
3298#ifndef PWM_EMBEDDED 3298#ifndef PWM_EMBEDDED
3299#include "pwmdoc.moc" 3299#include "pwmdoc.moc"
3300#endif 3300#endif