author | zautrix <zautrix> | 2005-03-25 00:08:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-25 00:08:08 (UTC) |
commit | 7c2e130ddd194f1c4b5365af6999a27c08232f4b (patch) (unidiff) | |
tree | 75665681327ee49d7650f4d840b5c8c772180fb4 /kaddressbook | |
parent | 5cf054b82738d65f9b0a34ccb51c993ee4a0189f (diff) | |
download | kdepimpi-7c2e130ddd194f1c4b5365af6999a27c08232f4b.zip kdepimpi-7c2e130ddd194f1c4b5365af6999a27c08232f4b.tar.gz kdepimpi-7c2e130ddd194f1c4b5365af6999a27c08232f4b.tar.bz2 |
fixes
-rw-r--r-- | kaddressbook/filtereditdialog.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp index 1194406..ef9b979 100644 --- a/kaddressbook/filtereditdialog.cpp +++ b/kaddressbook/filtereditdialog.cpp | |||
@@ -65,195 +65,195 @@ FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) | |||
65 | QStringList::Iterator iter; | 65 | QStringList::Iterator iter; |
66 | for ( iter = cats.begin(); iter != cats.end(); ++iter ) | 66 | for ( iter = cats.begin(); iter != cats.end(); ++iter ) |
67 | mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); | 67 | mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); |
68 | filterNameTextChanged( mNameEdit->text() ); | 68 | filterNameTextChanged( mNameEdit->text() ); |
69 | } | 69 | } |
70 | 70 | ||
71 | FilterEditDialog::~FilterEditDialog() | 71 | FilterEditDialog::~FilterEditDialog() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void FilterEditDialog::setFilter( const Filter &filter ) | 75 | void FilterEditDialog::setFilter( const Filter &filter ) |
76 | { | 76 | { |
77 | mNameEdit->setText( filter.name() ); | 77 | mNameEdit->setText( filter.name() ); |
78 | 78 | ||
79 | QStringList categories = filter.categories(); | 79 | QStringList categories = filter.categories(); |
80 | QListViewItem *item = mCategoriesView->firstChild(); | 80 | QListViewItem *item = mCategoriesView->firstChild(); |
81 | while ( item != 0 ) { | 81 | while ( item != 0 ) { |
82 | if ( categories.contains( item->text( 0 ) ) ) { | 82 | if ( categories.contains( item->text( 0 ) ) ) { |
83 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 83 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
84 | checkItem->setOn( true ); | 84 | checkItem->setOn( true ); |
85 | } | 85 | } |
86 | 86 | ||
87 | item = item->nextSibling(); | 87 | item = item->nextSibling(); |
88 | } | 88 | } |
89 | 89 | ||
90 | if ( filter.matchRule() == Filter::Matching ) | 90 | if ( filter.matchRule() == Filter::Matching ) |
91 | mMatchRuleGroup->setButton( 0 ); | 91 | mMatchRuleGroup->setButton( 0 ); |
92 | else | 92 | else |
93 | mMatchRuleGroup->setButton( 1 ); | 93 | mMatchRuleGroup->setButton( 1 ); |
94 | 94 | ||
95 | int c = filter.criteria() ; | 95 | int c = filter.criteria() ; |
96 | mPublic->setChecked(c &Filter::ShowPublic); | 96 | mPublic->setChecked(c &Filter::ShowPublic); |
97 | mPrivate->setChecked(c & Filter::ShowPrivate); | 97 | mPrivate->setChecked(c & Filter::ShowPrivate); |
98 | mConfidential->setChecked(c & Filter::ShowConfidential); | 98 | mConfidential->setChecked(c & Filter::ShowConfidential); |
99 | } | 99 | } |
100 | 100 | ||
101 | Filter FilterEditDialog::filter() | 101 | Filter FilterEditDialog::filter() |
102 | { | 102 | { |
103 | Filter filter; | 103 | Filter filter; |
104 | 104 | ||
105 | filter.setName( mNameEdit->text() ); | 105 | filter.setName( mNameEdit->text() ); |
106 | 106 | ||
107 | QStringList categories; | 107 | QStringList categories; |
108 | QListViewItem *item = mCategoriesView->firstChild(); | 108 | QListViewItem *item = mCategoriesView->firstChild(); |
109 | while ( item != 0 ) { | 109 | while ( item != 0 ) { |
110 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 110 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
111 | if ( checkItem->isOn() ) | 111 | if ( checkItem->isOn() ) |
112 | categories.append( item->text( 0 ) ); | 112 | categories.append( item->text( 0 ) ); |
113 | 113 | ||
114 | item = item->nextSibling(); | 114 | item = item->nextSibling(); |
115 | } | 115 | } |
116 | filter.setCategories( categories ); | 116 | filter.setCategories( categories ); |
117 | 117 | ||
118 | if ( mMatchRuleGroup->find( 0 )->isOn() ) | 118 | if ( mMatchRuleGroup->find( 0 )->isOn() ) |
119 | filter.setMatchRule( Filter::Matching ); | 119 | filter.setMatchRule( Filter::Matching ); |
120 | else | 120 | else |
121 | filter.setMatchRule( Filter::NotMatching ); | 121 | filter.setMatchRule( Filter::NotMatching ); |
122 | 122 | ||
123 | int c = 0; | 123 | int c = 0; |
124 | if (mPublic->isChecked()) c |= Filter::ShowPublic; | 124 | if (mPublic->isChecked()) c |= Filter::ShowPublic; |
125 | if (mPrivate->isChecked()) c |= Filter::ShowPrivate; | 125 | if (mPrivate->isChecked()) c |= Filter::ShowPrivate; |
126 | if (mConfidential->isChecked()) c |= Filter::ShowConfidential; | 126 | if (mConfidential->isChecked()) c |= Filter::ShowConfidential; |
127 | filter.setCriteria( c ) ; | 127 | filter.setCriteria( c ) ; |
128 | 128 | ||
129 | return filter; | 129 | return filter; |
130 | } | 130 | } |
131 | 131 | ||
132 | void FilterEditDialog::initGUI() | 132 | void FilterEditDialog::initGUI() |
133 | { | 133 | { |
134 | #ifndef KAB_EMBEDDED | 134 | #ifndef KAB_EMBEDDED |
135 | resize( 490, 300 ); | 135 | resize( 490, 300 ); |
136 | #else //KAB_EMBEDDED | 136 | #else //KAB_EMBEDDED |
137 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); | 137 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); |
138 | #endif //KAB_EMBEDDED | 138 | #endif //KAB_EMBEDDED |
139 | 139 | ||
140 | 140 | ||
141 | QWidget *page = plainPage(); | 141 | QWidget *page = plainPage(); |
142 | QLabel *label; | 142 | QLabel *label; |
143 | 143 | ||
144 | QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); | 144 | QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); |
145 | 145 | ||
146 | label = new QLabel( i18n( "Name" ), page ); | 146 | label = new QLabel( i18n( "Name" ), page ); |
147 | mNameEdit = new KLineEdit( page ); | 147 | mNameEdit = new KLineEdit( page ); |
148 | mNameEdit->setFocus(); | 148 | mNameEdit->setFocus(); |
149 | topLayout->addWidget( label, 0, 0 ); | 149 | topLayout->addWidget( label, 0, 0 ); |
150 | topLayout->addWidget( mNameEdit, 0, 1 ); | 150 | topLayout->addWidget( mNameEdit, 0, 1 ); |
151 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 151 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
152 | SLOT( filterNameTextChanged( const QString&) ) ); | 152 | SLOT( filterNameTextChanged( const QString&) ) ); |
153 | 153 | ||
154 | mCategoriesView = new KListView( page ); | 154 | mCategoriesView = new KListView( page ); |
155 | mCategoriesView->addColumn( i18n( "Categories" ) ); | 155 | mCategoriesView->addColumn( i18n( "Categories" ) ); |
156 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); | 156 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); |
157 | 157 | ||
158 | mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); | 158 | mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); |
159 | mMatchRuleGroup->setExclusive( true ); | 159 | mMatchRuleGroup->setExclusive( true ); |
160 | QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); | 160 | QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); |
161 | radio->setChecked( true ); | ||
162 | //mMatchRuleGroup->insert( radio ); | 161 | //mMatchRuleGroup->insert( radio ); |
163 | radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); | 162 | radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); |
163 | radio->setChecked( true ); | ||
164 | //mMatchRuleGroup->insert( radio ); | 164 | //mMatchRuleGroup->insert( radio ); |
165 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); | 165 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); |
166 | 166 | ||
167 | QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); | 167 | QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); |
168 | mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); | 168 | mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); |
169 | mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); | 169 | mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); |
170 | mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); | 170 | mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); |
171 | mPublic->setChecked( true ); | 171 | mPublic->setChecked( true ); |
172 | mPrivate->setChecked( true ); | 172 | mPrivate->setChecked( true ); |
173 | mConfidential->setChecked( true ); | 173 | mConfidential->setChecked( true ); |
174 | topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); | 174 | topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); |
175 | 175 | ||
176 | } | 176 | } |
177 | 177 | ||
178 | void FilterEditDialog::filterNameTextChanged( const QString &text ) | 178 | void FilterEditDialog::filterNameTextChanged( const QString &text ) |
179 | { | 179 | { |
180 | enableButtonOK( !text.isEmpty() ); | 180 | enableButtonOK( !text.isEmpty() ); |
181 | } | 181 | } |
182 | 182 | ||
183 | void FilterEditDialog::slotHelp() | 183 | void FilterEditDialog::slotHelp() |
184 | { | 184 | { |
185 | #ifndef KAB_EMBEDDED | 185 | #ifndef KAB_EMBEDDED |
186 | kapp->invokeHelp( "using-filters" ); | 186 | kapp->invokeHelp( "using-filters" ); |
187 | #endif //KAB_EMBEDDED | 187 | #endif //KAB_EMBEDDED |
188 | } | 188 | } |
189 | 189 | ||
190 | FilterDialog::FilterDialog( QWidget *parent, const char *name ) | 190 | FilterDialog::FilterDialog( QWidget *parent, const char *name ) |
191 | : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), | 191 | : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), |
192 | Ok | Cancel, Ok, parent, name, /*US false*/true, true ) | 192 | Ok | Cancel, Ok, parent, name, /*US false*/true, true ) |
193 | { | 193 | { |
194 | initGUI(); | 194 | initGUI(); |
195 | } | 195 | } |
196 | 196 | ||
197 | FilterDialog::~FilterDialog() | 197 | FilterDialog::~FilterDialog() |
198 | { | 198 | { |
199 | } | 199 | } |
200 | 200 | ||
201 | void FilterDialog::setFilters( const Filter::List &list ) | 201 | void FilterDialog::setFilters( const Filter::List &list ) |
202 | { | 202 | { |
203 | mFilterList.clear(); | 203 | mFilterList.clear(); |
204 | mInternalFilterList.clear(); | 204 | mInternalFilterList.clear(); |
205 | 205 | ||
206 | Filter::List::ConstIterator it; | 206 | Filter::List::ConstIterator it; |
207 | for ( it = list.begin(); it != list.end(); ++it ) { | 207 | for ( it = list.begin(); it != list.end(); ++it ) { |
208 | if ( (*it).isInternal() ) | 208 | if ( (*it).isInternal() ) |
209 | mInternalFilterList.append( *it ); | 209 | mInternalFilterList.append( *it ); |
210 | else | 210 | else |
211 | mFilterList.append( *it ); | 211 | mFilterList.append( *it ); |
212 | } | 212 | } |
213 | 213 | ||
214 | refresh(); | 214 | refresh(); |
215 | } | 215 | } |
216 | 216 | ||
217 | Filter::List FilterDialog::filters() const | 217 | Filter::List FilterDialog::filters() const |
218 | { | 218 | { |
219 | Filter::List list = mFilterList + mInternalFilterList; | 219 | Filter::List list = mFilterList + mInternalFilterList; |
220 | return list; | 220 | return list; |
221 | } | 221 | } |
222 | 222 | ||
223 | void FilterDialog::add() | 223 | void FilterDialog::add() |
224 | { | 224 | { |
225 | #ifndef KAB_EMBEDDED | 225 | #ifndef KAB_EMBEDDED |
226 | FilterEditDialog dlg( this ); | 226 | FilterEditDialog dlg( this ); |
227 | #else //KAB_EMBEDDED | 227 | #else //KAB_EMBEDDED |
228 | FilterEditDialog dlg( this->parentWidget() ); | 228 | FilterEditDialog dlg( this->parentWidget() ); |
229 | #endif //KAB_EMBEDDED | 229 | #endif //KAB_EMBEDDED |
230 | 230 | ||
231 | if ( dlg.exec() ) | 231 | if ( dlg.exec() ) |
232 | mFilterList.append( dlg.filter() ); | 232 | mFilterList.append( dlg.filter() ); |
233 | 233 | ||
234 | refresh(); | 234 | refresh(); |
235 | 235 | ||
236 | mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 ); | 236 | mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 ); |
237 | } | 237 | } |
238 | 238 | ||
239 | void FilterDialog::edit() | 239 | void FilterDialog::edit() |
240 | { | 240 | { |
241 | FilterEditDialog dlg( this ); | 241 | FilterEditDialog dlg( this ); |
242 | 242 | ||
243 | uint pos = mFilterListBox->currentItem(); | 243 | uint pos = mFilterListBox->currentItem(); |
244 | 244 | ||
245 | dlg.setFilter( mFilterList[ pos ] ); | 245 | dlg.setFilter( mFilterList[ pos ] ); |
246 | 246 | ||
247 | if ( dlg.exec() ) { | 247 | if ( dlg.exec() ) { |
248 | mFilterList.remove( mFilterList.at( pos ) ); | 248 | mFilterList.remove( mFilterList.at( pos ) ); |
249 | mFilterList.insert( mFilterList.at( pos ), dlg.filter() ); | 249 | mFilterList.insert( mFilterList.at( pos ), dlg.filter() ); |
250 | } | 250 | } |
251 | 251 | ||
252 | refresh(); | 252 | refresh(); |
253 | 253 | ||
254 | mFilterListBox->setCurrentItem( pos ); | 254 | mFilterListBox->setCurrentItem( pos ); |
255 | } | 255 | } |
256 | 256 | ||
257 | void FilterDialog::remove() | 257 | void FilterDialog::remove() |
258 | { | 258 | { |
259 | mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) ); | 259 | mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) ); |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index e8f6132..59aa5a5 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -3093,243 +3093,246 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
3093 | ++deletedAddresseeL; | 3093 | ++deletedAddresseeL; |
3094 | } else { | 3094 | } else { |
3095 | if ( ! syncManager->mWriteBackExistingOnly ) { | 3095 | if ( ! syncManager->mWriteBackExistingOnly ) { |
3096 | ++addedAddresseeR; | 3096 | ++addedAddresseeR; |
3097 | inL.setRevision( modifiedCalendar ); | 3097 | inL.setRevision( modifiedCalendar ); |
3098 | local->insertAddressee( inL, false ); | 3098 | local->insertAddressee( inL, false ); |
3099 | inR = inL; | 3099 | inR = inL; |
3100 | inR.setIDStr( ":" ); | 3100 | inR.setIDStr( ":" ); |
3101 | inR.setResource( 0 ); | 3101 | inR.setResource( 0 ); |
3102 | remote->insertAddressee( inR, false ); | 3102 | remote->insertAddressee( inR, false ); |
3103 | } | 3103 | } |
3104 | } | 3104 | } |
3105 | } | 3105 | } |
3106 | } else { | 3106 | } else { |
3107 | ++filteredOUT; | 3107 | ++filteredOUT; |
3108 | } | 3108 | } |
3109 | } | 3109 | } |
3110 | } | 3110 | } |
3111 | } | 3111 | } |
3112 | ++incCounter; | 3112 | ++incCounter; |
3113 | } | 3113 | } |
3114 | el.clear(); | 3114 | el.clear(); |
3115 | syncManager->hideProgressBar(); | 3115 | syncManager->hideProgressBar(); |
3116 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 3116 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
3117 | // get rid of micro seconds | 3117 | // get rid of micro seconds |
3118 | QTime t = mLastAddressbookSync.time(); | 3118 | QTime t = mLastAddressbookSync.time(); |
3119 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 3119 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
3120 | addresseeLSync.setRevision( mLastAddressbookSync ); | 3120 | addresseeLSync.setRevision( mLastAddressbookSync ); |
3121 | addresseeRSync.setRevision( mLastAddressbookSync ); | 3121 | addresseeRSync.setRevision( mLastAddressbookSync ); |
3122 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 3122 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
3123 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 3123 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
3124 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 3124 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
3125 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 3125 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
3126 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 3126 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
3127 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 3127 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
3128 | addresseeRSync.setNote( "" ) ; | 3128 | addresseeRSync.setNote( "" ) ; |
3129 | addresseeLSync.setNote( "" ); | 3129 | addresseeLSync.setNote( "" ); |
3130 | 3130 | ||
3131 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 3131 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
3132 | remote->insertAddressee( addresseeRSync, false ); | 3132 | remote->insertAddressee( addresseeRSync, false ); |
3133 | local->insertAddressee( addresseeLSync, false ); | 3133 | local->insertAddressee( addresseeLSync, false ); |
3134 | QString mes; | 3134 | QString mes; |
3135 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); | 3135 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); |
3136 | qDebug( mes ); | 3136 | qDebug( mes ); |
3137 | mes = i18n("Local addressbook changed!\n") +mes; | 3137 | mes = i18n("Local addressbook changed!\n") +mes; |
3138 | if ( syncManager->mShowSyncSummary ) { | 3138 | if ( syncManager->mShowSyncSummary ) { |
3139 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 3139 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
3140 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 3140 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
3141 | qDebug("KA: WB cancelled "); | 3141 | qDebug("KA: WB cancelled "); |
3142 | syncManager->mWriteBackFile = false; | 3142 | syncManager->mWriteBackFile = false; |
3143 | return syncOK; | 3143 | return syncOK; |
3144 | } | 3144 | } |
3145 | } | 3145 | } |
3146 | return syncOK; | 3146 | return syncOK; |
3147 | } | 3147 | } |
3148 | 3148 | ||
3149 | 3149 | ||
3150 | //this is a overwritten callbackmethods from the syncinterface | 3150 | //this is a overwritten callbackmethods from the syncinterface |
3151 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3151 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3152 | { | 3152 | { |
3153 | 3153 | ||
3154 | //pending prepare addresseeview for output | 3154 | //pending prepare addresseeview for output |
3155 | //pending detect, if remote file has REV field. if not switch to external sync | 3155 | //pending detect, if remote file has REV field. if not switch to external sync |
3156 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3156 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3157 | if ( manager != syncManager ) | 3157 | if ( manager != syncManager ) |
3158 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | 3158 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); |
3159 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3159 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3160 | 3160 | ||
3161 | AddressBook abLocal(filename,"syncContact"); | 3161 | AddressBook abLocal(filename,"syncContact"); |
3162 | bool syncOK = false; | 3162 | bool syncOK = false; |
3163 | if ( abLocal.load() ) { | 3163 | if ( abLocal.load() ) { |
3164 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3164 | qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3165 | bool external = false; | 3165 | bool external = false; |
3166 | bool isXML = false; | 3166 | bool isXML = false; |
3167 | if ( filename.right(4) == ".xml") { | 3167 | if ( filename.right(4) == ".xml") { |
3168 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3168 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3169 | isXML = true; | 3169 | isXML = true; |
3170 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3170 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3171 | } else { | 3171 | } else { |
3172 | external = !manager->mIsKapiFile; | 3172 | external = !manager->mIsKapiFile; |
3173 | if ( external ) { | 3173 | if ( external ) { |
3174 | qDebug("KA: Sync::Setting vcf mode to external "); | 3174 | qDebug("KA: Sync::Setting vcf mode to external "); |
3175 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3175 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3176 | AddressBook::Iterator it; | 3176 | AddressBook::Iterator it; |
3177 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3177 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3178 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3178 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3179 | (*it).computeCsum( mCurrentSyncDevice ); | 3179 | (*it).computeCsum( mCurrentSyncDevice ); |
3180 | } | 3180 | } |
3181 | } | 3181 | } |
3182 | } | 3182 | } |
3183 | //AddressBook::Iterator it; | 3183 | //AddressBook::Iterator it; |
3184 | //QStringList vcards; | 3184 | //QStringList vcards; |
3185 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3185 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3186 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3186 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3187 | //} | 3187 | //} |
3188 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3188 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3189 | syncManager->hideProgressBar(); | ||
3189 | if ( syncOK ) { | 3190 | if ( syncOK ) { |
3190 | if ( syncManager->mWriteBackFile ) | 3191 | if ( syncManager->mWriteBackFile ) |
3191 | { | 3192 | { |
3192 | if ( external ) | 3193 | if ( external ) |
3193 | abLocal.removeSyncAddressees( !isXML); | 3194 | abLocal.removeSyncAddressees( !isXML); |
3194 | qDebug("KA: Sync::Saving remote AB "); | 3195 | qDebug("KA: Sync::Saving remote AB "); |
3195 | if ( ! abLocal.saveAB()) | 3196 | if ( ! abLocal.saveAB()) |
3196 | qDebug("KA: sync::Error writing back AB to file "); | 3197 | qDebug("KA: sync::Error writing back AB to file "); |
3197 | if ( external ) { | 3198 | if ( external ) { |
3198 | // afterwrite processing | 3199 | // afterwrite processing |
3199 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3200 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3200 | } | 3201 | } |
3201 | } | 3202 | } |
3202 | } | 3203 | } |
3203 | setModified(); | 3204 | setModified(); |
3204 | 3205 | ||
3205 | } | 3206 | } |
3206 | abLocal.removeResources(); | 3207 | abLocal.removeResources(); |
3207 | if ( syncOK ) | 3208 | if ( syncOK ) |
3208 | mViewManager->refreshView(); | 3209 | mViewManager->refreshView(); |
3209 | return syncOK; | 3210 | return syncOK; |
3210 | 3211 | ||
3211 | } | 3212 | } |
3212 | void KABCore::removeSyncInfo( QString syncProfile) | 3213 | void KABCore::removeSyncInfo( QString syncProfile) |
3213 | { | 3214 | { |
3214 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3215 | qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3215 | mAddressBook->removeSyncInfo( syncProfile ); | 3216 | mAddressBook->removeSyncInfo( syncProfile ); |
3216 | setModified(); | 3217 | setModified(); |
3217 | } | 3218 | } |
3218 | 3219 | ||
3219 | 3220 | ||
3220 | //this is a overwritten callbackmethods from the syncinterface | 3221 | //this is a overwritten callbackmethods from the syncinterface |
3221 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3222 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3222 | { | 3223 | { |
3223 | if ( resource == "phone" ) | 3224 | if ( resource == "phone" ) |
3224 | return syncPhone(); | 3225 | return syncPhone(); |
3225 | disableBR( true ); | 3226 | disableBR( true ); |
3226 | if ( manager != syncManager ) | 3227 | if ( manager != syncManager ) |
3227 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | 3228 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); |
3228 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3229 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3229 | 3230 | ||
3230 | AddressBook abLocal( resource,"syncContact"); | 3231 | AddressBook abLocal( resource,"syncContact"); |
3231 | bool syncOK = false; | 3232 | bool syncOK = false; |
3232 | message(i18n("Loading DTM address data..."), false); | 3233 | message(i18n("Loading DTM address data..."), false); |
3233 | if ( abLocal.load() ) { | 3234 | if ( abLocal.load() ) { |
3234 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3235 | qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3235 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3236 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3236 | message(i18n("Sync preprocessing..."),false); | 3237 | message(i18n("Sync preprocessing..."),false); |
3237 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3238 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3238 | message(i18n("Synchronizing..."),false); | 3239 | message(i18n("Synchronizing..."),false); |
3239 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3240 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3241 | syncManager->hideProgressBar(); | ||
3240 | if ( syncOK ) { | 3242 | if ( syncOK ) { |
3241 | if ( syncManager->mWriteBackFile ) { | 3243 | if ( syncManager->mWriteBackFile ) { |
3242 | abLocal.removeSyncAddressees( false ); | 3244 | abLocal.removeSyncAddressees( false ); |
3243 | message(i18n("Saving DTM address data..."),false); | 3245 | message(i18n("Saving DTM address data..."),false); |
3244 | abLocal.saveAB(); | 3246 | abLocal.saveAB(); |
3245 | message(i18n("Sync postprocessing..."),false); | 3247 | message(i18n("Sync postprocessing..."),false); |
3246 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3248 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3247 | } | 3249 | } |
3248 | } else | 3250 | } else |
3249 | message( i18n("Sync cancelled or failed.") ); | 3251 | message( i18n("Sync cancelled or failed.") ); |
3250 | setModified(); | 3252 | setModified(); |
3251 | } | 3253 | } |
3252 | abLocal.removeResources(); | 3254 | abLocal.removeResources(); |
3253 | if ( syncOK ) { | 3255 | if ( syncOK ) { |
3254 | mViewManager->refreshView(); | 3256 | mViewManager->refreshView(); |
3255 | message(i18n("DTM syncing finished.")); | 3257 | message(i18n("DTM syncing finished.")); |
3256 | } | 3258 | } |
3257 | disableBR( false ); | 3259 | disableBR( false ); |
3258 | return syncOK; | 3260 | return syncOK; |
3259 | 3261 | ||
3260 | } | 3262 | } |
3261 | void KABCore::message( QString m, bool startTimer) | 3263 | void KABCore::message( QString m, bool startTimer) |
3262 | { | 3264 | { |
3263 | topLevelWidget()->setCaption( m ); | 3265 | topLevelWidget()->setCaption( m ); |
3264 | qApp->processEvents(); | 3266 | qApp->processEvents(); |
3265 | if ( startTimer ) | 3267 | if ( startTimer ) |
3266 | mMessageTimer->start( 15000, true ); | 3268 | mMessageTimer->start( 15000, true ); |
3267 | else | 3269 | else |
3268 | mMessageTimer->stop(); | 3270 | mMessageTimer->stop(); |
3269 | } | 3271 | } |
3270 | bool KABCore::syncPhone() | 3272 | bool KABCore::syncPhone() |
3271 | { | 3273 | { |
3272 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3274 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3273 | QString fileName = getPhoneFile(); | 3275 | QString fileName = getPhoneFile(); |
3274 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3276 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3275 | message(i18n("Phone access failed!")); | 3277 | message(i18n("Phone access failed!")); |
3276 | return false; | 3278 | return false; |
3277 | } | 3279 | } |
3278 | AddressBook abLocal( fileName,"syncContact"); | 3280 | AddressBook abLocal( fileName,"syncContact"); |
3279 | bool syncOK = false; | 3281 | bool syncOK = false; |
3280 | { | 3282 | { |
3281 | abLocal.importFromFile( fileName ); | 3283 | abLocal.importFromFile( fileName ); |
3282 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3284 | qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3283 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3285 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3284 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3286 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3285 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3287 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3286 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3288 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3289 | syncManager->hideProgressBar(); | ||
3287 | if ( syncOK ) { | 3290 | if ( syncOK ) { |
3288 | if ( syncManager->mWriteBackFile ) { | 3291 | if ( syncManager->mWriteBackFile ) { |
3289 | abLocal.removeSyncAddressees( true ); | 3292 | abLocal.removeSyncAddressees( true ); |
3290 | abLocal.saveABphone( fileName ); | 3293 | abLocal.saveABphone( fileName ); |
3291 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3294 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3292 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3295 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3293 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3296 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3294 | } | 3297 | } |
3295 | } | 3298 | } |
3296 | setModified(); | 3299 | setModified(); |
3297 | } | 3300 | } |
3298 | abLocal.removeResources(); | 3301 | abLocal.removeResources(); |
3299 | if ( syncOK ) | 3302 | if ( syncOK ) |
3300 | mViewManager->refreshView(); | 3303 | mViewManager->refreshView(); |
3301 | return syncOK; | 3304 | return syncOK; |
3302 | } | 3305 | } |
3303 | void KABCore::getFile( bool success ) | 3306 | void KABCore::getFile( bool success ) |
3304 | { | 3307 | { |
3305 | if ( ! success ) { | 3308 | if ( ! success ) { |
3306 | message( i18n("Error receiving file. Nothing changed!") ); | 3309 | message( i18n("Error receiving file. Nothing changed!") ); |
3307 | return; | 3310 | return; |
3308 | } | 3311 | } |
3309 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3312 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3310 | if ( count ) | 3313 | if ( count ) |
3311 | setModified( true ); | 3314 | setModified( true ); |
3312 | message( i18n("Pi-Sync successful!") ); | 3315 | message( i18n("Pi-Sync successful!") ); |
3313 | mViewManager->refreshView(); | 3316 | mViewManager->refreshView(); |
3314 | } | 3317 | } |
3315 | void KABCore::syncFileRequest() | 3318 | void KABCore::syncFileRequest() |
3316 | { | 3319 | { |
3317 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3320 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3318 | syncManager->slotSyncMenu( 999 ); | 3321 | syncManager->slotSyncMenu( 999 ); |
3319 | } | 3322 | } |
3320 | mAddressBook->export2File( sentSyncFile() ); | 3323 | mAddressBook->export2File( sentSyncFile() ); |
3321 | } | 3324 | } |
3322 | QString KABCore::sentSyncFile() | 3325 | QString KABCore::sentSyncFile() |
3323 | { | 3326 | { |
3324 | #ifdef DESKTOP_VERSION | 3327 | #ifdef DESKTOP_VERSION |
3325 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3328 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3326 | #else | 3329 | #else |
3327 | return QString( "/tmp/copysyncab.vcf" ); | 3330 | return QString( "/tmp/copysyncab.vcf" ); |
3328 | #endif | 3331 | #endif |
3329 | } | 3332 | } |
3330 | 3333 | ||
3331 | void KABCore::setCaptionBack() | 3334 | void KABCore::setCaptionBack() |
3332 | { | 3335 | { |
3333 | mMessageTimer->stop(); | 3336 | mMessageTimer->stop(); |
3334 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3337 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3335 | } | 3338 | } |