-rw-r--r-- | kaddressbook/kabcore.cpp | 509 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 38 | ||||
-rw-r--r-- | kaddressbook/kabprefs.h | 18 |
3 files changed, 73 insertions, 492 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index df634d0..f222234 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -129,76 +129,76 @@ $Id$ | |||
129 | #include <libkdepim/categoryselectdialog.h> | 129 | #include <libkdepim/categoryselectdialog.h> |
130 | #include <kabc/vcardconverter.h> | 130 | #include <kabc/vcardconverter.h> |
131 | 131 | ||
132 | 132 | ||
133 | #include "addresseeutil.h" | 133 | #include "addresseeutil.h" |
134 | #include "undocmds.h" | 134 | #include "undocmds.h" |
135 | #include "addresseeeditordialog.h" | 135 | #include "addresseeeditordialog.h" |
136 | #include "viewmanager.h" | 136 | #include "viewmanager.h" |
137 | #include "details/detailsviewcontainer.h" | 137 | #include "details/detailsviewcontainer.h" |
138 | #include "kabprefs.h" | 138 | #include "kabprefs.h" |
139 | #include "xxportmanager.h" | 139 | #include "xxportmanager.h" |
140 | #include "incsearchwidget.h" | 140 | #include "incsearchwidget.h" |
141 | #include "jumpbuttonbar.h" | 141 | #include "jumpbuttonbar.h" |
142 | #include "extensionmanager.h" | 142 | #include "extensionmanager.h" |
143 | #include "addresseeconfig.h" | 143 | #include "addresseeconfig.h" |
144 | #include <kcmultidialog.h> | 144 | #include <kcmultidialog.h> |
145 | 145 | ||
146 | #ifdef _WIN32_ | 146 | #ifdef _WIN32_ |
147 | 147 | ||
148 | #include "kaimportoldialog.h" | 148 | #include "kaimportoldialog.h" |
149 | #else | 149 | #else |
150 | #include <unistd.h> | 150 | #include <unistd.h> |
151 | #endif | 151 | #endif |
152 | // sync includes | 152 | // sync includes |
153 | #include <libkdepim/ksyncprofile.h> | 153 | #include <libkdepim/ksyncprofile.h> |
154 | #include <libkdepim/ksyncprefsdialog.h> | 154 | #include <libkdepim/ksyncprefsdialog.h> |
155 | 155 | ||
156 | 156 | ||
157 | bool pasteWithNewUid = true; | 157 | bool pasteWithNewUid = true; |
158 | 158 | ||
159 | #ifdef KAB_EMBEDDED | 159 | #ifdef KAB_EMBEDDED |
160 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 160 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
161 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 161 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
162 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 162 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
163 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 163 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
164 | #else //KAB_EMBEDDED | 164 | #else //KAB_EMBEDDED |
165 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 165 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
166 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 166 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
167 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 167 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
168 | mReadWrite( readWrite ), mModified( false ) | 168 | mReadWrite( readWrite ), mModified( false ) |
169 | #endif //KAB_EMBEDDED | 169 | #endif //KAB_EMBEDDED |
170 | { | 170 | { |
171 | 171 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | |
172 | mBlockSaveFlag = false; | 172 | // syncManager->setBlockSave(false); |
173 | mExtensionBarSplitter = 0; | 173 | mExtensionBarSplitter = 0; |
174 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 174 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
175 | 175 | ||
176 | mAddressBook = KABC::StdAddressBook::self(); | 176 | mAddressBook = KABC::StdAddressBook::self(); |
177 | KABC::StdAddressBook::setAutomaticSave( false ); | 177 | KABC::StdAddressBook::setAutomaticSave( false ); |
178 | 178 | ||
179 | #ifndef KAB_EMBEDDED | 179 | #ifndef KAB_EMBEDDED |
180 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 180 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
181 | #endif //KAB_EMBEDDED | 181 | #endif //KAB_EMBEDDED |
182 | 182 | ||
183 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 183 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
184 | SLOT( addressBookChanged() ) ); | 184 | SLOT( addressBookChanged() ) ); |
185 | 185 | ||
186 | #if 0 | 186 | #if 0 |
187 | // LP moved to addressbook init method | 187 | // LP moved to addressbook init method |
188 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 188 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
189 | "X-Department", "KADDRESSBOOK" ); | 189 | "X-Department", "KADDRESSBOOK" ); |
190 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 190 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
191 | "X-Profession", "KADDRESSBOOK" ); | 191 | "X-Profession", "KADDRESSBOOK" ); |
192 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 192 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
193 | "X-AssistantsName", "KADDRESSBOOK" ); | 193 | "X-AssistantsName", "KADDRESSBOOK" ); |
194 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 194 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
195 | "X-ManagersName", "KADDRESSBOOK" ); | 195 | "X-ManagersName", "KADDRESSBOOK" ); |
196 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 196 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
197 | "X-SpousesName", "KADDRESSBOOK" ); | 197 | "X-SpousesName", "KADDRESSBOOK" ); |
198 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 198 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
199 | "X-Office", "KADDRESSBOOK" ); | 199 | "X-Office", "KADDRESSBOOK" ); |
200 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 200 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
201 | "X-IMAddress", "KADDRESSBOOK" ); | 201 | "X-IMAddress", "KADDRESSBOOK" ); |
202 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 202 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
203 | "X-Anniversary", "KADDRESSBOOK" ); | 203 | "X-Anniversary", "KADDRESSBOOK" ); |
204 | 204 | ||
@@ -240,64 +240,66 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
240 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 240 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
241 | SLOT( sendMail( const QString& ) ) ); | 241 | SLOT( sendMail( const QString& ) ) ); |
242 | 242 | ||
243 | 243 | ||
244 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 244 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
245 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 245 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
246 | 246 | ||
247 | 247 | ||
248 | #ifndef KAB_EMBEDDED | 248 | #ifndef KAB_EMBEDDED |
249 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 249 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
250 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 250 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
251 | 251 | ||
252 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 252 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
253 | SLOT( browse( const QString& ) ) ); | 253 | SLOT( browse( const QString& ) ) ); |
254 | 254 | ||
255 | 255 | ||
256 | mAddressBookService = new KAddressBookService( this ); | 256 | mAddressBookService = new KAddressBookService( this ); |
257 | 257 | ||
258 | #endif //KAB_EMBEDDED | 258 | #endif //KAB_EMBEDDED |
259 | mEditorDialog = 0; | 259 | mEditorDialog = 0; |
260 | createAddresseeEditorDialog( this ); | 260 | createAddresseeEditorDialog( this ); |
261 | setModified( false ); | 261 | setModified( false ); |
262 | } | 262 | } |
263 | 263 | ||
264 | KABCore::~KABCore() | 264 | KABCore::~KABCore() |
265 | { | 265 | { |
266 | // save(); | 266 | // save(); |
267 | //saveSettings(); | 267 | //saveSettings(); |
268 | //KABPrefs::instance()->writeConfig(); | 268 | //KABPrefs::instance()->writeConfig(); |
269 | delete AddresseeConfig::instance(); | 269 | delete AddresseeConfig::instance(); |
270 | mAddressBook = 0; | 270 | mAddressBook = 0; |
271 | KABC::StdAddressBook::close(); | 271 | KABC::StdAddressBook::close(); |
272 | |||
273 | delete syncManager; | ||
272 | } | 274 | } |
273 | 275 | ||
274 | void KABCore::restoreSettings() | 276 | void KABCore::restoreSettings() |
275 | { | 277 | { |
276 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 278 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
277 | 279 | ||
278 | bool state; | 280 | bool state; |
279 | 281 | ||
280 | if (mMultipleViewsAtOnce) | 282 | if (mMultipleViewsAtOnce) |
281 | state = KABPrefs::instance()->mDetailsPageVisible; | 283 | state = KABPrefs::instance()->mDetailsPageVisible; |
282 | else | 284 | else |
283 | state = false; | 285 | state = false; |
284 | 286 | ||
285 | mActionDetails->setChecked( state ); | 287 | mActionDetails->setChecked( state ); |
286 | setDetailsVisible( state ); | 288 | setDetailsVisible( state ); |
287 | 289 | ||
288 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 290 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
289 | 291 | ||
290 | mActionJumpBar->setChecked( state ); | 292 | mActionJumpBar->setChecked( state ); |
291 | setJumpButtonBarVisible( state ); | 293 | setJumpButtonBarVisible( state ); |
292 | /*US | 294 | /*US |
293 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 295 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
294 | if ( splitterSize.count() == 0 ) { | 296 | if ( splitterSize.count() == 0 ) { |
295 | splitterSize.append( width() / 2 ); | 297 | splitterSize.append( width() / 2 ); |
296 | splitterSize.append( width() / 2 ); | 298 | splitterSize.append( width() / 2 ); |
297 | } | 299 | } |
298 | mMiniSplitter->setSizes( splitterSize ); | 300 | mMiniSplitter->setSizes( splitterSize ); |
299 | if ( mExtensionBarSplitter ) { | 301 | if ( mExtensionBarSplitter ) { |
300 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 302 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
301 | if ( splitterSize.count() == 0 ) { | 303 | if ( splitterSize.count() == 0 ) { |
302 | splitterSize.append( width() / 2 ); | 304 | splitterSize.append( width() / 2 ); |
303 | splitterSize.append( width() / 2 ); | 305 | splitterSize.append( width() / 2 ); |
@@ -1045,88 +1047,88 @@ void KABCore::editContact( const QString &uid ) | |||
1045 | QStringList uidList = mViewManager->selectedUids(); | 1047 | QStringList uidList = mViewManager->selectedUids(); |
1046 | if ( uidList.count() > 0 ) | 1048 | if ( uidList.count() > 0 ) |
1047 | localUID = *( uidList.at( 0 ) ); | 1049 | localUID = *( uidList.at( 0 ) ); |
1048 | } | 1050 | } |
1049 | 1051 | ||
1050 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1052 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1051 | if ( !addr.isEmpty() ) { | 1053 | if ( !addr.isEmpty() ) { |
1052 | mEditorDialog->setAddressee( addr ); | 1054 | mEditorDialog->setAddressee( addr ); |
1053 | KApplication::execDialog ( mEditorDialog ); | 1055 | KApplication::execDialog ( mEditorDialog ); |
1054 | } | 1056 | } |
1055 | } | 1057 | } |
1056 | 1058 | ||
1057 | /** | 1059 | /** |
1058 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1060 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1059 | the method will try to find a selected addressee in the view. | 1061 | the method will try to find a selected addressee in the view. |
1060 | */ | 1062 | */ |
1061 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1063 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1062 | { | 1064 | { |
1063 | if ( mMultipleViewsAtOnce ) | 1065 | if ( mMultipleViewsAtOnce ) |
1064 | { | 1066 | { |
1065 | editContact( uid ); | 1067 | editContact( uid ); |
1066 | } | 1068 | } |
1067 | else | 1069 | else |
1068 | { | 1070 | { |
1069 | setDetailsVisible( true ); | 1071 | setDetailsVisible( true ); |
1070 | mActionDetails->setChecked(true); | 1072 | mActionDetails->setChecked(true); |
1071 | } | 1073 | } |
1072 | 1074 | ||
1073 | } | 1075 | } |
1074 | 1076 | ||
1075 | void KABCore::save() | 1077 | void KABCore::save() |
1076 | { | 1078 | { |
1077 | if (mBlockSaveFlag) | 1079 | if (syncManager->blockSave()) |
1078 | return; | 1080 | return; |
1079 | mBlockSaveFlag = true; | 1081 | syncManager->setBlockSave(true); |
1080 | if ( !mModified ) | 1082 | if ( !mModified ) |
1081 | return; | 1083 | return; |
1082 | QString text = i18n( "There was an error while attempting to save\n the " | 1084 | QString text = i18n( "There was an error while attempting to save\n the " |
1083 | "address book. Please check that some \nother application is " | 1085 | "address book. Please check that some \nother application is " |
1084 | "not using it. " ); | 1086 | "not using it. " ); |
1085 | statusMessage(i18n("Saving addressbook ... ")); | 1087 | statusMessage(i18n("Saving addressbook ... ")); |
1086 | #ifndef KAB_EMBEDDED | 1088 | #ifndef KAB_EMBEDDED |
1087 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1089 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1088 | if ( !b || !b->save() ) { | 1090 | if ( !b || !b->save() ) { |
1089 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1091 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1090 | } | 1092 | } |
1091 | #else //KAB_EMBEDDED | 1093 | #else //KAB_EMBEDDED |
1092 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1094 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1093 | if ( !b || !b->save() ) { | 1095 | if ( !b || !b->save() ) { |
1094 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1096 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1095 | } | 1097 | } |
1096 | #endif //KAB_EMBEDDED | 1098 | #endif //KAB_EMBEDDED |
1097 | 1099 | ||
1098 | statusMessage(i18n("Addressbook saved!")); | 1100 | statusMessage(i18n("Addressbook saved!")); |
1099 | setModified( false ); | 1101 | setModified( false ); |
1100 | mBlockSaveFlag = false; | 1102 | syncManager->setBlockSave(false); |
1101 | } | 1103 | } |
1102 | 1104 | ||
1103 | void KABCore::statusMessage(QString mess , int time ) | 1105 | void KABCore::statusMessage(QString mess , int time ) |
1104 | { | 1106 | { |
1105 | //topLevelWidget()->setCaption( mess ); | 1107 | //topLevelWidget()->setCaption( mess ); |
1106 | // pending setting timer to revome message | 1108 | // pending setting timer to revome message |
1107 | } | 1109 | } |
1108 | void KABCore::undo() | 1110 | void KABCore::undo() |
1109 | { | 1111 | { |
1110 | UndoStack::instance()->undo(); | 1112 | UndoStack::instance()->undo(); |
1111 | 1113 | ||
1112 | // Refresh the view | 1114 | // Refresh the view |
1113 | mViewManager->refreshView(); | 1115 | mViewManager->refreshView(); |
1114 | } | 1116 | } |
1115 | 1117 | ||
1116 | void KABCore::redo() | 1118 | void KABCore::redo() |
1117 | { | 1119 | { |
1118 | RedoStack::instance()->redo(); | 1120 | RedoStack::instance()->redo(); |
1119 | 1121 | ||
1120 | // Refresh the view | 1122 | // Refresh the view |
1121 | mViewManager->refreshView(); | 1123 | mViewManager->refreshView(); |
1122 | } | 1124 | } |
1123 | 1125 | ||
1124 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1126 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1125 | { | 1127 | { |
1126 | if (mMultipleViewsAtOnce) | 1128 | if (mMultipleViewsAtOnce) |
1127 | { | 1129 | { |
1128 | if ( visible ) | 1130 | if ( visible ) |
1129 | mJumpButtonBar->show(); | 1131 | mJumpButtonBar->show(); |
1130 | else | 1132 | else |
1131 | mJumpButtonBar->hide(); | 1133 | mJumpButtonBar->hide(); |
1132 | } | 1134 | } |
@@ -1507,64 +1509,67 @@ void KABCore::initGUI() | |||
1507 | 1509 | ||
1508 | mDetailsSplitter = new QSplitter( this ); | 1510 | mDetailsSplitter = new QSplitter( this ); |
1509 | 1511 | ||
1510 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1512 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1511 | 1513 | ||
1512 | mViewManager = new ViewManager( this, viewSpace ); | 1514 | mViewManager = new ViewManager( this, viewSpace ); |
1513 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1515 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1514 | 1516 | ||
1515 | mDetails = new ViewContainer( mDetailsSplitter ); | 1517 | mDetails = new ViewContainer( mDetailsSplitter ); |
1516 | 1518 | ||
1517 | topLayout->addWidget( mDetailsSplitter ); | 1519 | topLayout->addWidget( mDetailsSplitter ); |
1518 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1520 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1519 | #else //KAB_NOSPLITTER | 1521 | #else //KAB_NOSPLITTER |
1520 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1522 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1521 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1523 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1522 | topLayout->setSpacing( 10 ); | 1524 | topLayout->setSpacing( 10 ); |
1523 | 1525 | ||
1524 | // mDetailsSplitter = new QSplitter( this ); | 1526 | // mDetailsSplitter = new QSplitter( this ); |
1525 | 1527 | ||
1526 | QVBox *viewSpace = new QVBox( this ); | 1528 | QVBox *viewSpace = new QVBox( this ); |
1527 | 1529 | ||
1528 | mViewManager = new ViewManager( this, viewSpace ); | 1530 | mViewManager = new ViewManager( this, viewSpace ); |
1529 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1531 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1530 | 1532 | ||
1531 | mDetails = new ViewContainer( this ); | 1533 | mDetails = new ViewContainer( this ); |
1532 | 1534 | ||
1533 | topLayout->addWidget( viewSpace ); | 1535 | topLayout->addWidget( viewSpace ); |
1534 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1536 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1535 | topLayout->addWidget( mDetails ); | 1537 | topLayout->addWidget( mDetails ); |
1536 | #endif //KAB_NOSPLITTER | 1538 | #endif //KAB_NOSPLITTER |
1537 | */ | 1539 | */ |
1538 | 1540 | ||
1541 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | ||
1542 | syncManager->setBlockSave(false); | ||
1543 | |||
1539 | 1544 | ||
1540 | #endif //KAB_EMBEDDED | 1545 | #endif //KAB_EMBEDDED |
1541 | initActions(); | 1546 | initActions(); |
1542 | 1547 | ||
1543 | #ifdef KAB_EMBEDDED | 1548 | #ifdef KAB_EMBEDDED |
1544 | addActionsManually(); | 1549 | addActionsManually(); |
1545 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1550 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1546 | mXXPortManager = new XXPortManager( this, this ); | 1551 | mXXPortManager = new XXPortManager( this, this ); |
1547 | 1552 | ||
1548 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1553 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1549 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1554 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1550 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1555 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1551 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1556 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1552 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1557 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1553 | // mIncSearchWidget->hide(); | 1558 | // mIncSearchWidget->hide(); |
1554 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1559 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1555 | SLOT( incrementalSearch( const QString& ) ) ); | 1560 | SLOT( incrementalSearch( const QString& ) ) ); |
1556 | 1561 | ||
1557 | 1562 | ||
1558 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1563 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1559 | 1564 | ||
1560 | topLayout->addWidget( mJumpButtonBar ); | 1565 | topLayout->addWidget( mJumpButtonBar ); |
1561 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1566 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1562 | 1567 | ||
1563 | // mMainWindow->getIconToolBar()->raise(); | 1568 | // mMainWindow->getIconToolBar()->raise(); |
1564 | 1569 | ||
1565 | #endif //KAB_EMBEDDED | 1570 | #endif //KAB_EMBEDDED |
1566 | 1571 | ||
1567 | } | 1572 | } |
1568 | void KABCore::initActions() | 1573 | void KABCore::initActions() |
1569 | { | 1574 | { |
1570 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1575 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
@@ -1869,66 +1874,66 @@ void KABCore::addActionsManually() | |||
1869 | mActionAboutKAddressbook->plug( helpMenu ); | 1874 | mActionAboutKAddressbook->plug( helpMenu ); |
1870 | 1875 | ||
1871 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1876 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1872 | 1877 | ||
1873 | mActionSave->plug( tb ); | 1878 | mActionSave->plug( tb ); |
1874 | mViewManager->getFilterAction()->plug ( tb); | 1879 | mViewManager->getFilterAction()->plug ( tb); |
1875 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1880 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1876 | mActionUndo->plug( tb ); | 1881 | mActionUndo->plug( tb ); |
1877 | mActionDelete->plug( tb ); | 1882 | mActionDelete->plug( tb ); |
1878 | mActionRedo->plug( tb ); | 1883 | mActionRedo->plug( tb ); |
1879 | } | 1884 | } |
1880 | } | 1885 | } |
1881 | //mActionQuit->plug ( tb ); | 1886 | //mActionQuit->plug ( tb ); |
1882 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1887 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1883 | 1888 | ||
1884 | //US link the searchwidget first to this. | 1889 | //US link the searchwidget first to this. |
1885 | // The real linkage to the toolbar happens later. | 1890 | // The real linkage to the toolbar happens later. |
1886 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1891 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1887 | //US tb->insertItem( mIncSearchWidget ); | 1892 | //US tb->insertItem( mIncSearchWidget ); |
1888 | /*US | 1893 | /*US |
1889 | mIncSearchWidget = new IncSearchWidget( tb ); | 1894 | mIncSearchWidget = new IncSearchWidget( tb ); |
1890 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1895 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1891 | SLOT( incrementalSearch( const QString& ) ) ); | 1896 | SLOT( incrementalSearch( const QString& ) ) ); |
1892 | 1897 | ||
1893 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1898 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1894 | 1899 | ||
1895 | //US topLayout->addWidget( mJumpButtonBar ); | 1900 | //US topLayout->addWidget( mJumpButtonBar ); |
1896 | this->layout()->add( mJumpButtonBar ); | 1901 | this->layout()->add( mJumpButtonBar ); |
1897 | */ | 1902 | */ |
1898 | 1903 | ||
1899 | #endif //KAB_EMBEDDED | 1904 | #endif //KAB_EMBEDDED |
1900 | 1905 | ||
1901 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 1906 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
1902 | fillSyncMenu(); | 1907 | syncManager->fillSyncMenu(); |
1903 | 1908 | ||
1904 | } | 1909 | } |
1905 | void KABCore::showLicence() | 1910 | void KABCore::showLicence() |
1906 | { | 1911 | { |
1907 | KApplication::showLicence(); | 1912 | KApplication::showLicence(); |
1908 | } | 1913 | } |
1909 | void KABCore::removeVoice() | 1914 | void KABCore::removeVoice() |
1910 | { | 1915 | { |
1911 | 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 ) | 1916 | 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 ) |
1912 | return; | 1917 | return; |
1913 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1918 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1914 | KABC::Addressee::List::Iterator it; | 1919 | KABC::Addressee::List::Iterator it; |
1915 | for ( it = list.begin(); it != list.end(); ++it ) { | 1920 | for ( it = list.begin(); it != list.end(); ++it ) { |
1916 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1921 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1917 | PhoneNumber::List::Iterator phoneIt; | 1922 | PhoneNumber::List::Iterator phoneIt; |
1918 | bool found = false; | 1923 | bool found = false; |
1919 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1924 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1920 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1925 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1921 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1926 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1922 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1927 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1923 | (*it).insertPhoneNumber( (*phoneIt) ); | 1928 | (*it).insertPhoneNumber( (*phoneIt) ); |
1924 | found = true; | 1929 | found = true; |
1925 | } | 1930 | } |
1926 | } | 1931 | } |
1927 | 1932 | ||
1928 | } | 1933 | } |
1929 | if ( found ) | 1934 | if ( found ) |
1930 | contactModified((*it) ); | 1935 | contactModified((*it) ); |
1931 | } | 1936 | } |
1932 | } | 1937 | } |
1933 | 1938 | ||
1934 | 1939 | ||
@@ -2072,510 +2077,105 @@ void KABCore::requestForDetails(const QString& sourceChannel, const QString& ses | |||
2072 | if (!foundUid.isEmpty()) | 2077 | if (!foundUid.isEmpty()) |
2073 | { | 2078 | { |
2074 | 2079 | ||
2075 | // raise Ka/Pi if it is in the background | 2080 | // raise Ka/Pi if it is in the background |
2076 | #ifndef DESKTOP_VERSION | 2081 | #ifndef DESKTOP_VERSION |
2077 | #ifndef KORG_NODCOP | 2082 | #ifndef KORG_NODCOP |
2078 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2083 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2079 | #endif | 2084 | #endif |
2080 | #endif | 2085 | #endif |
2081 | 2086 | ||
2082 | mMainWindow->showMaximized(); | 2087 | mMainWindow->showMaximized(); |
2083 | mMainWindow-> raise(); | 2088 | mMainWindow-> raise(); |
2084 | 2089 | ||
2085 | mViewManager->setSelected( "", false); | 2090 | mViewManager->setSelected( "", false); |
2086 | mViewManager->refreshView( "" ); | 2091 | mViewManager->refreshView( "" ); |
2087 | mViewManager->setSelected( foundUid, true ); | 2092 | mViewManager->setSelected( foundUid, true ); |
2088 | mViewManager->refreshView( foundUid ); | 2093 | mViewManager->refreshView( foundUid ); |
2089 | 2094 | ||
2090 | if ( !mMultipleViewsAtOnce ) | 2095 | if ( !mMultipleViewsAtOnce ) |
2091 | { | 2096 | { |
2092 | setDetailsVisible( true ); | 2097 | setDetailsVisible( true ); |
2093 | mActionDetails->setChecked(true); | 2098 | mActionDetails->setChecked(true); |
2094 | } | 2099 | } |
2095 | } | 2100 | } |
2096 | } | 2101 | } |
2097 | 2102 | ||
2098 | 2103 | ||
2099 | void KABCore::faq() | 2104 | void KABCore::faq() |
2100 | { | 2105 | { |
2101 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2106 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2102 | } | 2107 | } |
2103 | 2108 | ||
2104 | |||
2105 | void KABCore::fillSyncMenu() | ||
2106 | { | ||
2107 | if ( syncMenu->count() ) | ||
2108 | syncMenu->clear(); | ||
2109 | syncMenu->insertItem( i18n("Configure..."), 0 ); | ||
2110 | syncMenu->insertSeparator(); | ||
2111 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | ||
2112 | syncMenu->insertSeparator(); | ||
2113 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
2114 | config.setGroup("General"); | ||
2115 | QStringList prof = config.readListEntry("SyncProfileNames"); | ||
2116 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | ||
2117 | if ( prof.count() < 3 ) { | ||
2118 | prof.clear(); | ||
2119 | prof << i18n("Sharp_DTM"); | ||
2120 | prof << i18n("Local_file"); | ||
2121 | prof << i18n("Last_file"); | ||
2122 | KSyncProfile* temp = new KSyncProfile (); | ||
2123 | temp->setName( prof[0] ); | ||
2124 | temp->writeConfig(&config); | ||
2125 | temp->setName( prof[1] ); | ||
2126 | temp->writeConfig(&config); | ||
2127 | temp->setName( prof[2] ); | ||
2128 | temp->writeConfig(&config); | ||
2129 | config.setGroup("General"); | ||
2130 | config.writeEntry("SyncProfileNames",prof); | ||
2131 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | ||
2132 | config.sync(); | ||
2133 | delete temp; | ||
2134 | } | ||
2135 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | ||
2136 | KABPrefs::instance()->mSyncProfileNames = prof; | ||
2137 | int i; | ||
2138 | for ( i = 0; i < prof.count(); ++i ) { | ||
2139 | |||
2140 | syncMenu->insertItem( prof[i], 1000+i ); | ||
2141 | if ( i == 2 ) | ||
2142 | syncMenu->insertSeparator(); | ||
2143 | } | ||
2144 | QDir app_dir; | ||
2145 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | ||
2146 | syncMenu->setItemEnabled( false , 1000 ); | ||
2147 | } | ||
2148 | //probaly useless | ||
2149 | //mView->setupExternSyncProfiles(); | ||
2150 | } | ||
2151 | void KABCore::slotSyncMenu( int action ) | ||
2152 | { | ||
2153 | //qDebug("syncaction %d ", action); | ||
2154 | if ( action == 0 ) { | ||
2155 | |||
2156 | // seems to be a Qt2 event handling bug | ||
2157 | // syncmenu.clear causes a segfault at first time | ||
2158 | // when we call it after the main event loop, it is ok | ||
2159 | // same behaviour when calling OM/Pi via QCOP for the first time | ||
2160 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | ||
2161 | //confSync(); | ||
2162 | |||
2163 | return; | ||
2164 | } | ||
2165 | if ( action == 1 ) { | ||
2166 | multiSync( true ); | ||
2167 | return; | ||
2168 | } | ||
2169 | |||
2170 | if (mBlockSaveFlag) | ||
2171 | return; | ||
2172 | mBlockSaveFlag = true; | ||
2173 | mCurrentSyncProfile = action - 1000 ; | ||
2174 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; | ||
2175 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; | ||
2176 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
2177 | KSyncProfile* temp = new KSyncProfile (); | ||
2178 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
2179 | temp->readConfig(&config); | ||
2180 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
2181 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | ||
2182 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
2183 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
2184 | KABPrefs::instance()->mWriteBackInFuture = 0; | ||
2185 | if ( temp->getWriteBackFuture() ) | ||
2186 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
2187 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | ||
2188 | if ( action == 1000 ) { | ||
2189 | syncSharp(); | ||
2190 | |||
2191 | } else if ( action == 1001 ) { | ||
2192 | syncLocalFile(); | ||
2193 | |||
2194 | } else if ( action == 1002 ) { | ||
2195 | quickSyncLocalFile(); | ||
2196 | |||
2197 | } else if ( action >= 1003 ) { | ||
2198 | if ( temp->getIsLocalFileSync() ) { | ||
2199 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | ||
2200 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | ||
2201 | } else { | ||
2202 | if ( temp->getIsPhoneSync() ) { | ||
2203 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | ||
2204 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | ||
2205 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | ||
2206 | syncPhone(); | ||
2207 | } else | ||
2208 | syncRemote( temp ); | ||
2209 | |||
2210 | } | ||
2211 | } | ||
2212 | delete temp; | ||
2213 | mBlockSaveFlag = false; | ||
2214 | } | ||
2215 | |||
2216 | void KABCore::syncLocalFile() | ||
2217 | { | ||
2218 | |||
2219 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; | ||
2220 | |||
2221 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | ||
2222 | if ( fn == "" ) | ||
2223 | return; | ||
2224 | if ( syncWithFile( fn, false ) ) { | ||
2225 | qDebug("syncLocalFile() successful "); | ||
2226 | } | ||
2227 | |||
2228 | } | ||
2229 | bool KABCore::syncWithFile( QString fn , bool quick ) | ||
2230 | { | ||
2231 | bool ret = false; | ||
2232 | QFileInfo info; | ||
2233 | info.setFile( fn ); | ||
2234 | QString mess; | ||
2235 | bool loadbup = true; | ||
2236 | if ( !info. exists() ) { | ||
2237 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | ||
2238 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
2239 | mess ); | ||
2240 | return ret; | ||
2241 | } | ||
2242 | int result = 0; | ||
2243 | if ( !quick ) { | ||
2244 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | ||
2245 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
2246 | mess, | ||
2247 | i18n("Sync"), i18n("Cancel"), 0, | ||
2248 | 0, 1 ); | ||
2249 | if ( result ) | ||
2250 | return false; | ||
2251 | } | ||
2252 | if ( KABPrefs::instance()->mAskForPreferences ) | ||
2253 | edit_sync_options(); | ||
2254 | if ( result == 0 ) { | ||
2255 | //qDebug("Now sycing ... "); | ||
2256 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) | ||
2257 | setCaption( i18n("Synchronization successful") ); | ||
2258 | else | ||
2259 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | ||
2260 | if ( ! quick ) | ||
2261 | KABPrefs::instance()->mLastSyncedLocalFile = fn; | ||
2262 | setModified(); | ||
2263 | } | ||
2264 | return ret; | ||
2265 | } | ||
2266 | void KABCore::quickSyncLocalFile() | ||
2267 | { | ||
2268 | |||
2269 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { | ||
2270 | qDebug("quick syncLocalFile() successful "); | ||
2271 | |||
2272 | } | ||
2273 | } | ||
2274 | void KABCore::multiSync( bool askforPrefs ) | ||
2275 | { | ||
2276 | if (mBlockSaveFlag) | ||
2277 | return; | ||
2278 | mBlockSaveFlag = true; | ||
2279 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | ||
2280 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
2281 | question, | ||
2282 | i18n("Yes"), i18n("No"), | ||
2283 | 0, 0 ) != 0 ) { | ||
2284 | mBlockSaveFlag = false; | ||
2285 | setCaption(i18n("Aborted! Nothing synced!")); | ||
2286 | return; | ||
2287 | } | ||
2288 | mCurrentSyncDevice = i18n("Multiple profiles") ; | ||
2289 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; | ||
2290 | if ( askforPrefs ) { | ||
2291 | edit_sync_options(); | ||
2292 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; | ||
2293 | } | ||
2294 | setCaption(i18n("Multiple sync started.") ); | ||
2295 | qApp->processEvents(); | ||
2296 | int num = ringSync() ; | ||
2297 | if ( num > 1 ) | ||
2298 | ringSync(); | ||
2299 | mBlockSaveFlag = false; | ||
2300 | if ( num ) | ||
2301 | save(); | ||
2302 | if ( num ) | ||
2303 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | ||
2304 | else | ||
2305 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | ||
2306 | return; | ||
2307 | } | ||
2308 | int KABCore::ringSync() | ||
2309 | { | ||
2310 | int syncedProfiles = 0; | ||
2311 | int i; | ||
2312 | QTime timer; | ||
2313 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
2314 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; | ||
2315 | KSyncProfile* temp = new KSyncProfile (); | ||
2316 | KABPrefs::instance()->mAskForPreferences = false; | ||
2317 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | ||
2318 | mCurrentSyncProfile = i; | ||
2319 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | ||
2320 | temp->readConfig(&config); | ||
2321 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { | ||
2322 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | ||
2323 | ++syncedProfiles; | ||
2324 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
2325 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
2326 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
2327 | KABPrefs::instance()->mWriteBackInFuture = 0; | ||
2328 | if ( temp->getWriteBackFuture() ) | ||
2329 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
2330 | KABPrefs::instance()->mShowSyncSummary = false; | ||
2331 | mCurrentSyncDevice = syncProfileNames[i] ; | ||
2332 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | ||
2333 | if ( i == 0 ) { | ||
2334 | syncSharp(); | ||
2335 | } else { | ||
2336 | if ( temp->getIsLocalFileSync() ) { | ||
2337 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) | ||
2338 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | ||
2339 | } else { | ||
2340 | if ( temp->getIsPhoneSync() ) { | ||
2341 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | ||
2342 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | ||
2343 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | ||
2344 | syncPhone(); | ||
2345 | } else | ||
2346 | syncRemote( temp, false ); | ||
2347 | |||
2348 | } | ||
2349 | } | ||
2350 | timer.start(); | ||
2351 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | ||
2352 | while ( timer.elapsed () < 2000 ) { | ||
2353 | qApp->processEvents(); | ||
2354 | #ifndef _WIN32_ | ||
2355 | sleep (1); | ||
2356 | #endif | ||
2357 | } | ||
2358 | |||
2359 | } | ||
2360 | |||
2361 | } | ||
2362 | delete temp; | ||
2363 | return syncedProfiles; | ||
2364 | } | ||
2365 | |||
2366 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | ||
2367 | { | ||
2368 | QString question; | ||
2369 | if ( ask ) { | ||
2370 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | ||
2371 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
2372 | question, | ||
2373 | i18n("Yes"), i18n("No"), | ||
2374 | 0, 0 ) != 0 ) | ||
2375 | return; | ||
2376 | } | ||
2377 | QString command = prof->getPreSyncCommandAB(); | ||
2378 | int fi; | ||
2379 | if ( (fi = command.find("$PWD$")) > 0 ) { | ||
2380 | QString pwd = getPassword(); | ||
2381 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | ||
2382 | |||
2383 | } | ||
2384 | int maxlen = 30; | ||
2385 | if ( QApplication::desktop()->width() > 320 ) | ||
2386 | maxlen += 25; | ||
2387 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | ||
2388 | int fileSize = 0; | ||
2389 | int result = system ( command ); | ||
2390 | // 0 : okay | ||
2391 | // 256: no such file or dir | ||
2392 | // | ||
2393 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | ||
2394 | if ( result != 0 ) { | ||
2395 | int len = maxlen; | ||
2396 | while ( len < command.length() ) { | ||
2397 | command.insert( len , "\n" ); | ||
2398 | len += maxlen +2; | ||
2399 | } | ||
2400 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | ||
2401 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | ||
2402 | question, | ||
2403 | i18n("Okay!")) ; | ||
2404 | setCaption ("KO/Pi"); | ||
2405 | return; | ||
2406 | } | ||
2407 | setCaption ( i18n( "Copying succeed." ) ); | ||
2408 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | ||
2409 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { | ||
2410 | // Event* e = mView->getLastSyncEvent(); | ||
2411 | // e->setReadOnly( false ); | ||
2412 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
2413 | // e->setReadOnly( true ); | ||
2414 | if ( KABPrefs::instance()->mWriteBackFile ) { | ||
2415 | command = prof->getPostSyncCommandAB(); | ||
2416 | int fi; | ||
2417 | if ( (fi = command.find("$PWD$")) > 0 ) { | ||
2418 | QString pwd = getPassword(); | ||
2419 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | ||
2420 | |||
2421 | } | ||
2422 | setCaption ( i18n( "Writing back file ..." ) ); | ||
2423 | result = system ( command ); | ||
2424 | qDebug("KO: Writing back file result: %d ", result); | ||
2425 | if ( result != 0 ) { | ||
2426 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | ||
2427 | return; | ||
2428 | } else { | ||
2429 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | ||
2430 | } | ||
2431 | } | ||
2432 | } | ||
2433 | return; | ||
2434 | } | ||
2435 | #include <qpushbutton.h> | ||
2436 | #include <qradiobutton.h> | ||
2437 | #include <qbuttongroup.h> | ||
2438 | void KABCore::edit_sync_options() | ||
2439 | { | ||
2440 | //mDialogManager->showSyncOptions(); | ||
2441 | //KABPrefs::instance()->mSyncAlgoPrefs | ||
2442 | QDialog dia( this, "dia", true ); | ||
2443 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | ||
2444 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | ||
2445 | QVBoxLayout lay ( &dia ); | ||
2446 | lay.setSpacing( 2 ); | ||
2447 | lay.setMargin( 3 ); | ||
2448 | lay.addWidget(&gr); | ||
2449 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | ||
2450 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | ||
2451 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | ||
2452 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | ||
2453 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | ||
2454 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | ||
2455 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | ||
2456 | QPushButton pb ( "OK", &dia); | ||
2457 | lay.addWidget( &pb ); | ||
2458 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2459 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | ||
2460 | case 0: | ||
2461 | loc.setChecked( true); | ||
2462 | break; | ||
2463 | case 1: | ||
2464 | rem.setChecked( true ); | ||
2465 | break; | ||
2466 | case 2: | ||
2467 | newest.setChecked( true); | ||
2468 | break; | ||
2469 | case 3: | ||
2470 | ask.setChecked( true); | ||
2471 | break; | ||
2472 | case 4: | ||
2473 | f_loc.setChecked( true); | ||
2474 | break; | ||
2475 | case 5: | ||
2476 | f_rem.setChecked( true); | ||
2477 | break; | ||
2478 | case 6: | ||
2479 | // both.setChecked( true); | ||
2480 | break; | ||
2481 | default: | ||
2482 | break; | ||
2483 | } | ||
2484 | if ( dia.exec() ) { | ||
2485 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | ||
2486 | } | ||
2487 | |||
2488 | |||
2489 | } | ||
2490 | QString KABCore::getPassword( ) | ||
2491 | { | ||
2492 | QString retfile = ""; | ||
2493 | QDialog dia ( this, "input-dialog", true ); | ||
2494 | QLineEdit lab ( &dia ); | ||
2495 | lab.setEchoMode( QLineEdit::Password ); | ||
2496 | QVBoxLayout lay( &dia ); | ||
2497 | lay.setMargin(7); | ||
2498 | lay.setSpacing(7); | ||
2499 | lay.addWidget( &lab); | ||
2500 | dia.setFixedSize( 230,50 ); | ||
2501 | dia.setCaption( i18n("Enter password") ); | ||
2502 | QPushButton pb ( "OK", &dia); | ||
2503 | lay.addWidget( &pb ); | ||
2504 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2505 | dia.show(); | ||
2506 | int res = dia.exec(); | ||
2507 | if ( res ) | ||
2508 | retfile = lab.text(); | ||
2509 | dia.hide(); | ||
2510 | qApp->processEvents(); | ||
2511 | return retfile; | ||
2512 | |||
2513 | } | ||
2514 | #include <libkcal/syncdefines.h> | 2109 | #include <libkcal/syncdefines.h> |
2515 | 2110 | ||
2516 | KABC::Addressee KABCore::getLastSyncAddressee() | 2111 | KABC::Addressee KABCore::getLastSyncAddressee() |
2517 | { | 2112 | { |
2518 | Addressee lse; | 2113 | Addressee lse; |
2114 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | ||
2115 | |||
2519 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2116 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2520 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2117 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2521 | if (lse.isEmpty()) { | 2118 | if (lse.isEmpty()) { |
2522 | qDebug("Creating new last-syncAddressee "); | 2119 | qDebug("Creating new last-syncAddressee "); |
2523 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2120 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2524 | QString sum = ""; | 2121 | QString sum = ""; |
2525 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2122 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2526 | sum = "E: "; | 2123 | sum = "E: "; |
2527 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2124 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2528 | lse.setRevision( mLastAddressbookSync ); | 2125 | lse.setRevision( mLastAddressbookSync ); |
2529 | lse.setCategories( i18n("SyncEvent") ); | 2126 | lse.setCategories( i18n("SyncEvent") ); |
2530 | mAddressBook->insertAddressee( lse ); | 2127 | mAddressBook->insertAddressee( lse ); |
2531 | } | 2128 | } |
2532 | return lse; | 2129 | return lse; |
2533 | } | 2130 | } |
2534 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2131 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2535 | { | 2132 | { |
2536 | 2133 | ||
2537 | //void setZaurusId(int id); | 2134 | //void setZaurusId(int id); |
2538 | // int zaurusId() const; | 2135 | // int zaurusId() const; |
2539 | // void setZaurusUid(int id); | 2136 | // void setZaurusUid(int id); |
2540 | // int zaurusUid() const; | 2137 | // int zaurusUid() const; |
2541 | // void setZaurusStat(int id); | 2138 | // void setZaurusStat(int id); |
2542 | // int zaurusStat() const; | 2139 | // int zaurusStat() const; |
2543 | // 0 equal | 2140 | // 0 equal |
2544 | // 1 take local | 2141 | // 1 take local |
2545 | // 2 take remote | 2142 | // 2 take remote |
2546 | // 3 cancel | 2143 | // 3 cancel |
2547 | QDateTime lastSync = mLastAddressbookSync; | 2144 | QDateTime lastSync = mLastAddressbookSync; |
2548 | QDateTime localMod = local->revision(); | 2145 | QDateTime localMod = local->revision(); |
2549 | QDateTime remoteMod = remote->revision(); | 2146 | QDateTime remoteMod = remote->revision(); |
2147 | |||
2148 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | ||
2149 | |||
2550 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2150 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2551 | bool remCh, locCh; | 2151 | bool remCh, locCh; |
2552 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2152 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2553 | 2153 | ||
2554 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2154 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2555 | locCh = ( localMod > mLastAddressbookSync ); | 2155 | locCh = ( localMod > mLastAddressbookSync ); |
2556 | if ( !remCh && ! locCh ) { | 2156 | if ( !remCh && ! locCh ) { |
2557 | //qDebug("both not changed "); | 2157 | //qDebug("both not changed "); |
2558 | lastSync = localMod.addDays(1); | 2158 | lastSync = localMod.addDays(1); |
2559 | if ( mode <= SYNC_PREF_ASK ) | 2159 | if ( mode <= SYNC_PREF_ASK ) |
2560 | return 0; | 2160 | return 0; |
2561 | } else { | 2161 | } else { |
2562 | if ( locCh ) { | 2162 | if ( locCh ) { |
2563 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2163 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2564 | lastSync = localMod.addDays( -1 ); | 2164 | lastSync = localMod.addDays( -1 ); |
2565 | if ( !remCh ) | 2165 | if ( !remCh ) |
2566 | remoteMod =( lastSync.addDays( -1 ) ); | 2166 | remoteMod =( lastSync.addDays( -1 ) ); |
2567 | } else { | 2167 | } else { |
2568 | //qDebug(" not loc changed "); | 2168 | //qDebug(" not loc changed "); |
2569 | lastSync = localMod.addDays( 1 ); | 2169 | lastSync = localMod.addDays( 1 ); |
2570 | if ( remCh ) | 2170 | if ( remCh ) |
2571 | remoteMod =( lastSync.addDays( 1 ) ); | 2171 | remoteMod =( lastSync.addDays( 1 ) ); |
2572 | 2172 | ||
2573 | } | 2173 | } |
2574 | } | 2174 | } |
2575 | full = true; | 2175 | full = true; |
2576 | if ( mode < SYNC_PREF_ASK ) | 2176 | if ( mode < SYNC_PREF_ASK ) |
2577 | mode = SYNC_PREF_ASK; | 2177 | mode = SYNC_PREF_ASK; |
2578 | } else { | 2178 | } else { |
2579 | if ( localMod == remoteMod ) | 2179 | if ( localMod == remoteMod ) |
2580 | return 0; | 2180 | return 0; |
2581 | 2181 | ||
@@ -2624,73 +2224,79 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i | |||
2624 | if ( localMod > remoteMod ) | 2224 | if ( localMod > remoteMod ) |
2625 | return 1; | 2225 | return 1; |
2626 | else | 2226 | else |
2627 | return 2; | 2227 | return 2; |
2628 | break; | 2228 | break; |
2629 | case SYNC_PREF_ASK: | 2229 | case SYNC_PREF_ASK: |
2630 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2230 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2631 | if ( lastSync > remoteMod ) | 2231 | if ( lastSync > remoteMod ) |
2632 | return 1; | 2232 | return 1; |
2633 | if ( lastSync > localMod ) | 2233 | if ( lastSync > localMod ) |
2634 | return 2; | 2234 | return 2; |
2635 | localIsNew = localMod >= remoteMod; | 2235 | localIsNew = localMod >= remoteMod; |
2636 | //qDebug("conflict! ************************************** "); | 2236 | //qDebug("conflict! ************************************** "); |
2637 | { | 2237 | { |
2638 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2238 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2639 | result = acd.executeD(localIsNew); | 2239 | result = acd.executeD(localIsNew); |
2640 | return result; | 2240 | return result; |
2641 | } | 2241 | } |
2642 | break; | 2242 | break; |
2643 | case SYNC_PREF_FORCE_LOCAL: | 2243 | case SYNC_PREF_FORCE_LOCAL: |
2644 | return 1; | 2244 | return 1; |
2645 | break; | 2245 | break; |
2646 | case SYNC_PREF_FORCE_REMOTE: | 2246 | case SYNC_PREF_FORCE_REMOTE: |
2647 | return 2; | 2247 | return 2; |
2648 | break; | 2248 | break; |
2649 | 2249 | ||
2650 | default: | 2250 | default: |
2651 | // SYNC_PREF_TAKE_BOTH not implemented | 2251 | // SYNC_PREF_TAKE_BOTH not implemented |
2652 | break; | 2252 | break; |
2653 | } | 2253 | } |
2654 | return 0; | 2254 | return 0; |
2655 | } | 2255 | } |
2256 | |||
2257 | |||
2656 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2258 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2657 | { | 2259 | { |
2658 | bool syncOK = true; | 2260 | bool syncOK = true; |
2659 | int addedAddressee = 0; | 2261 | int addedAddressee = 0; |
2660 | int addedAddresseeR = 0; | 2262 | int addedAddresseeR = 0; |
2661 | int deletedAddresseeR = 0; | 2263 | int deletedAddresseeR = 0; |
2662 | int deletedAddresseeL = 0; | 2264 | int deletedAddresseeL = 0; |
2663 | int changedLocal = 0; | 2265 | int changedLocal = 0; |
2664 | int changedRemote = 0; | 2266 | int changedRemote = 0; |
2267 | |||
2268 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | ||
2269 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | ||
2270 | |||
2665 | //QPtrList<Addressee> el = local->rawAddressees(); | 2271 | //QPtrList<Addressee> el = local->rawAddressees(); |
2666 | Addressee addresseeR; | 2272 | Addressee addresseeR; |
2667 | QString uid; | 2273 | QString uid; |
2668 | int take; | 2274 | int take; |
2669 | Addressee addresseeL; | 2275 | Addressee addresseeL; |
2670 | Addressee addresseeRSync; | 2276 | Addressee addresseeRSync; |
2671 | Addressee addresseeLSync; | 2277 | Addressee addresseeLSync; |
2672 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2278 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2673 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2279 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2674 | bool fullDateRange = false; | 2280 | bool fullDateRange = false; |
2675 | local->resetTempSyncStat(); | 2281 | local->resetTempSyncStat(); |
2676 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2282 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2677 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2283 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2678 | addresseeLSync = getLastSyncAddressee(); | 2284 | addresseeLSync = getLastSyncAddressee(); |
2679 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2285 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2680 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2286 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2681 | if ( !addresseeR.isEmpty() ) { | 2287 | if ( !addresseeR.isEmpty() ) { |
2682 | addresseeRSync = addresseeR; | 2288 | addresseeRSync = addresseeR; |
2683 | remote->removeAddressee(addresseeR ); | 2289 | remote->removeAddressee(addresseeR ); |
2684 | 2290 | ||
2685 | } else { | 2291 | } else { |
2686 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2292 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2687 | addresseeRSync = addresseeLSync ; | 2293 | addresseeRSync = addresseeLSync ; |
2688 | } else { | 2294 | } else { |
2689 | qDebug("FULLDATE 1"); | 2295 | qDebug("FULLDATE 1"); |
2690 | fullDateRange = true; | 2296 | fullDateRange = true; |
2691 | Addressee newAdd; | 2297 | Addressee newAdd; |
2692 | addresseeRSync = newAdd; | 2298 | addresseeRSync = newAdd; |
2693 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2299 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2694 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2300 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2695 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2301 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2696 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2302 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
@@ -2892,70 +2498,74 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2892 | } | 2498 | } |
2893 | ++incCounter; | 2499 | ++incCounter; |
2894 | } | 2500 | } |
2895 | el.clear(); | 2501 | el.clear(); |
2896 | bar.hide(); | 2502 | bar.hide(); |
2897 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2503 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2898 | // get rid of micro seconds | 2504 | // get rid of micro seconds |
2899 | QTime t = mLastAddressbookSync.time(); | 2505 | QTime t = mLastAddressbookSync.time(); |
2900 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2506 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2901 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2507 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2902 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2508 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2903 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2509 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2904 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2510 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2905 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2511 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2906 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2512 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2907 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2513 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2908 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2514 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2909 | addresseeRSync.setNote( "" ) ; | 2515 | addresseeRSync.setNote( "" ) ; |
2910 | addresseeLSync.setNote( "" ); | 2516 | addresseeLSync.setNote( "" ); |
2911 | 2517 | ||
2912 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2518 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2913 | remote->insertAddressee( addresseeRSync, false ); | 2519 | remote->insertAddressee( addresseeRSync, false ); |
2914 | local->insertAddressee( addresseeLSync, false ); | 2520 | local->insertAddressee( addresseeLSync, false ); |
2915 | QString mes; | 2521 | QString mes; |
2916 | 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 ); | 2522 | 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 ); |
2917 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2523 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2918 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2524 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2919 | } | 2525 | } |
2920 | qDebug( mes ); | 2526 | qDebug( mes ); |
2921 | return syncOK; | 2527 | return syncOK; |
2922 | } | 2528 | } |
2923 | 2529 | ||
2924 | bool KABCore::syncAB(QString filename, int mode) | 2530 | |
2531 | //this is a overwritten callbackmethods from the syncinterface | ||
2532 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | ||
2925 | { | 2533 | { |
2926 | 2534 | ||
2927 | //pending prepare addresseeview for output | 2535 | //pending prepare addresseeview for output |
2928 | //pending detect, if remote file has REV field. if not switch to external sync | 2536 | //pending detect, if remote file has REV field. if not switch to external sync |
2929 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2537 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2538 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | ||
2539 | |||
2930 | AddressBook abLocal(filename,"syncContact"); | 2540 | AddressBook abLocal(filename,"syncContact"); |
2931 | bool syncOK = false; | 2541 | bool syncOK = false; |
2932 | if ( abLocal.load() ) { | 2542 | if ( abLocal.load() ) { |
2933 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2543 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2934 | bool external = false; | 2544 | bool external = false; |
2935 | bool isXML = false; | 2545 | bool isXML = false; |
2936 | if ( filename.right(4) == ".xml") { | 2546 | if ( filename.right(4) == ".xml") { |
2937 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2547 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2938 | isXML = true; | 2548 | isXML = true; |
2939 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2549 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2940 | } else { | 2550 | } else { |
2941 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2551 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2942 | if ( ! lse.isEmpty() ) { | 2552 | if ( ! lse.isEmpty() ) { |
2943 | if ( lse.familyName().left(4) == "!E: " ) | 2553 | if ( lse.familyName().left(4) == "!E: " ) |
2944 | external = true; | 2554 | external = true; |
2945 | } else { | 2555 | } else { |
2946 | bool found = false; | 2556 | bool found = false; |
2947 | AddressBook::Iterator it; | 2557 | AddressBook::Iterator it; |
2948 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2558 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2949 | if ( (*it).revision().date().year() > 2003 ) { | 2559 | if ( (*it).revision().date().year() > 2003 ) { |
2950 | found = true; | 2560 | found = true; |
2951 | break; | 2561 | break; |
2952 | } | 2562 | } |
2953 | } | 2563 | } |
2954 | external = ! found; | 2564 | external = ! found; |
2955 | } | 2565 | } |
2956 | 2566 | ||
2957 | if ( external ) { | 2567 | if ( external ) { |
2958 | qDebug("Setting vcf mode to external "); | 2568 | qDebug("Setting vcf mode to external "); |
2959 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2569 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2960 | AddressBook::Iterator it; | 2570 | AddressBook::Iterator it; |
2961 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2571 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
@@ -2979,90 +2589,81 @@ bool KABCore::syncAB(QString filename, int mode) | |||
2979 | abLocal.saveAB(); | 2589 | abLocal.saveAB(); |
2980 | if ( isXML ) { | 2590 | if ( isXML ) { |
2981 | // afterwrite processing | 2591 | // afterwrite processing |
2982 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2592 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2983 | } | 2593 | } |
2984 | } | 2594 | } |
2985 | } | 2595 | } |
2986 | setModified(); | 2596 | setModified(); |
2987 | 2597 | ||
2988 | } | 2598 | } |
2989 | if ( syncOK ) | 2599 | if ( syncOK ) |
2990 | mViewManager->refreshView(); | 2600 | mViewManager->refreshView(); |
2991 | return syncOK; | 2601 | return syncOK; |
2992 | #if 0 | 2602 | #if 0 |
2993 | 2603 | ||
2994 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2604 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2995 | getEventViewerDialog()->setSyncMode( true ); | 2605 | getEventViewerDialog()->setSyncMode( true ); |
2996 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2606 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2997 | getEventViewerDialog()->setSyncMode( false ); | 2607 | getEventViewerDialog()->setSyncMode( false ); |
2998 | if ( syncOK ) { | 2608 | if ( syncOK ) { |
2999 | if ( KOPrefs::instance()->mWriteBackFile ) | 2609 | if ( KOPrefs::instance()->mWriteBackFile ) |
3000 | { | 2610 | { |
3001 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2611 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
3002 | storage->save(); | 2612 | storage->save(); |
3003 | } | 2613 | } |
3004 | } | 2614 | } |
3005 | setModified(); | 2615 | setModified(); |
3006 | } | 2616 | } |
3007 | 2617 | ||
3008 | #endif | 2618 | #endif |
3009 | } | 2619 | } |
3010 | 2620 | ||
3011 | void KABCore::confSync() | 2621 | |
3012 | { | 2622 | //this is a overwritten callbackmethods from the syncinterface |
3013 | static KSyncPrefsDialog* sp = 0; | 2623 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3014 | if ( ! sp ) { | ||
3015 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | ||
3016 | } | ||
3017 | sp->usrReadConfig(); | ||
3018 | #ifndef DESKTOP_VERSION | ||
3019 | sp->showMaximized(); | ||
3020 | #else | ||
3021 | sp->show(); | ||
3022 | #endif | ||
3023 | sp->exec(); | ||
3024 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | ||
3025 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | ||
3026 | fillSyncMenu(); | ||
3027 | } | ||
3028 | void KABCore::syncSharp() | ||
3029 | { | ||
3030 | if ( ! syncExternal("sharp") ) | ||
3031 | qDebug("ERROR sync sharp ");; | ||
3032 | } | ||
3033 | bool KABCore::syncExternal(QString resource) | ||
3034 | { | 2624 | { |
3035 | if ( mModified ) | 2625 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3036 | save(); | 2626 | |
3037 | if ( KABPrefs::instance()->mAskForPreferences ) | ||
3038 | edit_sync_options(); | ||
3039 | qDebug("syncSharp() "); | ||
3040 | AddressBook abLocal( resource,"syncContact"); | 2627 | AddressBook abLocal( resource,"syncContact"); |
3041 | bool syncOK = false; | 2628 | bool syncOK = false; |
3042 | if ( abLocal.load() ) { | 2629 | if ( abLocal.load() ) { |
3043 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2630 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3044 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2631 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3045 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2632 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2633 | qDebug("KABCore::syncExternal: why do we acces here KABPrefs and not somehow KSyncProfile? "); | ||
3046 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); | 2634 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); |
3047 | if ( syncOK ) { | 2635 | if ( syncOK ) { |
3048 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2636 | if ( KABPrefs::instance()->mWriteBackFile ) { |
3049 | abLocal.saveAB(); | 2637 | abLocal.saveAB(); |
3050 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2638 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
3051 | } | 2639 | } |
3052 | } | 2640 | } |
3053 | setModified(); | 2641 | setModified(); |
3054 | } | 2642 | } |
3055 | if ( syncOK ) | 2643 | if ( syncOK ) |
3056 | mViewManager->refreshView(); | 2644 | mViewManager->refreshView(); |
3057 | return syncOK; | 2645 | return syncOK; |
3058 | 2646 | ||
3059 | } | 2647 | } |
3060 | void KABCore::syncPhone() | 2648 | |
2649 | //called by the syncmanager to indicate that the work has to marked as dirty. | ||
2650 | void KABCore::sync_setModified() | ||
3061 | { | 2651 | { |
3062 | if ( mModified ) | 2652 | setModified(); |
3063 | save(); | 2653 | } |
3064 | qDebug("pending syncPhone(); "); | ||
3065 | //mView->syncPhone(); | ||
3066 | setModified(); | ||
3067 | 2654 | ||
2655 | //called by the syncmanager to ask if the dirty flag is set. | ||
2656 | bool KABCore::sync_isModified() | ||
2657 | { | ||
2658 | return mModified; | ||
3068 | } | 2659 | } |
2660 | |||
2661 | |||
2662 | //called by the syncmanager to indicate that the work has to be saved. | ||
2663 | void KABCore::sync_save() | ||
2664 | { | ||
2665 | save(); | ||
2666 | } | ||
2667 | |||
2668 | |||
2669 | |||
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index e89bf41..ef61d6d 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -3,100 +3,101 @@ | |||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <ksyncmanager.h> | ||
35 | 36 | ||
36 | namespace KABC { | 37 | namespace KABC { |
37 | class AddressBook; | 38 | class AddressBook; |
38 | } | 39 | } |
39 | 40 | ||
40 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
41 | class KAboutData; | 42 | class KAboutData; |
42 | class KConfig; | 43 | class KConfig; |
43 | 44 | ||
44 | class KAddressBookService; | 45 | class KAddressBookService; |
45 | class LDAPSearchDialog; | 46 | class LDAPSearchDialog; |
46 | #else //KAB_EMBEDDED | 47 | #else //KAB_EMBEDDED |
47 | class KAddressBookMain; | 48 | class KAddressBookMain; |
48 | //US class QAction; | 49 | //US class QAction; |
49 | #endif //KAB_EMBEDDED | 50 | #endif //KAB_EMBEDDED |
50 | class KCMultiDialog; | 51 | class KCMultiDialog; |
51 | class KXMLGUIClient; | 52 | class KXMLGUIClient; |
52 | class ExtensionManager; | 53 | class ExtensionManager; |
53 | class XXPortManager; | 54 | class XXPortManager; |
54 | class JumpButtonBar; | 55 | class JumpButtonBar; |
55 | class IncSearchWidget; | 56 | class IncSearchWidget; |
56 | class KDGanttMinimizeSplitter; | 57 | class KDGanttMinimizeSplitter; |
57 | class KAction; | 58 | class KAction; |
58 | class KActionCollection; | 59 | class KActionCollection; |
59 | class KToggleAction; | 60 | class KToggleAction; |
60 | class KSyncProfile; | 61 | class KSyncProfile; |
61 | 62 | ||
62 | class QAction; | 63 | class QAction; |
63 | class QMenuBar; | 64 | class QMenuBar; |
64 | class QSplitter; | 65 | class QSplitter; |
65 | class ViewContainer; | 66 | class ViewContainer; |
66 | class ViewManager; | 67 | class ViewManager; |
67 | class AddresseeEditorDialog; | 68 | class AddresseeEditorDialog; |
68 | class Ir; | 69 | class Ir; |
69 | 70 | ||
70 | class KABCore : public QWidget | 71 | class KABCore : public QWidget, public KSyncInterface |
71 | { | 72 | { |
72 | Q_OBJECT | 73 | Q_OBJECT |
73 | 74 | ||
74 | public: | 75 | public: |
75 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 76 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
76 | 77 | ||
77 | 78 | ||
78 | ~KABCore(); | 79 | ~KABCore(); |
79 | 80 | ||
80 | 81 | ||
81 | #ifdef KAB_EMBEDDED | 82 | #ifdef KAB_EMBEDDED |
82 | //US added functionality | 83 | //US added functionality |
83 | QPopupMenu* getViewMenu() {return viewMenu;} | 84 | QPopupMenu* getViewMenu() {return viewMenu;} |
84 | QPopupMenu* getFilterMenu() {return filterMenu;} | 85 | QPopupMenu* getFilterMenu() {return filterMenu;} |
85 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 86 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
86 | void addActionsManually(); | 87 | void addActionsManually(); |
87 | #endif //KAB_EMBEDDED | 88 | #endif //KAB_EMBEDDED |
88 | /** | 89 | /** |
89 | Restores the global settings. | 90 | Restores the global settings. |
90 | */ | 91 | */ |
91 | void restoreSettings(); | 92 | void restoreSettings(); |
92 | 93 | ||
93 | /** | 94 | /** |
94 | Saves the global settings. | 95 | Saves the global settings. |
95 | */ | 96 | */ |
96 | void saveSettings(); | 97 | void saveSettings(); |
97 | 98 | ||
98 | /** | 99 | /** |
99 | Returns a pointer to the StdAddressBook of the application. | 100 | Returns a pointer to the StdAddressBook of the application. |
100 | */ | 101 | */ |
101 | KABC::AddressBook *addressBook() const; | 102 | KABC::AddressBook *addressBook() const; |
102 | 103 | ||
@@ -312,65 +313,65 @@ class KABCore : public QWidget | |||
312 | 313 | ||
313 | /** | 314 | /** |
314 | Launches the configuration dialog. | 315 | Launches the configuration dialog. |
315 | */ | 316 | */ |
316 | void openConfigDialog(); | 317 | void openConfigDialog(); |
317 | 318 | ||
318 | /** | 319 | /** |
319 | Launches the ldap search dialog. | 320 | Launches the ldap search dialog. |
320 | */ | 321 | */ |
321 | void openLDAPDialog(); | 322 | void openLDAPDialog(); |
322 | 323 | ||
323 | /** | 324 | /** |
324 | Creates a KAddressBookPrinter, which will display the print | 325 | Creates a KAddressBookPrinter, which will display the print |
325 | dialog and do the printing. | 326 | dialog and do the printing. |
326 | */ | 327 | */ |
327 | void print(); | 328 | void print(); |
328 | 329 | ||
329 | /** | 330 | /** |
330 | Registers a new GUI client, so plugins can register its actions. | 331 | Registers a new GUI client, so plugins can register its actions. |
331 | */ | 332 | */ |
332 | void addGUIClient( KXMLGUIClient *client ); | 333 | void addGUIClient( KXMLGUIClient *client ); |
333 | 334 | ||
334 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 335 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
335 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 336 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
336 | 337 | ||
337 | 338 | ||
338 | signals: | 339 | signals: |
339 | void contactSelected( const QString &name ); | 340 | void contactSelected( const QString &name ); |
340 | void contactSelected( const QPixmap &pixmap ); | 341 | void contactSelected( const QPixmap &pixmap ); |
341 | public slots: | 342 | public slots: |
342 | void setDetailsVisible( bool visible ); | 343 | void setDetailsVisible( bool visible ); |
343 | void setDetailsToState(); | 344 | void setDetailsToState(); |
344 | void slotSyncMenu( int ); | 345 | // void slotSyncMenu( int ); |
345 | private slots: | 346 | private slots: |
346 | void setJumpButtonBarVisible( bool visible ); | 347 | void setJumpButtonBarVisible( bool visible ); |
347 | void importFromOL(); | 348 | void importFromOL(); |
348 | void extensionModified( const KABC::Addressee::List &list ); | 349 | void extensionModified( const KABC::Addressee::List &list ); |
349 | void extensionChanged( int id ); | 350 | void extensionChanged( int id ); |
350 | void clipboardDataChanged(); | 351 | void clipboardDataChanged(); |
351 | void updateActionMenu(); | 352 | void updateActionMenu(); |
352 | void configureKeyBindings(); | 353 | void configureKeyBindings(); |
353 | void removeVoice(); | 354 | void removeVoice(); |
354 | #ifdef KAB_EMBEDDED | 355 | #ifdef KAB_EMBEDDED |
355 | void configureResources(); | 356 | void configureResources(); |
356 | #endif //KAB_EMBEDDED | 357 | #endif //KAB_EMBEDDED |
357 | 358 | ||
358 | void slotEditorDestroyed( const QString &uid ); | 359 | void slotEditorDestroyed( const QString &uid ); |
359 | void configurationChanged(); | 360 | void configurationChanged(); |
360 | void addressBookChanged(); | 361 | void addressBookChanged(); |
361 | 362 | ||
362 | private: | 363 | private: |
363 | void initGUI(); | 364 | void initGUI(); |
364 | void initActions(); | 365 | void initActions(); |
365 | 366 | ||
366 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 367 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
367 | const char *name = 0 ); | 368 | const char *name = 0 ); |
368 | 369 | ||
369 | KXMLGUIClient *mGUIClient; | 370 | KXMLGUIClient *mGUIClient; |
370 | 371 | ||
371 | KABC::AddressBook *mAddressBook; | 372 | KABC::AddressBook *mAddressBook; |
372 | 373 | ||
373 | ViewManager *mViewManager; | 374 | ViewManager *mViewManager; |
374 | // QSplitter *mDetailsSplitter; | 375 | // QSplitter *mDetailsSplitter; |
375 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 376 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
376 | ViewContainer *mDetails; | 377 | ViewContainer *mDetails; |
@@ -418,68 +419,63 @@ class KABCore : public QWidget | |||
418 | KAction *mActionConfigResources; | 419 | KAction *mActionConfigResources; |
419 | KAction *mActionConfigKAddressbook; | 420 | KAction *mActionConfigKAddressbook; |
420 | KAction *mActionConfigShortcuts; | 421 | KAction *mActionConfigShortcuts; |
421 | KAction *mActionConfigureToolbars; | 422 | KAction *mActionConfigureToolbars; |
422 | KAction *mActionKeyBindings; | 423 | KAction *mActionKeyBindings; |
423 | KToggleAction *mActionJumpBar; | 424 | KToggleAction *mActionJumpBar; |
424 | KToggleAction *mActionDetails; | 425 | KToggleAction *mActionDetails; |
425 | KAction *mActionWhoAmI; | 426 | KAction *mActionWhoAmI; |
426 | KAction *mActionCategories; | 427 | KAction *mActionCategories; |
427 | KAction *mActionAboutKAddressbook; | 428 | KAction *mActionAboutKAddressbook; |
428 | KAction *mActionLicence; | 429 | KAction *mActionLicence; |
429 | KAction *mActionFaq; | 430 | KAction *mActionFaq; |
430 | 431 | ||
431 | KAction *mActionDeleteView; | 432 | KAction *mActionDeleteView; |
432 | 433 | ||
433 | QPopupMenu *viewMenu; | 434 | QPopupMenu *viewMenu; |
434 | QPopupMenu *filterMenu; | 435 | QPopupMenu *filterMenu; |
435 | QPopupMenu *settingsMenu; | 436 | QPopupMenu *settingsMenu; |
436 | QPopupMenu *changeMenu; | 437 | QPopupMenu *changeMenu; |
437 | //US QAction *mActionSave; | 438 | //US QAction *mActionSave; |
438 | QPopupMenu *ImportMenu; | 439 | QPopupMenu *ImportMenu; |
439 | QPopupMenu *ExportMenu; | 440 | QPopupMenu *ExportMenu; |
440 | //LR additional methods | 441 | //LR additional methods |
441 | KAction *mActionRemoveVoice; | 442 | KAction *mActionRemoveVoice; |
442 | KAction * mActionImportOL; | 443 | KAction * mActionImportOL; |
443 | 444 | ||
444 | #ifndef KAB_EMBEDDED | 445 | #ifndef KAB_EMBEDDED |
445 | KAddressBookService *mAddressBookService; | 446 | KAddressBookService *mAddressBookService; |
446 | #endif //KAB_EMBEDDED | 447 | #endif //KAB_EMBEDDED |
447 | 448 | ||
448 | class KABCorePrivate; | 449 | class KABCorePrivate; |
449 | KABCorePrivate *d; | 450 | KABCorePrivate *d; |
450 | bool mBlockSaveFlag; | 451 | //US bool mBlockSaveFlag; |
451 | 452 | ||
452 | #ifdef KAB_EMBEDDED | 453 | #ifdef KAB_EMBEDDED |
453 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 454 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
454 | #endif //KAB_EMBEDDED | 455 | #endif //KAB_EMBEDDED |
456 | |||
457 | //this are the overwritten callbackmethods from the syncinterface | ||
458 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | ||
459 | virtual bool syncExternal(KSyncManager* manager, QString resource); | ||
460 | |||
461 | //called by the syncmanager to indicate that the work has to marked as dirty. | ||
462 | virtual void sync_setModified(); | ||
463 | //called by the syncmanager to ask if the dirty flag is set. | ||
464 | virtual bool KABCore::sync_isModified(); | ||
465 | //called by the syncmanager to indicate that the work has to be saved. | ||
466 | virtual void sync_save(); | ||
467 | |||
455 | // LR ******************************* | 468 | // LR ******************************* |
456 | // sync stuff! | 469 | // sync stuff! |
457 | QPopupMenu *syncMenu; | 470 | QPopupMenu *syncMenu; |
458 | void fillSyncMenu(); | 471 | KSyncManager* syncManager; |
459 | QString mCurrentSyncDevice; | ||
460 | QString mCurrentSyncName; | ||
461 | void quickSyncLocalFile(); | ||
462 | bool syncWithFile( QString fn , bool quick ); | ||
463 | void syncLocalFile(); | ||
464 | void syncPhone(); | ||
465 | void syncSharp(); | ||
466 | bool syncExternal(QString); | ||
467 | void multiSync( bool askforPrefs ); | ||
468 | int mCurrentSyncProfile ; | ||
469 | void syncRemote( KSyncProfile* prof, bool ask = true); | ||
470 | void edit_sync_options(); | ||
471 | bool syncAB(QString filename, int mode); | ||
472 | int ringSync(); | ||
473 | QString getPassword( ); | ||
474 | int mGlobalSyncMode; | 472 | int mGlobalSyncMode; |
475 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 473 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
476 | KABC::Addressee getLastSyncAddressee(); | 474 | KABC::Addressee getLastSyncAddressee(); |
477 | QDateTime mLastAddressbookSync; | 475 | QDateTime mLastAddressbookSync; |
478 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 476 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
479 | public slots: | ||
480 | void confSync(); | ||
481 | // ********************* | 477 | // ********************* |
482 | 478 | ||
483 | }; | 479 | }; |
484 | 480 | ||
485 | #endif | 481 | #endif |
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h index 9926aa0..e4f359c 100644 --- a/kaddressbook/kabprefs.h +++ b/kaddressbook/kabprefs.h | |||
@@ -53,56 +53,40 @@ class KABPrefs : public KPimPrefs | |||
53 | 53 | ||
54 | /** Set preferences to default values */ | 54 | /** Set preferences to default values */ |
55 | // void usrSetDefaults(); | 55 | // void usrSetDefaults(); |
56 | 56 | ||
57 | /** Read preferences from config file */ | 57 | /** Read preferences from config file */ |
58 | // void usrReadConfig(); | 58 | // void usrReadConfig(); |
59 | 59 | ||
60 | /** Write preferences to config file */ | 60 | /** Write preferences to config file */ |
61 | // void usrWriteConfig(); | 61 | // void usrWriteConfig(); |
62 | #endif //KAB_EMBEDDED | 62 | #endif //KAB_EMBEDDED |
63 | 63 | ||
64 | 64 | ||
65 | // GUI | 65 | // GUI |
66 | bool mJumpButtonBarVisible; | 66 | bool mJumpButtonBarVisible; |
67 | bool mDetailsPageVisible; | 67 | bool mDetailsPageVisible; |
68 | bool mMultipleViewsAtOnce; | 68 | bool mMultipleViewsAtOnce; |
69 | bool mSearchWithReturn; | 69 | bool mSearchWithReturn; |
70 | QValueList<int> mExtensionsSplitter; | 70 | QValueList<int> mExtensionsSplitter; |
71 | QValueList<int> mDetailsSplitter; | 71 | QValueList<int> mDetailsSplitter; |
72 | 72 | ||
73 | // Extensions stuff | 73 | // Extensions stuff |
74 | int mCurrentExtension; | 74 | int mCurrentExtension; |
75 | QStringList mActiveExtensions; | 75 | QStringList mActiveExtensions; |
76 | 76 | ||
77 | // Views stuff | 77 | // Views stuff |
78 | QString mCurrentView; | 78 | QString mCurrentView; |
79 | QStringList mViewNames; | 79 | QStringList mViewNames; |
80 | 80 | ||
81 | // Filter | 81 | // Filter |
82 | int mCurrentFilter; | 82 | int mCurrentFilter; |
83 | 83 | ||
84 | void setCategoryDefaults(); | 84 | void setCategoryDefaults(); |
85 | // sync stuff | 85 | |
86 | QString mLocalMachineName; | ||
87 | QStringList mExternSyncProfiles; | ||
88 | QStringList mSyncProfileNames; | ||
89 | bool mAskForPreferences; | ||
90 | bool mShowSyncSummary; | ||
91 | bool mShowSyncEvents; | ||
92 | bool mShowTodoInAgenda; | ||
93 | bool mWriteBackExistingOnly; | ||
94 | int mSyncAlgoPrefs; | ||
95 | int mRingSyncAlgoPrefs; | ||
96 | bool mWriteBackFile; | ||
97 | int mWriteBackInFuture; | ||
98 | QString mPhoneDevice; | ||
99 | QString mPhoneConnection; | ||
100 | QString mPhoneModel; | ||
101 | QString mLastSyncedLocalFile; // save! | ||
102 | private: | 86 | private: |
103 | KABPrefs(); | 87 | KABPrefs(); |
104 | 88 | ||
105 | static KABPrefs *sInstance; | 89 | static KABPrefs *sInstance; |
106 | }; | 90 | }; |
107 | 91 | ||
108 | #endif | 92 | #endif |