-rw-r--r-- | kaddressbook/kabcore.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 6e482b5..e6bdde9 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1861,1112 +1861,1115 @@ void KABCore::initActions() | |||
1861 | // misc | 1861 | // misc |
1862 | // only enable LDAP lookup if we can handle the protocol | 1862 | // only enable LDAP lookup if we can handle the protocol |
1863 | #ifndef KAB_EMBEDDED | 1863 | #ifndef KAB_EMBEDDED |
1864 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1864 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1865 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1865 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1866 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1866 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1867 | "ldap_lookup" ); | 1867 | "ldap_lookup" ); |
1868 | } | 1868 | } |
1869 | #else //KAB_EMBEDDED | 1869 | #else //KAB_EMBEDDED |
1870 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1870 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1871 | #endif //KAB_EMBEDDED | 1871 | #endif //KAB_EMBEDDED |
1872 | 1872 | ||
1873 | 1873 | ||
1874 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1874 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1875 | SLOT( setWhoAmI() ), actionCollection(), | 1875 | SLOT( setWhoAmI() ), actionCollection(), |
1876 | "set_personal" ); | 1876 | "set_personal" ); |
1877 | 1877 | ||
1878 | 1878 | ||
1879 | 1879 | ||
1880 | 1880 | ||
1881 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1881 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1882 | SLOT( setCategories() ), actionCollection(), | 1882 | SLOT( setCategories() ), actionCollection(), |
1883 | "edit_set_categories" ); | 1883 | "edit_set_categories" ); |
1884 | 1884 | ||
1885 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1885 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1886 | SLOT( removeVoice() ), actionCollection(), | 1886 | SLOT( removeVoice() ), actionCollection(), |
1887 | "remove_voice" ); | 1887 | "remove_voice" ); |
1888 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1888 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1889 | SLOT( importFromOL() ), actionCollection(), | 1889 | SLOT( importFromOL() ), actionCollection(), |
1890 | "import_OL" ); | 1890 | "import_OL" ); |
1891 | #ifdef KAB_EMBEDDED | 1891 | #ifdef KAB_EMBEDDED |
1892 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1892 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1893 | this, SLOT( showLicence() ), actionCollection(), | 1893 | this, SLOT( showLicence() ), actionCollection(), |
1894 | "licence_about_data" ); | 1894 | "licence_about_data" ); |
1895 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1895 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1896 | this, SLOT( faq() ), actionCollection(), | 1896 | this, SLOT( faq() ), actionCollection(), |
1897 | "faq_about_data" ); | 1897 | "faq_about_data" ); |
1898 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1898 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1899 | this, SLOT( whatsnew() ), actionCollection(), | 1899 | this, SLOT( whatsnew() ), actionCollection(), |
1900 | "wn" ); | 1900 | "wn" ); |
1901 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1901 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1902 | this, SLOT( synchowto() ), actionCollection(), | 1902 | this, SLOT( synchowto() ), actionCollection(), |
1903 | "sync" ); | 1903 | "sync" ); |
1904 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 1904 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
1905 | this, SLOT( kdesynchowto() ), actionCollection(), | 1905 | this, SLOT( kdesynchowto() ), actionCollection(), |
1906 | "kdesync" ); | 1906 | "kdesync" ); |
1907 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 1907 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
1908 | this, SLOT( multisynchowto() ), actionCollection(), | 1908 | this, SLOT( multisynchowto() ), actionCollection(), |
1909 | "multisync" ); | 1909 | "multisync" ); |
1910 | 1910 | ||
1911 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1911 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1912 | this, SLOT( createAboutData() ), actionCollection(), | 1912 | this, SLOT( createAboutData() ), actionCollection(), |
1913 | "kaddressbook_about_data" ); | 1913 | "kaddressbook_about_data" ); |
1914 | #endif //KAB_EMBEDDED | 1914 | #endif //KAB_EMBEDDED |
1915 | 1915 | ||
1916 | clipboardDataChanged(); | 1916 | clipboardDataChanged(); |
1917 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1917 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1918 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1918 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1919 | } | 1919 | } |
1920 | 1920 | ||
1921 | //US we need this function, to plug all actions into the correct menues. | 1921 | //US we need this function, to plug all actions into the correct menues. |
1922 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1922 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1923 | void KABCore::addActionsManually() | 1923 | void KABCore::addActionsManually() |
1924 | { | 1924 | { |
1925 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1925 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1926 | 1926 | ||
1927 | #ifdef KAB_EMBEDDED | 1927 | #ifdef KAB_EMBEDDED |
1928 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1928 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1929 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1929 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1930 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1930 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1931 | 1931 | ||
1932 | KToolBar* tb = mMainWindow->toolBar(); | 1932 | KToolBar* tb = mMainWindow->toolBar(); |
1933 | 1933 | ||
1934 | #ifndef DESKTOP_VERSION | 1934 | #ifndef DESKTOP_VERSION |
1935 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 1935 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
1936 | #endif | 1936 | #endif |
1937 | QMenuBar* mb = mMainWindow->menuBar(); | 1937 | QMenuBar* mb = mMainWindow->menuBar(); |
1938 | 1938 | ||
1939 | //US setup menubar. | 1939 | //US setup menubar. |
1940 | //Disable the following block if you do not want to have a menubar. | 1940 | //Disable the following block if you do not want to have a menubar. |
1941 | mb->insertItem( "&File", fileMenu ); | 1941 | mb->insertItem( "&File", fileMenu ); |
1942 | mb->insertItem( "&Edit", editMenu ); | 1942 | mb->insertItem( "&Edit", editMenu ); |
1943 | mb->insertItem( "&View", viewMenu ); | 1943 | mb->insertItem( "&View", viewMenu ); |
1944 | mb->insertItem( "&Settings", settingsMenu ); | 1944 | mb->insertItem( "&Settings", settingsMenu ); |
1945 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1945 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1946 | mb->insertItem( "&Change selected", changeMenu ); | 1946 | mb->insertItem( "&Change selected", changeMenu ); |
1947 | mb->insertItem( "&Help", helpMenu ); | 1947 | mb->insertItem( "&Help", helpMenu ); |
1948 | mIncSearchWidget = new IncSearchWidget( tb ); | 1948 | mIncSearchWidget = new IncSearchWidget( tb ); |
1949 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1949 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1950 | #ifndef DESKTOP_VERSION | 1950 | #ifndef DESKTOP_VERSION |
1951 | } else { | 1951 | } else { |
1952 | //US setup toolbar | 1952 | //US setup toolbar |
1953 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1953 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1954 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1954 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1955 | menuBarTB->insertItem( "ME", popupBarTB); | 1955 | menuBarTB->insertItem( "ME", popupBarTB); |
1956 | tb->insertWidget(-1, 0, menuBarTB); | 1956 | tb->insertWidget(-1, 0, menuBarTB); |
1957 | mIncSearchWidget = new IncSearchWidget( tb ); | 1957 | mIncSearchWidget = new IncSearchWidget( tb ); |
1958 | 1958 | ||
1959 | tb->enableMoving(false); | 1959 | tb->enableMoving(false); |
1960 | popupBarTB->insertItem( "&File", fileMenu ); | 1960 | popupBarTB->insertItem( "&File", fileMenu ); |
1961 | popupBarTB->insertItem( "&Edit", editMenu ); | 1961 | popupBarTB->insertItem( "&Edit", editMenu ); |
1962 | popupBarTB->insertItem( "&View", viewMenu ); | 1962 | popupBarTB->insertItem( "&View", viewMenu ); |
1963 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1963 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1964 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1964 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1965 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1965 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1966 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1966 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1967 | popupBarTB->insertItem( "&Help", helpMenu ); | 1967 | popupBarTB->insertItem( "&Help", helpMenu ); |
1968 | if (QApplication::desktop()->width() > 320 ) { | 1968 | if (QApplication::desktop()->width() > 320 ) { |
1969 | // mViewManager->getFilterAction()->plug ( tb); | 1969 | // mViewManager->getFilterAction()->plug ( tb); |
1970 | } | 1970 | } |
1971 | } | 1971 | } |
1972 | #endif | 1972 | #endif |
1973 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1973 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1974 | 1974 | ||
1975 | 1975 | ||
1976 | 1976 | ||
1977 | //US Now connect the actions with the menue entries. | 1977 | //US Now connect the actions with the menue entries. |
1978 | mActionPrint->plug( fileMenu ); | 1978 | mActionPrint->plug( fileMenu ); |
1979 | mActionMail->plug( fileMenu ); | 1979 | mActionMail->plug( fileMenu ); |
1980 | fileMenu->insertSeparator(); | 1980 | fileMenu->insertSeparator(); |
1981 | 1981 | ||
1982 | mActionNewContact->plug( fileMenu ); | 1982 | mActionNewContact->plug( fileMenu ); |
1983 | mActionNewContact->plug( tb ); | 1983 | mActionNewContact->plug( tb ); |
1984 | 1984 | ||
1985 | mActionEditAddressee->plug( fileMenu ); | 1985 | mActionEditAddressee->plug( fileMenu ); |
1986 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1986 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1987 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1987 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1988 | mActionEditAddressee->plug( tb ); | 1988 | mActionEditAddressee->plug( tb ); |
1989 | 1989 | ||
1990 | fileMenu->insertSeparator(); | 1990 | fileMenu->insertSeparator(); |
1991 | mActionSave->plug( fileMenu ); | 1991 | mActionSave->plug( fileMenu ); |
1992 | fileMenu->insertItem( "&Import", ImportMenu ); | 1992 | fileMenu->insertItem( "&Import", ImportMenu ); |
1993 | fileMenu->insertItem( "&Export", ExportMenu ); | 1993 | fileMenu->insertItem( "&Export", ExportMenu ); |
1994 | fileMenu->insertSeparator(); | 1994 | fileMenu->insertSeparator(); |
1995 | mActionMailVCard->plug( fileMenu ); | 1995 | mActionMailVCard->plug( fileMenu ); |
1996 | #ifndef DESKTOP_VERSION | 1996 | #ifndef DESKTOP_VERSION |
1997 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1997 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1998 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1998 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1999 | #endif | 1999 | #endif |
2000 | fileMenu->insertSeparator(); | 2000 | fileMenu->insertSeparator(); |
2001 | mActionQuit->plug( fileMenu ); | 2001 | mActionQuit->plug( fileMenu ); |
2002 | #ifdef _WIN32_ | 2002 | #ifdef _WIN32_ |
2003 | mActionImportOL->plug( ImportMenu ); | 2003 | mActionImportOL->plug( ImportMenu ); |
2004 | #endif | 2004 | #endif |
2005 | // edit menu | 2005 | // edit menu |
2006 | mActionUndo->plug( editMenu ); | 2006 | mActionUndo->plug( editMenu ); |
2007 | mActionRedo->plug( editMenu ); | 2007 | mActionRedo->plug( editMenu ); |
2008 | editMenu->insertSeparator(); | 2008 | editMenu->insertSeparator(); |
2009 | mActionCut->plug( editMenu ); | 2009 | mActionCut->plug( editMenu ); |
2010 | mActionCopy->plug( editMenu ); | 2010 | mActionCopy->plug( editMenu ); |
2011 | mActionPaste->plug( editMenu ); | 2011 | mActionPaste->plug( editMenu ); |
2012 | mActionDelete->plug( editMenu ); | 2012 | mActionDelete->plug( editMenu ); |
2013 | editMenu->insertSeparator(); | 2013 | editMenu->insertSeparator(); |
2014 | mActionSelectAll->plug( editMenu ); | 2014 | mActionSelectAll->plug( editMenu ); |
2015 | 2015 | ||
2016 | mActionRemoveVoice->plug( changeMenu ); | 2016 | mActionRemoveVoice->plug( changeMenu ); |
2017 | // settings menu | 2017 | // settings menu |
2018 | //US special menuentry to configure the addressbook resources. On KDE | 2018 | //US special menuentry to configure the addressbook resources. On KDE |
2019 | // you do that through the control center !!! | 2019 | // you do that through the control center !!! |
2020 | mActionConfigResources->plug( settingsMenu ); | 2020 | mActionConfigResources->plug( settingsMenu ); |
2021 | settingsMenu->insertSeparator(); | 2021 | settingsMenu->insertSeparator(); |
2022 | 2022 | ||
2023 | mActionConfigKAddressbook->plug( settingsMenu ); | 2023 | mActionConfigKAddressbook->plug( settingsMenu ); |
2024 | 2024 | ||
2025 | if ( mIsPart ) { | 2025 | if ( mIsPart ) { |
2026 | //US not implemented yet | 2026 | //US not implemented yet |
2027 | //mActionConfigShortcuts->plug( settingsMenu ); | 2027 | //mActionConfigShortcuts->plug( settingsMenu ); |
2028 | //mActionConfigureToolbars->plug( settingsMenu ); | 2028 | //mActionConfigureToolbars->plug( settingsMenu ); |
2029 | 2029 | ||
2030 | } else { | 2030 | } else { |
2031 | //US not implemented yet | 2031 | //US not implemented yet |
2032 | //mActionKeyBindings->plug( settingsMenu ); | 2032 | //mActionKeyBindings->plug( settingsMenu ); |
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | settingsMenu->insertSeparator(); | 2035 | settingsMenu->insertSeparator(); |
2036 | 2036 | ||
2037 | mActionJumpBar->plug( settingsMenu ); | 2037 | mActionJumpBar->plug( settingsMenu ); |
2038 | mActionDetails->plug( settingsMenu ); | 2038 | mActionDetails->plug( settingsMenu ); |
2039 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2039 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2040 | mActionDetails->plug( tb ); | 2040 | mActionDetails->plug( tb ); |
2041 | settingsMenu->insertSeparator(); | 2041 | settingsMenu->insertSeparator(); |
2042 | mActionBR->plug(settingsMenu ); | 2042 | mActionBR->plug(settingsMenu ); |
2043 | settingsMenu->insertSeparator(); | 2043 | settingsMenu->insertSeparator(); |
2044 | 2044 | ||
2045 | mActionWhoAmI->plug( settingsMenu ); | 2045 | mActionWhoAmI->plug( settingsMenu ); |
2046 | mActionCategories->plug( settingsMenu ); | 2046 | mActionCategories->plug( settingsMenu ); |
2047 | 2047 | ||
2048 | 2048 | ||
2049 | mActionWN->plug( helpMenu ); | 2049 | mActionWN->plug( helpMenu ); |
2050 | mActionSyncHowto->plug( helpMenu ); | 2050 | mActionSyncHowto->plug( helpMenu ); |
2051 | mActionKdeSyncHowto->plug( helpMenu ); | 2051 | mActionKdeSyncHowto->plug( helpMenu ); |
2052 | mActionMultiSyncHowto->plug( helpMenu ); | 2052 | mActionMultiSyncHowto->plug( helpMenu ); |
2053 | mActionFaq->plug( helpMenu ); | 2053 | mActionFaq->plug( helpMenu ); |
2054 | mActionLicence->plug( helpMenu ); | 2054 | mActionLicence->plug( helpMenu ); |
2055 | mActionAboutKAddressbook->plug( helpMenu ); | 2055 | mActionAboutKAddressbook->plug( helpMenu ); |
2056 | 2056 | ||
2057 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2057 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2058 | 2058 | ||
2059 | mActionSave->plug( tb ); | 2059 | mActionSave->plug( tb ); |
2060 | mViewManager->getFilterAction()->plug ( tb); | 2060 | mViewManager->getFilterAction()->plug ( tb); |
2061 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2061 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2062 | mActionUndo->plug( tb ); | 2062 | mActionUndo->plug( tb ); |
2063 | mActionDelete->plug( tb ); | 2063 | mActionDelete->plug( tb ); |
2064 | mActionRedo->plug( tb ); | 2064 | mActionRedo->plug( tb ); |
2065 | } | 2065 | } |
2066 | } else { | 2066 | } else { |
2067 | mActionSave->plug( tb ); | 2067 | mActionSave->plug( tb ); |
2068 | tb->enableMoving(false); | 2068 | tb->enableMoving(false); |
2069 | } | 2069 | } |
2070 | //mActionQuit->plug ( tb ); | 2070 | //mActionQuit->plug ( tb ); |
2071 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2071 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2072 | 2072 | ||
2073 | //US link the searchwidget first to this. | 2073 | //US link the searchwidget first to this. |
2074 | // The real linkage to the toolbar happens later. | 2074 | // The real linkage to the toolbar happens later. |
2075 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2075 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2076 | //US tb->insertItem( mIncSearchWidget ); | 2076 | //US tb->insertItem( mIncSearchWidget ); |
2077 | /*US | 2077 | /*US |
2078 | mIncSearchWidget = new IncSearchWidget( tb ); | 2078 | mIncSearchWidget = new IncSearchWidget( tb ); |
2079 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2079 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2080 | SLOT( incrementalSearch( const QString& ) ) ); | 2080 | SLOT( incrementalSearch( const QString& ) ) ); |
2081 | 2081 | ||
2082 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2082 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2083 | 2083 | ||
2084 | //US topLayout->addWidget( mJumpButtonBar ); | 2084 | //US topLayout->addWidget( mJumpButtonBar ); |
2085 | this->layout()->add( mJumpButtonBar ); | 2085 | this->layout()->add( mJumpButtonBar ); |
2086 | */ | 2086 | */ |
2087 | 2087 | ||
2088 | #endif //KAB_EMBEDDED | 2088 | #endif //KAB_EMBEDDED |
2089 | 2089 | ||
2090 | mActionExport2phone->plug( ExportMenu ); | 2090 | mActionExport2phone->plug( ExportMenu ); |
2091 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2091 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2092 | syncManager->fillSyncMenu(); | 2092 | syncManager->fillSyncMenu(); |
2093 | 2093 | ||
2094 | } | 2094 | } |
2095 | void KABCore::showLicence() | 2095 | void KABCore::showLicence() |
2096 | { | 2096 | { |
2097 | KApplication::showLicence(); | 2097 | KApplication::showLicence(); |
2098 | } | 2098 | } |
2099 | void KABCore::removeVoice() | 2099 | void KABCore::removeVoice() |
2100 | { | 2100 | { |
2101 | 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 ) | 2101 | 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 ) |
2102 | return; | 2102 | return; |
2103 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2103 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2104 | KABC::Addressee::List::Iterator it; | 2104 | KABC::Addressee::List::Iterator it; |
2105 | for ( it = list.begin(); it != list.end(); ++it ) { | 2105 | for ( it = list.begin(); it != list.end(); ++it ) { |
2106 | 2106 | ||
2107 | if ( (*it).removeVoice() ) | 2107 | if ( (*it).removeVoice() ) |
2108 | contactModified((*it) ); | 2108 | contactModified((*it) ); |
2109 | } | 2109 | } |
2110 | } | 2110 | } |
2111 | 2111 | ||
2112 | 2112 | ||
2113 | 2113 | ||
2114 | void KABCore::clipboardDataChanged() | 2114 | void KABCore::clipboardDataChanged() |
2115 | { | 2115 | { |
2116 | 2116 | ||
2117 | if ( mReadWrite ) | 2117 | if ( mReadWrite ) |
2118 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2118 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2119 | 2119 | ||
2120 | } | 2120 | } |
2121 | 2121 | ||
2122 | void KABCore::updateActionMenu() | 2122 | void KABCore::updateActionMenu() |
2123 | { | 2123 | { |
2124 | UndoStack *undo = UndoStack::instance(); | 2124 | UndoStack *undo = UndoStack::instance(); |
2125 | RedoStack *redo = RedoStack::instance(); | 2125 | RedoStack *redo = RedoStack::instance(); |
2126 | 2126 | ||
2127 | if ( undo->isEmpty() ) | 2127 | if ( undo->isEmpty() ) |
2128 | mActionUndo->setText( i18n( "Undo" ) ); | 2128 | mActionUndo->setText( i18n( "Undo" ) ); |
2129 | else | 2129 | else |
2130 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2130 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2131 | 2131 | ||
2132 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2132 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2133 | 2133 | ||
2134 | if ( !redo->top() ) | 2134 | if ( !redo->top() ) |
2135 | mActionRedo->setText( i18n( "Redo" ) ); | 2135 | mActionRedo->setText( i18n( "Redo" ) ); |
2136 | else | 2136 | else |
2137 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2137 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2138 | 2138 | ||
2139 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2139 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2140 | } | 2140 | } |
2141 | 2141 | ||
2142 | void KABCore::configureKeyBindings() | 2142 | void KABCore::configureKeyBindings() |
2143 | { | 2143 | { |
2144 | #ifndef KAB_EMBEDDED | 2144 | #ifndef KAB_EMBEDDED |
2145 | KKeyDialog::configure( actionCollection(), true ); | 2145 | KKeyDialog::configure( actionCollection(), true ); |
2146 | #else //KAB_EMBEDDED | 2146 | #else //KAB_EMBEDDED |
2147 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2147 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2148 | #endif //KAB_EMBEDDED | 2148 | #endif //KAB_EMBEDDED |
2149 | } | 2149 | } |
2150 | 2150 | ||
2151 | #ifdef KAB_EMBEDDED | 2151 | #ifdef KAB_EMBEDDED |
2152 | void KABCore::configureResources() | 2152 | void KABCore::configureResources() |
2153 | { | 2153 | { |
2154 | KRES::KCMKResources dlg( this, "" , 0 ); | 2154 | KRES::KCMKResources dlg( this, "" , 0 ); |
2155 | 2155 | ||
2156 | if ( !dlg.exec() ) | 2156 | if ( !dlg.exec() ) |
2157 | return; | 2157 | return; |
2158 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2158 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2159 | } | 2159 | } |
2160 | #endif //KAB_EMBEDDED | 2160 | #endif //KAB_EMBEDDED |
2161 | 2161 | ||
2162 | 2162 | ||
2163 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2163 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2164 | * for the attendees list of an event. | 2164 | * for the attendees list of an event. |
2165 | */ | 2165 | */ |
2166 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2166 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2167 | { | 2167 | { |
2168 | QStringList nameList; | 2168 | QStringList nameList; |
2169 | QStringList emailList; | 2169 | QStringList emailList; |
2170 | QStringList uidList; | 2170 | QStringList uidList; |
2171 | 2171 | ||
2172 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2172 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2173 | uint i=0; | 2173 | uint i=0; |
2174 | for (i=0; i < list.count(); i++) | 2174 | for (i=0; i < list.count(); i++) |
2175 | { | 2175 | { |
2176 | nameList.append(list[i].realName()); | 2176 | nameList.append(list[i].realName()); |
2177 | emailList.append(list[i].preferredEmail()); | 2177 | emailList.append(list[i].preferredEmail()); |
2178 | uidList.append(list[i].uid()); | 2178 | uidList.append(list[i].uid()); |
2179 | } | 2179 | } |
2180 | 2180 | ||
2181 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2181 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2182 | 2182 | ||
2183 | } | 2183 | } |
2184 | 2184 | ||
2185 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2185 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2186 | * to put them into the calendar. | 2186 | * to put them into the calendar. |
2187 | */ | 2187 | */ |
2188 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2188 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2189 | { | 2189 | { |
2190 | // qDebug("KABCore::requestForBirthdayList"); | 2190 | // qDebug("KABCore::requestForBirthdayList"); |
2191 | QStringList birthdayList; | 2191 | QStringList birthdayList; |
2192 | QStringList anniversaryList; | 2192 | QStringList anniversaryList; |
2193 | QStringList realNameList; | 2193 | QStringList realNameList; |
2194 | QStringList preferredEmailList; | 2194 | QStringList preferredEmailList; |
2195 | QStringList assembledNameList; | 2195 | QStringList assembledNameList; |
2196 | QStringList uidList; | 2196 | QStringList uidList; |
2197 | 2197 | ||
2198 | KABC::AddressBook::Iterator it; | 2198 | KABC::AddressBook::Iterator it; |
2199 | 2199 | ||
2200 | int count = 0; | 2200 | int count = 0; |
2201 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2201 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2202 | ++count; | 2202 | ++count; |
2203 | } | 2203 | } |
2204 | QProgressBar bar(count,0 ); | 2204 | QProgressBar bar(count,0 ); |
2205 | int w = 300; | 2205 | int w = 300; |
2206 | if ( QApplication::desktop()->width() < 320 ) | 2206 | if ( QApplication::desktop()->width() < 320 ) |
2207 | w = 220; | 2207 | w = 220; |
2208 | int h = bar.sizeHint().height() ; | 2208 | int h = bar.sizeHint().height() ; |
2209 | int dw = QApplication::desktop()->width(); | 2209 | int dw = QApplication::desktop()->width(); |
2210 | int dh = QApplication::desktop()->height(); | 2210 | int dh = QApplication::desktop()->height(); |
2211 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2211 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2212 | bar.show(); | 2212 | bar.show(); |
2213 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2213 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2214 | qApp->processEvents(); | 2214 | qApp->processEvents(); |
2215 | 2215 | ||
2216 | QDate bday; | 2216 | QDate bday; |
2217 | QString anni; | 2217 | QString anni; |
2218 | QString formattedbday; | 2218 | QString formattedbday; |
2219 | 2219 | ||
2220 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2220 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2221 | { | 2221 | { |
2222 | if ( ! bar.isVisible() ) | 2222 | if ( ! bar.isVisible() ) |
2223 | return; | 2223 | return; |
2224 | bar.setProgress( count++ ); | 2224 | bar.setProgress( count++ ); |
2225 | qApp->processEvents(); | 2225 | qApp->processEvents(); |
2226 | bday = (*it).birthday().date(); | 2226 | bday = (*it).birthday().date(); |
2227 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2227 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2228 | 2228 | ||
2229 | if ( bday.isValid() || !anni.isEmpty()) | 2229 | if ( bday.isValid() || !anni.isEmpty()) |
2230 | { | 2230 | { |
2231 | if (bday.isValid()) | 2231 | if (bday.isValid()) |
2232 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2232 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2233 | else | 2233 | else |
2234 | formattedbday = "NOTVALID"; | 2234 | formattedbday = "NOTVALID"; |
2235 | if (anni.isEmpty()) | 2235 | if (anni.isEmpty()) |
2236 | anni = "INVALID"; | 2236 | anni = "INVALID"; |
2237 | 2237 | ||
2238 | birthdayList.append(formattedbday); | 2238 | birthdayList.append(formattedbday); |
2239 | anniversaryList.append(anni); //should be ISODate | 2239 | anniversaryList.append(anni); //should be ISODate |
2240 | realNameList.append((*it).realName()); | 2240 | realNameList.append((*it).realName()); |
2241 | preferredEmailList.append((*it).preferredEmail()); | 2241 | preferredEmailList.append((*it).preferredEmail()); |
2242 | assembledNameList.append((*it).assembledName()); | 2242 | assembledNameList.append((*it).assembledName()); |
2243 | uidList.append((*it).uid()); | 2243 | uidList.append((*it).uid()); |
2244 | 2244 | ||
2245 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2245 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2246 | } | 2246 | } |
2247 | } | 2247 | } |
2248 | 2248 | ||
2249 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2249 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2250 | 2250 | ||
2251 | } | 2251 | } |
2252 | 2252 | ||
2253 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2253 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2254 | */ | 2254 | */ |
2255 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2255 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2256 | { | 2256 | { |
2257 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2257 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2258 | 2258 | ||
2259 | QString foundUid = QString::null; | 2259 | QString foundUid = QString::null; |
2260 | if ( ! uid.isEmpty() ) { | 2260 | if ( ! uid.isEmpty() ) { |
2261 | Addressee adrr = mAddressBook->findByUid( uid ); | 2261 | Addressee adrr = mAddressBook->findByUid( uid ); |
2262 | if ( !adrr.isEmpty() ) { | 2262 | if ( !adrr.isEmpty() ) { |
2263 | foundUid = uid; | 2263 | foundUid = uid; |
2264 | } | 2264 | } |
2265 | if ( email == "sendbacklist" ) { | 2265 | if ( email == "sendbacklist" ) { |
2266 | //qDebug("ssssssssssssssssssssssend "); | 2266 | //qDebug("ssssssssssssssssssssssend "); |
2267 | QStringList nameList; | 2267 | QStringList nameList; |
2268 | QStringList emailList; | 2268 | QStringList emailList; |
2269 | QStringList uidList; | 2269 | QStringList uidList; |
2270 | nameList.append(adrr.realName()); | 2270 | nameList.append(adrr.realName()); |
2271 | emailList = adrr.emails(); | 2271 | emailList = adrr.emails(); |
2272 | uidList.append( adrr.preferredEmail()); | 2272 | uidList.append( adrr.preferredEmail()); |
2273 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2273 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2274 | return; | 2274 | return; |
2275 | } | 2275 | } |
2276 | 2276 | ||
2277 | } | 2277 | } |
2278 | 2278 | ||
2279 | if ( email == "sendbacklist" ) | 2279 | if ( email == "sendbacklist" ) |
2280 | return; | 2280 | return; |
2281 | if (foundUid.isEmpty()) | 2281 | if (foundUid.isEmpty()) |
2282 | { | 2282 | { |
2283 | //find the uid of the person first | 2283 | //find the uid of the person first |
2284 | Addressee::List namelist; | 2284 | Addressee::List namelist; |
2285 | Addressee::List emaillist; | 2285 | Addressee::List emaillist; |
2286 | 2286 | ||
2287 | if (!name.isEmpty()) | 2287 | if (!name.isEmpty()) |
2288 | namelist = mAddressBook->findByName( name ); | 2288 | namelist = mAddressBook->findByName( name ); |
2289 | 2289 | ||
2290 | if (!email.isEmpty()) | 2290 | if (!email.isEmpty()) |
2291 | emaillist = mAddressBook->findByEmail( email ); | 2291 | emaillist = mAddressBook->findByEmail( email ); |
2292 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2292 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2293 | //check if we have a match in Namelist and Emaillist | 2293 | //check if we have a match in Namelist and Emaillist |
2294 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2294 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2295 | foundUid = emaillist[0].uid(); | 2295 | foundUid = emaillist[0].uid(); |
2296 | } | 2296 | } |
2297 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2297 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2298 | foundUid = namelist[0].uid(); | 2298 | foundUid = namelist[0].uid(); |
2299 | else | 2299 | else |
2300 | { | 2300 | { |
2301 | for (int i = 0; i < namelist.count(); i++) | 2301 | for (int i = 0; i < namelist.count(); i++) |
2302 | { | 2302 | { |
2303 | for (int j = 0; j < emaillist.count(); j++) | 2303 | for (int j = 0; j < emaillist.count(); j++) |
2304 | { | 2304 | { |
2305 | if (namelist[i] == emaillist[j]) | 2305 | if (namelist[i] == emaillist[j]) |
2306 | { | 2306 | { |
2307 | foundUid = namelist[i].uid(); | 2307 | foundUid = namelist[i].uid(); |
2308 | } | 2308 | } |
2309 | } | 2309 | } |
2310 | } | 2310 | } |
2311 | } | 2311 | } |
2312 | } | 2312 | } |
2313 | else | 2313 | else |
2314 | { | 2314 | { |
2315 | foundUid = uid; | 2315 | foundUid = uid; |
2316 | } | 2316 | } |
2317 | 2317 | ||
2318 | if (!foundUid.isEmpty()) | 2318 | if (!foundUid.isEmpty()) |
2319 | { | 2319 | { |
2320 | 2320 | ||
2321 | // raise Ka/Pi if it is in the background | 2321 | // raise Ka/Pi if it is in the background |
2322 | #ifndef DESKTOP_VERSION | 2322 | #ifndef DESKTOP_VERSION |
2323 | #ifndef KORG_NODCOP | 2323 | #ifndef KORG_NODCOP |
2324 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2324 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2325 | #endif | 2325 | #endif |
2326 | #endif | 2326 | #endif |
2327 | 2327 | ||
2328 | mMainWindow->showMaximized(); | 2328 | mMainWindow->showMaximized(); |
2329 | mMainWindow-> raise(); | 2329 | mMainWindow-> raise(); |
2330 | 2330 | ||
2331 | mViewManager->setSelected( "", false); | 2331 | mViewManager->setSelected( "", false); |
2332 | mViewManager->refreshView( "" ); | 2332 | mViewManager->refreshView( "" ); |
2333 | mViewManager->setSelected( foundUid, true ); | 2333 | mViewManager->setSelected( foundUid, true ); |
2334 | mViewManager->refreshView( foundUid ); | 2334 | mViewManager->refreshView( foundUid ); |
2335 | 2335 | ||
2336 | if ( !mMultipleViewsAtOnce ) | 2336 | if ( !mMultipleViewsAtOnce ) |
2337 | { | 2337 | { |
2338 | setDetailsVisible( true ); | 2338 | setDetailsVisible( true ); |
2339 | mActionDetails->setChecked(true); | 2339 | mActionDetails->setChecked(true); |
2340 | } | 2340 | } |
2341 | } | 2341 | } |
2342 | } | 2342 | } |
2343 | 2343 | ||
2344 | void KABCore::whatsnew() | 2344 | void KABCore::whatsnew() |
2345 | { | 2345 | { |
2346 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2346 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2347 | } | 2347 | } |
2348 | void KABCore::synchowto() | 2348 | void KABCore::synchowto() |
2349 | { | 2349 | { |
2350 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2350 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2351 | } | 2351 | } |
2352 | void KABCore::kdesynchowto() | 2352 | void KABCore::kdesynchowto() |
2353 | { | 2353 | { |
2354 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2354 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2355 | } | 2355 | } |
2356 | void KABCore::multisynchowto() | 2356 | void KABCore::multisynchowto() |
2357 | { | 2357 | { |
2358 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2358 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2359 | } | 2359 | } |
2360 | void KABCore::faq() | 2360 | void KABCore::faq() |
2361 | { | 2361 | { |
2362 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2362 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2363 | } | 2363 | } |
2364 | 2364 | ||
2365 | #include <libkcal/syncdefines.h> | 2365 | #include <libkcal/syncdefines.h> |
2366 | 2366 | ||
2367 | KABC::Addressee KABCore::getLastSyncAddressee() | 2367 | KABC::Addressee KABCore::getLastSyncAddressee() |
2368 | { | 2368 | { |
2369 | Addressee lse; | 2369 | Addressee lse; |
2370 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2370 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2371 | 2371 | ||
2372 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2372 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2373 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2373 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2374 | if (lse.isEmpty()) { | 2374 | if (lse.isEmpty()) { |
2375 | qDebug("Creating new last-syncAddressee "); | 2375 | qDebug("Creating new last-syncAddressee "); |
2376 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2376 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2377 | QString sum = ""; | 2377 | QString sum = ""; |
2378 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2378 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2379 | sum = "E: "; | 2379 | sum = "E: "; |
2380 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2380 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2381 | lse.setRevision( mLastAddressbookSync ); | 2381 | lse.setRevision( mLastAddressbookSync ); |
2382 | lse.setCategories( i18n("SyncEvent") ); | 2382 | lse.setCategories( i18n("SyncEvent") ); |
2383 | mAddressBook->insertAddressee( lse ); | 2383 | mAddressBook->insertAddressee( lse ); |
2384 | } | 2384 | } |
2385 | return lse; | 2385 | return lse; |
2386 | } | 2386 | } |
2387 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2387 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2388 | { | 2388 | { |
2389 | 2389 | ||
2390 | //void setZaurusId(int id); | 2390 | //void setZaurusId(int id); |
2391 | // int zaurusId() const; | 2391 | // int zaurusId() const; |
2392 | // void setZaurusUid(int id); | 2392 | // void setZaurusUid(int id); |
2393 | // int zaurusUid() const; | 2393 | // int zaurusUid() const; |
2394 | // void setZaurusStat(int id); | 2394 | // void setZaurusStat(int id); |
2395 | // int zaurusStat() const; | 2395 | // int zaurusStat() const; |
2396 | // 0 equal | 2396 | // 0 equal |
2397 | // 1 take local | 2397 | // 1 take local |
2398 | // 2 take remote | 2398 | // 2 take remote |
2399 | // 3 cancel | 2399 | // 3 cancel |
2400 | QDateTime lastSync = mLastAddressbookSync; | 2400 | QDateTime lastSync = mLastAddressbookSync; |
2401 | QDateTime localMod = local->revision(); | 2401 | QDateTime localMod = local->revision(); |
2402 | QDateTime remoteMod = remote->revision(); | 2402 | QDateTime remoteMod = remote->revision(); |
2403 | 2403 | ||
2404 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2404 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2405 | 2405 | ||
2406 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2406 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2407 | bool remCh, locCh; | 2407 | bool remCh, locCh; |
2408 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2408 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2409 | qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2409 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2410 | locCh = ( localMod > mLastAddressbookSync ); | 2410 | locCh = ( localMod > mLastAddressbookSync ); |
2411 | if ( !remCh && ! locCh ) { | 2411 | if ( !remCh && ! locCh ) { |
2412 | qDebug("both not changed "); | 2412 | //qDebug("both not changed "); |
2413 | lastSync = localMod.addDays(1); | 2413 | lastSync = localMod.addDays(1); |
2414 | if ( mode <= SYNC_PREF_ASK ) | 2414 | if ( mode <= SYNC_PREF_ASK ) |
2415 | return 0; | 2415 | return 0; |
2416 | } else { | 2416 | } else { |
2417 | if ( locCh ) { | 2417 | if ( locCh ) { |
2418 | qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2418 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2419 | lastSync = localMod.addDays( -1 ); | 2419 | lastSync = localMod.addDays( -1 ); |
2420 | if ( !remCh ) | 2420 | if ( !remCh ) |
2421 | remoteMod =( lastSync.addDays( -1 ) ); | 2421 | remoteMod =( lastSync.addDays( -1 ) ); |
2422 | } else { | 2422 | } else { |
2423 | qDebug(" not loc changed "); | 2423 | //qDebug(" not loc changed "); |
2424 | lastSync = localMod.addDays( 1 ); | 2424 | lastSync = localMod.addDays( 1 ); |
2425 | if ( remCh ) { | 2425 | if ( remCh ) { |
2426 | qDebug("rem changed "); | 2426 | //qDebug("rem changed "); |
2427 | remoteMod =( lastSync.addDays( 1 ) ); | 2427 | remoteMod =( lastSync.addDays( 1 ) ); |
2428 | } | 2428 | } |
2429 | 2429 | ||
2430 | } | 2430 | } |
2431 | } | 2431 | } |
2432 | full = true; | 2432 | full = true; |
2433 | if ( mode < SYNC_PREF_ASK ) | 2433 | if ( mode < SYNC_PREF_ASK ) |
2434 | mode = SYNC_PREF_ASK; | 2434 | mode = SYNC_PREF_ASK; |
2435 | } else { | 2435 | } else { |
2436 | if ( localMod == remoteMod ) | 2436 | if ( localMod == remoteMod ) |
2437 | return 0; | 2437 | return 0; |
2438 | 2438 | ||
2439 | } | 2439 | } |
2440 | qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2440 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2441 | qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2441 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2442 | //full = true; //debug only | 2442 | //full = true; //debug only |
2443 | if ( full ) { | 2443 | if ( full ) { |
2444 | bool equ = ( (*local) == (*remote) ); | 2444 | bool equ = ( (*local) == (*remote) ); |
2445 | if ( equ ) { | 2445 | if ( equ ) { |
2446 | qDebug("equal "); | 2446 | //qDebug("equal "); |
2447 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2447 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2448 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2448 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2449 | } | 2449 | } |
2450 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2450 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2451 | return 0; | 2451 | return 0; |
2452 | 2452 | ||
2453 | }//else //debug only | 2453 | }//else //debug only |
2454 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2454 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2455 | } | 2455 | } |
2456 | int result; | 2456 | int result; |
2457 | bool localIsNew; | 2457 | bool localIsNew; |
2458 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2458 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2459 | 2459 | ||
2460 | if ( full && mode < SYNC_PREF_NEWEST ) | 2460 | if ( full && mode < SYNC_PREF_NEWEST ) |
2461 | mode = SYNC_PREF_ASK; | 2461 | mode = SYNC_PREF_ASK; |
2462 | 2462 | ||
2463 | switch( mode ) { | 2463 | switch( mode ) { |
2464 | case SYNC_PREF_LOCAL: | 2464 | case SYNC_PREF_LOCAL: |
2465 | if ( lastSync > remoteMod ) | 2465 | if ( lastSync > remoteMod ) |
2466 | return 1; | 2466 | return 1; |
2467 | if ( lastSync > localMod ) | 2467 | if ( lastSync > localMod ) |
2468 | return 2; | 2468 | return 2; |
2469 | return 1; | 2469 | return 1; |
2470 | break; | 2470 | break; |
2471 | case SYNC_PREF_REMOTE: | 2471 | case SYNC_PREF_REMOTE: |
2472 | if ( lastSync > remoteMod ) | 2472 | if ( lastSync > remoteMod ) |
2473 | return 1; | 2473 | return 1; |
2474 | if ( lastSync > localMod ) | 2474 | if ( lastSync > localMod ) |
2475 | return 2; | 2475 | return 2; |
2476 | return 2; | 2476 | return 2; |
2477 | break; | 2477 | break; |
2478 | case SYNC_PREF_NEWEST: | 2478 | case SYNC_PREF_NEWEST: |
2479 | if ( localMod > remoteMod ) | 2479 | if ( localMod > remoteMod ) |
2480 | return 1; | 2480 | return 1; |
2481 | else | 2481 | else |
2482 | return 2; | 2482 | return 2; |
2483 | break; | 2483 | break; |
2484 | case SYNC_PREF_ASK: | 2484 | case SYNC_PREF_ASK: |
2485 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2485 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2486 | if ( lastSync > remoteMod ) | 2486 | if ( lastSync > remoteMod ) |
2487 | return 1; | 2487 | return 1; |
2488 | if ( lastSync > localMod ) | 2488 | if ( lastSync > localMod ) |
2489 | return 2; | 2489 | return 2; |
2490 | localIsNew = localMod >= remoteMod; | 2490 | localIsNew = localMod >= remoteMod; |
2491 | //qDebug("conflict! ************************************** "); | 2491 | //qDebug("conflict! ************************************** "); |
2492 | { | 2492 | { |
2493 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2493 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2494 | result = acd.executeD(localIsNew); | 2494 | result = acd.executeD(localIsNew); |
2495 | return result; | 2495 | return result; |
2496 | } | 2496 | } |
2497 | break; | 2497 | break; |
2498 | case SYNC_PREF_FORCE_LOCAL: | 2498 | case SYNC_PREF_FORCE_LOCAL: |
2499 | return 1; | 2499 | return 1; |
2500 | break; | 2500 | break; |
2501 | case SYNC_PREF_FORCE_REMOTE: | 2501 | case SYNC_PREF_FORCE_REMOTE: |
2502 | return 2; | 2502 | return 2; |
2503 | break; | 2503 | break; |
2504 | 2504 | ||
2505 | default: | 2505 | default: |
2506 | // SYNC_PREF_TAKE_BOTH not implemented | 2506 | // SYNC_PREF_TAKE_BOTH not implemented |
2507 | break; | 2507 | break; |
2508 | } | 2508 | } |
2509 | return 0; | 2509 | return 0; |
2510 | } | 2510 | } |
2511 | 2511 | ||
2512 | 2512 | ||
2513 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2513 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2514 | { | 2514 | { |
2515 | bool syncOK = true; | 2515 | bool syncOK = true; |
2516 | int addedAddressee = 0; | 2516 | int addedAddressee = 0; |
2517 | int addedAddresseeR = 0; | 2517 | int addedAddresseeR = 0; |
2518 | int deletedAddresseeR = 0; | 2518 | int deletedAddresseeR = 0; |
2519 | int deletedAddresseeL = 0; | 2519 | int deletedAddresseeL = 0; |
2520 | int changedLocal = 0; | 2520 | int changedLocal = 0; |
2521 | int changedRemote = 0; | 2521 | int changedRemote = 0; |
2522 | 2522 | ||
2523 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2523 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2524 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2524 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2525 | 2525 | ||
2526 | //QPtrList<Addressee> el = local->rawAddressees(); | 2526 | //QPtrList<Addressee> el = local->rawAddressees(); |
2527 | Addressee addresseeR; | 2527 | Addressee addresseeR; |
2528 | QString uid; | 2528 | QString uid; |
2529 | int take; | 2529 | int take; |
2530 | Addressee addresseeL; | 2530 | Addressee addresseeL; |
2531 | Addressee addresseeRSync; | 2531 | Addressee addresseeRSync; |
2532 | Addressee addresseeLSync; | 2532 | Addressee addresseeLSync; |
2533 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2533 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2534 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2534 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2535 | bool fullDateRange = false; | 2535 | bool fullDateRange = false; |
2536 | local->resetTempSyncStat(); | 2536 | local->resetTempSyncStat(); |
2537 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2537 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2538 | if ( syncManager->syncWithDesktop() ) { | 2538 | if ( syncManager->syncWithDesktop() ) { |
2539 | // remote->removeSyncInfo( QString());//remove all info | 2539 | // remote->removeSyncInfo( QString());//remove all info |
2540 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2540 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2541 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2541 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2542 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2542 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2543 | } else { | 2543 | } else { |
2544 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2544 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2545 | } | 2545 | } |
2546 | } | 2546 | } |
2547 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2547 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2548 | addresseeLSync = getLastSyncAddressee(); | 2548 | addresseeLSync = getLastSyncAddressee(); |
2549 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2549 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2550 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2550 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2551 | if ( !addresseeR.isEmpty() ) { | 2551 | if ( !addresseeR.isEmpty() ) { |
2552 | addresseeRSync = addresseeR; | 2552 | addresseeRSync = addresseeR; |
2553 | remote->removeAddressee(addresseeR ); | 2553 | remote->removeAddressee(addresseeR ); |
2554 | 2554 | ||
2555 | } else { | 2555 | } else { |
2556 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2556 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2557 | addresseeRSync = addresseeLSync ; | 2557 | addresseeRSync = addresseeLSync ; |
2558 | } else { | 2558 | } else { |
2559 | qDebug("FULLDATE 1"); | 2559 | //qDebug("FULLDATE 1"); |
2560 | fullDateRange = true; | 2560 | fullDateRange = true; |
2561 | Addressee newAdd; | 2561 | Addressee newAdd; |
2562 | addresseeRSync = newAdd; | 2562 | addresseeRSync = newAdd; |
2563 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2563 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2564 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2564 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2565 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2565 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2566 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2566 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2567 | } | 2567 | } |
2568 | } | 2568 | } |
2569 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2569 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2570 | qDebug("FULLDATE 2"); | 2570 | // qDebug("FULLDATE 2"); |
2571 | fullDateRange = true; | 2571 | fullDateRange = true; |
2572 | } | 2572 | } |
2573 | if ( ! fullDateRange ) { | 2573 | if ( ! fullDateRange ) { |
2574 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2574 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2575 | 2575 | ||
2576 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2576 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2577 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2577 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2578 | fullDateRange = true; | 2578 | fullDateRange = true; |
2579 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2579 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2580 | } | 2580 | } |
2581 | } | 2581 | } |
2582 | // fullDateRange = true; // debug only! | 2582 | // fullDateRange = true; // debug only! |
2583 | if ( fullDateRange ) | 2583 | if ( fullDateRange ) |
2584 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2584 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2585 | else | 2585 | else |
2586 | mLastAddressbookSync = addresseeLSync.revision(); | 2586 | mLastAddressbookSync = addresseeLSync.revision(); |
2587 | // for resyncing if own file has changed | 2587 | // for resyncing if own file has changed |
2588 | // PENDING fixme later when implemented | 2588 | // PENDING fixme later when implemented |
2589 | #if 0 | 2589 | #if 0 |
2590 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2590 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2591 | mLastAddressbookSync = loadedFileVersion; | 2591 | mLastAddressbookSync = loadedFileVersion; |
2592 | qDebug("setting mLastAddressbookSync "); | 2592 | qDebug("setting mLastAddressbookSync "); |
2593 | } | 2593 | } |
2594 | #endif | 2594 | #endif |
2595 | 2595 | ||
2596 | //qDebug("*************************** "); | 2596 | //qDebug("*************************** "); |
2597 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2597 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2598 | QStringList er = remote->uidList(); | 2598 | QStringList er = remote->uidList(); |
2599 | Addressee inR ;//= er.first(); | 2599 | Addressee inR ;//= er.first(); |
2600 | Addressee inL; | 2600 | Addressee inL; |
2601 | 2601 | ||
2602 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2602 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2603 | 2603 | ||
2604 | int modulo = (er.count()/10)+1; | 2604 | int modulo = (er.count()/10)+1; |
2605 | int incCounter = 0; | 2605 | int incCounter = 0; |
2606 | while ( incCounter < er.count()) { | 2606 | while ( incCounter < er.count()) { |
2607 | if (syncManager->isProgressBarCanceled()) | 2607 | if (syncManager->isProgressBarCanceled()) |
2608 | return false; | 2608 | return false; |
2609 | if ( incCounter % modulo == 0 ) | 2609 | if ( incCounter % modulo == 0 ) |
2610 | syncManager->showProgressBar(incCounter); | 2610 | syncManager->showProgressBar(incCounter); |
2611 | 2611 | ||
2612 | uid = er[ incCounter ]; | 2612 | uid = er[ incCounter ]; |
2613 | bool skipIncidence = false; | 2613 | bool skipIncidence = false; |
2614 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2614 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2615 | skipIncidence = true; | 2615 | skipIncidence = true; |
2616 | QString idS,OidS; | 2616 | QString idS,OidS; |
2617 | qApp->processEvents(); | 2617 | qApp->processEvents(); |
2618 | if ( !skipIncidence ) { | 2618 | if ( !skipIncidence ) { |
2619 | inL = local->findByUid( uid ); | 2619 | inL = local->findByUid( uid ); |
2620 | inR = remote->findByUid( uid ); | 2620 | inR = remote->findByUid( uid ); |
2621 | //inL.setResource( 0 ); | 2621 | //inL.setResource( 0 ); |
2622 | //inR.setResource( 0 ); | 2622 | //inR.setResource( 0 ); |
2623 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2623 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2624 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2624 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2625 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2625 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2626 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2626 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2627 | if ( take == 3 ) | 2627 | if ( take == 3 ) |
2628 | return false; | 2628 | return false; |
2629 | if ( take == 1 ) {// take local ********************** | 2629 | if ( take == 1 ) {// take local ********************** |
2630 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2630 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2631 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2631 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2632 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2632 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2633 | local->insertAddressee( inL, false ); | 2633 | local->insertAddressee( inL, false ); |
2634 | idS = inR.externalUID(); | 2634 | idS = inR.externalUID(); |
2635 | OidS = inR.originalExternalUID(); | 2635 | OidS = inR.originalExternalUID(); |
2636 | } | 2636 | } |
2637 | else | 2637 | else |
2638 | idS = inR.IDStr(); | 2638 | idS = inR.IDStr(); |
2639 | remote->removeAddressee( inR ); | 2639 | remote->removeAddressee( inR ); |
2640 | inR = inL; | 2640 | inR = inL; |
2641 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2641 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2642 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2642 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2643 | inR.setOriginalExternalUID( OidS ); | 2643 | inR.setOriginalExternalUID( OidS ); |
2644 | inR.setExternalUID( idS ); | 2644 | inR.setExternalUID( idS ); |
2645 | if ( syncManager->syncWithDesktop() ) { | 2645 | if ( syncManager->syncWithDesktop() ) { |
2646 | inR.setIDStr("changed" ); | 2646 | inR.setIDStr("changed" ); |
2647 | } | 2647 | } |
2648 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2648 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2649 | } else { | 2649 | } else { |
2650 | inR.setIDStr( idS ); | 2650 | inR.setIDStr( idS ); |
2651 | } | 2651 | } |
2652 | inR.setResource( 0 ); | 2652 | inR.setResource( 0 ); |
2653 | remote->insertAddressee( inR , false); | 2653 | remote->insertAddressee( inR , false); |
2654 | ++changedRemote; | 2654 | ++changedRemote; |
2655 | } else { // take == 2 take remote ********************** | 2655 | } else { // take == 2 take remote ********************** |
2656 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2656 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2657 | if ( inR.revision().date().year() < 2004 ) | 2657 | if ( inR.revision().date().year() < 2004 ) |
2658 | inR.setRevision( modifiedCalendar ); | 2658 | inR.setRevision( modifiedCalendar ); |
2659 | } | 2659 | } |
2660 | idS = inL.IDStr(); | 2660 | idS = inL.IDStr(); |
2661 | local->removeAddressee( inL ); | 2661 | local->removeAddressee( inL ); |
2662 | inL = inR; | 2662 | inL = inR; |
2663 | inL.setIDStr( idS ); | 2663 | inL.setIDStr( idS ); |
2664 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2664 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2665 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2665 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2666 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2666 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2667 | } | 2667 | } |
2668 | inL.setResource( 0 ); | 2668 | inL.setResource( 0 ); |
2669 | local->insertAddressee( inL , false ); | 2669 | local->insertAddressee( inL , false ); |
2670 | ++changedLocal; | 2670 | ++changedLocal; |
2671 | } | 2671 | } |
2672 | } | 2672 | } |
2673 | } | 2673 | } |
2674 | } else { // no conflict ********** add or delete remote | 2674 | } else { // no conflict ********** add or delete remote |
2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2675 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2676 | QString des = addresseeLSync.note(); | 2676 | QString des = addresseeLSync.note(); |
2677 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2677 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2678 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2678 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2679 | remote->insertAddressee( inR, false ); | 2679 | remote->insertAddressee( inR, false ); |
2680 | ++deletedAddresseeR; | 2680 | ++deletedAddresseeR; |
2681 | } else { | 2681 | } else { |
2682 | inR.setRevision( modifiedCalendar ); | 2682 | inR.setRevision( modifiedCalendar ); |
2683 | remote->insertAddressee( inR, false ); | 2683 | remote->insertAddressee( inR, false ); |
2684 | inL = inR; | 2684 | inL = inR; |
2685 | inL.setIDStr( ":" ); | 2685 | inL.setIDStr( ":" ); |
2686 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2686 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2687 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2687 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2688 | inL.setResource( 0 ); | 2688 | inL.setResource( 0 ); |
2689 | local->insertAddressee( inL , false); | 2689 | local->insertAddressee( inL , false); |
2690 | ++addedAddressee; | 2690 | ++addedAddressee; |
2691 | } | 2691 | } |
2692 | } else { | 2692 | } else { |
2693 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2693 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2694 | inR.setRevision( modifiedCalendar ); | 2694 | inR.setRevision( modifiedCalendar ); |
2695 | remote->insertAddressee( inR, false ); | 2695 | remote->insertAddressee( inR, false ); |
2696 | inR.setResource( 0 ); | 2696 | inR.setResource( 0 ); |
2697 | local->insertAddressee( inR, false ); | 2697 | local->insertAddressee( inR, false ); |
2698 | ++addedAddressee; | 2698 | ++addedAddressee; |
2699 | } else { | 2699 | } else { |
2700 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2700 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2701 | remote->removeAddressee( inR ); | 2701 | remote->removeAddressee( inR ); |
2702 | ++deletedAddresseeR; | 2702 | ++deletedAddresseeR; |
2703 | } | 2703 | } |
2704 | } | 2704 | } |
2705 | } | 2705 | } |
2706 | } | 2706 | } |
2707 | ++incCounter; | 2707 | ++incCounter; |
2708 | } | 2708 | } |
2709 | er.clear(); | 2709 | er.clear(); |
2710 | QStringList el = local->uidList(); | 2710 | QStringList el = local->uidList(); |
2711 | modulo = (el.count()/10)+1; | 2711 | modulo = (el.count()/10)+1; |
2712 | 2712 | ||
2713 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2713 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2714 | incCounter = 0; | 2714 | incCounter = 0; |
2715 | while ( incCounter < el.count()) { | 2715 | while ( incCounter < el.count()) { |
2716 | qApp->processEvents(); | 2716 | qApp->processEvents(); |
2717 | if (syncManager->isProgressBarCanceled()) | 2717 | if (syncManager->isProgressBarCanceled()) |
2718 | return false; | 2718 | return false; |
2719 | if ( incCounter % modulo == 0 ) | 2719 | if ( incCounter % modulo == 0 ) |
2720 | syncManager->showProgressBar(incCounter); | 2720 | syncManager->showProgressBar(incCounter); |
2721 | uid = el[ incCounter ]; | 2721 | uid = el[ incCounter ]; |
2722 | bool skipIncidence = false; | 2722 | bool skipIncidence = false; |
2723 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2723 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2724 | skipIncidence = true; | 2724 | skipIncidence = true; |
2725 | if ( !skipIncidence ) { | 2725 | if ( !skipIncidence ) { |
2726 | inL = local->findByUid( uid ); | 2726 | inL = local->findByUid( uid ); |
2727 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2727 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2728 | inR = remote->findByUid( uid ); | 2728 | inR = remote->findByUid( uid ); |
2729 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local | 2729 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local |
2730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2731 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2731 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2732 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2732 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2733 | local->removeAddressee( inL ); | 2733 | local->removeAddressee( inL ); |
2734 | ++deletedAddresseeL; | 2734 | ++deletedAddresseeL; |
2735 | } else { | 2735 | } else { |
2736 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2736 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2737 | inL.removeID(mCurrentSyncDevice ); | 2737 | inL.removeID(mCurrentSyncDevice ); |
2738 | ++addedAddresseeR; | 2738 | ++addedAddresseeR; |
2739 | inL.setRevision( modifiedCalendar ); | 2739 | inL.setRevision( modifiedCalendar ); |
2740 | local->insertAddressee( inL, false ); | 2740 | local->insertAddressee( inL, false ); |
2741 | inR = inL; | 2741 | inR = inL; |
2742 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2742 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2743 | inR.setResource( 0 ); | 2743 | inR.setResource( 0 ); |
2744 | remote->insertAddressee( inR, false ); | 2744 | remote->insertAddressee( inR, false ); |
2745 | } | 2745 | } |
2746 | } | 2746 | } |
2747 | } else { | 2747 | } else { |
2748 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2748 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2749 | //qDebug("data %s ", inL.revision().toString().latin1()); | 2749 | //qDebug("data %s ", inL.revision().toString().latin1()); |
2750 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2750 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2751 | local->removeAddressee( inL ); | 2751 | local->removeAddressee( inL ); |
2752 | ++deletedAddresseeL; | 2752 | ++deletedAddresseeL; |
2753 | } else { | 2753 | } else { |
2754 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2754 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2755 | ++addedAddresseeR; | 2755 | ++addedAddresseeR; |
2756 | inL.setRevision( modifiedCalendar ); | 2756 | inL.setRevision( modifiedCalendar ); |
2757 | local->insertAddressee( inL, false ); | 2757 | local->insertAddressee( inL, false ); |
2758 | inR = inL; | 2758 | inR = inL; |
2759 | inR.setIDStr( ":" ); | 2759 | inR.setIDStr( ":" ); |
2760 | inR.setResource( 0 ); | 2760 | inR.setResource( 0 ); |
2761 | remote->insertAddressee( inR, false ); | 2761 | remote->insertAddressee( inR, false ); |
2762 | } | 2762 | } |
2763 | } | 2763 | } |
2764 | } | 2764 | } |
2765 | } | 2765 | } |
2766 | } | 2766 | } |
2767 | } | 2767 | } |
2768 | ++incCounter; | 2768 | ++incCounter; |
2769 | } | 2769 | } |
2770 | el.clear(); | 2770 | el.clear(); |
2771 | syncManager->hideProgressBar(); | 2771 | syncManager->hideProgressBar(); |
2772 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2772 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2773 | // get rid of micro seconds | 2773 | // get rid of micro seconds |
2774 | QTime t = mLastAddressbookSync.time(); | 2774 | QTime t = mLastAddressbookSync.time(); |
2775 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2775 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2776 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2776 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2777 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2777 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2778 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2778 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2779 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2779 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2780 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2780 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2781 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2781 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2782 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2782 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2783 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2783 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2784 | addresseeRSync.setNote( "" ) ; | 2784 | addresseeRSync.setNote( "" ) ; |
2785 | addresseeLSync.setNote( "" ); | 2785 | addresseeLSync.setNote( "" ); |
2786 | 2786 | ||
2787 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2787 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2788 | remote->insertAddressee( addresseeRSync, false ); | 2788 | remote->insertAddressee( addresseeRSync, false ); |
2789 | local->insertAddressee( addresseeLSync, false ); | 2789 | local->insertAddressee( addresseeLSync, false ); |
2790 | QString mes; | 2790 | QString mes; |
2791 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2791 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2792 | qDebug( mes ); | 2792 | qDebug( mes ); |
2793 | mes = i18n("Local addressbook changed!\n") +mes; | 2793 | mes = i18n("Local addressbook changed!\n") +mes; |
2794 | if ( syncManager->mShowSyncSummary ) { | 2794 | if ( syncManager->mShowSyncSummary ) { |
2795 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 2795 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
2796 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 2796 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
2797 | qDebug("cancelled "); | 2797 | qDebug("cancelled "); |
2798 | return false; | 2798 | return false; |
2799 | } | 2799 | } |
2800 | } | 2800 | } |
2801 | return syncOK; | 2801 | return syncOK; |
2802 | } | 2802 | } |
2803 | 2803 | ||
2804 | 2804 | ||
2805 | //this is a overwritten callbackmethods from the syncinterface | 2805 | //this is a overwritten callbackmethods from the syncinterface |
2806 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2806 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2807 | { | 2807 | { |
2808 | 2808 | ||
2809 | //pending prepare addresseeview for output | 2809 | //pending prepare addresseeview for output |
2810 | //pending detect, if remote file has REV field. if not switch to external sync | 2810 | //pending detect, if remote file has REV field. if not switch to external sync |
2811 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2811 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2812 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2812 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2813 | 2813 | ||
2814 | AddressBook abLocal(filename,"syncContact"); | 2814 | AddressBook abLocal(filename,"syncContact"); |
2815 | bool syncOK = false; | 2815 | bool syncOK = false; |
2816 | if ( abLocal.load() ) { | 2816 | if ( abLocal.load() ) { |
2817 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2817 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2818 | bool external = false; | 2818 | bool external = false; |
2819 | bool isXML = false; | 2819 | bool isXML = false; |
2820 | if ( filename.right(4) == ".xml") { | 2820 | if ( filename.right(4) == ".xml") { |
2821 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2821 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2822 | isXML = true; | 2822 | isXML = true; |
2823 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2823 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2824 | } else { | 2824 | } else { |
2825 | external = !manager->mIsKapiFile; | 2825 | external = !manager->mIsKapiFile; |
2826 | if ( external ) { | 2826 | if ( external ) { |
2827 | qDebug("Setting vcf mode to external "); | 2827 | qDebug("Setting vcf mode to external "); |
2828 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2828 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2829 | AddressBook::Iterator it; | 2829 | AddressBook::Iterator it; |
2830 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2830 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2831 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2831 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2832 | (*it).computeCsum( mCurrentSyncDevice ); | 2832 | (*it).computeCsum( mCurrentSyncDevice ); |
2833 | } | 2833 | } |
2834 | } | 2834 | } |
2835 | } | 2835 | } |
2836 | //AddressBook::Iterator it; | 2836 | //AddressBook::Iterator it; |
2837 | //QStringList vcards; | 2837 | //QStringList vcards; |
2838 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2838 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2839 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2839 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2840 | //} | 2840 | //} |
2841 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2841 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2842 | if ( syncOK ) { | 2842 | if ( syncOK ) { |
2843 | if ( syncManager->mWriteBackFile ) | 2843 | if ( syncManager->mWriteBackFile ) |
2844 | { | 2844 | { |
2845 | if ( external ) | 2845 | if ( external ) |
2846 | abLocal.removeSyncAddressees( !isXML); | 2846 | abLocal.removeSyncAddressees( !isXML); |
2847 | qDebug("Saving remote AB "); | 2847 | qDebug("Saving remote AB "); |
2848 | if ( ! abLocal.saveAB()) | 2848 | if ( ! abLocal.saveAB()) |
2849 | qDebug("Error writing back AB to file "); | 2849 | qDebug("Error writing back AB to file "); |
2850 | if ( external ) { | 2850 | if ( external ) { |
2851 | // afterwrite processing | 2851 | // afterwrite processing |
2852 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 2852 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
2853 | } | 2853 | } |
2854 | } | 2854 | } |
2855 | } | 2855 | } |
2856 | setModified(); | 2856 | setModified(); |
2857 | 2857 | ||
2858 | } | 2858 | } |
2859 | abLocal.removeResources(); | ||
2859 | if ( syncOK ) | 2860 | if ( syncOK ) |
2860 | mViewManager->refreshView(); | 2861 | mViewManager->refreshView(); |
2861 | return syncOK; | 2862 | return syncOK; |
2862 | 2863 | ||
2863 | } | 2864 | } |
2864 | void KABCore::removeSyncInfo( QString syncProfile) | 2865 | void KABCore::removeSyncInfo( QString syncProfile) |
2865 | { | 2866 | { |
2866 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2867 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2867 | mAddressBook->removeSyncInfo( syncProfile ); | 2868 | mAddressBook->removeSyncInfo( syncProfile ); |
2868 | setModified(); | 2869 | setModified(); |
2869 | } | 2870 | } |
2870 | 2871 | ||
2871 | 2872 | ||
2872 | //this is a overwritten callbackmethods from the syncinterface | 2873 | //this is a overwritten callbackmethods from the syncinterface |
2873 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2874 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2874 | { | 2875 | { |
2875 | if ( resource == "phone" ) | 2876 | if ( resource == "phone" ) |
2876 | return syncPhone(); | 2877 | return syncPhone(); |
2877 | disableBR( true ); | 2878 | disableBR( true ); |
2878 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2879 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2879 | 2880 | ||
2880 | AddressBook abLocal( resource,"syncContact"); | 2881 | AddressBook abLocal( resource,"syncContact"); |
2881 | bool syncOK = false; | 2882 | bool syncOK = false; |
2882 | if ( abLocal.load() ) { | 2883 | if ( abLocal.load() ) { |
2883 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2884 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2884 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2885 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2885 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2886 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2886 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2887 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2887 | if ( syncOK ) { | 2888 | if ( syncOK ) { |
2888 | if ( syncManager->mWriteBackFile ) { | 2889 | if ( syncManager->mWriteBackFile ) { |
2889 | abLocal.removeSyncAddressees( false ); | 2890 | abLocal.removeSyncAddressees( false ); |
2890 | abLocal.saveAB(); | 2891 | abLocal.saveAB(); |
2891 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2892 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2892 | } | 2893 | } |
2893 | } else | 2894 | } else |
2894 | message( i18n("Sync cancelled or failed.") ); | 2895 | message( i18n("Sync cancelled or failed.") ); |
2895 | setModified(); | 2896 | setModified(); |
2896 | } | 2897 | } |
2898 | abLocal.removeResources(); | ||
2897 | if ( syncOK ) | 2899 | if ( syncOK ) |
2898 | mViewManager->refreshView(); | 2900 | mViewManager->refreshView(); |
2899 | disableBR( false ); | 2901 | disableBR( false ); |
2900 | return syncOK; | 2902 | return syncOK; |
2901 | 2903 | ||
2902 | } | 2904 | } |
2903 | void KABCore::message( QString m ) | 2905 | void KABCore::message( QString m ) |
2904 | { | 2906 | { |
2905 | topLevelWidget()->setCaption( m ); | 2907 | topLevelWidget()->setCaption( m ); |
2906 | mMessageTimer->start( 15000, true ); | 2908 | mMessageTimer->start( 15000, true ); |
2907 | } | 2909 | } |
2908 | bool KABCore::syncPhone() | 2910 | bool KABCore::syncPhone() |
2909 | { | 2911 | { |
2910 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2912 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2911 | QString fileName = getPhoneFile(); | 2913 | QString fileName = getPhoneFile(); |
2912 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2914 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2913 | message(i18n("Phone access failed!")); | 2915 | message(i18n("Phone access failed!")); |
2914 | return false; | 2916 | return false; |
2915 | } | 2917 | } |
2916 | AddressBook abLocal( fileName,"syncContact"); | 2918 | AddressBook abLocal( fileName,"syncContact"); |
2917 | bool syncOK = false; | 2919 | bool syncOK = false; |
2918 | { | 2920 | { |
2919 | abLocal.importFromFile( fileName ); | 2921 | abLocal.importFromFile( fileName ); |
2920 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2922 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2921 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2923 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2922 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2924 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2923 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2925 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2924 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2926 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2925 | if ( syncOK ) { | 2927 | if ( syncOK ) { |
2926 | if ( syncManager->mWriteBackFile ) { | 2928 | if ( syncManager->mWriteBackFile ) { |
2927 | abLocal.removeSyncAddressees( true ); | 2929 | abLocal.removeSyncAddressees( true ); |
2928 | abLocal.saveABphone( fileName ); | 2930 | abLocal.saveABphone( fileName ); |
2929 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2931 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2930 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2932 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2931 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2933 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2932 | } | 2934 | } |
2933 | } | 2935 | } |
2934 | setModified(); | 2936 | setModified(); |
2935 | } | 2937 | } |
2938 | abLocal.removeResources(); | ||
2936 | if ( syncOK ) | 2939 | if ( syncOK ) |
2937 | mViewManager->refreshView(); | 2940 | mViewManager->refreshView(); |
2938 | return syncOK; | 2941 | return syncOK; |
2939 | } | 2942 | } |
2940 | void KABCore::getFile( bool success ) | 2943 | void KABCore::getFile( bool success ) |
2941 | { | 2944 | { |
2942 | if ( ! success ) { | 2945 | if ( ! success ) { |
2943 | message( i18n("Error receiving file. Nothing changed!") ); | 2946 | message( i18n("Error receiving file. Nothing changed!") ); |
2944 | return; | 2947 | return; |
2945 | } | 2948 | } |
2946 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2949 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2947 | if ( count ) | 2950 | if ( count ) |
2948 | setModified( true ); | 2951 | setModified( true ); |
2949 | message( i18n("Pi-Sync successful!") ); | 2952 | message( i18n("Pi-Sync successful!") ); |
2950 | mViewManager->refreshView(); | 2953 | mViewManager->refreshView(); |
2951 | } | 2954 | } |
2952 | void KABCore::syncFileRequest() | 2955 | void KABCore::syncFileRequest() |
2953 | { | 2956 | { |
2954 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 2957 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
2955 | syncManager->slotSyncMenu( 999 ); | 2958 | syncManager->slotSyncMenu( 999 ); |
2956 | } | 2959 | } |
2957 | mAddressBook->export2File( sentSyncFile() ); | 2960 | mAddressBook->export2File( sentSyncFile() ); |
2958 | } | 2961 | } |
2959 | QString KABCore::sentSyncFile() | 2962 | QString KABCore::sentSyncFile() |
2960 | { | 2963 | { |
2961 | #ifdef DESKTOP_VERSION | 2964 | #ifdef DESKTOP_VERSION |
2962 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2965 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2963 | #else | 2966 | #else |
2964 | return QString( "/tmp/copysyncab.vcf" ); | 2967 | return QString( "/tmp/copysyncab.vcf" ); |
2965 | #endif | 2968 | #endif |
2966 | } | 2969 | } |
2967 | 2970 | ||
2968 | void KABCore::setCaptionBack() | 2971 | void KABCore::setCaptionBack() |
2969 | { | 2972 | { |
2970 | mMessageTimer->stop(); | 2973 | mMessageTimer->stop(); |
2971 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2974 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2972 | } | 2975 | } |