author | zautrix <zautrix> | 2005-04-03 22:00:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-03 22:00:17 (UTC) |
commit | 30359da3c126e67f6c75400323fcca4c159c3d93 (patch) (unidiff) | |
tree | 71fbc8d5574ebe5156171af935f9c5da99d9ffcf /kaddressbook | |
parent | 23d4df2516068bfbf8d968b94763d0a6d6e13271 (diff) | |
download | kdepimpi-30359da3c126e67f6c75400323fcca4c159c3d93.zip kdepimpi-30359da3c126e67f6c75400323fcca4c159c3d93.tar.gz kdepimpi-30359da3c126e67f6c75400323fcca4c159c3d93.tar.bz2 |
sync fixes
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index eba74a6..20b107e 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -2103,1308 +2103,1310 @@ void KABCore::initActions() | |||
2103 | 2103 | ||
2104 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, | 2104 | mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, |
2105 | this, SLOT( storagehowto() ), actionCollection(), | 2105 | this, SLOT( storagehowto() ), actionCollection(), |
2106 | "storage" ); | 2106 | "storage" ); |
2107 | 2107 | ||
2108 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2108 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2109 | this, SLOT( synchowto() ), actionCollection(), | 2109 | this, SLOT( synchowto() ), actionCollection(), |
2110 | "sync" ); | 2110 | "sync" ); |
2111 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2111 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2112 | this, SLOT( kdesynchowto() ), actionCollection(), | 2112 | this, SLOT( kdesynchowto() ), actionCollection(), |
2113 | "kdesync" ); | 2113 | "kdesync" ); |
2114 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2114 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2115 | this, SLOT( multisynchowto() ), actionCollection(), | 2115 | this, SLOT( multisynchowto() ), actionCollection(), |
2116 | "multisync" ); | 2116 | "multisync" ); |
2117 | 2117 | ||
2118 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2118 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2119 | this, SLOT( createAboutData() ), actionCollection(), | 2119 | this, SLOT( createAboutData() ), actionCollection(), |
2120 | "kaddressbook_about_data" ); | 2120 | "kaddressbook_about_data" ); |
2121 | #endif //KAB_EMBEDDED | 2121 | #endif //KAB_EMBEDDED |
2122 | 2122 | ||
2123 | clipboardDataChanged(); | 2123 | clipboardDataChanged(); |
2124 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2124 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2125 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2125 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2126 | } | 2126 | } |
2127 | 2127 | ||
2128 | //US we need this function, to plug all actions into the correct menues. | 2128 | //US we need this function, to plug all actions into the correct menues. |
2129 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2129 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2130 | void KABCore::addActionsManually() | 2130 | void KABCore::addActionsManually() |
2131 | { | 2131 | { |
2132 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2132 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2133 | 2133 | ||
2134 | #ifdef KAB_EMBEDDED | 2134 | #ifdef KAB_EMBEDDED |
2135 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2135 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2136 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2136 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2137 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2137 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2138 | 2138 | ||
2139 | KToolBar* tb = mMainWindow->toolBar(); | 2139 | KToolBar* tb = mMainWindow->toolBar(); |
2140 | mMainWindow->setToolBarsMovable (false ); | 2140 | mMainWindow->setToolBarsMovable (false ); |
2141 | #ifndef DESKTOP_VERSION | 2141 | #ifndef DESKTOP_VERSION |
2142 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2142 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2143 | #endif | 2143 | #endif |
2144 | QMenuBar* mb = mMainWindow->menuBar(); | 2144 | QMenuBar* mb = mMainWindow->menuBar(); |
2145 | 2145 | ||
2146 | //US setup menubar. | 2146 | //US setup menubar. |
2147 | //Disable the following block if you do not want to have a menubar. | 2147 | //Disable the following block if you do not want to have a menubar. |
2148 | mb->insertItem( i18n("&File"), fileMenu ); | 2148 | mb->insertItem( i18n("&File"), fileMenu ); |
2149 | mb->insertItem( i18n("&Edit"), editMenu ); | 2149 | mb->insertItem( i18n("&Edit"), editMenu ); |
2150 | mb->insertItem( i18n("&View"), viewMenu ); | 2150 | mb->insertItem( i18n("&View"), viewMenu ); |
2151 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2151 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2152 | #ifdef DESKTOP_VERSION | 2152 | #ifdef DESKTOP_VERSION |
2153 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2153 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2154 | #else | 2154 | #else |
2155 | mb->insertItem( i18n("Sync"), syncMenu ); | 2155 | mb->insertItem( i18n("Sync"), syncMenu ); |
2156 | #endif | 2156 | #endif |
2157 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2157 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2158 | mb->insertItem( i18n("&Help"), helpMenu ); | 2158 | mb->insertItem( i18n("&Help"), helpMenu ); |
2159 | mIncSearchWidget = new IncSearchWidget( tb ); | 2159 | mIncSearchWidget = new IncSearchWidget( tb ); |
2160 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2160 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2161 | #ifndef DESKTOP_VERSION | 2161 | #ifndef DESKTOP_VERSION |
2162 | } else { | 2162 | } else { |
2163 | //US setup toolbar | 2163 | //US setup toolbar |
2164 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2164 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2165 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2165 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2166 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); | 2166 | menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); |
2167 | tb->insertWidget(-1, 0, menuBarTB); | 2167 | tb->insertWidget(-1, 0, menuBarTB); |
2168 | mIncSearchWidget = new IncSearchWidget( tb ); | 2168 | mIncSearchWidget = new IncSearchWidget( tb ); |
2169 | tb->enableMoving(false); | 2169 | tb->enableMoving(false); |
2170 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2170 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2171 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2171 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2172 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2172 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2173 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2173 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2174 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2174 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2175 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2175 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2176 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2176 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2177 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2177 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2178 | if (QApplication::desktop()->width() > 320 ) { | 2178 | if (QApplication::desktop()->width() > 320 ) { |
2179 | // mViewManager->getFilterAction()->plug ( tb); | 2179 | // mViewManager->getFilterAction()->plug ( tb); |
2180 | } | 2180 | } |
2181 | } | 2181 | } |
2182 | #endif | 2182 | #endif |
2183 | mIncSearchWidget->setSize(); | 2183 | mIncSearchWidget->setSize(); |
2184 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2184 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2185 | 2185 | ||
2186 | 2186 | ||
2187 | 2187 | ||
2188 | //US Now connect the actions with the menue entries. | 2188 | //US Now connect the actions with the menue entries. |
2189 | #ifdef DESKTOP_VERSION | 2189 | #ifdef DESKTOP_VERSION |
2190 | mActionPrint->plug( fileMenu ); | 2190 | mActionPrint->plug( fileMenu ); |
2191 | mActionPrintDetails->plug( fileMenu ); | 2191 | mActionPrintDetails->plug( fileMenu ); |
2192 | fileMenu->insertSeparator(); | 2192 | fileMenu->insertSeparator(); |
2193 | #endif | 2193 | #endif |
2194 | mActionMail->plug( fileMenu ); | 2194 | mActionMail->plug( fileMenu ); |
2195 | fileMenu->insertSeparator(); | 2195 | fileMenu->insertSeparator(); |
2196 | 2196 | ||
2197 | mActionNewContact->plug( editMenu ); | 2197 | mActionNewContact->plug( editMenu ); |
2198 | mActionNewContact->plug( tb ); | 2198 | mActionNewContact->plug( tb ); |
2199 | 2199 | ||
2200 | mActionEditAddressee->plug( editMenu ); | 2200 | mActionEditAddressee->plug( editMenu ); |
2201 | editMenu->insertSeparator(); | 2201 | editMenu->insertSeparator(); |
2202 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2202 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2203 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2203 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2204 | mActionEditAddressee->plug( tb ); | 2204 | mActionEditAddressee->plug( tb ); |
2205 | 2205 | ||
2206 | // fileMenu->insertSeparator(); | 2206 | // fileMenu->insertSeparator(); |
2207 | mActionSave->plug( fileMenu ); | 2207 | mActionSave->plug( fileMenu ); |
2208 | fileMenu->insertItem( "&Import", ImportMenu ); | 2208 | fileMenu->insertItem( "&Import", ImportMenu ); |
2209 | fileMenu->insertItem( "&Export", ExportMenu ); | 2209 | fileMenu->insertItem( "&Export", ExportMenu ); |
2210 | editMenu->insertItem( i18n("&Change"), changeMenu ); | 2210 | editMenu->insertItem( i18n("&Change"), changeMenu ); |
2211 | editMenu->insertSeparator(); | 2211 | editMenu->insertSeparator(); |
2212 | #ifndef DESKTOP_VERSION | 2212 | #ifndef DESKTOP_VERSION |
2213 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2213 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2214 | #endif | 2214 | #endif |
2215 | #if 0 | 2215 | #if 0 |
2216 | // PENDING fix MailVCard | 2216 | // PENDING fix MailVCard |
2217 | fileMenu->insertSeparator(); | 2217 | fileMenu->insertSeparator(); |
2218 | mActionMailVCard->plug( fileMenu ); | 2218 | mActionMailVCard->plug( fileMenu ); |
2219 | #endif | 2219 | #endif |
2220 | #ifndef DESKTOP_VERSION | 2220 | #ifndef DESKTOP_VERSION |
2221 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2221 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2222 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2222 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2223 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2223 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2224 | #endif | 2224 | #endif |
2225 | fileMenu->insertSeparator(); | 2225 | fileMenu->insertSeparator(); |
2226 | mActionQuit->plug( fileMenu ); | 2226 | mActionQuit->plug( fileMenu ); |
2227 | #ifdef _OL_IMPORT_ | 2227 | #ifdef _OL_IMPORT_ |
2228 | mActionImportOL->plug( ImportMenu ); | 2228 | mActionImportOL->plug( ImportMenu ); |
2229 | #endif | 2229 | #endif |
2230 | // edit menu | 2230 | // edit menu |
2231 | mActionUndo->plug( editMenu ); | 2231 | mActionUndo->plug( editMenu ); |
2232 | mActionRedo->plug( editMenu ); | 2232 | mActionRedo->plug( editMenu ); |
2233 | editMenu->insertSeparator(); | 2233 | editMenu->insertSeparator(); |
2234 | mActionCut->plug( editMenu ); | 2234 | mActionCut->plug( editMenu ); |
2235 | mActionCopy->plug( editMenu ); | 2235 | mActionCopy->plug( editMenu ); |
2236 | mActionPaste->plug( editMenu ); | 2236 | mActionPaste->plug( editMenu ); |
2237 | mActionDelete->plug( editMenu ); | 2237 | mActionDelete->plug( editMenu ); |
2238 | editMenu->insertSeparator(); | 2238 | editMenu->insertSeparator(); |
2239 | mActionSelectAll->plug( editMenu ); | 2239 | mActionSelectAll->plug( editMenu ); |
2240 | 2240 | ||
2241 | mActionSetFormattedName->plug( changeMenu ); | 2241 | mActionSetFormattedName->plug( changeMenu ); |
2242 | mActionRemoveVoice->plug( changeMenu ); | 2242 | mActionRemoveVoice->plug( changeMenu ); |
2243 | // settingsmings menu | 2243 | // settingsmings menu |
2244 | //US special menuentry to configure the addressbook resources. On KDE | 2244 | //US special menuentry to configure the addressbook resources. On KDE |
2245 | // you do that through the control center !!! | 2245 | // you do that through the control center !!! |
2246 | // settingsMenu->insertSeparator(); | 2246 | // settingsMenu->insertSeparator(); |
2247 | 2247 | ||
2248 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); | 2248 | mActionConfigKAddressbook->plug( settingsMenu, 0 ); |
2249 | mActionConfigResources->plug( settingsMenu,1 ); | 2249 | mActionConfigResources->plug( settingsMenu,1 ); |
2250 | settingsMenu->insertSeparator(2); | 2250 | settingsMenu->insertSeparator(2); |
2251 | 2251 | ||
2252 | if ( mIsPart ) { | 2252 | if ( mIsPart ) { |
2253 | //US not implemented yet | 2253 | //US not implemented yet |
2254 | //mActionConfigShortcuts->plug( settingsMenu ); | 2254 | //mActionConfigShortcuts->plug( settingsMenu ); |
2255 | //mActionConfigureToolbars->plug( settingsMenu ); | 2255 | //mActionConfigureToolbars->plug( settingsMenu ); |
2256 | 2256 | ||
2257 | } else { | 2257 | } else { |
2258 | //US not implemented yet | 2258 | //US not implemented yet |
2259 | //mActionKeyBindings->plug( settingsMenu ); | 2259 | //mActionKeyBindings->plug( settingsMenu ); |
2260 | } | 2260 | } |
2261 | 2261 | ||
2262 | mActionEditCategories->plug( settingsMenu ); | 2262 | mActionEditCategories->plug( settingsMenu ); |
2263 | mActionManageCategories->plug( settingsMenu ); | 2263 | mActionManageCategories->plug( settingsMenu ); |
2264 | mActionJumpBar->plug( viewMenu,0 ); | 2264 | mActionJumpBar->plug( viewMenu,0 ); |
2265 | mActionDetails->plug( viewMenu,0 ); | 2265 | mActionDetails->plug( viewMenu,0 ); |
2266 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2266 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2267 | mActionDetails->plug( tb ); | 2267 | mActionDetails->plug( tb ); |
2268 | settingsMenu->insertSeparator(); | 2268 | settingsMenu->insertSeparator(); |
2269 | #ifndef DESKTOP_VERSION | 2269 | #ifndef DESKTOP_VERSION |
2270 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2270 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2271 | settingsMenu->insertSeparator(); | 2271 | settingsMenu->insertSeparator(); |
2272 | #endif | 2272 | #endif |
2273 | 2273 | ||
2274 | mActionWhoAmI->plug( settingsMenu ); | 2274 | mActionWhoAmI->plug( settingsMenu ); |
2275 | //mActionEditCategories->plug( changeMenu ); | 2275 | //mActionEditCategories->plug( changeMenu ); |
2276 | mActionCategories->plug( changeMenu ); | 2276 | mActionCategories->plug( changeMenu ); |
2277 | //mActionManageCategories->plug( changeMenu ); | 2277 | //mActionManageCategories->plug( changeMenu ); |
2278 | 2278 | ||
2279 | //mActionCategories->plug( settingsMenu ); | 2279 | //mActionCategories->plug( settingsMenu ); |
2280 | 2280 | ||
2281 | 2281 | ||
2282 | mActionWN->plug( helpMenu ); | 2282 | mActionWN->plug( helpMenu ); |
2283 | mActionStorageHowto->plug( helpMenu ); | 2283 | mActionStorageHowto->plug( helpMenu ); |
2284 | mActionSyncHowto->plug( helpMenu ); | 2284 | mActionSyncHowto->plug( helpMenu ); |
2285 | mActionKdeSyncHowto->plug( helpMenu ); | 2285 | mActionKdeSyncHowto->plug( helpMenu ); |
2286 | mActionMultiSyncHowto->plug( helpMenu ); | 2286 | mActionMultiSyncHowto->plug( helpMenu ); |
2287 | mActionFaq->plug( helpMenu ); | 2287 | mActionFaq->plug( helpMenu ); |
2288 | mActionLicence->plug( helpMenu ); | 2288 | mActionLicence->plug( helpMenu ); |
2289 | mActionAboutKAddressbook->plug( helpMenu ); | 2289 | mActionAboutKAddressbook->plug( helpMenu ); |
2290 | 2290 | ||
2291 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2291 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2292 | 2292 | ||
2293 | mActionSave->plug( tb ); | 2293 | mActionSave->plug( tb ); |
2294 | mViewManager->getFilterAction()->plug ( tb); | 2294 | mViewManager->getFilterAction()->plug ( tb); |
2295 | //LR hide filteraction on started in 480x640 | 2295 | //LR hide filteraction on started in 480x640 |
2296 | if (QApplication::desktop()->width() == 480 ) { | 2296 | if (QApplication::desktop()->width() == 480 ) { |
2297 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 2297 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
2298 | } | 2298 | } |
2299 | mActionUndo->plug( tb ); | 2299 | mActionUndo->plug( tb ); |
2300 | mActionDelete->plug( tb ); | 2300 | mActionDelete->plug( tb ); |
2301 | mActionRedo->plug( tb ); | 2301 | mActionRedo->plug( tb ); |
2302 | } else { | 2302 | } else { |
2303 | mActionSave->plug( tb ); | 2303 | mActionSave->plug( tb ); |
2304 | tb->enableMoving(false); | 2304 | tb->enableMoving(false); |
2305 | } | 2305 | } |
2306 | //mActionQuit->plug ( tb ); | 2306 | //mActionQuit->plug ( tb ); |
2307 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2307 | //tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2308 | 2308 | ||
2309 | //US link the searchwidget first to this. | 2309 | //US link the searchwidget first to this. |
2310 | // The real linkage to the toolbar happens later. | 2310 | // The real linkage to the toolbar happens later. |
2311 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2311 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2312 | //US tb->insertItem( mIncSearchWidget ); | 2312 | //US tb->insertItem( mIncSearchWidget ); |
2313 | /*US | 2313 | /*US |
2314 | mIncSearchWidget = new IncSearchWidget( tb ); | 2314 | mIncSearchWidget = new IncSearchWidget( tb ); |
2315 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2315 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2316 | SLOT( incrementalSearch( const QString& ) ) ); | 2316 | SLOT( incrementalSearch( const QString& ) ) ); |
2317 | 2317 | ||
2318 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2318 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2319 | 2319 | ||
2320 | //US topLayout->addWidget( mJumpButtonBar ); | 2320 | //US topLayout->addWidget( mJumpButtonBar ); |
2321 | this->layout()->add( mJumpButtonBar ); | 2321 | this->layout()->add( mJumpButtonBar ); |
2322 | */ | 2322 | */ |
2323 | 2323 | ||
2324 | #endif //KAB_EMBEDDED | 2324 | #endif //KAB_EMBEDDED |
2325 | 2325 | ||
2326 | mActionExport2phone->plug( ExportMenu ); | 2326 | mActionExport2phone->plug( ExportMenu ); |
2327 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2327 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2328 | syncManager->fillSyncMenu(); | 2328 | syncManager->fillSyncMenu(); |
2329 | 2329 | ||
2330 | } | 2330 | } |
2331 | void KABCore::showLicence() | 2331 | void KABCore::showLicence() |
2332 | { | 2332 | { |
2333 | KApplication::showLicence(); | 2333 | KApplication::showLicence(); |
2334 | } | 2334 | } |
2335 | 2335 | ||
2336 | void KABCore::manageCategories( ) | 2336 | void KABCore::manageCategories( ) |
2337 | { | 2337 | { |
2338 | KABCatPrefs* cp = new KABCatPrefs(); | 2338 | KABCatPrefs* cp = new KABCatPrefs(); |
2339 | cp->show(); | 2339 | cp->show(); |
2340 | int w =cp->sizeHint().width() ; | 2340 | int w =cp->sizeHint().width() ; |
2341 | int h = cp->sizeHint().height() ; | 2341 | int h = cp->sizeHint().height() ; |
2342 | int dw = QApplication::desktop()->width(); | 2342 | int dw = QApplication::desktop()->width(); |
2343 | int dh = QApplication::desktop()->height(); | 2343 | int dh = QApplication::desktop()->height(); |
2344 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2344 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2345 | if ( !cp->exec() ) { | 2345 | if ( !cp->exec() ) { |
2346 | delete cp; | 2346 | delete cp; |
2347 | return; | 2347 | return; |
2348 | } | 2348 | } |
2349 | int count = 0; | 2349 | int count = 0; |
2350 | int cc = 0; | 2350 | int cc = 0; |
2351 | message( i18n("Please wait, processing categories...")); | 2351 | message( i18n("Please wait, processing categories...")); |
2352 | if ( cp->addCat() ) { | 2352 | if ( cp->addCat() ) { |
2353 | KABC::AddressBook::Iterator it; | 2353 | KABC::AddressBook::Iterator it; |
2354 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2354 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2355 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2355 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2356 | ++cc; | 2356 | ++cc; |
2357 | if ( cc %10 == 0) | 2357 | if ( cc %10 == 0) |
2358 | message(i18n("Processing contact #%1").arg(cc)); | 2358 | message(i18n("Processing contact #%1").arg(cc)); |
2359 | QStringList catIncList = (*it).categories(); | 2359 | QStringList catIncList = (*it).categories(); |
2360 | int i; | 2360 | int i; |
2361 | for( i = 0; i< catIncList.count(); ++i ) { | 2361 | for( i = 0; i< catIncList.count(); ++i ) { |
2362 | if ( !catList.contains (catIncList[i])) { | 2362 | if ( !catList.contains (catIncList[i])) { |
2363 | catList.append( catIncList[i] ); | 2363 | catList.append( catIncList[i] ); |
2364 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2364 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2365 | ++count; | 2365 | ++count; |
2366 | } | 2366 | } |
2367 | } | 2367 | } |
2368 | } | 2368 | } |
2369 | catList.sort(); | 2369 | catList.sort(); |
2370 | KABPrefs::instance()->mCustomCategories = catList; | 2370 | KABPrefs::instance()->mCustomCategories = catList; |
2371 | KABPrefs::instance()->writeConfig(); | 2371 | KABPrefs::instance()->writeConfig(); |
2372 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2372 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2373 | } else { | 2373 | } else { |
2374 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2374 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2375 | QStringList catIncList; | 2375 | QStringList catIncList; |
2376 | QStringList newCatList; | 2376 | QStringList newCatList; |
2377 | KABC::AddressBook::Iterator it; | 2377 | KABC::AddressBook::Iterator it; |
2378 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2378 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2379 | ++cc; | 2379 | ++cc; |
2380 | if ( cc %10 == 0) | 2380 | if ( cc %10 == 0) |
2381 | message(i18n("Processing contact #%1").arg(cc)); | 2381 | message(i18n("Processing contact #%1").arg(cc)); |
2382 | QStringList catIncList = (*it).categories(); | 2382 | QStringList catIncList = (*it).categories(); |
2383 | int i; | 2383 | int i; |
2384 | if ( catIncList.count() ) { | 2384 | if ( catIncList.count() ) { |
2385 | newCatList.clear(); | 2385 | newCatList.clear(); |
2386 | for( i = 0; i< catIncList.count(); ++i ) { | 2386 | for( i = 0; i< catIncList.count(); ++i ) { |
2387 | if ( catList.contains (catIncList[i])) { | 2387 | if ( catList.contains (catIncList[i])) { |
2388 | newCatList.append( catIncList[i] ); | 2388 | newCatList.append( catIncList[i] ); |
2389 | } | 2389 | } |
2390 | } | 2390 | } |
2391 | newCatList.sort(); | 2391 | newCatList.sort(); |
2392 | (*it).setCategories( newCatList ); | 2392 | (*it).setCategories( newCatList ); |
2393 | mAddressBook->insertAddressee( (*it) ); | 2393 | mAddressBook->insertAddressee( (*it) ); |
2394 | } | 2394 | } |
2395 | } | 2395 | } |
2396 | setModified( true ); | 2396 | setModified( true ); |
2397 | mViewManager->refreshView(); | 2397 | mViewManager->refreshView(); |
2398 | message( i18n("Removing categories done!")); | 2398 | message( i18n("Removing categories done!")); |
2399 | } | 2399 | } |
2400 | delete cp; | 2400 | delete cp; |
2401 | } | 2401 | } |
2402 | void KABCore::removeVoice() | 2402 | void KABCore::removeVoice() |
2403 | { | 2403 | { |
2404 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2404 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2405 | return; | 2405 | return; |
2406 | XXPortSelectDialog dlg( this, false, this ); | 2406 | XXPortSelectDialog dlg( this, false, this ); |
2407 | if ( !dlg.exec() ) | 2407 | if ( !dlg.exec() ) |
2408 | return; | 2408 | return; |
2409 | mAddressBook->setUntagged(); | 2409 | mAddressBook->setUntagged(); |
2410 | dlg.tagSelected(); | 2410 | dlg.tagSelected(); |
2411 | message(i18n("Removing voice..."), false ); | 2411 | message(i18n("Removing voice..."), false ); |
2412 | KABC::AddressBook::Iterator it; | 2412 | KABC::AddressBook::Iterator it; |
2413 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2413 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2414 | if ( (*it).tagged() ) { | 2414 | if ( (*it).tagged() ) { |
2415 | (*it).removeVoice(); | 2415 | (*it).removeVoice(); |
2416 | } | 2416 | } |
2417 | } | 2417 | } |
2418 | message(i18n("Refreshing view...") ); | 2418 | message(i18n("Refreshing view...") ); |
2419 | qApp->processEvents(); | 2419 | qApp->processEvents(); |
2420 | mViewManager->refreshView( "" ); | 2420 | mViewManager->refreshView( "" ); |
2421 | Addressee add; | 2421 | Addressee add; |
2422 | mDetails->setAddressee( add ); | 2422 | mDetails->setAddressee( add ); |
2423 | message(i18n("Remove voice completed!") ); | 2423 | message(i18n("Remove voice completed!") ); |
2424 | 2424 | ||
2425 | 2425 | ||
2426 | 2426 | ||
2427 | } | 2427 | } |
2428 | 2428 | ||
2429 | void KABCore::setFormattedName() | 2429 | void KABCore::setFormattedName() |
2430 | { | 2430 | { |
2431 | KABFormatPrefs setpref; | 2431 | KABFormatPrefs setpref; |
2432 | if ( !setpref.exec() ) { | 2432 | if ( !setpref.exec() ) { |
2433 | return; | 2433 | return; |
2434 | } | 2434 | } |
2435 | XXPortSelectDialog dlg( this, false, this ); | 2435 | XXPortSelectDialog dlg( this, false, this ); |
2436 | if ( !dlg.exec() ) | 2436 | if ( !dlg.exec() ) |
2437 | return; | 2437 | return; |
2438 | mAddressBook->setUntagged(); | 2438 | mAddressBook->setUntagged(); |
2439 | dlg.tagSelected(); | 2439 | dlg.tagSelected(); |
2440 | int count = 0; | 2440 | int count = 0; |
2441 | KABC::AddressBook::Iterator it; | 2441 | KABC::AddressBook::Iterator it; |
2442 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2442 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2443 | if ( (*it).tagged() ) { | 2443 | if ( (*it).tagged() ) { |
2444 | ++count; | 2444 | ++count; |
2445 | if ( count %10 == 0 ) | 2445 | if ( count %10 == 0 ) |
2446 | message(i18n("Changing contact #%1").arg( count ) ); | 2446 | message(i18n("Changing contact #%1").arg( count ) ); |
2447 | qApp->processEvents(); | 2447 | qApp->processEvents(); |
2448 | QString fName; | 2448 | QString fName; |
2449 | if ( setpref.simple->isChecked() ) | 2449 | if ( setpref.simple->isChecked() ) |
2450 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); | 2450 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); |
2451 | else if ( setpref.full->isChecked() ) | 2451 | else if ( setpref.full->isChecked() ) |
2452 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); | 2452 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); |
2453 | else if ( setpref.reverse->isChecked() ) | 2453 | else if ( setpref.reverse->isChecked() ) |
2454 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); | 2454 | fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); |
2455 | else | 2455 | else |
2456 | fName = (*it).organization(); | 2456 | fName = (*it).organization(); |
2457 | if ( setpref.setCompany->isChecked() ) | 2457 | if ( setpref.setCompany->isChecked() ) |
2458 | if ( fName.isEmpty() || fName =="," ) | 2458 | if ( fName.isEmpty() || fName =="," ) |
2459 | fName = (*it).organization(); | 2459 | fName = (*it).organization(); |
2460 | (*it).setFormattedName( fName ); | 2460 | (*it).setFormattedName( fName ); |
2461 | } | 2461 | } |
2462 | } | 2462 | } |
2463 | message(i18n("Refreshing view...") ); | 2463 | message(i18n("Refreshing view...") ); |
2464 | qApp->processEvents(); | 2464 | qApp->processEvents(); |
2465 | mViewManager->refreshView( "" ); | 2465 | mViewManager->refreshView( "" ); |
2466 | Addressee add; | 2466 | Addressee add; |
2467 | mDetails->setAddressee( add ); | 2467 | mDetails->setAddressee( add ); |
2468 | message(i18n("Setting formatted name completed!") ); | 2468 | message(i18n("Setting formatted name completed!") ); |
2469 | } | 2469 | } |
2470 | 2470 | ||
2471 | void KABCore::clipboardDataChanged() | 2471 | void KABCore::clipboardDataChanged() |
2472 | { | 2472 | { |
2473 | 2473 | ||
2474 | if ( mReadWrite ) | 2474 | if ( mReadWrite ) |
2475 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2475 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2476 | 2476 | ||
2477 | } | 2477 | } |
2478 | 2478 | ||
2479 | void KABCore::updateActionMenu() | 2479 | void KABCore::updateActionMenu() |
2480 | { | 2480 | { |
2481 | UndoStack *undo = UndoStack::instance(); | 2481 | UndoStack *undo = UndoStack::instance(); |
2482 | RedoStack *redo = RedoStack::instance(); | 2482 | RedoStack *redo = RedoStack::instance(); |
2483 | 2483 | ||
2484 | if ( undo->isEmpty() ) | 2484 | if ( undo->isEmpty() ) |
2485 | mActionUndo->setText( i18n( "Undo" ) ); | 2485 | mActionUndo->setText( i18n( "Undo" ) ); |
2486 | else | 2486 | else |
2487 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2487 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2488 | 2488 | ||
2489 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2489 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2490 | 2490 | ||
2491 | if ( !redo->top() ) | 2491 | if ( !redo->top() ) |
2492 | mActionRedo->setText( i18n( "Redo" ) ); | 2492 | mActionRedo->setText( i18n( "Redo" ) ); |
2493 | else | 2493 | else |
2494 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2494 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2495 | 2495 | ||
2496 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2496 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2497 | } | 2497 | } |
2498 | 2498 | ||
2499 | void KABCore::configureKeyBindings() | 2499 | void KABCore::configureKeyBindings() |
2500 | { | 2500 | { |
2501 | #ifndef KAB_EMBEDDED | 2501 | #ifndef KAB_EMBEDDED |
2502 | KKeyDialog::configure( actionCollection(), true ); | 2502 | KKeyDialog::configure( actionCollection(), true ); |
2503 | #else //KAB_EMBEDDED | 2503 | #else //KAB_EMBEDDED |
2504 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2504 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2505 | #endif //KAB_EMBEDDED | 2505 | #endif //KAB_EMBEDDED |
2506 | } | 2506 | } |
2507 | 2507 | ||
2508 | #ifdef KAB_EMBEDDED | 2508 | #ifdef KAB_EMBEDDED |
2509 | void KABCore::configureResources() | 2509 | void KABCore::configureResources() |
2510 | { | 2510 | { |
2511 | KRES::KCMKResources dlg( this, "" , 0 ); | 2511 | KRES::KCMKResources dlg( this, "" , 0 ); |
2512 | 2512 | ||
2513 | if ( !dlg.exec() ) | 2513 | if ( !dlg.exec() ) |
2514 | return; | 2514 | return; |
2515 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2515 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2516 | } | 2516 | } |
2517 | #endif //KAB_EMBEDDED | 2517 | #endif //KAB_EMBEDDED |
2518 | 2518 | ||
2519 | 2519 | ||
2520 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2520 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2521 | * for the attendees list of an event. | 2521 | * for the attendees list of an event. |
2522 | */ | 2522 | */ |
2523 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2523 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2524 | { | 2524 | { |
2525 | 2525 | ||
2526 | bool ok = false; | 2526 | bool ok = false; |
2527 | mEmailSourceChannel = sourceChannel; | 2527 | mEmailSourceChannel = sourceChannel; |
2528 | mEmailSourceUID = uid; | 2528 | mEmailSourceUID = uid; |
2529 | callContactdialog(); | 2529 | callContactdialog(); |
2530 | #if 0 | 2530 | #if 0 |
2531 | int wid = uid.toInt( &ok ); | 2531 | int wid = uid.toInt( &ok ); |
2532 | qDebug("UID %s ", uid.latin1()); | 2532 | qDebug("UID %s ", uid.latin1()); |
2533 | if ( ok ) { | 2533 | if ( ok ) { |
2534 | if ( wid != QApplication::desktop()->width() ) { | 2534 | if ( wid != QApplication::desktop()->width() ) { |
2535 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); | 2535 | qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); |
2536 | message( i18n("Resizing, please wait...") ); | 2536 | message( i18n("Resizing, please wait...") ); |
2537 | mMainWindow->showMinimized(); | 2537 | mMainWindow->showMinimized(); |
2538 | /* | 2538 | /* |
2539 | { | 2539 | { |
2540 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2540 | QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2541 | } | 2541 | } |
2542 | */ | 2542 | */ |
2543 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); | 2543 | QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); |
2544 | return; | 2544 | return; |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | } else { | 2547 | } else { |
2548 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); | 2548 | qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); |
2549 | } | 2549 | } |
2550 | callContactdialog(); | 2550 | callContactdialog(); |
2551 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); | 2551 | //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); |
2552 | #endif | 2552 | #endif |
2553 | } | 2553 | } |
2554 | void KABCore::resizeAndCallContactdialog() | 2554 | void KABCore::resizeAndCallContactdialog() |
2555 | { | 2555 | { |
2556 | updateMainWindow(); | 2556 | updateMainWindow(); |
2557 | QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) ); | 2557 | QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) ); |
2558 | } | 2558 | } |
2559 | 2559 | ||
2560 | void KABCore::callContactdialog() | 2560 | void KABCore::callContactdialog() |
2561 | { | 2561 | { |
2562 | QStringList nameList; | 2562 | QStringList nameList; |
2563 | QStringList emailList; | 2563 | QStringList emailList; |
2564 | QStringList uidList; | 2564 | QStringList uidList; |
2565 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); | 2565 | qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); |
2566 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2566 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2567 | uint i=0; | 2567 | uint i=0; |
2568 | for (i=0; i < list.count(); i++) | 2568 | for (i=0; i < list.count(); i++) |
2569 | { | 2569 | { |
2570 | nameList.append(list[i].realName()); | 2570 | nameList.append(list[i].realName()); |
2571 | emailList.append(list[i].preferredEmail()); | 2571 | emailList.append(list[i].preferredEmail()); |
2572 | uidList.append(list[i].uid()); | 2572 | uidList.append(list[i].uid()); |
2573 | } | 2573 | } |
2574 | QString uid = mEmailSourceUID; | 2574 | QString uid = mEmailSourceUID; |
2575 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); | 2575 | //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); |
2576 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); | 2576 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); |
2577 | 2577 | ||
2578 | } | 2578 | } |
2579 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2579 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2580 | * to put them into the calendar. | 2580 | * to put them into the calendar. |
2581 | */ | 2581 | */ |
2582 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2582 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2583 | { | 2583 | { |
2584 | // qDebug("KABCore::requestForBirthdayList"); | 2584 | // qDebug("KABCore::requestForBirthdayList"); |
2585 | QStringList birthdayList; | 2585 | QStringList birthdayList; |
2586 | QStringList anniversaryList; | 2586 | QStringList anniversaryList; |
2587 | QStringList realNameList; | 2587 | QStringList realNameList; |
2588 | QStringList preferredEmailList; | 2588 | QStringList preferredEmailList; |
2589 | QStringList assembledNameList; | 2589 | QStringList assembledNameList; |
2590 | QStringList uidList; | 2590 | QStringList uidList; |
2591 | 2591 | ||
2592 | KABC::AddressBook::Iterator it; | 2592 | KABC::AddressBook::Iterator it; |
2593 | 2593 | ||
2594 | int count = 0; | 2594 | int count = 0; |
2595 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2595 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2596 | ++count; | 2596 | ++count; |
2597 | } | 2597 | } |
2598 | QProgressBar bar(count,0 ); | 2598 | QProgressBar bar(count,0 ); |
2599 | int w = 300; | 2599 | int w = 300; |
2600 | if ( QApplication::desktop()->width() < 320 ) | 2600 | if ( QApplication::desktop()->width() < 320 ) |
2601 | w = 220; | 2601 | w = 220; |
2602 | int h = bar.sizeHint().height() ; | 2602 | int h = bar.sizeHint().height() ; |
2603 | int dw = QApplication::desktop()->width(); | 2603 | int dw = QApplication::desktop()->width(); |
2604 | int dh = QApplication::desktop()->height(); | 2604 | int dh = QApplication::desktop()->height(); |
2605 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2605 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2606 | bar.show(); | 2606 | bar.show(); |
2607 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2607 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2608 | qApp->processEvents(); | 2608 | qApp->processEvents(); |
2609 | 2609 | ||
2610 | QDate bday; | 2610 | QDate bday; |
2611 | QString anni; | 2611 | QString anni; |
2612 | QString formattedbday; | 2612 | QString formattedbday; |
2613 | 2613 | ||
2614 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2614 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2615 | { | 2615 | { |
2616 | if ( ! bar.isVisible() ) | 2616 | if ( ! bar.isVisible() ) |
2617 | return; | 2617 | return; |
2618 | bar.setProgress( count++ ); | 2618 | bar.setProgress( count++ ); |
2619 | qApp->processEvents(); | 2619 | qApp->processEvents(); |
2620 | bday = (*it).birthday().date(); | 2620 | bday = (*it).birthday().date(); |
2621 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2621 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2622 | 2622 | ||
2623 | if ( bday.isValid() || !anni.isEmpty()) | 2623 | if ( bday.isValid() || !anni.isEmpty()) |
2624 | { | 2624 | { |
2625 | if (bday.isValid()) | 2625 | if (bday.isValid()) |
2626 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2626 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2627 | else | 2627 | else |
2628 | formattedbday = "NOTVALID"; | 2628 | formattedbday = "NOTVALID"; |
2629 | if (anni.isEmpty()) | 2629 | if (anni.isEmpty()) |
2630 | anni = "INVALID"; | 2630 | anni = "INVALID"; |
2631 | 2631 | ||
2632 | birthdayList.append(formattedbday); | 2632 | birthdayList.append(formattedbday); |
2633 | anniversaryList.append(anni); //should be ISODate | 2633 | anniversaryList.append(anni); //should be ISODate |
2634 | realNameList.append((*it).realName()); | 2634 | realNameList.append((*it).realName()); |
2635 | preferredEmailList.append((*it).preferredEmail()); | 2635 | preferredEmailList.append((*it).preferredEmail()); |
2636 | assembledNameList.append((*it).assembledName()); | 2636 | assembledNameList.append((*it).assembledName()); |
2637 | uidList.append((*it).uid()); | 2637 | uidList.append((*it).uid()); |
2638 | 2638 | ||
2639 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2639 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2640 | } | 2640 | } |
2641 | } | 2641 | } |
2642 | 2642 | ||
2643 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2643 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2644 | 2644 | ||
2645 | } | 2645 | } |
2646 | 2646 | ||
2647 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2647 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2648 | */ | 2648 | */ |
2649 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2649 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2650 | { | 2650 | { |
2651 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2651 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2652 | 2652 | ||
2653 | QString foundUid = QString::null; | 2653 | QString foundUid = QString::null; |
2654 | if ( ! uid.isEmpty() ) { | 2654 | if ( ! uid.isEmpty() ) { |
2655 | Addressee adrr = mAddressBook->findByUid( uid ); | 2655 | Addressee adrr = mAddressBook->findByUid( uid ); |
2656 | if ( !adrr.isEmpty() ) { | 2656 | if ( !adrr.isEmpty() ) { |
2657 | foundUid = uid; | 2657 | foundUid = uid; |
2658 | } | 2658 | } |
2659 | if ( email == "sendbacklist" ) { | 2659 | if ( email == "sendbacklist" ) { |
2660 | //qDebug("ssssssssssssssssssssssend "); | 2660 | //qDebug("ssssssssssssssssssssssend "); |
2661 | QStringList nameList; | 2661 | QStringList nameList; |
2662 | QStringList emailList; | 2662 | QStringList emailList; |
2663 | QStringList uidList; | 2663 | QStringList uidList; |
2664 | nameList.append(adrr.realName()); | 2664 | nameList.append(adrr.realName()); |
2665 | emailList = adrr.emails(); | 2665 | emailList = adrr.emails(); |
2666 | uidList.append( adrr.preferredEmail()); | 2666 | uidList.append( adrr.preferredEmail()); |
2667 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2667 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2668 | return; | 2668 | return; |
2669 | } | 2669 | } |
2670 | 2670 | ||
2671 | } | 2671 | } |
2672 | 2672 | ||
2673 | if ( email == "sendbacklist" ) | 2673 | if ( email == "sendbacklist" ) |
2674 | return; | 2674 | return; |
2675 | if (foundUid.isEmpty()) | 2675 | if (foundUid.isEmpty()) |
2676 | { | 2676 | { |
2677 | //find the uid of the person first | 2677 | //find the uid of the person first |
2678 | Addressee::List namelist; | 2678 | Addressee::List namelist; |
2679 | Addressee::List emaillist; | 2679 | Addressee::List emaillist; |
2680 | 2680 | ||
2681 | if (!name.isEmpty()) | 2681 | if (!name.isEmpty()) |
2682 | namelist = mAddressBook->findByName( name ); | 2682 | namelist = mAddressBook->findByName( name ); |
2683 | 2683 | ||
2684 | if (!email.isEmpty()) | 2684 | if (!email.isEmpty()) |
2685 | emaillist = mAddressBook->findByEmail( email ); | 2685 | emaillist = mAddressBook->findByEmail( email ); |
2686 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2686 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2687 | //check if we have a match in Namelist and Emaillist | 2687 | //check if we have a match in Namelist and Emaillist |
2688 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2688 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2689 | foundUid = emaillist[0].uid(); | 2689 | foundUid = emaillist[0].uid(); |
2690 | } | 2690 | } |
2691 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2691 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2692 | foundUid = namelist[0].uid(); | 2692 | foundUid = namelist[0].uid(); |
2693 | else | 2693 | else |
2694 | { | 2694 | { |
2695 | for (int i = 0; i < namelist.count(); i++) | 2695 | for (int i = 0; i < namelist.count(); i++) |
2696 | { | 2696 | { |
2697 | for (int j = 0; j < emaillist.count(); j++) | 2697 | for (int j = 0; j < emaillist.count(); j++) |
2698 | { | 2698 | { |
2699 | if (namelist[i] == emaillist[j]) | 2699 | if (namelist[i] == emaillist[j]) |
2700 | { | 2700 | { |
2701 | foundUid = namelist[i].uid(); | 2701 | foundUid = namelist[i].uid(); |
2702 | } | 2702 | } |
2703 | } | 2703 | } |
2704 | } | 2704 | } |
2705 | } | 2705 | } |
2706 | } | 2706 | } |
2707 | else | 2707 | else |
2708 | { | 2708 | { |
2709 | foundUid = uid; | 2709 | foundUid = uid; |
2710 | } | 2710 | } |
2711 | 2711 | ||
2712 | if (!foundUid.isEmpty()) | 2712 | if (!foundUid.isEmpty()) |
2713 | { | 2713 | { |
2714 | 2714 | ||
2715 | // raise Ka/Pi if it is in the background | 2715 | // raise Ka/Pi if it is in the background |
2716 | #ifndef DESKTOP_VERSION | 2716 | #ifndef DESKTOP_VERSION |
2717 | #ifndef KORG_NODCOP | 2717 | #ifndef KORG_NODCOP |
2718 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2718 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2719 | #endif | 2719 | #endif |
2720 | #endif | 2720 | #endif |
2721 | 2721 | ||
2722 | mMainWindow->showMaximized(); | 2722 | mMainWindow->showMaximized(); |
2723 | mMainWindow-> raise(); | 2723 | mMainWindow-> raise(); |
2724 | 2724 | ||
2725 | mViewManager->setSelected( "", false); | 2725 | mViewManager->setSelected( "", false); |
2726 | mViewManager->refreshView( "" ); | 2726 | mViewManager->refreshView( "" ); |
2727 | mViewManager->setSelected( foundUid, true ); | 2727 | mViewManager->setSelected( foundUid, true ); |
2728 | mViewManager->refreshView( foundUid ); | 2728 | mViewManager->refreshView( foundUid ); |
2729 | 2729 | ||
2730 | if ( !mMultipleViewsAtOnce ) | 2730 | if ( !mMultipleViewsAtOnce ) |
2731 | { | 2731 | { |
2732 | setDetailsVisible( true ); | 2732 | setDetailsVisible( true ); |
2733 | mActionDetails->setChecked(true); | 2733 | mActionDetails->setChecked(true); |
2734 | } | 2734 | } |
2735 | } | 2735 | } |
2736 | } | 2736 | } |
2737 | void KABCore::storagehowto() | 2737 | void KABCore::storagehowto() |
2738 | { | 2738 | { |
2739 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); | 2739 | KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); |
2740 | } | 2740 | } |
2741 | void KABCore::whatsnew() | 2741 | void KABCore::whatsnew() |
2742 | { | 2742 | { |
2743 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2743 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2744 | } | 2744 | } |
2745 | void KABCore::synchowto() | 2745 | void KABCore::synchowto() |
2746 | { | 2746 | { |
2747 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2747 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2748 | } | 2748 | } |
2749 | void KABCore::kdesynchowto() | 2749 | void KABCore::kdesynchowto() |
2750 | { | 2750 | { |
2751 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2751 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2752 | } | 2752 | } |
2753 | void KABCore::multisynchowto() | 2753 | void KABCore::multisynchowto() |
2754 | { | 2754 | { |
2755 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2755 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2756 | } | 2756 | } |
2757 | void KABCore::faq() | 2757 | void KABCore::faq() |
2758 | { | 2758 | { |
2759 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2759 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2760 | } | 2760 | } |
2761 | 2761 | ||
2762 | #include <libkcal/syncdefines.h> | 2762 | #include <libkcal/syncdefines.h> |
2763 | 2763 | ||
2764 | KABC::Addressee KABCore::getLastSyncAddressee() | 2764 | KABC::Addressee KABCore::getLastSyncAddressee() |
2765 | { | 2765 | { |
2766 | Addressee lse; | 2766 | Addressee lse; |
2767 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2767 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2768 | 2768 | ||
2769 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2769 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2770 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2770 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2771 | if (lse.isEmpty()) { | 2771 | if (lse.isEmpty()) { |
2772 | qDebug("KA: Creating new last-syncAddressee "); | 2772 | qDebug("KA: Creating new last-syncAddressee "); |
2773 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2773 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2774 | QString sum = ""; | 2774 | QString sum = ""; |
2775 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2775 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2776 | sum = "E: "; | 2776 | sum = "E: "; |
2777 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2777 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2778 | lse.setRevision( mLastAddressbookSync ); | 2778 | lse.setRevision( mLastAddressbookSync ); |
2779 | lse.setCategories( i18n("SyncEvent") ); | 2779 | lse.setCategories( i18n("SyncEvent") ); |
2780 | mAddressBook->insertAddressee( lse ); | 2780 | mAddressBook->insertAddressee( lse ); |
2781 | } | 2781 | } |
2782 | return lse; | 2782 | return lse; |
2783 | } | 2783 | } |
2784 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2784 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2785 | { | 2785 | { |
2786 | 2786 | ||
2787 | //void setZaurusId(int id); | 2787 | //void setZaurusId(int id); |
2788 | // int zaurusId() const; | 2788 | // int zaurusId() const; |
2789 | // void setZaurusUid(int id); | 2789 | // void setZaurusUid(int id); |
2790 | // int zaurusUid() const; | 2790 | // int zaurusUid() const; |
2791 | // void setZaurusStat(int id); | 2791 | // void setZaurusStat(int id); |
2792 | // int zaurusStat() const; | 2792 | // int zaurusStat() const; |
2793 | // 0 equal | 2793 | // 0 equal |
2794 | // 1 take local | 2794 | // 1 take local |
2795 | // 2 take remote | 2795 | // 2 take remote |
2796 | // 3 cancel | 2796 | // 3 cancel |
2797 | QDateTime lastSync = mLastAddressbookSync; | 2797 | QDateTime lastSync = mLastAddressbookSync; |
2798 | QDateTime localMod = local->revision(); | 2798 | QDateTime localMod = local->revision(); |
2799 | QDateTime remoteMod = remote->revision(); | 2799 | QDateTime remoteMod = remote->revision(); |
2800 | 2800 | ||
2801 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2801 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2802 | 2802 | ||
2803 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2803 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2804 | bool remCh, locCh; | 2804 | bool remCh, locCh; |
2805 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2805 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2806 | //if ( remCh ) | 2806 | //if ( remCh ) |
2807 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2807 | // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2808 | locCh = ( localMod > mLastAddressbookSync ); | 2808 | locCh = ( localMod > mLastAddressbookSync ); |
2809 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); | 2809 | //qDebug("cahnged rem %d loc %d",remCh, locCh ); |
2810 | if ( !remCh && ! locCh ) { | 2810 | if ( !remCh && ! locCh ) { |
2811 | //qDebug("both not changed "); | 2811 | //qDebug("both not changed "); |
2812 | lastSync = localMod.addDays(1); | 2812 | lastSync = localMod.addDays(1); |
2813 | if ( mode <= SYNC_PREF_ASK ) | 2813 | if ( mode <= SYNC_PREF_ASK ) |
2814 | return 0; | 2814 | return 0; |
2815 | } else { | 2815 | } else { |
2816 | if ( locCh ) { | 2816 | if ( locCh ) { |
2817 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2817 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2818 | lastSync = localMod.addDays( -1 ); | 2818 | lastSync = localMod.addDays( -1 ); |
2819 | if ( !remCh ) | 2819 | if ( !remCh ) |
2820 | remoteMod =( lastSync.addDays( -1 ) ); | 2820 | remoteMod =( lastSync.addDays( -1 ) ); |
2821 | } else { | 2821 | } else { |
2822 | //qDebug(" not loc changed "); | 2822 | //qDebug(" not loc changed "); |
2823 | lastSync = localMod.addDays( 1 ); | 2823 | lastSync = localMod.addDays( 1 ); |
2824 | if ( remCh ) { | 2824 | if ( remCh ) { |
2825 | //qDebug("rem changed "); | 2825 | //qDebug("rem changed "); |
2826 | remoteMod =( lastSync.addDays( 1 ) ); | 2826 | remoteMod =( lastSync.addDays( 1 ) ); |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | } | 2829 | } |
2830 | } | 2830 | } |
2831 | full = true; | 2831 | full = true; |
2832 | if ( mode < SYNC_PREF_ASK ) | 2832 | if ( mode < SYNC_PREF_ASK ) |
2833 | mode = SYNC_PREF_ASK; | 2833 | mode = SYNC_PREF_ASK; |
2834 | } else { | 2834 | } else { |
2835 | if ( localMod == remoteMod ) | 2835 | if ( localMod == remoteMod ) |
2836 | return 0; | 2836 | return 0; |
2837 | 2837 | ||
2838 | } | 2838 | } |
2839 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2839 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2840 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2840 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2841 | //full = true; //debug only | 2841 | //full = true; //debug only |
2842 | if ( full ) { | 2842 | if ( full ) { |
2843 | bool equ = ( (*local) == (*remote) ); | 2843 | bool equ = ( (*local) == (*remote) ); |
2844 | if ( equ ) { | 2844 | if ( equ ) { |
2845 | //qDebug("equal "); | 2845 | //qDebug("equal "); |
2846 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2846 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2847 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2847 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2848 | } | 2848 | } |
2849 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2849 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2850 | return 0; | 2850 | return 0; |
2851 | 2851 | ||
2852 | }//else //debug only | 2852 | }//else //debug only |
2853 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2853 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2854 | } | 2854 | } |
2855 | int result; | 2855 | int result; |
2856 | bool localIsNew; | 2856 | bool localIsNew; |
2857 | //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() ); | 2857 | //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() ); |
2858 | 2858 | ||
2859 | if ( full && mode < SYNC_PREF_NEWEST ) | 2859 | if ( full && mode < SYNC_PREF_NEWEST ) |
2860 | mode = SYNC_PREF_ASK; | 2860 | mode = SYNC_PREF_ASK; |
2861 | 2861 | ||
2862 | switch( mode ) { | 2862 | switch( mode ) { |
2863 | case SYNC_PREF_LOCAL: | 2863 | case SYNC_PREF_LOCAL: |
2864 | if ( lastSync > remoteMod ) | 2864 | if ( lastSync > remoteMod ) |
2865 | return 1; | 2865 | return 1; |
2866 | if ( lastSync > localMod ) | 2866 | if ( lastSync > localMod ) |
2867 | return 2; | 2867 | return 2; |
2868 | return 1; | 2868 | return 1; |
2869 | break; | 2869 | break; |
2870 | case SYNC_PREF_REMOTE: | 2870 | case SYNC_PREF_REMOTE: |
2871 | if ( lastSync > remoteMod ) | ||
2872 | return 1; | ||
2873 | if ( lastSync > localMod ) | 2871 | if ( lastSync > localMod ) |
2874 | return 2; | 2872 | return 2; |
2873 | if ( lastSync > remoteMod ) | ||
2874 | return 1; | ||
2875 | return 2; | 2875 | return 2; |
2876 | break; | 2876 | break; |
2877 | case SYNC_PREF_NEWEST: | 2877 | case SYNC_PREF_NEWEST: |
2878 | if ( localMod > remoteMod ) | 2878 | if ( localMod > remoteMod ) |
2879 | return 1; | 2879 | return 1; |
2880 | else | 2880 | else |
2881 | return 2; | 2881 | return 2; |
2882 | break; | 2882 | break; |
2883 | case SYNC_PREF_ASK: | 2883 | case SYNC_PREF_ASK: |
2884 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2884 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2885 | if ( lastSync > remoteMod && lastSync > localMod) | ||
2886 | return 0; | ||
2885 | if ( lastSync > remoteMod ) | 2887 | if ( lastSync > remoteMod ) |
2886 | return 1; | 2888 | return 1; |
2887 | if ( lastSync > localMod ) { | 2889 | if ( lastSync > localMod ) { |
2888 | return 2; | 2890 | return 2; |
2889 | } | 2891 | } |
2890 | localIsNew = localMod >= remoteMod; | 2892 | localIsNew = localMod >= remoteMod; |
2891 | //qDebug("conflict! ************************************** "); | 2893 | //qDebug("conflict! ************************************** "); |
2892 | { | 2894 | { |
2893 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2895 | KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2894 | result = acd.executeD(localIsNew); | 2896 | result = acd.executeD(localIsNew); |
2895 | return result; | 2897 | return result; |
2896 | } | 2898 | } |
2897 | break; | 2899 | break; |
2898 | case SYNC_PREF_FORCE_LOCAL: | 2900 | case SYNC_PREF_FORCE_LOCAL: |
2899 | return 1; | 2901 | return 1; |
2900 | break; | 2902 | break; |
2901 | case SYNC_PREF_FORCE_REMOTE: | 2903 | case SYNC_PREF_FORCE_REMOTE: |
2902 | return 2; | 2904 | return 2; |
2903 | break; | 2905 | break; |
2904 | 2906 | ||
2905 | default: | 2907 | default: |
2906 | // SYNC_PREF_TAKE_BOTH not implemented | 2908 | // SYNC_PREF_TAKE_BOTH not implemented |
2907 | break; | 2909 | break; |
2908 | } | 2910 | } |
2909 | return 0; | 2911 | return 0; |
2910 | } | 2912 | } |
2911 | 2913 | ||
2912 | 2914 | ||
2913 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2915 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2914 | { | 2916 | { |
2915 | bool syncOK = true; | 2917 | bool syncOK = true; |
2916 | int addedAddressee = 0; | 2918 | int addedAddressee = 0; |
2917 | int addedAddresseeR = 0; | 2919 | int addedAddresseeR = 0; |
2918 | int deletedAddresseeR = 0; | 2920 | int deletedAddresseeR = 0; |
2919 | int deletedAddresseeL = 0; | 2921 | int deletedAddresseeL = 0; |
2920 | int changedLocal = 0; | 2922 | int changedLocal = 0; |
2921 | int changedRemote = 0; | 2923 | int changedRemote = 0; |
2922 | int filteredIN = 0; | 2924 | int filteredIN = 0; |
2923 | int filteredOUT = 0; | 2925 | int filteredOUT = 0; |
2924 | 2926 | ||
2925 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2927 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2926 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2928 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2927 | 2929 | ||
2928 | //QPtrList<Addressee> el = local->rawAddressees(); | 2930 | //QPtrList<Addressee> el = local->rawAddressees(); |
2929 | Addressee addresseeR; | 2931 | Addressee addresseeR; |
2930 | QString uid; | 2932 | QString uid; |
2931 | int take; | 2933 | int take; |
2932 | Addressee addresseeL; | 2934 | Addressee addresseeL; |
2933 | Addressee addresseeRSync; | 2935 | Addressee addresseeRSync; |
2934 | Addressee addresseeLSync; | 2936 | Addressee addresseeLSync; |
2935 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2937 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2936 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2938 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2937 | bool fullDateRange = false; | 2939 | bool fullDateRange = false; |
2938 | local->resetTempSyncStat(); | 2940 | local->resetTempSyncStat(); |
2939 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2941 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2940 | if ( syncManager->syncWithDesktop() ) { | 2942 | if ( syncManager->syncWithDesktop() ) { |
2941 | // remote->removeSyncInfo( QString());//remove all info | 2943 | // remote->removeSyncInfo( QString());//remove all info |
2942 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2944 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2943 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2945 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2944 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2946 | qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2945 | } else { | 2947 | } else { |
2946 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2948 | qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2947 | } | 2949 | } |
2948 | } | 2950 | } |
2949 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2951 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2950 | addresseeLSync = getLastSyncAddressee(); | 2952 | addresseeLSync = getLastSyncAddressee(); |
2951 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2953 | qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2952 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2954 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2953 | if ( !addresseeR.isEmpty() ) { | 2955 | if ( !addresseeR.isEmpty() ) { |
2954 | addresseeRSync = addresseeR; | 2956 | addresseeRSync = addresseeR; |
2955 | remote->removeAddressee(addresseeR ); | 2957 | remote->removeAddressee(addresseeR ); |
2956 | 2958 | ||
2957 | } else { | 2959 | } else { |
2958 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2960 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2959 | addresseeRSync = addresseeLSync ; | 2961 | addresseeRSync = addresseeLSync ; |
2960 | } else { | 2962 | } else { |
2961 | //qDebug("FULLDATE 1"); | 2963 | //qDebug("FULLDATE 1"); |
2962 | fullDateRange = true; | 2964 | fullDateRange = true; |
2963 | Addressee newAdd; | 2965 | Addressee newAdd; |
2964 | addresseeRSync = newAdd; | 2966 | addresseeRSync = newAdd; |
2965 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2967 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2966 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2968 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2967 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2969 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2968 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2970 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2969 | } | 2971 | } |
2970 | } | 2972 | } |
2971 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2973 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2972 | // qDebug("FULLDATE 2"); | 2974 | // qDebug("FULLDATE 2"); |
2973 | fullDateRange = true; | 2975 | fullDateRange = true; |
2974 | } | 2976 | } |
2975 | if ( ! fullDateRange ) { | 2977 | if ( ! fullDateRange ) { |
2976 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2978 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2977 | 2979 | ||
2978 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2980 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2979 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2981 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2980 | fullDateRange = true; | 2982 | fullDateRange = true; |
2981 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2983 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2982 | } | 2984 | } |
2983 | } | 2985 | } |
2984 | // fullDateRange = true; // debug only! | 2986 | // fullDateRange = true; // debug only! |
2985 | if ( fullDateRange ) | 2987 | if ( fullDateRange ) |
2986 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2988 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2987 | else | 2989 | else |
2988 | mLastAddressbookSync = addresseeLSync.revision(); | 2990 | mLastAddressbookSync = addresseeLSync.revision(); |
2989 | // for resyncing if own file has changed | 2991 | // for resyncing if own file has changed |
2990 | // PENDING fixme later when implemented | 2992 | // PENDING fixme later when implemented |
2991 | #if 0 | 2993 | #if 0 |
2992 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2994 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2993 | mLastAddressbookSync = loadedFileVersion; | 2995 | mLastAddressbookSync = loadedFileVersion; |
2994 | qDebug("setting mLastAddressbookSync "); | 2996 | qDebug("setting mLastAddressbookSync "); |
2995 | } | 2997 | } |
2996 | #endif | 2998 | #endif |
2997 | 2999 | ||
2998 | 3000 | ||
2999 | // ********** setting filters **************** | 3001 | // ********** setting filters **************** |
3000 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); | 3002 | Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); |
3001 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); | 3003 | Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); |
3002 | 3004 | ||
3003 | //qDebug("*************************** "); | 3005 | //qDebug("*************************** "); |
3004 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 3006 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
3005 | QStringList er = remote->uidList(); | 3007 | QStringList er = remote->uidList(); |
3006 | Addressee inR ;//= er.first(); | 3008 | Addressee inR ;//= er.first(); |
3007 | Addressee inL; | 3009 | Addressee inL; |
3008 | 3010 | ||
3009 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 3011 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
3010 | 3012 | ||
3011 | int modulo = (er.count()/10)+1; | 3013 | int modulo = (er.count()/10)+1; |
3012 | int incCounter = 0; | 3014 | int incCounter = 0; |
3013 | while ( incCounter < er.count()) { | 3015 | while ( incCounter < er.count()) { |
3014 | if (syncManager->isProgressBarCanceled()) | 3016 | if (syncManager->isProgressBarCanceled()) |
3015 | return false; | 3017 | return false; |
3016 | if ( incCounter % modulo == 0 ) | 3018 | if ( incCounter % modulo == 0 ) |
3017 | syncManager->showProgressBar(incCounter); | 3019 | syncManager->showProgressBar(incCounter); |
3018 | 3020 | ||
3019 | uid = er[ incCounter ]; | 3021 | uid = er[ incCounter ]; |
3020 | bool skipIncidence = false; | 3022 | bool skipIncidence = false; |
3021 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3023 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3022 | skipIncidence = true; | 3024 | skipIncidence = true; |
3023 | QString idS,OidS; | 3025 | QString idS,OidS; |
3024 | qApp->processEvents(); | 3026 | qApp->processEvents(); |
3025 | if ( !skipIncidence ) { | 3027 | if ( !skipIncidence ) { |
3026 | inL = local->findByUid( uid ); | 3028 | inL = local->findByUid( uid ); |
3027 | inR = remote->findByUid( uid ); | 3029 | inR = remote->findByUid( uid ); |
3028 | //inL.setResource( 0 ); | 3030 | //inL.setResource( 0 ); |
3029 | //inR.setResource( 0 ); | 3031 | //inR.setResource( 0 ); |
3030 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 3032 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
3031 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3033 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3032 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 3034 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
3033 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 3035 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
3034 | if ( take == 3 ) | 3036 | if ( take == 3 ) |
3035 | return false; | 3037 | return false; |
3036 | if ( take == 1 ) {// take local ********************** | 3038 | if ( take == 1 ) {// take local ********************** |
3037 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3039 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3038 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3040 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3039 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3041 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3040 | local->insertAddressee( inL, false ); | 3042 | local->insertAddressee( inL, false ); |
3041 | idS = inR.externalUID(); | 3043 | idS = inR.externalUID(); |
3042 | OidS = inR.originalExternalUID(); | 3044 | OidS = inR.originalExternalUID(); |
3043 | } | 3045 | } |
3044 | else | 3046 | else |
3045 | idS = inR.IDStr(); | 3047 | idS = inR.IDStr(); |
3046 | remote->removeAddressee( inR ); | 3048 | remote->removeAddressee( inR ); |
3047 | inR = inL; | 3049 | inR = inL; |
3048 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 3050 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
3049 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3051 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3050 | inR.setOriginalExternalUID( OidS ); | 3052 | inR.setOriginalExternalUID( OidS ); |
3051 | inR.setExternalUID( idS ); | 3053 | inR.setExternalUID( idS ); |
3052 | if ( syncManager->syncWithDesktop() ) { | 3054 | if ( syncManager->syncWithDesktop() ) { |
3053 | inR.setIDStr("changed" ); | 3055 | inR.setIDStr("changed" ); |
3054 | } | 3056 | } |
3055 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 3057 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
3056 | } else { | 3058 | } else { |
3057 | inR.setIDStr( idS ); | 3059 | inR.setIDStr( idS ); |
3058 | } | 3060 | } |
3059 | inR.setResource( 0 ); | 3061 | inR.setResource( 0 ); |
3060 | remote->insertAddressee( inR , false); | 3062 | remote->insertAddressee( inR , false); |
3061 | ++changedRemote; | 3063 | ++changedRemote; |
3062 | } else { // take == 2 take remote ********************** | 3064 | } else { // take == 2 take remote ********************** |
3063 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3065 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3064 | if ( inR.revision().date().year() < 2004 ) | 3066 | if ( inR.revision().date().year() < 2004 ) |
3065 | inR.setRevision( modifiedCalendar ); | 3067 | inR.setRevision( modifiedCalendar ); |
3066 | } | 3068 | } |
3067 | idS = inL.IDStr(); | 3069 | idS = inL.IDStr(); |
3068 | local->removeAddressee( inL ); | 3070 | local->removeAddressee( inL ); |
3069 | inL = inR; | 3071 | inL = inR; |
3070 | inL.setIDStr( idS ); | 3072 | inL.setIDStr( idS ); |
3071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3073 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3072 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3074 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3073 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3075 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3074 | } | 3076 | } |
3075 | inL.setResource( 0 ); | 3077 | inL.setResource( 0 ); |
3076 | local->insertAddressee( inL , false ); | 3078 | local->insertAddressee( inL , false ); |
3077 | ++changedLocal; | 3079 | ++changedLocal; |
3078 | } | 3080 | } |
3079 | } | 3081 | } |
3080 | } | 3082 | } |
3081 | } else { // no conflict ********** add or delete remote | 3083 | } else { // no conflict ********** add or delete remote |
3082 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { | 3084 | if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { |
3083 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3085 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3084 | QString des = addresseeLSync.note(); | 3086 | QString des = addresseeLSync.note(); |
3085 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 3087 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
3086 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 3088 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
3087 | remote->insertAddressee( inR, false ); | 3089 | remote->insertAddressee( inR, false ); |
3088 | ++deletedAddresseeR; | 3090 | ++deletedAddresseeR; |
3089 | } else { | 3091 | } else { |
3090 | inR.setRevision( modifiedCalendar ); | 3092 | inR.setRevision( modifiedCalendar ); |
3091 | remote->insertAddressee( inR, false ); | 3093 | remote->insertAddressee( inR, false ); |
3092 | inL = inR; | 3094 | inL = inR; |
3093 | inL.setIDStr( ":" ); | 3095 | inL.setIDStr( ":" ); |
3094 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 3096 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
3095 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 3097 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
3096 | inL.setResource( 0 ); | 3098 | inL.setResource( 0 ); |
3097 | local->insertAddressee( inL , false); | 3099 | local->insertAddressee( inL , false); |
3098 | ++addedAddressee; | 3100 | ++addedAddressee; |
3099 | } | 3101 | } |
3100 | } else { | 3102 | } else { |
3101 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 3103 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
3102 | inR.setRevision( modifiedCalendar ); | 3104 | inR.setRevision( modifiedCalendar ); |
3103 | remote->insertAddressee( inR, false ); | 3105 | remote->insertAddressee( inR, false ); |
3104 | inR.setResource( 0 ); | 3106 | inR.setResource( 0 ); |
3105 | local->insertAddressee( inR, false ); | 3107 | local->insertAddressee( inR, false ); |
3106 | ++addedAddressee; | 3108 | ++addedAddressee; |
3107 | } else { | 3109 | } else { |
3108 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 3110 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
3109 | remote->removeAddressee( inR ); | 3111 | remote->removeAddressee( inR ); |
3110 | ++deletedAddresseeR; | 3112 | ++deletedAddresseeR; |
3111 | } | 3113 | } |
3112 | } | 3114 | } |
3113 | } else { | 3115 | } else { |
3114 | ++filteredIN; | 3116 | ++filteredIN; |
3115 | } | 3117 | } |
3116 | } | 3118 | } |
3117 | } | 3119 | } |
3118 | ++incCounter; | 3120 | ++incCounter; |
3119 | } | 3121 | } |
3120 | er.clear(); | 3122 | er.clear(); |
3121 | QStringList el = local->uidList(); | 3123 | QStringList el = local->uidList(); |
3122 | modulo = (el.count()/10)+1; | 3124 | modulo = (el.count()/10)+1; |
3123 | 3125 | ||
3124 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 3126 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
3125 | incCounter = 0; | 3127 | incCounter = 0; |
3126 | while ( incCounter < el.count()) { | 3128 | while ( incCounter < el.count()) { |
3127 | qApp->processEvents(); | 3129 | qApp->processEvents(); |
3128 | if (syncManager->isProgressBarCanceled()) | 3130 | if (syncManager->isProgressBarCanceled()) |
3129 | return false; | 3131 | return false; |
3130 | if ( incCounter % modulo == 0 ) | 3132 | if ( incCounter % modulo == 0 ) |
3131 | syncManager->showProgressBar(incCounter); | 3133 | syncManager->showProgressBar(incCounter); |
3132 | uid = el[ incCounter ]; | 3134 | uid = el[ incCounter ]; |
3133 | bool skipIncidence = false; | 3135 | bool skipIncidence = false; |
3134 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 3136 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
3135 | skipIncidence = true; | 3137 | skipIncidence = true; |
3136 | if ( !skipIncidence ) { | 3138 | if ( !skipIncidence ) { |
3137 | inL = local->findByUid( uid ); | 3139 | inL = local->findByUid( uid ); |
3138 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 3140 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
3139 | inR = remote->findByUid( uid ); | 3141 | inR = remote->findByUid( uid ); |
3140 | if ( inR.isEmpty() ){ | 3142 | if ( inR.isEmpty() ){ |
3141 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { | 3143 | if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { |
3142 | // no conflict ********** add or delete local | 3144 | // no conflict ********** add or delete local |
3143 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 3145 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
3144 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 3146 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
3145 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3147 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3146 | local->removeAddressee( inL ); | 3148 | local->removeAddressee( inL ); |
3147 | ++deletedAddresseeL; | 3149 | ++deletedAddresseeL; |
3148 | } else { | 3150 | } else { |
3149 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3151 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3150 | inL.removeID(mCurrentSyncDevice ); | 3152 | inL.removeID(mCurrentSyncDevice ); |
3151 | ++addedAddresseeR; | 3153 | ++addedAddresseeR; |
3152 | inL.setRevision( modifiedCalendar ); | 3154 | inL.setRevision( modifiedCalendar ); |
3153 | local->insertAddressee( inL, false ); | 3155 | local->insertAddressee( inL, false ); |
3154 | inR = inL; | 3156 | inR = inL; |
3155 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 3157 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
3156 | inR.setResource( 0 ); | 3158 | inR.setResource( 0 ); |
3157 | remote->insertAddressee( inR, false ); | 3159 | remote->insertAddressee( inR, false ); |
3158 | } | 3160 | } |
3159 | } | 3161 | } |
3160 | } else { | 3162 | } else { |
3161 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 3163 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
3162 | //qDebug("data %s ", inL.revision().toString().latin1()); | 3164 | //qDebug("data %s ", inL.revision().toString().latin1()); |
3163 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 3165 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
3164 | local->removeAddressee( inL ); | 3166 | local->removeAddressee( inL ); |
3165 | ++deletedAddresseeL; | 3167 | ++deletedAddresseeL; |
3166 | } else { | 3168 | } else { |
3167 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3169 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3168 | ++addedAddresseeR; | 3170 | ++addedAddresseeR; |
3169 | inL.setRevision( modifiedCalendar ); | 3171 | inL.setRevision( modifiedCalendar ); |
3170 | local->insertAddressee( inL, false ); | 3172 | local->insertAddressee( inL, false ); |
3171 | inR = inL; | 3173 | inR = inL; |
3172 | inR.setIDStr( ":" ); | 3174 | inR.setIDStr( ":" ); |
3173 | inR.setResource( 0 ); | 3175 | inR.setResource( 0 ); |
3174 | remote->insertAddressee( inR, false ); | 3176 | remote->insertAddressee( inR, false ); |
3175 | } | 3177 | } |
3176 | } | 3178 | } |
3177 | } | 3179 | } |
3178 | } else { | 3180 | } else { |
3179 | ++filteredOUT; | 3181 | ++filteredOUT; |
3180 | } | 3182 | } |
3181 | } | 3183 | } |
3182 | } | 3184 | } |
3183 | } | 3185 | } |
3184 | ++incCounter; | 3186 | ++incCounter; |
3185 | } | 3187 | } |
3186 | el.clear(); | 3188 | el.clear(); |
3187 | syncManager->hideProgressBar(); | 3189 | syncManager->hideProgressBar(); |
3188 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3190 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3189 | // get rid of micro seconds | 3191 | // get rid of micro seconds |
3190 | QTime t = mLastAddressbookSync.time(); | 3192 | QTime t = mLastAddressbookSync.time(); |
3191 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3193 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3192 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3194 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3193 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3195 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3194 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3196 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3195 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3197 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3196 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3198 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3197 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3199 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3198 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3200 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3199 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3201 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3200 | addresseeRSync.setNote( "" ) ; | 3202 | addresseeRSync.setNote( "" ) ; |
3201 | addresseeLSync.setNote( "" ); | 3203 | addresseeLSync.setNote( "" ); |
3202 | 3204 | ||
3203 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3205 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3204 | remote->insertAddressee( addresseeRSync, false ); | 3206 | remote->insertAddressee( addresseeRSync, false ); |
3205 | local->insertAddressee( addresseeLSync, false ); | 3207 | local->insertAddressee( addresseeLSync, false ); |
3206 | QString mes; | 3208 | QString mes; |
3207 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3209 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3208 | qDebug( mes ); | 3210 | qDebug( mes ); |
3209 | mes = i18n("Local addressbook changed!\n") +mes; | 3211 | mes = i18n("Local addressbook changed!\n") +mes; |
3210 | if ( syncManager->mShowSyncSummary ) { | 3212 | if ( syncManager->mShowSyncSummary ) { |
3211 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3213 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3212 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3214 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3213 | qDebug("KA: WB cancelled "); | 3215 | qDebug("KA: WB cancelled "); |
3214 | syncManager->mWriteBackFile = false; | 3216 | syncManager->mWriteBackFile = false; |
3215 | return syncOK; | 3217 | return syncOK; |
3216 | } | 3218 | } |
3217 | } | 3219 | } |
3218 | return syncOK; | 3220 | return syncOK; |
3219 | } | 3221 | } |
3220 | 3222 | ||
3221 | 3223 | ||
3222 | //this is a overwritten callbackmethods from the syncinterface | 3224 | //this is a overwritten callbackmethods from the syncinterface |
3223 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3225 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3224 | { | 3226 | { |
3225 | 3227 | ||
3226 | //pending prepare addresseeview for output | 3228 | //pending prepare addresseeview for output |
3227 | //pending detect, if remote file has REV field. if not switch to external sync | 3229 | //pending detect, if remote file has REV field. if not switch to external sync |
3228 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3230 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3229 | if ( manager != syncManager ) | 3231 | if ( manager != syncManager ) |
3230 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3232 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3231 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3233 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3232 | 3234 | ||
3233 | AddressBook abLocal(filename,"syncContact"); | 3235 | AddressBook abLocal(filename,"syncContact"); |
3234 | bool syncOK = false; | 3236 | bool syncOK = false; |
3235 | if ( abLocal.load() ) { | 3237 | if ( abLocal.load() ) { |
3236 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3238 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3237 | bool external = false; | 3239 | bool external = false; |
3238 | bool isXML = false; | 3240 | bool isXML = false; |
3239 | if ( filename.right(4) == ".xml") { | 3241 | if ( filename.right(4) == ".xml") { |
3240 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3242 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3241 | isXML = true; | 3243 | isXML = true; |
3242 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3244 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3243 | } else { | 3245 | } else { |
3244 | external = !manager->mIsKapiFile; | 3246 | external = !manager->mIsKapiFile; |
3245 | if ( external ) { | 3247 | if ( external ) { |
3246 | qDebug("KA: Sync::Setting vcf mode to external "); | 3248 | qDebug("KA: Sync::Setting vcf mode to external "); |
3247 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3249 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3248 | AddressBook::Iterator it; | 3250 | AddressBook::Iterator it; |
3249 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3251 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3250 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3252 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3251 | (*it).computeCsum( mCurrentSyncDevice ); | 3253 | (*it).computeCsum( mCurrentSyncDevice ); |
3252 | } | 3254 | } |
3253 | } | 3255 | } |
3254 | } | 3256 | } |
3255 | //AddressBook::Iterator it; | 3257 | //AddressBook::Iterator it; |
3256 | //QStringList vcards; | 3258 | //QStringList vcards; |
3257 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3259 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3258 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3260 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3259 | //} | 3261 | //} |
3260 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3262 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3261 | syncManager->hideProgressBar(); | 3263 | syncManager->hideProgressBar(); |
3262 | if ( syncOK ) { | 3264 | if ( syncOK ) { |
3263 | if ( syncManager->mWriteBackFile ) | 3265 | if ( syncManager->mWriteBackFile ) |
3264 | { | 3266 | { |
3265 | if ( external ) | 3267 | if ( external ) |
3266 | abLocal.removeSyncAddressees( !isXML); | 3268 | abLocal.removeSyncAddressees( !isXML); |
3267 | qDebug("KA: Sync::Saving remote AB "); | 3269 | qDebug("KA: Sync::Saving remote AB "); |
3268 | if ( ! abLocal.saveAB()) | 3270 | if ( ! abLocal.saveAB()) |
3269 | qDebug("KA: sync::Error writing back AB to file "); | 3271 | qDebug("KA: sync::Error writing back AB to file "); |
3270 | if ( external ) { | 3272 | if ( external ) { |
3271 | // afterwrite processing | 3273 | // afterwrite processing |
3272 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3274 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3273 | } | 3275 | } |
3274 | } | 3276 | } |
3275 | } | 3277 | } |
3276 | setModified(); | 3278 | setModified(); |
3277 | 3279 | ||
3278 | } | 3280 | } |
3279 | abLocal.removeResources(); | 3281 | abLocal.removeResources(); |
3280 | if ( syncOK ) | 3282 | if ( syncOK ) |
3281 | mViewManager->refreshView(); | 3283 | mViewManager->refreshView(); |
3282 | return syncOK; | 3284 | return syncOK; |
3283 | 3285 | ||
3284 | } | 3286 | } |
3285 | void KABCore::removeSyncInfo( QString syncProfile) | 3287 | void KABCore::removeSyncInfo( QString syncProfile) |
3286 | { | 3288 | { |
3287 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3289 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3288 | mAddressBook->removeSyncInfo( syncProfile ); | 3290 | mAddressBook->removeSyncInfo( syncProfile ); |
3289 | setModified(); | 3291 | setModified(); |
3290 | } | 3292 | } |
3291 | 3293 | ||
3292 | 3294 | ||
3293 | //this is a overwritten callbackmethods from the syncinterface | 3295 | //this is a overwritten callbackmethods from the syncinterface |
3294 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3296 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3295 | { | 3297 | { |
3296 | if ( resource == "phone" ) | 3298 | if ( resource == "phone" ) |
3297 | return syncPhone(); | 3299 | return syncPhone(); |
3298 | disableBR( true ); | 3300 | disableBR( true ); |
3299 | if ( manager != syncManager ) | 3301 | if ( manager != syncManager ) |
3300 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3302 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3301 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3303 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3302 | 3304 | ||
3303 | AddressBook abLocal( resource,"syncContact"); | 3305 | AddressBook abLocal( resource,"syncContact"); |
3304 | bool syncOK = false; | 3306 | bool syncOK = false; |
3305 | message(i18n("Loading DTM address data..."), false); | 3307 | message(i18n("Loading DTM address data..."), false); |
3306 | if ( abLocal.load() ) { | 3308 | if ( abLocal.load() ) { |
3307 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3309 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3308 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3310 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3309 | message(i18n("Sync preprocessing..."),false); | 3311 | message(i18n("Sync preprocessing..."),false); |
3310 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3312 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3311 | message(i18n("Synchronizing..."),false); | 3313 | message(i18n("Synchronizing..."),false); |
3312 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3314 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3313 | syncManager->hideProgressBar(); | 3315 | syncManager->hideProgressBar(); |
3314 | if ( syncOK ) { | 3316 | if ( syncOK ) { |
3315 | if ( syncManager->mWriteBackFile ) { | 3317 | if ( syncManager->mWriteBackFile ) { |
3316 | abLocal.removeSyncAddressees( false ); | 3318 | abLocal.removeSyncAddressees( false ); |
3317 | message(i18n("Saving DTM address data..."),false); | 3319 | message(i18n("Saving DTM address data..."),false); |
3318 | abLocal.saveAB(); | 3320 | abLocal.saveAB(); |
3319 | message(i18n("Sync postprocessing..."),false); | 3321 | message(i18n("Sync postprocessing..."),false); |
3320 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3322 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3321 | } | 3323 | } |
3322 | } else | 3324 | } else |
3323 | message( i18n("Sync cancelled or failed.") ); | 3325 | message( i18n("Sync cancelled or failed.") ); |
3324 | setModified(); | 3326 | setModified(); |
3325 | } | 3327 | } |
3326 | abLocal.removeResources(); | 3328 | abLocal.removeResources(); |
3327 | if ( syncOK ) { | 3329 | if ( syncOK ) { |
3328 | mViewManager->refreshView(); | 3330 | mViewManager->refreshView(); |
3329 | message(i18n("DTM syncing finished.")); | 3331 | message(i18n("DTM syncing finished.")); |
3330 | } | 3332 | } |
3331 | disableBR( false ); | 3333 | disableBR( false ); |
3332 | return syncOK; | 3334 | return syncOK; |
3333 | 3335 | ||
3334 | } | 3336 | } |
3335 | void KABCore::message( QString m, bool startTimer) | 3337 | void KABCore::message( QString m, bool startTimer) |
3336 | { | 3338 | { |
3337 | topLevelWidget()->setCaption( m ); | 3339 | topLevelWidget()->setCaption( m ); |
3338 | qApp->processEvents(); | 3340 | qApp->processEvents(); |
3339 | if ( startTimer ) | 3341 | if ( startTimer ) |
3340 | mMessageTimer->start( 15000, true ); | 3342 | mMessageTimer->start( 15000, true ); |
3341 | else | 3343 | else |
3342 | mMessageTimer->stop(); | 3344 | mMessageTimer->stop(); |
3343 | } | 3345 | } |
3344 | bool KABCore::syncPhone() | 3346 | bool KABCore::syncPhone() |
3345 | { | 3347 | { |
3346 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3348 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3347 | QString fileName = getPhoneFile(); | 3349 | QString fileName = getPhoneFile(); |
3348 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3350 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3349 | message(i18n("Phone access failed!")); | 3351 | message(i18n("Phone access failed!")); |
3350 | return false; | 3352 | return false; |
3351 | } | 3353 | } |
3352 | AddressBook abLocal( fileName,"syncContact"); | 3354 | AddressBook abLocal( fileName,"syncContact"); |
3353 | bool syncOK = false; | 3355 | bool syncOK = false; |
3354 | { | 3356 | { |
3355 | abLocal.importFromFile( fileName ); | 3357 | abLocal.importFromFile( fileName ); |
3356 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3358 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3357 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3359 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3358 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3360 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3359 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3361 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3360 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3362 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3361 | syncManager->hideProgressBar(); | 3363 | syncManager->hideProgressBar(); |
3362 | if ( syncOK ) { | 3364 | if ( syncOK ) { |
3363 | if ( syncManager->mWriteBackFile ) { | 3365 | if ( syncManager->mWriteBackFile ) { |
3364 | abLocal.removeSyncAddressees( true ); | 3366 | abLocal.removeSyncAddressees( true ); |
3365 | abLocal.saveABphone( fileName ); | 3367 | abLocal.saveABphone( fileName ); |
3366 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3368 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3367 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3369 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3368 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3370 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3369 | } | 3371 | } |
3370 | } | 3372 | } |
3371 | setModified(); | 3373 | setModified(); |
3372 | } | 3374 | } |
3373 | abLocal.removeResources(); | 3375 | abLocal.removeResources(); |
3374 | if ( syncOK ) | 3376 | if ( syncOK ) |
3375 | mViewManager->refreshView(); | 3377 | mViewManager->refreshView(); |
3376 | return syncOK; | 3378 | return syncOK; |
3377 | } | 3379 | } |
3378 | void KABCore::getFile( bool success ) | 3380 | void KABCore::getFile( bool success ) |
3379 | { | 3381 | { |
3380 | if ( ! success ) { | 3382 | if ( ! success ) { |
3381 | message( i18n("Error receiving file. Nothing changed!") ); | 3383 | message( i18n("Error receiving file. Nothing changed!") ); |
3382 | return; | 3384 | return; |
3383 | } | 3385 | } |
3384 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3386 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3385 | if ( count ) | 3387 | if ( count ) |
3386 | setModified( true ); | 3388 | setModified( true ); |
3387 | message( i18n("Pi-Sync successful!") ); | 3389 | message( i18n("Pi-Sync successful!") ); |
3388 | mViewManager->refreshView(); | 3390 | mViewManager->refreshView(); |
3389 | } | 3391 | } |
3390 | void KABCore::syncFileRequest() | 3392 | void KABCore::syncFileRequest() |
3391 | { | 3393 | { |
3392 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3394 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3393 | syncManager->slotSyncMenu( 999 ); | 3395 | syncManager->slotSyncMenu( 999 ); |
3394 | } | 3396 | } |
3395 | mAddressBook->export2File( sentSyncFile() ); | 3397 | mAddressBook->export2File( sentSyncFile() ); |
3396 | } | 3398 | } |
3397 | QString KABCore::sentSyncFile() | 3399 | QString KABCore::sentSyncFile() |
3398 | { | 3400 | { |
3399 | #ifdef DESKTOP_VERSION | 3401 | #ifdef DESKTOP_VERSION |
3400 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3402 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3401 | #else | 3403 | #else |
3402 | return QString( "/tmp/copysyncab.vcf" ); | 3404 | return QString( "/tmp/copysyncab.vcf" ); |
3403 | #endif | 3405 | #endif |
3404 | } | 3406 | } |
3405 | 3407 | ||
3406 | void KABCore::setCaptionBack() | 3408 | void KABCore::setCaptionBack() |
3407 | { | 3409 | { |
3408 | mMessageTimer->stop(); | 3410 | mMessageTimer->stop(); |
3409 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3411 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3410 | } | 3412 | } |