author | zautrix <zautrix> | 2004-09-18 14:22:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-18 14:22:10 (UTC) |
commit | ca8fcf3fd4dc068747d8f31e2189145b22853d55 (patch) (unidiff) | |
tree | 29417ffd55d1c4186922a64ed0cdf1c6a1cc69a3 /kaddressbook | |
parent | bb16660f29fc709791aa0ee4cb63a40710a994a8 (diff) | |
download | kdepimpi-ca8fcf3fd4dc068747d8f31e2189145b22853d55.zip kdepimpi-ca8fcf3fd4dc068747d8f31e2189145b22853d55.tar.gz kdepimpi-ca8fcf3fd4dc068747d8f31e2189145b22853d55.tar.bz2 |
more AB sync
-rw-r--r-- | kaddressbook/kabcore.cpp | 206 |
1 files changed, 92 insertions, 114 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 53c63ff..f497541 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,809 +1,811 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
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 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qprogressbar.h> | ||
36 | 37 | ||
37 | #ifndef KAB_EMBEDDED | 38 | #ifndef KAB_EMBEDDED |
38 | #include <qclipboard.h> | 39 | #include <qclipboard.h> |
39 | #include <qdir.h> | 40 | #include <qdir.h> |
40 | #include <qfile.h> | 41 | #include <qfile.h> |
41 | #include <qapplicaton.h> | 42 | #include <qapplicaton.h> |
43 | #include <qprogressbar.h> | ||
42 | #include <qlayout.h> | 44 | #include <qlayout.h> |
43 | #include <qregexp.h> | 45 | #include <qregexp.h> |
44 | #include <qvbox.h> | 46 | #include <qvbox.h> |
45 | #include <kabc/addresseelist.h> | 47 | #include <kabc/addresseelist.h> |
46 | #include <kabc/errorhandler.h> | 48 | #include <kabc/errorhandler.h> |
47 | #include <kabc/resource.h> | 49 | #include <kabc/resource.h> |
48 | #include <kabc/vcardconverter.h> | 50 | #include <kabc/vcardconverter.h> |
49 | #include <kapplication.h> | 51 | #include <kapplication.h> |
50 | #include <kactionclasses.h> | 52 | #include <kactionclasses.h> |
51 | #include <kcmultidialog.h> | 53 | #include <kcmultidialog.h> |
52 | #include <kdebug.h> | 54 | #include <kdebug.h> |
53 | #include <kdeversion.h> | 55 | #include <kdeversion.h> |
54 | #include <kkeydialog.h> | 56 | #include <kkeydialog.h> |
55 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
56 | #include <kprinter.h> | 58 | #include <kprinter.h> |
57 | #include <kprotocolinfo.h> | 59 | #include <kprotocolinfo.h> |
58 | #include <kresources/selectdialog.h> | 60 | #include <kresources/selectdialog.h> |
59 | #include <kstandarddirs.h> | 61 | #include <kstandarddirs.h> |
60 | #include <ktempfile.h> | 62 | #include <ktempfile.h> |
61 | #include <kxmlguiclient.h> | 63 | #include <kxmlguiclient.h> |
62 | #include <kaboutdata.h> | 64 | #include <kaboutdata.h> |
63 | #include <libkdepim/categoryselectdialog.h> | 65 | #include <libkdepim/categoryselectdialog.h> |
64 | 66 | ||
65 | #include "addresseeutil.h" | 67 | #include "addresseeutil.h" |
66 | #include "addresseeeditordialog.h" | 68 | #include "addresseeeditordialog.h" |
67 | #include "extensionmanager.h" | 69 | #include "extensionmanager.h" |
68 | #include "kstdaction.h" | 70 | #include "kstdaction.h" |
69 | #include "kaddressbookservice.h" | 71 | #include "kaddressbookservice.h" |
70 | #include "ldapsearchdialog.h" | 72 | #include "ldapsearchdialog.h" |
71 | #include "printing/printingwizard.h" | 73 | #include "printing/printingwizard.h" |
72 | #else // KAB_EMBEDDED | 74 | #else // KAB_EMBEDDED |
73 | 75 | ||
74 | #include <kapplication.h> | 76 | #include <kapplication.h> |
75 | #include "KDGanttMinimizeSplitter.h" | 77 | #include "KDGanttMinimizeSplitter.h" |
76 | #include "kaddressbookmain.h" | 78 | #include "kaddressbookmain.h" |
77 | #include "kactioncollection.h" | 79 | #include "kactioncollection.h" |
78 | #include "addresseedialog.h" | 80 | #include "addresseedialog.h" |
79 | //US | 81 | //US |
80 | #include <addresseeview.h> | 82 | #include <addresseeview.h> |
81 | 83 | ||
82 | #include <qapp.h> | 84 | #include <qapp.h> |
83 | #include <qmenubar.h> | 85 | #include <qmenubar.h> |
84 | //#include <qtoolbar.h> | 86 | //#include <qtoolbar.h> |
85 | #include <qmessagebox.h> | 87 | #include <qmessagebox.h> |
86 | #include <kdebug.h> | 88 | #include <kdebug.h> |
87 | #include <kiconloader.h> // needed for SmallIcon | 89 | #include <kiconloader.h> // needed for SmallIcon |
88 | #include <kresources/kcmkresources.h> | 90 | #include <kresources/kcmkresources.h> |
89 | #include <ktoolbar.h> | 91 | #include <ktoolbar.h> |
90 | 92 | ||
91 | 93 | ||
92 | //#include <qlabel.h> | 94 | //#include <qlabel.h> |
93 | 95 | ||
94 | 96 | ||
95 | #ifndef DESKTOP_VERSION | 97 | #ifndef DESKTOP_VERSION |
96 | #include <qpe/ir.h> | 98 | #include <qpe/ir.h> |
97 | #include <qpe/qpemenubar.h> | 99 | #include <qpe/qpemenubar.h> |
98 | #include <qtopia/qcopenvelope_qws.h> | 100 | #include <qtopia/qcopenvelope_qws.h> |
99 | #else | 101 | #else |
100 | 102 | ||
101 | #include <qmenubar.h> | 103 | #include <qmenubar.h> |
102 | #endif | 104 | #endif |
103 | 105 | ||
104 | #endif // KAB_EMBEDDED | 106 | #endif // KAB_EMBEDDED |
105 | #include "kcmconfigs/kcmkabconfig.h" | 107 | #include "kcmconfigs/kcmkabconfig.h" |
106 | #include "kcmconfigs/kcmkdepimconfig.h" | 108 | #include "kcmconfigs/kcmkdepimconfig.h" |
107 | #include "kpimglobalprefs.h" | 109 | #include "kpimglobalprefs.h" |
108 | #include "externalapphandler.h" | 110 | #include "externalapphandler.h" |
109 | 111 | ||
110 | 112 | ||
111 | #include <kresources/selectdialog.h> | 113 | #include <kresources/selectdialog.h> |
112 | #include <kmessagebox.h> | 114 | #include <kmessagebox.h> |
113 | 115 | ||
114 | #include <picture.h> | 116 | #include <picture.h> |
115 | #include <resource.h> | 117 | #include <resource.h> |
116 | 118 | ||
117 | //US#include <qsplitter.h> | 119 | //US#include <qsplitter.h> |
118 | #include <qmap.h> | 120 | #include <qmap.h> |
119 | #include <qdir.h> | 121 | #include <qdir.h> |
120 | #include <qfile.h> | 122 | #include <qfile.h> |
121 | #include <qvbox.h> | 123 | #include <qvbox.h> |
122 | #include <qlayout.h> | 124 | #include <qlayout.h> |
123 | #include <qclipboard.h> | 125 | #include <qclipboard.h> |
124 | #include <qtextstream.h> | 126 | #include <qtextstream.h> |
125 | 127 | ||
126 | #include <libkdepim/categoryselectdialog.h> | 128 | #include <libkdepim/categoryselectdialog.h> |
127 | #include <kabc/vcardconverter.h> | 129 | #include <kabc/vcardconverter.h> |
128 | 130 | ||
129 | 131 | ||
130 | #include "addresseeutil.h" | 132 | #include "addresseeutil.h" |
131 | #include "undocmds.h" | 133 | #include "undocmds.h" |
132 | #include "addresseeeditordialog.h" | 134 | #include "addresseeeditordialog.h" |
133 | #include "viewmanager.h" | 135 | #include "viewmanager.h" |
134 | #include "details/detailsviewcontainer.h" | 136 | #include "details/detailsviewcontainer.h" |
135 | #include "kabprefs.h" | 137 | #include "kabprefs.h" |
136 | #include "xxportmanager.h" | 138 | #include "xxportmanager.h" |
137 | #include "incsearchwidget.h" | 139 | #include "incsearchwidget.h" |
138 | #include "jumpbuttonbar.h" | 140 | #include "jumpbuttonbar.h" |
139 | #include "extensionmanager.h" | 141 | #include "extensionmanager.h" |
140 | #include "addresseeconfig.h" | 142 | #include "addresseeconfig.h" |
141 | #include <kcmultidialog.h> | 143 | #include <kcmultidialog.h> |
142 | 144 | ||
143 | #ifdef _WIN32_ | 145 | #ifdef _WIN32_ |
144 | 146 | ||
145 | #include "kaimportoldialog.h" | 147 | #include "kaimportoldialog.h" |
146 | #else | 148 | #else |
147 | #include <unistd.h> | 149 | #include <unistd.h> |
148 | #endif | 150 | #endif |
149 | // sync includes | 151 | // sync includes |
150 | #include <libkdepim/ksyncprofile.h> | 152 | #include <libkdepim/ksyncprofile.h> |
151 | #include <libkdepim/ksyncprefsdialog.h> | 153 | #include <libkdepim/ksyncprefsdialog.h> |
152 | 154 | ||
153 | 155 | ||
154 | bool pasteWithNewUid = true; | 156 | bool pasteWithNewUid = true; |
155 | 157 | ||
156 | #ifdef KAB_EMBEDDED | 158 | #ifdef KAB_EMBEDDED |
157 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 159 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
158 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 160 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
159 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 161 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
160 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 162 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
161 | #else //KAB_EMBEDDED | 163 | #else //KAB_EMBEDDED |
162 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 164 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
163 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 165 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
164 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 166 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
165 | mReadWrite( readWrite ), mModified( false ) | 167 | mReadWrite( readWrite ), mModified( false ) |
166 | #endif //KAB_EMBEDDED | 168 | #endif //KAB_EMBEDDED |
167 | { | 169 | { |
168 | 170 | ||
169 | mBlockSaveFlag = false; | 171 | mBlockSaveFlag = false; |
170 | mExtensionBarSplitter = 0; | 172 | mExtensionBarSplitter = 0; |
171 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 173 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
172 | 174 | ||
173 | mAddressBook = KABC::StdAddressBook::self(); | 175 | mAddressBook = KABC::StdAddressBook::self(); |
174 | KABC::StdAddressBook::setAutomaticSave( false ); | 176 | KABC::StdAddressBook::setAutomaticSave( false ); |
175 | 177 | ||
176 | #ifndef KAB_EMBEDDED | 178 | #ifndef KAB_EMBEDDED |
177 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 179 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
178 | #endif //KAB_EMBEDDED | 180 | #endif //KAB_EMBEDDED |
179 | 181 | ||
180 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 182 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
181 | SLOT( addressBookChanged() ) ); | 183 | SLOT( addressBookChanged() ) ); |
182 | 184 | ||
183 | #if 0 | 185 | #if 0 |
184 | // LP moved to addressbook init method | 186 | // LP moved to addressbook init method |
185 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 187 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
186 | "X-Department", "KADDRESSBOOK" ); | 188 | "X-Department", "KADDRESSBOOK" ); |
187 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 189 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
188 | "X-Profession", "KADDRESSBOOK" ); | 190 | "X-Profession", "KADDRESSBOOK" ); |
189 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 191 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
190 | "X-AssistantsName", "KADDRESSBOOK" ); | 192 | "X-AssistantsName", "KADDRESSBOOK" ); |
191 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 193 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
192 | "X-ManagersName", "KADDRESSBOOK" ); | 194 | "X-ManagersName", "KADDRESSBOOK" ); |
193 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 195 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
194 | "X-SpousesName", "KADDRESSBOOK" ); | 196 | "X-SpousesName", "KADDRESSBOOK" ); |
195 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 197 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
196 | "X-Office", "KADDRESSBOOK" ); | 198 | "X-Office", "KADDRESSBOOK" ); |
197 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 199 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
198 | "X-IMAddress", "KADDRESSBOOK" ); | 200 | "X-IMAddress", "KADDRESSBOOK" ); |
199 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 201 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
200 | "X-Anniversary", "KADDRESSBOOK" ); | 202 | "X-Anniversary", "KADDRESSBOOK" ); |
201 | 203 | ||
202 | //US added this field to become compatible with Opie/qtopia addressbook | 204 | //US added this field to become compatible with Opie/qtopia addressbook |
203 | // values can be "female" or "male" or "". An empty field represents undefined. | 205 | // values can be "female" or "male" or "". An empty field represents undefined. |
204 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 206 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
205 | "X-Gender", "KADDRESSBOOK" ); | 207 | "X-Gender", "KADDRESSBOOK" ); |
206 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 208 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
207 | "X-Children", "KADDRESSBOOK" ); | 209 | "X-Children", "KADDRESSBOOK" ); |
208 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 210 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
209 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 211 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
210 | #endif | 212 | #endif |
211 | initGUI(); | 213 | initGUI(); |
212 | 214 | ||
213 | mIncSearchWidget->setFocus(); | 215 | mIncSearchWidget->setFocus(); |
214 | 216 | ||
215 | 217 | ||
216 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 218 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
217 | SLOT( setContactSelected( const QString& ) ) ); | 219 | SLOT( setContactSelected( const QString& ) ) ); |
218 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 220 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
219 | SLOT( executeContact( const QString& ) ) ); | 221 | SLOT( executeContact( const QString& ) ) ); |
220 | 222 | ||
221 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 223 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
222 | SLOT( deleteContacts( ) ) ); | 224 | SLOT( deleteContacts( ) ) ); |
223 | connect( mViewManager, SIGNAL( modified() ), | 225 | connect( mViewManager, SIGNAL( modified() ), |
224 | SLOT( setModified() ) ); | 226 | SLOT( setModified() ) ); |
225 | 227 | ||
226 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 228 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
227 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 229 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
228 | 230 | ||
229 | connect( mXXPortManager, SIGNAL( modified() ), | 231 | connect( mXXPortManager, SIGNAL( modified() ), |
230 | SLOT( setModified() ) ); | 232 | SLOT( setModified() ) ); |
231 | 233 | ||
232 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 234 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
233 | SLOT( incrementalSearch( const QString& ) ) ); | 235 | SLOT( incrementalSearch( const QString& ) ) ); |
234 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 236 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
235 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 237 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
236 | 238 | ||
237 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 239 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
238 | SLOT( sendMail( const QString& ) ) ); | 240 | SLOT( sendMail( const QString& ) ) ); |
239 | 241 | ||
240 | 242 | ||
241 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 243 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
242 | 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&))); | 244 | 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&))); |
243 | 245 | ||
244 | 246 | ||
245 | #ifndef KAB_EMBEDDED | 247 | #ifndef KAB_EMBEDDED |
246 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 248 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
247 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 249 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
248 | 250 | ||
249 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 251 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
250 | SLOT( browse( const QString& ) ) ); | 252 | SLOT( browse( const QString& ) ) ); |
251 | 253 | ||
252 | 254 | ||
253 | mAddressBookService = new KAddressBookService( this ); | 255 | mAddressBookService = new KAddressBookService( this ); |
254 | 256 | ||
255 | #endif //KAB_EMBEDDED | 257 | #endif //KAB_EMBEDDED |
256 | mEditorDialog = 0; | 258 | mEditorDialog = 0; |
257 | createAddresseeEditorDialog( this ); | 259 | createAddresseeEditorDialog( this ); |
258 | setModified( false ); | 260 | setModified( false ); |
259 | } | 261 | } |
260 | 262 | ||
261 | KABCore::~KABCore() | 263 | KABCore::~KABCore() |
262 | { | 264 | { |
263 | // save(); | 265 | // save(); |
264 | //saveSettings(); | 266 | //saveSettings(); |
265 | //KABPrefs::instance()->writeConfig(); | 267 | //KABPrefs::instance()->writeConfig(); |
266 | delete AddresseeConfig::instance(); | 268 | delete AddresseeConfig::instance(); |
267 | mAddressBook = 0; | 269 | mAddressBook = 0; |
268 | KABC::StdAddressBook::close(); | 270 | KABC::StdAddressBook::close(); |
269 | } | 271 | } |
270 | 272 | ||
271 | void KABCore::restoreSettings() | 273 | void KABCore::restoreSettings() |
272 | { | 274 | { |
273 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 275 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
274 | 276 | ||
275 | bool state; | 277 | bool state; |
276 | 278 | ||
277 | if (mMultipleViewsAtOnce) | 279 | if (mMultipleViewsAtOnce) |
278 | state = KABPrefs::instance()->mDetailsPageVisible; | 280 | state = KABPrefs::instance()->mDetailsPageVisible; |
279 | else | 281 | else |
280 | state = false; | 282 | state = false; |
281 | 283 | ||
282 | mActionDetails->setChecked( state ); | 284 | mActionDetails->setChecked( state ); |
283 | setDetailsVisible( state ); | 285 | setDetailsVisible( state ); |
284 | 286 | ||
285 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 287 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
286 | 288 | ||
287 | mActionJumpBar->setChecked( state ); | 289 | mActionJumpBar->setChecked( state ); |
288 | setJumpButtonBarVisible( state ); | 290 | setJumpButtonBarVisible( state ); |
289 | /*US | 291 | /*US |
290 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 292 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
291 | if ( splitterSize.count() == 0 ) { | 293 | if ( splitterSize.count() == 0 ) { |
292 | splitterSize.append( width() / 2 ); | 294 | splitterSize.append( width() / 2 ); |
293 | splitterSize.append( width() / 2 ); | 295 | splitterSize.append( width() / 2 ); |
294 | } | 296 | } |
295 | mMiniSplitter->setSizes( splitterSize ); | 297 | mMiniSplitter->setSizes( splitterSize ); |
296 | if ( mExtensionBarSplitter ) { | 298 | if ( mExtensionBarSplitter ) { |
297 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 299 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
298 | if ( splitterSize.count() == 0 ) { | 300 | if ( splitterSize.count() == 0 ) { |
299 | splitterSize.append( width() / 2 ); | 301 | splitterSize.append( width() / 2 ); |
300 | splitterSize.append( width() / 2 ); | 302 | splitterSize.append( width() / 2 ); |
301 | } | 303 | } |
302 | mExtensionBarSplitter->setSizes( splitterSize ); | 304 | mExtensionBarSplitter->setSizes( splitterSize ); |
303 | 305 | ||
304 | } | 306 | } |
305 | */ | 307 | */ |
306 | mViewManager->restoreSettings(); | 308 | mViewManager->restoreSettings(); |
307 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 309 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
308 | mExtensionManager->restoreSettings(); | 310 | mExtensionManager->restoreSettings(); |
309 | #ifdef DESKTOP_VERSION | 311 | #ifdef DESKTOP_VERSION |
310 | int wid = width(); | 312 | int wid = width(); |
311 | if ( wid < 10 ) | 313 | if ( wid < 10 ) |
312 | wid = 400; | 314 | wid = 400; |
313 | #else | 315 | #else |
314 | int wid = QApplication::desktop()->width(); | 316 | int wid = QApplication::desktop()->width(); |
315 | if ( wid < 640 ) | 317 | if ( wid < 640 ) |
316 | wid = QApplication::desktop()->height(); | 318 | wid = QApplication::desktop()->height(); |
317 | #endif | 319 | #endif |
318 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 320 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
319 | if ( true /*splitterSize.count() == 0*/ ) { | 321 | if ( true /*splitterSize.count() == 0*/ ) { |
320 | splitterSize.append( wid / 2 ); | 322 | splitterSize.append( wid / 2 ); |
321 | splitterSize.append( wid / 2 ); | 323 | splitterSize.append( wid / 2 ); |
322 | } | 324 | } |
323 | mMiniSplitter->setSizes( splitterSize ); | 325 | mMiniSplitter->setSizes( splitterSize ); |
324 | if ( mExtensionBarSplitter ) { | 326 | if ( mExtensionBarSplitter ) { |
325 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 327 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
326 | if ( true /*splitterSize.count() == 0*/ ) { | 328 | if ( true /*splitterSize.count() == 0*/ ) { |
327 | splitterSize.append( wid / 2 ); | 329 | splitterSize.append( wid / 2 ); |
328 | splitterSize.append( wid / 2 ); | 330 | splitterSize.append( wid / 2 ); |
329 | } | 331 | } |
330 | mExtensionBarSplitter->setSizes( splitterSize ); | 332 | mExtensionBarSplitter->setSizes( splitterSize ); |
331 | 333 | ||
332 | } | 334 | } |
333 | 335 | ||
334 | 336 | ||
335 | } | 337 | } |
336 | 338 | ||
337 | void KABCore::saveSettings() | 339 | void KABCore::saveSettings() |
338 | { | 340 | { |
339 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 341 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
340 | if ( mExtensionBarSplitter ) | 342 | if ( mExtensionBarSplitter ) |
341 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 343 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
342 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 344 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
343 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 345 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
344 | #ifndef KAB_EMBEDDED | 346 | #ifndef KAB_EMBEDDED |
345 | 347 | ||
346 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 348 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
347 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 349 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
348 | #endif //KAB_EMBEDDED | 350 | #endif //KAB_EMBEDDED |
349 | mExtensionManager->saveSettings(); | 351 | mExtensionManager->saveSettings(); |
350 | mViewManager->saveSettings(); | 352 | mViewManager->saveSettings(); |
351 | 353 | ||
352 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 354 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
353 | } | 355 | } |
354 | 356 | ||
355 | KABC::AddressBook *KABCore::addressBook() const | 357 | KABC::AddressBook *KABCore::addressBook() const |
356 | { | 358 | { |
357 | return mAddressBook; | 359 | return mAddressBook; |
358 | } | 360 | } |
359 | 361 | ||
360 | KConfig *KABCore::config() | 362 | KConfig *KABCore::config() |
361 | { | 363 | { |
362 | #ifndef KAB_EMBEDDED | 364 | #ifndef KAB_EMBEDDED |
363 | return KABPrefs::instance()->config(); | 365 | return KABPrefs::instance()->config(); |
364 | #else //KAB_EMBEDDED | 366 | #else //KAB_EMBEDDED |
365 | return KABPrefs::instance()->getConfig(); | 367 | return KABPrefs::instance()->getConfig(); |
366 | #endif //KAB_EMBEDDED | 368 | #endif //KAB_EMBEDDED |
367 | } | 369 | } |
368 | 370 | ||
369 | KActionCollection *KABCore::actionCollection() const | 371 | KActionCollection *KABCore::actionCollection() const |
370 | { | 372 | { |
371 | return mGUIClient->actionCollection(); | 373 | return mGUIClient->actionCollection(); |
372 | } | 374 | } |
373 | 375 | ||
374 | KABC::Field *KABCore::currentSearchField() const | 376 | KABC::Field *KABCore::currentSearchField() const |
375 | { | 377 | { |
376 | if (mIncSearchWidget) | 378 | if (mIncSearchWidget) |
377 | return mIncSearchWidget->currentField(); | 379 | return mIncSearchWidget->currentField(); |
378 | else | 380 | else |
379 | return 0; | 381 | return 0; |
380 | } | 382 | } |
381 | 383 | ||
382 | QStringList KABCore::selectedUIDs() const | 384 | QStringList KABCore::selectedUIDs() const |
383 | { | 385 | { |
384 | return mViewManager->selectedUids(); | 386 | return mViewManager->selectedUids(); |
385 | } | 387 | } |
386 | 388 | ||
387 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 389 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
388 | { | 390 | { |
389 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 391 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
390 | 392 | ||
391 | QPtrList<KRES::Resource> kresResources; | 393 | QPtrList<KRES::Resource> kresResources; |
392 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 394 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
393 | KABC::Resource *resource; | 395 | KABC::Resource *resource; |
394 | while ( ( resource = resIt.current() ) != 0 ) { | 396 | while ( ( resource = resIt.current() ) != 0 ) { |
395 | ++resIt; | 397 | ++resIt; |
396 | if ( !resource->readOnly() ) { | 398 | if ( !resource->readOnly() ) { |
397 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 399 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
398 | if ( res ) | 400 | if ( res ) |
399 | kresResources.append( res ); | 401 | kresResources.append( res ); |
400 | } | 402 | } |
401 | } | 403 | } |
402 | 404 | ||
403 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 405 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
404 | return static_cast<KABC::Resource*>( res ); | 406 | return static_cast<KABC::Resource*>( res ); |
405 | } | 407 | } |
406 | 408 | ||
407 | #ifndef KAB_EMBEDDED | 409 | #ifndef KAB_EMBEDDED |
408 | KAboutData *KABCore::createAboutData() | 410 | KAboutData *KABCore::createAboutData() |
409 | #else //KAB_EMBEDDED | 411 | #else //KAB_EMBEDDED |
410 | void KABCore::createAboutData() | 412 | void KABCore::createAboutData() |
411 | #endif //KAB_EMBEDDED | 413 | #endif //KAB_EMBEDDED |
412 | { | 414 | { |
413 | #ifndef KAB_EMBEDDED | 415 | #ifndef KAB_EMBEDDED |
414 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 416 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
415 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 417 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
416 | KAboutData::License_GPL_V2, | 418 | KAboutData::License_GPL_V2, |
417 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 419 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
418 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 420 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
419 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 421 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
420 | about->addAuthor( "Cornelius Schumacher", | 422 | about->addAuthor( "Cornelius Schumacher", |
421 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 423 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
422 | "schumacher@kde.org" ); | 424 | "schumacher@kde.org" ); |
423 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 425 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
424 | "mpilone@slac.com" ); | 426 | "mpilone@slac.com" ); |
425 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 427 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
426 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 428 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
427 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 429 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
428 | "michel@klaralvdalens-datakonsult.se" ); | 430 | "michel@klaralvdalens-datakonsult.se" ); |
429 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 431 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
430 | "hansen@kde.org" ); | 432 | "hansen@kde.org" ); |
431 | 433 | ||
432 | return about; | 434 | return about; |
433 | #endif //KAB_EMBEDDED | 435 | #endif //KAB_EMBEDDED |
434 | 436 | ||
435 | QString version; | 437 | QString version; |
436 | #include <../version> | 438 | #include <../version> |
437 | QMessageBox::about( this, "About KAddressbook/Pi", | 439 | QMessageBox::about( this, "About KAddressbook/Pi", |
438 | "KAddressbook/Platform-independent\n" | 440 | "KAddressbook/Platform-independent\n" |
439 | "(KA/Pi) " +version + " - " + | 441 | "(KA/Pi) " +version + " - " + |
440 | #ifdef DESKTOP_VERSION | 442 | #ifdef DESKTOP_VERSION |
441 | "Desktop Edition\n" | 443 | "Desktop Edition\n" |
442 | #else | 444 | #else |
443 | "PDA-Edition\n" | 445 | "PDA-Edition\n" |
444 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 446 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
445 | #endif | 447 | #endif |
446 | 448 | ||
447 | "(c) 2004 Ulf Schenk\n" | 449 | "(c) 2004 Ulf Schenk\n" |
448 | "(c) 2004 Lutz Rogowski\n" | 450 | "(c) 2004 Lutz Rogowski\n" |
449 | "(c) 1997-2003, The KDE PIM Team\n" | 451 | "(c) 1997-2003, The KDE PIM Team\n" |
450 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 452 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
451 | "Don Sanders Original author\n" | 453 | "Don Sanders Original author\n" |
452 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 454 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
453 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 455 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
454 | "Greg Stern DCOP interface\n" | 456 | "Greg Stern DCOP interface\n" |
455 | "Mark Westcot Contact pinning\n" | 457 | "Mark Westcot Contact pinning\n" |
456 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 458 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
457 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 459 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
458 | #ifdef _WIN32_ | 460 | #ifdef _WIN32_ |
459 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 461 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
460 | #endif | 462 | #endif |
461 | ); | 463 | ); |
462 | } | 464 | } |
463 | 465 | ||
464 | void KABCore::setContactSelected( const QString &uid ) | 466 | void KABCore::setContactSelected( const QString &uid ) |
465 | { | 467 | { |
466 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 468 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
467 | if ( !mDetails->isHidden() ) | 469 | if ( !mDetails->isHidden() ) |
468 | mDetails->setAddressee( addr ); | 470 | mDetails->setAddressee( addr ); |
469 | 471 | ||
470 | if ( !addr.isEmpty() ) { | 472 | if ( !addr.isEmpty() ) { |
471 | emit contactSelected( addr.formattedName() ); | 473 | emit contactSelected( addr.formattedName() ); |
472 | KABC::Picture pic = addr.photo(); | 474 | KABC::Picture pic = addr.photo(); |
473 | if ( pic.isIntern() ) { | 475 | if ( pic.isIntern() ) { |
474 | //US emit contactSelected( pic.data() ); | 476 | //US emit contactSelected( pic.data() ); |
475 | //US instead use: | 477 | //US instead use: |
476 | QPixmap px; | 478 | QPixmap px; |
477 | if (pic.data().isNull() != true) | 479 | if (pic.data().isNull() != true) |
478 | { | 480 | { |
479 | px.convertFromImage(pic.data()); | 481 | px.convertFromImage(pic.data()); |
480 | } | 482 | } |
481 | 483 | ||
482 | emit contactSelected( px ); | 484 | emit contactSelected( px ); |
483 | } | 485 | } |
484 | } | 486 | } |
485 | 487 | ||
486 | 488 | ||
487 | mExtensionManager->setSelectionChanged(); | 489 | mExtensionManager->setSelectionChanged(); |
488 | 490 | ||
489 | // update the actions | 491 | // update the actions |
490 | bool selected = !uid.isEmpty(); | 492 | bool selected = !uid.isEmpty(); |
491 | 493 | ||
492 | if ( mReadWrite ) { | 494 | if ( mReadWrite ) { |
493 | mActionCut->setEnabled( selected ); | 495 | mActionCut->setEnabled( selected ); |
494 | mActionPaste->setEnabled( selected ); | 496 | mActionPaste->setEnabled( selected ); |
495 | } | 497 | } |
496 | 498 | ||
497 | mActionCopy->setEnabled( selected ); | 499 | mActionCopy->setEnabled( selected ); |
498 | mActionDelete->setEnabled( selected ); | 500 | mActionDelete->setEnabled( selected ); |
499 | mActionEditAddressee->setEnabled( selected ); | 501 | mActionEditAddressee->setEnabled( selected ); |
500 | mActionMail->setEnabled( selected ); | 502 | mActionMail->setEnabled( selected ); |
501 | mActionMailVCard->setEnabled( selected ); | 503 | mActionMailVCard->setEnabled( selected ); |
502 | //if (mActionBeam) | 504 | //if (mActionBeam) |
503 | //mActionBeam->setEnabled( selected ); | 505 | //mActionBeam->setEnabled( selected ); |
504 | 506 | ||
505 | if (mActionBeamVCard) | 507 | if (mActionBeamVCard) |
506 | mActionBeamVCard->setEnabled( selected ); | 508 | mActionBeamVCard->setEnabled( selected ); |
507 | 509 | ||
508 | mActionWhoAmI->setEnabled( selected ); | 510 | mActionWhoAmI->setEnabled( selected ); |
509 | mActionCategories->setEnabled( selected ); | 511 | mActionCategories->setEnabled( selected ); |
510 | } | 512 | } |
511 | 513 | ||
512 | void KABCore::sendMail() | 514 | void KABCore::sendMail() |
513 | { | 515 | { |
514 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 516 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
515 | } | 517 | } |
516 | 518 | ||
517 | void KABCore::sendMail( const QString& emaillist ) | 519 | void KABCore::sendMail( const QString& emaillist ) |
518 | { | 520 | { |
519 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 521 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
520 | if (emaillist.contains(",") > 0) | 522 | if (emaillist.contains(",") > 0) |
521 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 523 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
522 | else | 524 | else |
523 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 525 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
524 | } | 526 | } |
525 | 527 | ||
526 | 528 | ||
527 | 529 | ||
528 | void KABCore::mailVCard() | 530 | void KABCore::mailVCard() |
529 | { | 531 | { |
530 | QStringList uids = mViewManager->selectedUids(); | 532 | QStringList uids = mViewManager->selectedUids(); |
531 | if ( !uids.isEmpty() ) | 533 | if ( !uids.isEmpty() ) |
532 | mailVCard( uids ); | 534 | mailVCard( uids ); |
533 | } | 535 | } |
534 | 536 | ||
535 | void KABCore::mailVCard( const QStringList& uids ) | 537 | void KABCore::mailVCard( const QStringList& uids ) |
536 | { | 538 | { |
537 | QStringList urls; | 539 | QStringList urls; |
538 | 540 | ||
539 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 541 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
540 | 542 | ||
541 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 543 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
542 | 544 | ||
543 | 545 | ||
544 | 546 | ||
545 | QDir().mkdir( dirName, true ); | 547 | QDir().mkdir( dirName, true ); |
546 | 548 | ||
547 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 549 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
548 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 550 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
549 | 551 | ||
550 | if ( a.isEmpty() ) | 552 | if ( a.isEmpty() ) |
551 | continue; | 553 | continue; |
552 | 554 | ||
553 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 555 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
554 | 556 | ||
555 | QString fileName = dirName + "/" + name; | 557 | QString fileName = dirName + "/" + name; |
556 | 558 | ||
557 | QFile outFile(fileName); | 559 | QFile outFile(fileName); |
558 | 560 | ||
559 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 561 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
560 | KABC::VCardConverter converter; | 562 | KABC::VCardConverter converter; |
561 | QString vcard; | 563 | QString vcard; |
562 | 564 | ||
563 | converter.addresseeToVCard( a, vcard ); | 565 | converter.addresseeToVCard( a, vcard ); |
564 | 566 | ||
565 | QTextStream t( &outFile ); // use a text stream | 567 | QTextStream t( &outFile ); // use a text stream |
566 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 568 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
567 | t << vcard; | 569 | t << vcard; |
568 | 570 | ||
569 | outFile.close(); | 571 | outFile.close(); |
570 | 572 | ||
571 | urls.append( fileName ); | 573 | urls.append( fileName ); |
572 | } | 574 | } |
573 | } | 575 | } |
574 | 576 | ||
575 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 577 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
576 | 578 | ||
577 | 579 | ||
578 | /*US | 580 | /*US |
579 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 581 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
580 | QString::null, // subject | 582 | QString::null, // subject |
581 | QString::null, // body | 583 | QString::null, // body |
582 | QString::null, | 584 | QString::null, |
583 | urls ); // attachments | 585 | urls ); // attachments |
584 | */ | 586 | */ |
585 | 587 | ||
586 | } | 588 | } |
587 | 589 | ||
588 | /** | 590 | /** |
589 | Beams the "WhoAmI contact. | 591 | Beams the "WhoAmI contact. |
590 | */ | 592 | */ |
591 | void KABCore::beamMySelf() | 593 | void KABCore::beamMySelf() |
592 | { | 594 | { |
593 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 595 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
594 | if (!a.isEmpty()) | 596 | if (!a.isEmpty()) |
595 | { | 597 | { |
596 | QStringList uids; | 598 | QStringList uids; |
597 | uids << a.uid(); | 599 | uids << a.uid(); |
598 | 600 | ||
599 | beamVCard(uids); | 601 | beamVCard(uids); |
600 | } else { | 602 | } else { |
601 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 603 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
602 | 604 | ||
603 | 605 | ||
604 | } | 606 | } |
605 | } | 607 | } |
606 | 608 | ||
607 | void KABCore::beamVCard() | 609 | void KABCore::beamVCard() |
608 | { | 610 | { |
609 | QStringList uids = mViewManager->selectedUids(); | 611 | QStringList uids = mViewManager->selectedUids(); |
610 | if ( !uids.isEmpty() ) | 612 | if ( !uids.isEmpty() ) |
611 | beamVCard( uids ); | 613 | beamVCard( uids ); |
612 | } | 614 | } |
613 | 615 | ||
614 | 616 | ||
615 | void KABCore::beamVCard(const QStringList& uids) | 617 | void KABCore::beamVCard(const QStringList& uids) |
616 | { | 618 | { |
617 | /*US | 619 | /*US |
618 | QString beamFilename; | 620 | QString beamFilename; |
619 | Opie::OPimContact c; | 621 | Opie::OPimContact c; |
620 | if ( actionPersonal->isOn() ) { | 622 | if ( actionPersonal->isOn() ) { |
621 | beamFilename = addressbookPersonalVCardName(); | 623 | beamFilename = addressbookPersonalVCardName(); |
622 | if ( !QFile::exists( beamFilename ) ) | 624 | if ( !QFile::exists( beamFilename ) ) |
623 | return; // can't beam a non-existent file | 625 | return; // can't beam a non-existent file |
624 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 626 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
625 | beamFilename ); | 627 | beamFilename ); |
626 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 628 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
627 | Opie::OPimContactAccess::List allList = access->allRecords(); | 629 | Opie::OPimContactAccess::List allList = access->allRecords(); |
628 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 630 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
629 | c = *it; | 631 | c = *it; |
630 | 632 | ||
631 | delete access; | 633 | delete access; |
632 | } else { | 634 | } else { |
633 | unlink( beamfile ); // delete if exists | 635 | unlink( beamfile ); // delete if exists |
634 | mkdir("/tmp/obex/", 0755); | 636 | mkdir("/tmp/obex/", 0755); |
635 | c = m_abView -> currentEntry(); | 637 | c = m_abView -> currentEntry(); |
636 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 638 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
637 | beamfile ); | 639 | beamfile ); |
638 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 640 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
639 | access->add( c ); | 641 | access->add( c ); |
640 | access->save(); | 642 | access->save(); |
641 | delete access; | 643 | delete access; |
642 | 644 | ||
643 | beamFilename = beamfile; | 645 | beamFilename = beamfile; |
644 | } | 646 | } |
645 | 647 | ||
646 | owarn << "Beaming: " << beamFilename << oendl; | 648 | owarn << "Beaming: " << beamFilename << oendl; |
647 | */ | 649 | */ |
648 | 650 | ||
649 | #if 0 | 651 | #if 0 |
650 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 652 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
651 | 653 | ||
652 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 654 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
653 | 655 | ||
654 | QString name = "contact.vcf"; | 656 | QString name = "contact.vcf"; |
655 | 657 | ||
656 | QString fileName = dirName + "/" + name; | 658 | QString fileName = dirName + "/" + name; |
657 | #endif | 659 | #endif |
658 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 660 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
659 | // | 661 | // |
660 | QString fileName = "/tmp/kapibeamfile.vcf"; | 662 | QString fileName = "/tmp/kapibeamfile.vcf"; |
661 | 663 | ||
662 | 664 | ||
663 | //QDir().mkdir( dirName, true ); | 665 | //QDir().mkdir( dirName, true ); |
664 | 666 | ||
665 | 667 | ||
666 | KABC::VCardConverter converter; | 668 | KABC::VCardConverter converter; |
667 | QString description; | 669 | QString description; |
668 | QString datastream; | 670 | QString datastream; |
669 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 671 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
670 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 672 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
671 | 673 | ||
672 | if ( a.isEmpty() ) | 674 | if ( a.isEmpty() ) |
673 | continue; | 675 | continue; |
674 | 676 | ||
675 | if (description.isEmpty()) | 677 | if (description.isEmpty()) |
676 | description = a.formattedName(); | 678 | description = a.formattedName(); |
677 | 679 | ||
678 | QString vcard; | 680 | QString vcard; |
679 | converter.addresseeToVCard( a, vcard ); | 681 | converter.addresseeToVCard( a, vcard ); |
680 | int start = 0; | 682 | int start = 0; |
681 | int next; | 683 | int next; |
682 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 684 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
683 | int semi = vcard.find(";", next); | 685 | int semi = vcard.find(";", next); |
684 | int dopp = vcard.find(":", next); | 686 | int dopp = vcard.find(":", next); |
685 | int sep; | 687 | int sep; |
686 | if ( semi < dopp && semi >= 0 ) | 688 | if ( semi < dopp && semi >= 0 ) |
687 | sep = semi ; | 689 | sep = semi ; |
688 | else | 690 | else |
689 | sep = dopp; | 691 | sep = dopp; |
690 | datastream +=vcard.mid( start, next - start); | 692 | datastream +=vcard.mid( start, next - start); |
691 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 693 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
692 | start = sep; | 694 | start = sep; |
693 | } | 695 | } |
694 | datastream += vcard.mid( start,vcard.length() ); | 696 | datastream += vcard.mid( start,vcard.length() ); |
695 | } | 697 | } |
696 | #ifndef DESKTOP_VERSION | 698 | #ifndef DESKTOP_VERSION |
697 | QFile outFile(fileName); | 699 | QFile outFile(fileName); |
698 | if ( outFile.open(IO_WriteOnly) ) { | 700 | if ( outFile.open(IO_WriteOnly) ) { |
699 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 701 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
700 | QTextStream t( &outFile ); // use a text stream | 702 | QTextStream t( &outFile ); // use a text stream |
701 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 703 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
702 | t <<datastream; | 704 | t <<datastream; |
703 | outFile.close(); | 705 | outFile.close(); |
704 | Ir *ir = new Ir( this ); | 706 | Ir *ir = new Ir( this ); |
705 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 707 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
706 | ir->send( fileName, description, "text/x-vCard" ); | 708 | ir->send( fileName, description, "text/x-vCard" ); |
707 | } else { | 709 | } else { |
708 | qDebug("Error open temp beam file "); | 710 | qDebug("Error open temp beam file "); |
709 | return; | 711 | return; |
710 | } | 712 | } |
711 | #endif | 713 | #endif |
712 | 714 | ||
713 | } | 715 | } |
714 | 716 | ||
715 | void KABCore::beamDone( Ir *ir ) | 717 | void KABCore::beamDone( Ir *ir ) |
716 | { | 718 | { |
717 | #ifndef DESKTOP_VERSION | 719 | #ifndef DESKTOP_VERSION |
718 | delete ir; | 720 | delete ir; |
719 | #endif | 721 | #endif |
720 | } | 722 | } |
721 | 723 | ||
722 | 724 | ||
723 | void KABCore::browse( const QString& url ) | 725 | void KABCore::browse( const QString& url ) |
724 | { | 726 | { |
725 | #ifndef KAB_EMBEDDED | 727 | #ifndef KAB_EMBEDDED |
726 | kapp->invokeBrowser( url ); | 728 | kapp->invokeBrowser( url ); |
727 | #else //KAB_EMBEDDED | 729 | #else //KAB_EMBEDDED |
728 | qDebug("KABCore::browse must be fixed"); | 730 | qDebug("KABCore::browse must be fixed"); |
729 | #endif //KAB_EMBEDDED | 731 | #endif //KAB_EMBEDDED |
730 | } | 732 | } |
731 | 733 | ||
732 | void KABCore::selectAllContacts() | 734 | void KABCore::selectAllContacts() |
733 | { | 735 | { |
734 | mViewManager->setSelected( QString::null, true ); | 736 | mViewManager->setSelected( QString::null, true ); |
735 | } | 737 | } |
736 | 738 | ||
737 | void KABCore::deleteContacts() | 739 | void KABCore::deleteContacts() |
738 | { | 740 | { |
739 | QStringList uidList = mViewManager->selectedUids(); | 741 | QStringList uidList = mViewManager->selectedUids(); |
740 | deleteContacts( uidList ); | 742 | deleteContacts( uidList ); |
741 | } | 743 | } |
742 | 744 | ||
743 | void KABCore::deleteContacts( const QStringList &uids ) | 745 | void KABCore::deleteContacts( const QStringList &uids ) |
744 | { | 746 | { |
745 | if ( uids.count() > 0 ) { | 747 | if ( uids.count() > 0 ) { |
746 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 748 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
747 | UndoStack::instance()->push( command ); | 749 | UndoStack::instance()->push( command ); |
748 | RedoStack::instance()->clear(); | 750 | RedoStack::instance()->clear(); |
749 | 751 | ||
750 | // now if we deleted anything, refresh | 752 | // now if we deleted anything, refresh |
751 | setContactSelected( QString::null ); | 753 | setContactSelected( QString::null ); |
752 | setModified( true ); | 754 | setModified( true ); |
753 | } | 755 | } |
754 | } | 756 | } |
755 | 757 | ||
756 | void KABCore::copyContacts() | 758 | void KABCore::copyContacts() |
757 | { | 759 | { |
758 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 760 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
759 | 761 | ||
760 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 762 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
761 | 763 | ||
762 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 764 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
763 | 765 | ||
764 | QClipboard *cb = QApplication::clipboard(); | 766 | QClipboard *cb = QApplication::clipboard(); |
765 | cb->setText( clipText ); | 767 | cb->setText( clipText ); |
766 | } | 768 | } |
767 | 769 | ||
768 | void KABCore::cutContacts() | 770 | void KABCore::cutContacts() |
769 | { | 771 | { |
770 | QStringList uidList = mViewManager->selectedUids(); | 772 | QStringList uidList = mViewManager->selectedUids(); |
771 | 773 | ||
772 | //US if ( uidList.size() > 0 ) { | 774 | //US if ( uidList.size() > 0 ) { |
773 | if ( uidList.count() > 0 ) { | 775 | if ( uidList.count() > 0 ) { |
774 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 776 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
775 | UndoStack::instance()->push( command ); | 777 | UndoStack::instance()->push( command ); |
776 | RedoStack::instance()->clear(); | 778 | RedoStack::instance()->clear(); |
777 | 779 | ||
778 | setModified( true ); | 780 | setModified( true ); |
779 | } | 781 | } |
780 | } | 782 | } |
781 | 783 | ||
782 | void KABCore::pasteContacts() | 784 | void KABCore::pasteContacts() |
783 | { | 785 | { |
784 | QClipboard *cb = QApplication::clipboard(); | 786 | QClipboard *cb = QApplication::clipboard(); |
785 | 787 | ||
786 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 788 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
787 | 789 | ||
788 | pasteContacts( list ); | 790 | pasteContacts( list ); |
789 | } | 791 | } |
790 | 792 | ||
791 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 793 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
792 | { | 794 | { |
793 | KABC::Resource *resource = requestResource( this ); | 795 | KABC::Resource *resource = requestResource( this ); |
794 | KABC::Addressee::List::Iterator it; | 796 | KABC::Addressee::List::Iterator it; |
795 | for ( it = list.begin(); it != list.end(); ++it ) | 797 | for ( it = list.begin(); it != list.end(); ++it ) |
796 | (*it).setResource( resource ); | 798 | (*it).setResource( resource ); |
797 | 799 | ||
798 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 800 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
799 | UndoStack::instance()->push( command ); | 801 | UndoStack::instance()->push( command ); |
800 | RedoStack::instance()->clear(); | 802 | RedoStack::instance()->clear(); |
801 | 803 | ||
802 | setModified( true ); | 804 | setModified( true ); |
803 | } | 805 | } |
804 | 806 | ||
805 | void KABCore::setWhoAmI() | 807 | void KABCore::setWhoAmI() |
806 | { | 808 | { |
807 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 809 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
808 | 810 | ||
809 | if ( addrList.count() > 1 ) { | 811 | if ( addrList.count() > 1 ) { |
@@ -1832,1065 +1834,1041 @@ void KABCore::addActionsManually() | |||
1832 | mActionRedo->plug( editMenu ); | 1834 | mActionRedo->plug( editMenu ); |
1833 | editMenu->insertSeparator(); | 1835 | editMenu->insertSeparator(); |
1834 | mActionCut->plug( editMenu ); | 1836 | mActionCut->plug( editMenu ); |
1835 | mActionCopy->plug( editMenu ); | 1837 | mActionCopy->plug( editMenu ); |
1836 | mActionPaste->plug( editMenu ); | 1838 | mActionPaste->plug( editMenu ); |
1837 | mActionDelete->plug( editMenu ); | 1839 | mActionDelete->plug( editMenu ); |
1838 | editMenu->insertSeparator(); | 1840 | editMenu->insertSeparator(); |
1839 | mActionSelectAll->plug( editMenu ); | 1841 | mActionSelectAll->plug( editMenu ); |
1840 | 1842 | ||
1841 | mActionRemoveVoice->plug( changeMenu ); | 1843 | mActionRemoveVoice->plug( changeMenu ); |
1842 | // settings menu | 1844 | // settings menu |
1843 | //US special menuentry to configure the addressbook resources. On KDE | 1845 | //US special menuentry to configure the addressbook resources. On KDE |
1844 | // you do that through the control center !!! | 1846 | // you do that through the control center !!! |
1845 | mActionConfigResources->plug( settingsMenu ); | 1847 | mActionConfigResources->plug( settingsMenu ); |
1846 | settingsMenu->insertSeparator(); | 1848 | settingsMenu->insertSeparator(); |
1847 | 1849 | ||
1848 | mActionConfigKAddressbook->plug( settingsMenu ); | 1850 | mActionConfigKAddressbook->plug( settingsMenu ); |
1849 | 1851 | ||
1850 | if ( mIsPart ) { | 1852 | if ( mIsPart ) { |
1851 | mActionConfigShortcuts->plug( settingsMenu ); | 1853 | mActionConfigShortcuts->plug( settingsMenu ); |
1852 | mActionConfigureToolbars->plug( settingsMenu ); | 1854 | mActionConfigureToolbars->plug( settingsMenu ); |
1853 | 1855 | ||
1854 | } else { | 1856 | } else { |
1855 | mActionKeyBindings->plug( settingsMenu ); | 1857 | mActionKeyBindings->plug( settingsMenu ); |
1856 | } | 1858 | } |
1857 | 1859 | ||
1858 | settingsMenu->insertSeparator(); | 1860 | settingsMenu->insertSeparator(); |
1859 | 1861 | ||
1860 | mActionJumpBar->plug( settingsMenu ); | 1862 | mActionJumpBar->plug( settingsMenu ); |
1861 | mActionDetails->plug( settingsMenu ); | 1863 | mActionDetails->plug( settingsMenu ); |
1862 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1864 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1863 | mActionDetails->plug( tb ); | 1865 | mActionDetails->plug( tb ); |
1864 | settingsMenu->insertSeparator(); | 1866 | settingsMenu->insertSeparator(); |
1865 | 1867 | ||
1866 | mActionWhoAmI->plug( settingsMenu ); | 1868 | mActionWhoAmI->plug( settingsMenu ); |
1867 | mActionCategories->plug( settingsMenu ); | 1869 | mActionCategories->plug( settingsMenu ); |
1868 | 1870 | ||
1869 | mActionLicence->plug( helpMenu ); | 1871 | mActionLicence->plug( helpMenu ); |
1870 | mActionFaq->plug( helpMenu ); | 1872 | mActionFaq->plug( helpMenu ); |
1871 | mActionAboutKAddressbook->plug( helpMenu ); | 1873 | mActionAboutKAddressbook->plug( helpMenu ); |
1872 | 1874 | ||
1873 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1875 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1874 | 1876 | ||
1875 | mActionSave->plug( tb ); | 1877 | mActionSave->plug( tb ); |
1876 | mViewManager->getFilterAction()->plug ( tb); | 1878 | mViewManager->getFilterAction()->plug ( tb); |
1877 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1879 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1878 | mActionUndo->plug( tb ); | 1880 | mActionUndo->plug( tb ); |
1879 | mActionDelete->plug( tb ); | 1881 | mActionDelete->plug( tb ); |
1880 | mActionRedo->plug( tb ); | 1882 | mActionRedo->plug( tb ); |
1881 | } | 1883 | } |
1882 | } | 1884 | } |
1883 | //mActionQuit->plug ( tb ); | 1885 | //mActionQuit->plug ( tb ); |
1884 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1886 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1885 | 1887 | ||
1886 | //US link the searchwidget first to this. | 1888 | //US link the searchwidget first to this. |
1887 | // The real linkage to the toolbar happens later. | 1889 | // The real linkage to the toolbar happens later. |
1888 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1890 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1889 | //US tb->insertItem( mIncSearchWidget ); | 1891 | //US tb->insertItem( mIncSearchWidget ); |
1890 | /*US | 1892 | /*US |
1891 | mIncSearchWidget = new IncSearchWidget( tb ); | 1893 | mIncSearchWidget = new IncSearchWidget( tb ); |
1892 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1894 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1893 | SLOT( incrementalSearch( const QString& ) ) ); | 1895 | SLOT( incrementalSearch( const QString& ) ) ); |
1894 | 1896 | ||
1895 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1897 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1896 | 1898 | ||
1897 | //US topLayout->addWidget( mJumpButtonBar ); | 1899 | //US topLayout->addWidget( mJumpButtonBar ); |
1898 | this->layout()->add( mJumpButtonBar ); | 1900 | this->layout()->add( mJumpButtonBar ); |
1899 | */ | 1901 | */ |
1900 | 1902 | ||
1901 | #endif //KAB_EMBEDDED | 1903 | #endif //KAB_EMBEDDED |
1902 | 1904 | ||
1903 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 1905 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
1904 | fillSyncMenu(); | 1906 | fillSyncMenu(); |
1905 | 1907 | ||
1906 | } | 1908 | } |
1907 | void KABCore::showLicence() | 1909 | void KABCore::showLicence() |
1908 | { | 1910 | { |
1909 | KApplication::showLicence(); | 1911 | KApplication::showLicence(); |
1910 | } | 1912 | } |
1911 | void KABCore::removeVoice() | 1913 | void KABCore::removeVoice() |
1912 | { | 1914 | { |
1913 | 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 ) | 1915 | 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 ) |
1914 | return; | 1916 | return; |
1915 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1917 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1916 | KABC::Addressee::List::Iterator it; | 1918 | KABC::Addressee::List::Iterator it; |
1917 | for ( it = list.begin(); it != list.end(); ++it ) { | 1919 | for ( it = list.begin(); it != list.end(); ++it ) { |
1918 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1920 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1919 | PhoneNumber::List::Iterator phoneIt; | 1921 | PhoneNumber::List::Iterator phoneIt; |
1920 | bool found = false; | 1922 | bool found = false; |
1921 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1923 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1922 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1924 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1923 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1925 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1924 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1926 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1925 | (*it).insertPhoneNumber( (*phoneIt) ); | 1927 | (*it).insertPhoneNumber( (*phoneIt) ); |
1926 | found = true; | 1928 | found = true; |
1927 | } | 1929 | } |
1928 | } | 1930 | } |
1929 | 1931 | ||
1930 | } | 1932 | } |
1931 | if ( found ) | 1933 | if ( found ) |
1932 | contactModified((*it) ); | 1934 | contactModified((*it) ); |
1933 | } | 1935 | } |
1934 | } | 1936 | } |
1935 | 1937 | ||
1936 | 1938 | ||
1937 | 1939 | ||
1938 | void KABCore::clipboardDataChanged() | 1940 | void KABCore::clipboardDataChanged() |
1939 | { | 1941 | { |
1940 | 1942 | ||
1941 | if ( mReadWrite ) | 1943 | if ( mReadWrite ) |
1942 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1944 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1943 | 1945 | ||
1944 | } | 1946 | } |
1945 | 1947 | ||
1946 | void KABCore::updateActionMenu() | 1948 | void KABCore::updateActionMenu() |
1947 | { | 1949 | { |
1948 | UndoStack *undo = UndoStack::instance(); | 1950 | UndoStack *undo = UndoStack::instance(); |
1949 | RedoStack *redo = RedoStack::instance(); | 1951 | RedoStack *redo = RedoStack::instance(); |
1950 | 1952 | ||
1951 | if ( undo->isEmpty() ) | 1953 | if ( undo->isEmpty() ) |
1952 | mActionUndo->setText( i18n( "Undo" ) ); | 1954 | mActionUndo->setText( i18n( "Undo" ) ); |
1953 | else | 1955 | else |
1954 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1956 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1955 | 1957 | ||
1956 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1958 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1957 | 1959 | ||
1958 | if ( !redo->top() ) | 1960 | if ( !redo->top() ) |
1959 | mActionRedo->setText( i18n( "Redo" ) ); | 1961 | mActionRedo->setText( i18n( "Redo" ) ); |
1960 | else | 1962 | else |
1961 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1963 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1962 | 1964 | ||
1963 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1965 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1964 | } | 1966 | } |
1965 | 1967 | ||
1966 | void KABCore::configureKeyBindings() | 1968 | void KABCore::configureKeyBindings() |
1967 | { | 1969 | { |
1968 | #ifndef KAB_EMBEDDED | 1970 | #ifndef KAB_EMBEDDED |
1969 | KKeyDialog::configure( actionCollection(), true ); | 1971 | KKeyDialog::configure( actionCollection(), true ); |
1970 | #else //KAB_EMBEDDED | 1972 | #else //KAB_EMBEDDED |
1971 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1973 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1972 | #endif //KAB_EMBEDDED | 1974 | #endif //KAB_EMBEDDED |
1973 | } | 1975 | } |
1974 | 1976 | ||
1975 | #ifdef KAB_EMBEDDED | 1977 | #ifdef KAB_EMBEDDED |
1976 | void KABCore::configureResources() | 1978 | void KABCore::configureResources() |
1977 | { | 1979 | { |
1978 | KRES::KCMKResources dlg( this, "" , 0 ); | 1980 | KRES::KCMKResources dlg( this, "" , 0 ); |
1979 | 1981 | ||
1980 | if ( !dlg.exec() ) | 1982 | if ( !dlg.exec() ) |
1981 | return; | 1983 | return; |
1982 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1984 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1983 | } | 1985 | } |
1984 | #endif //KAB_EMBEDDED | 1986 | #endif //KAB_EMBEDDED |
1985 | 1987 | ||
1986 | 1988 | ||
1987 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 1989 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
1988 | * for the attendees list of an event. | 1990 | * for the attendees list of an event. |
1989 | */ | 1991 | */ |
1990 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 1992 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
1991 | { | 1993 | { |
1992 | QStringList nameList; | 1994 | QStringList nameList; |
1993 | QStringList emailList; | 1995 | QStringList emailList; |
1994 | QStringList uidList; | 1996 | QStringList uidList; |
1995 | 1997 | ||
1996 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 1998 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
1997 | uint i=0; | 1999 | uint i=0; |
1998 | for (i=0; i < list.count(); i++) | 2000 | for (i=0; i < list.count(); i++) |
1999 | { | 2001 | { |
2000 | nameList.append(list[i].realName()); | 2002 | nameList.append(list[i].realName()); |
2001 | emailList.append(list[i].preferredEmail()); | 2003 | emailList.append(list[i].preferredEmail()); |
2002 | uidList.append(list[i].uid()); | 2004 | uidList.append(list[i].uid()); |
2003 | } | 2005 | } |
2004 | 2006 | ||
2005 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2006 | 2008 | ||
2007 | } | 2009 | } |
2008 | 2010 | ||
2009 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2011 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2010 | */ | 2012 | */ |
2011 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2013 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2012 | { | 2014 | { |
2013 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2015 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2014 | 2016 | ||
2015 | QString foundUid = QString::null; | 2017 | QString foundUid = QString::null; |
2016 | if ( ! uid.isEmpty() ) { | 2018 | if ( ! uid.isEmpty() ) { |
2017 | Addressee adrr = mAddressBook->findByUid( uid ); | 2019 | Addressee adrr = mAddressBook->findByUid( uid ); |
2018 | if ( !adrr.isEmpty() ) { | 2020 | if ( !adrr.isEmpty() ) { |
2019 | foundUid = uid; | 2021 | foundUid = uid; |
2020 | } | 2022 | } |
2021 | if ( email == "sendbacklist" ) { | 2023 | if ( email == "sendbacklist" ) { |
2022 | //qDebug("ssssssssssssssssssssssend "); | 2024 | //qDebug("ssssssssssssssssssssssend "); |
2023 | QStringList nameList; | 2025 | QStringList nameList; |
2024 | QStringList emailList; | 2026 | QStringList emailList; |
2025 | QStringList uidList; | 2027 | QStringList uidList; |
2026 | nameList.append(adrr.realName()); | 2028 | nameList.append(adrr.realName()); |
2027 | emailList = adrr.emails(); | 2029 | emailList = adrr.emails(); |
2028 | uidList.append( adrr.preferredEmail()); | 2030 | uidList.append( adrr.preferredEmail()); |
2029 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2031 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2030 | return; | 2032 | return; |
2031 | } | 2033 | } |
2032 | 2034 | ||
2033 | } | 2035 | } |
2034 | 2036 | ||
2035 | if ( email == "sendbacklist" ) | 2037 | if ( email == "sendbacklist" ) |
2036 | return; | 2038 | return; |
2037 | if (foundUid.isEmpty()) | 2039 | if (foundUid.isEmpty()) |
2038 | { | 2040 | { |
2039 | //find the uid of the person first | 2041 | //find the uid of the person first |
2040 | Addressee::List namelist; | 2042 | Addressee::List namelist; |
2041 | Addressee::List emaillist; | 2043 | Addressee::List emaillist; |
2042 | 2044 | ||
2043 | if (!name.isEmpty()) | 2045 | if (!name.isEmpty()) |
2044 | namelist = mAddressBook->findByName( name ); | 2046 | namelist = mAddressBook->findByName( name ); |
2045 | 2047 | ||
2046 | if (!email.isEmpty()) | 2048 | if (!email.isEmpty()) |
2047 | emaillist = mAddressBook->findByEmail( email ); | 2049 | emaillist = mAddressBook->findByEmail( email ); |
2048 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2050 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2049 | //check if we have a match in Namelist and Emaillist | 2051 | //check if we have a match in Namelist and Emaillist |
2050 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2052 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2051 | foundUid = emaillist[0].uid(); | 2053 | foundUid = emaillist[0].uid(); |
2052 | } | 2054 | } |
2053 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2055 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2054 | foundUid = namelist[0].uid(); | 2056 | foundUid = namelist[0].uid(); |
2055 | else | 2057 | else |
2056 | { | 2058 | { |
2057 | for (int i = 0; i < namelist.count(); i++) | 2059 | for (int i = 0; i < namelist.count(); i++) |
2058 | { | 2060 | { |
2059 | for (int j = 0; j < emaillist.count(); j++) | 2061 | for (int j = 0; j < emaillist.count(); j++) |
2060 | { | 2062 | { |
2061 | if (namelist[i] == emaillist[j]) | 2063 | if (namelist[i] == emaillist[j]) |
2062 | { | 2064 | { |
2063 | foundUid = namelist[i].uid(); | 2065 | foundUid = namelist[i].uid(); |
2064 | } | 2066 | } |
2065 | } | 2067 | } |
2066 | } | 2068 | } |
2067 | } | 2069 | } |
2068 | } | 2070 | } |
2069 | else | 2071 | else |
2070 | { | 2072 | { |
2071 | foundUid = uid; | 2073 | foundUid = uid; |
2072 | } | 2074 | } |
2073 | 2075 | ||
2074 | if (!foundUid.isEmpty()) | 2076 | if (!foundUid.isEmpty()) |
2075 | { | 2077 | { |
2076 | 2078 | ||
2077 | // raise Ka/Pi if it is in the background | 2079 | // raise Ka/Pi if it is in the background |
2078 | #ifndef DESKTOP_VERSION | 2080 | #ifndef DESKTOP_VERSION |
2079 | #ifndef KORG_NODCOP | 2081 | #ifndef KORG_NODCOP |
2080 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2082 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2081 | #endif | 2083 | #endif |
2082 | #endif | 2084 | #endif |
2083 | 2085 | ||
2084 | mMainWindow->showMaximized(); | 2086 | mMainWindow->showMaximized(); |
2085 | mMainWindow-> raise(); | 2087 | mMainWindow-> raise(); |
2086 | 2088 | ||
2087 | mViewManager->setSelected( "", false); | 2089 | mViewManager->setSelected( "", false); |
2088 | mViewManager->refreshView( "" ); | 2090 | mViewManager->refreshView( "" ); |
2089 | mViewManager->setSelected( foundUid, true ); | 2091 | mViewManager->setSelected( foundUid, true ); |
2090 | mViewManager->refreshView( foundUid ); | 2092 | mViewManager->refreshView( foundUid ); |
2091 | 2093 | ||
2092 | if ( !mMultipleViewsAtOnce ) | 2094 | if ( !mMultipleViewsAtOnce ) |
2093 | { | 2095 | { |
2094 | setDetailsVisible( true ); | 2096 | setDetailsVisible( true ); |
2095 | mActionDetails->setChecked(true); | 2097 | mActionDetails->setChecked(true); |
2096 | } | 2098 | } |
2097 | } | 2099 | } |
2098 | } | 2100 | } |
2099 | 2101 | ||
2100 | 2102 | ||
2101 | void KABCore::faq() | 2103 | void KABCore::faq() |
2102 | { | 2104 | { |
2103 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2105 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2104 | } | 2106 | } |
2105 | 2107 | ||
2106 | 2108 | ||
2107 | void KABCore::fillSyncMenu() | 2109 | void KABCore::fillSyncMenu() |
2108 | { | 2110 | { |
2109 | if ( syncMenu->count() ) | 2111 | if ( syncMenu->count() ) |
2110 | syncMenu->clear(); | 2112 | syncMenu->clear(); |
2111 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 2113 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
2112 | syncMenu->insertSeparator(); | 2114 | syncMenu->insertSeparator(); |
2113 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 2115 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
2114 | syncMenu->insertSeparator(); | 2116 | syncMenu->insertSeparator(); |
2115 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2117 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2116 | config.setGroup("General"); | 2118 | config.setGroup("General"); |
2117 | QStringList prof = config.readListEntry("SyncProfileNames"); | 2119 | QStringList prof = config.readListEntry("SyncProfileNames"); |
2118 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 2120 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
2119 | if ( prof.count() < 3 ) { | 2121 | if ( prof.count() < 3 ) { |
2120 | prof.clear(); | 2122 | prof.clear(); |
2121 | prof << i18n("Sharp_DTM"); | 2123 | prof << i18n("Sharp_DTM"); |
2122 | prof << i18n("Local_file"); | 2124 | prof << i18n("Local_file"); |
2123 | prof << i18n("Last_file"); | 2125 | prof << i18n("Last_file"); |
2124 | KSyncProfile* temp = new KSyncProfile (); | 2126 | KSyncProfile* temp = new KSyncProfile (); |
2125 | temp->setName( prof[0] ); | 2127 | temp->setName( prof[0] ); |
2126 | temp->writeConfig(&config); | 2128 | temp->writeConfig(&config); |
2127 | temp->setName( prof[1] ); | 2129 | temp->setName( prof[1] ); |
2128 | temp->writeConfig(&config); | 2130 | temp->writeConfig(&config); |
2129 | temp->setName( prof[2] ); | 2131 | temp->setName( prof[2] ); |
2130 | temp->writeConfig(&config); | 2132 | temp->writeConfig(&config); |
2131 | config.setGroup("General"); | 2133 | config.setGroup("General"); |
2132 | config.writeEntry("SyncProfileNames",prof); | 2134 | config.writeEntry("SyncProfileNames",prof); |
2133 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 2135 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
2134 | config.sync(); | 2136 | config.sync(); |
2135 | delete temp; | 2137 | delete temp; |
2136 | } | 2138 | } |
2137 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 2139 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
2138 | KABPrefs::instance()->mSyncProfileNames = prof; | 2140 | KABPrefs::instance()->mSyncProfileNames = prof; |
2139 | int i; | 2141 | int i; |
2140 | for ( i = 0; i < prof.count(); ++i ) { | 2142 | for ( i = 0; i < prof.count(); ++i ) { |
2141 | 2143 | ||
2142 | syncMenu->insertItem( prof[i], 1000+i ); | 2144 | syncMenu->insertItem( prof[i], 1000+i ); |
2143 | if ( i == 2 ) | 2145 | if ( i == 2 ) |
2144 | syncMenu->insertSeparator(); | 2146 | syncMenu->insertSeparator(); |
2145 | } | 2147 | } |
2146 | QDir app_dir; | 2148 | QDir app_dir; |
2147 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 2149 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
2148 | syncMenu->setItemEnabled( false , 1000 ); | 2150 | syncMenu->setItemEnabled( false , 1000 ); |
2149 | } | 2151 | } |
2150 | //probaly useless | 2152 | //probaly useless |
2151 | //mView->setupExternSyncProfiles(); | 2153 | //mView->setupExternSyncProfiles(); |
2152 | } | 2154 | } |
2153 | void KABCore::slotSyncMenu( int action ) | 2155 | void KABCore::slotSyncMenu( int action ) |
2154 | { | 2156 | { |
2155 | //qDebug("syncaction %d ", action); | 2157 | //qDebug("syncaction %d ", action); |
2156 | if ( action == 0 ) { | 2158 | if ( action == 0 ) { |
2157 | 2159 | ||
2158 | // seems to be a Qt2 event handling bug | 2160 | // seems to be a Qt2 event handling bug |
2159 | // syncmenu.clear causes a segfault at first time | 2161 | // syncmenu.clear causes a segfault at first time |
2160 | // when we call it after the main event loop, it is ok | 2162 | // when we call it after the main event loop, it is ok |
2161 | // same behaviour when calling OM/Pi via QCOP for the first time | 2163 | // same behaviour when calling OM/Pi via QCOP for the first time |
2162 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 2164 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
2163 | //confSync(); | 2165 | //confSync(); |
2164 | 2166 | ||
2165 | return; | 2167 | return; |
2166 | } | 2168 | } |
2167 | if ( action == 1 ) { | 2169 | if ( action == 1 ) { |
2168 | multiSync( true ); | 2170 | multiSync( true ); |
2169 | return; | 2171 | return; |
2170 | } | 2172 | } |
2171 | 2173 | ||
2172 | if (mBlockSaveFlag) | 2174 | if (mBlockSaveFlag) |
2173 | return; | 2175 | return; |
2174 | mBlockSaveFlag = true; | 2176 | mBlockSaveFlag = true; |
2175 | mCurrentSyncProfile = action - 1000 ; | 2177 | mCurrentSyncProfile = action - 1000 ; |
2176 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; | 2178 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; |
2177 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; | 2179 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; |
2178 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2180 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2179 | KSyncProfile* temp = new KSyncProfile (); | 2181 | KSyncProfile* temp = new KSyncProfile (); |
2180 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2182 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2181 | temp->readConfig(&config); | 2183 | temp->readConfig(&config); |
2182 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2184 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2183 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2185 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2184 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2186 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2185 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2187 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2186 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2188 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2187 | if ( temp->getWriteBackFuture() ) | 2189 | if ( temp->getWriteBackFuture() ) |
2188 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2190 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2189 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2191 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2190 | if ( action == 1000 ) { | 2192 | if ( action == 1000 ) { |
2191 | syncSharp(); | 2193 | syncSharp(); |
2192 | 2194 | ||
2193 | } else if ( action == 1001 ) { | 2195 | } else if ( action == 1001 ) { |
2194 | syncLocalFile(); | 2196 | syncLocalFile(); |
2195 | 2197 | ||
2196 | } else if ( action == 1002 ) { | 2198 | } else if ( action == 1002 ) { |
2197 | quickSyncLocalFile(); | 2199 | quickSyncLocalFile(); |
2198 | 2200 | ||
2199 | } else if ( action >= 1003 ) { | 2201 | } else if ( action >= 1003 ) { |
2200 | if ( temp->getIsLocalFileSync() ) { | 2202 | if ( temp->getIsLocalFileSync() ) { |
2201 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 2203 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
2202 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2204 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2203 | } else { | 2205 | } else { |
2204 | if ( temp->getIsPhoneSync() ) { | 2206 | if ( temp->getIsPhoneSync() ) { |
2205 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2207 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2206 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2208 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2207 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2209 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2208 | syncPhone(); | 2210 | syncPhone(); |
2209 | } else | 2211 | } else |
2210 | syncRemote( temp ); | 2212 | syncRemote( temp ); |
2211 | 2213 | ||
2212 | } | 2214 | } |
2213 | } | 2215 | } |
2214 | delete temp; | 2216 | delete temp; |
2215 | mBlockSaveFlag = false; | 2217 | mBlockSaveFlag = false; |
2216 | } | 2218 | } |
2217 | 2219 | ||
2218 | void KABCore::syncLocalFile() | 2220 | void KABCore::syncLocalFile() |
2219 | { | 2221 | { |
2220 | 2222 | ||
2221 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; | 2223 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; |
2222 | 2224 | ||
2223 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2225 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2224 | if ( fn == "" ) | 2226 | if ( fn == "" ) |
2225 | return; | 2227 | return; |
2226 | if ( syncWithFile( fn, false ) ) { | 2228 | if ( syncWithFile( fn, false ) ) { |
2227 | qDebug("syncLocalFile() successful "); | 2229 | qDebug("syncLocalFile() successful "); |
2228 | } | 2230 | } |
2229 | 2231 | ||
2230 | } | 2232 | } |
2231 | bool KABCore::syncWithFile( QString fn , bool quick ) | 2233 | bool KABCore::syncWithFile( QString fn , bool quick ) |
2232 | { | 2234 | { |
2233 | bool ret = false; | 2235 | bool ret = false; |
2234 | QFileInfo info; | 2236 | QFileInfo info; |
2235 | info.setFile( fn ); | 2237 | info.setFile( fn ); |
2236 | QString mess; | 2238 | QString mess; |
2237 | bool loadbup = true; | 2239 | bool loadbup = true; |
2238 | if ( !info. exists() ) { | 2240 | if ( !info. exists() ) { |
2239 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2241 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2240 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2242 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2241 | mess ); | 2243 | mess ); |
2242 | return ret; | 2244 | return ret; |
2243 | } | 2245 | } |
2244 | int result = 0; | 2246 | int result = 0; |
2245 | if ( !quick ) { | 2247 | if ( !quick ) { |
2246 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2248 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2247 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2249 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2248 | mess, | 2250 | mess, |
2249 | i18n("Sync"), i18n("Cancel"), 0, | 2251 | i18n("Sync"), i18n("Cancel"), 0, |
2250 | 0, 1 ); | 2252 | 0, 1 ); |
2251 | if ( result ) | 2253 | if ( result ) |
2252 | return false; | 2254 | return false; |
2253 | } | 2255 | } |
2254 | if ( KABPrefs::instance()->mAskForPreferences ) | 2256 | if ( KABPrefs::instance()->mAskForPreferences ) |
2255 | edit_sync_options(); | 2257 | edit_sync_options(); |
2256 | if ( result == 0 ) { | 2258 | if ( result == 0 ) { |
2257 | //qDebug("Now sycing ... "); | 2259 | //qDebug("Now sycing ... "); |
2258 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) | 2260 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) |
2259 | setCaption( i18n("Synchronization successful") ); | 2261 | setCaption( i18n("Synchronization successful") ); |
2260 | else | 2262 | else |
2261 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2263 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2262 | if ( ! quick ) | 2264 | if ( ! quick ) |
2263 | KABPrefs::instance()->mLastSyncedLocalFile = fn; | 2265 | KABPrefs::instance()->mLastSyncedLocalFile = fn; |
2264 | setModified(); | 2266 | setModified(); |
2265 | } | 2267 | } |
2266 | return ret; | 2268 | return ret; |
2267 | } | 2269 | } |
2268 | void KABCore::quickSyncLocalFile() | 2270 | void KABCore::quickSyncLocalFile() |
2269 | { | 2271 | { |
2270 | 2272 | ||
2271 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2273 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2272 | qDebug("quick syncLocalFile() successful "); | 2274 | qDebug("quick syncLocalFile() successful "); |
2273 | 2275 | ||
2274 | } | 2276 | } |
2275 | } | 2277 | } |
2276 | void KABCore::multiSync( bool askforPrefs ) | 2278 | void KABCore::multiSync( bool askforPrefs ) |
2277 | { | 2279 | { |
2278 | if (mBlockSaveFlag) | 2280 | if (mBlockSaveFlag) |
2279 | return; | 2281 | return; |
2280 | mBlockSaveFlag = true; | 2282 | mBlockSaveFlag = true; |
2281 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 2283 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
2282 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2284 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2283 | question, | 2285 | question, |
2284 | i18n("Yes"), i18n("No"), | 2286 | i18n("Yes"), i18n("No"), |
2285 | 0, 0 ) != 0 ) { | 2287 | 0, 0 ) != 0 ) { |
2286 | mBlockSaveFlag = false; | 2288 | mBlockSaveFlag = false; |
2287 | setCaption(i18n("Aborted! Nothing synced!")); | 2289 | setCaption(i18n("Aborted! Nothing synced!")); |
2288 | return; | 2290 | return; |
2289 | } | 2291 | } |
2290 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 2292 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
2291 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; | 2293 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; |
2292 | if ( askforPrefs ) { | 2294 | if ( askforPrefs ) { |
2293 | edit_sync_options(); | 2295 | edit_sync_options(); |
2294 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; | 2296 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; |
2295 | } | 2297 | } |
2296 | setCaption(i18n("Multiple sync started.") ); | 2298 | setCaption(i18n("Multiple sync started.") ); |
2297 | qApp->processEvents(); | 2299 | qApp->processEvents(); |
2298 | int num = ringSync() ; | 2300 | int num = ringSync() ; |
2299 | if ( num > 1 ) | 2301 | if ( num > 1 ) |
2300 | ringSync(); | 2302 | ringSync(); |
2301 | mBlockSaveFlag = false; | 2303 | mBlockSaveFlag = false; |
2302 | if ( num ) | 2304 | if ( num ) |
2303 | save(); | 2305 | save(); |
2304 | if ( num ) | 2306 | if ( num ) |
2305 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 2307 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
2306 | else | 2308 | else |
2307 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 2309 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
2308 | return; | 2310 | return; |
2309 | } | 2311 | } |
2310 | int KABCore::ringSync() | 2312 | int KABCore::ringSync() |
2311 | { | 2313 | { |
2312 | int syncedProfiles = 0; | 2314 | int syncedProfiles = 0; |
2313 | int i; | 2315 | int i; |
2314 | QTime timer; | 2316 | QTime timer; |
2315 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2317 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2316 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; | 2318 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; |
2317 | KSyncProfile* temp = new KSyncProfile (); | 2319 | KSyncProfile* temp = new KSyncProfile (); |
2318 | KABPrefs::instance()->mAskForPreferences = false; | 2320 | KABPrefs::instance()->mAskForPreferences = false; |
2319 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 2321 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
2320 | mCurrentSyncProfile = i; | 2322 | mCurrentSyncProfile = i; |
2321 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 2323 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
2322 | temp->readConfig(&config); | 2324 | temp->readConfig(&config); |
2323 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { | 2325 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { |
2324 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 2326 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
2325 | ++syncedProfiles; | 2327 | ++syncedProfiles; |
2326 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2328 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2327 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2329 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2328 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2330 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2329 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2331 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2330 | if ( temp->getWriteBackFuture() ) | 2332 | if ( temp->getWriteBackFuture() ) |
2331 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2333 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2332 | KABPrefs::instance()->mShowSyncSummary = false; | 2334 | KABPrefs::instance()->mShowSyncSummary = false; |
2333 | mCurrentSyncDevice = syncProfileNames[i] ; | 2335 | mCurrentSyncDevice = syncProfileNames[i] ; |
2334 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | 2336 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; |
2335 | if ( i == 0 ) { | 2337 | if ( i == 0 ) { |
2336 | syncSharp(); | 2338 | syncSharp(); |
2337 | } else { | 2339 | } else { |
2338 | if ( temp->getIsLocalFileSync() ) { | 2340 | if ( temp->getIsLocalFileSync() ) { |
2339 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) | 2341 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) |
2340 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2342 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2341 | } else { | 2343 | } else { |
2342 | if ( temp->getIsPhoneSync() ) { | 2344 | if ( temp->getIsPhoneSync() ) { |
2343 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2345 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2344 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2346 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2345 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2347 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2346 | syncPhone(); | 2348 | syncPhone(); |
2347 | } else | 2349 | } else |
2348 | syncRemote( temp, false ); | 2350 | syncRemote( temp, false ); |
2349 | 2351 | ||
2350 | } | 2352 | } |
2351 | } | 2353 | } |
2352 | timer.start(); | 2354 | timer.start(); |
2353 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 2355 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
2354 | while ( timer.elapsed () < 2000 ) { | 2356 | while ( timer.elapsed () < 2000 ) { |
2355 | qApp->processEvents(); | 2357 | qApp->processEvents(); |
2356 | #ifndef _WIN32_ | 2358 | #ifndef _WIN32_ |
2357 | sleep (1); | 2359 | sleep (1); |
2358 | #endif | 2360 | #endif |
2359 | } | 2361 | } |
2360 | 2362 | ||
2361 | } | 2363 | } |
2362 | 2364 | ||
2363 | } | 2365 | } |
2364 | delete temp; | 2366 | delete temp; |
2365 | return syncedProfiles; | 2367 | return syncedProfiles; |
2366 | } | 2368 | } |
2367 | 2369 | ||
2368 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | 2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) |
2369 | { | 2371 | { |
2370 | QString question; | 2372 | QString question; |
2371 | if ( ask ) { | 2373 | if ( ask ) { |
2372 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2374 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2373 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2375 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2374 | question, | 2376 | question, |
2375 | i18n("Yes"), i18n("No"), | 2377 | i18n("Yes"), i18n("No"), |
2376 | 0, 0 ) != 0 ) | 2378 | 0, 0 ) != 0 ) |
2377 | return; | 2379 | return; |
2378 | } | 2380 | } |
2379 | QString command = prof->getPreSyncCommandAB(); | 2381 | QString command = prof->getPreSyncCommandAB(); |
2380 | int fi; | 2382 | int fi; |
2381 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2383 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2382 | QString pwd = getPassword(); | 2384 | QString pwd = getPassword(); |
2383 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2385 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2384 | 2386 | ||
2385 | } | 2387 | } |
2386 | int maxlen = 30; | 2388 | int maxlen = 30; |
2387 | if ( QApplication::desktop()->width() > 320 ) | 2389 | if ( QApplication::desktop()->width() > 320 ) |
2388 | maxlen += 25; | 2390 | maxlen += 25; |
2389 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2391 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2390 | int fileSize = 0; | 2392 | int fileSize = 0; |
2391 | int result = system ( command ); | 2393 | int result = system ( command ); |
2392 | // 0 : okay | 2394 | // 0 : okay |
2393 | // 256: no such file or dir | 2395 | // 256: no such file or dir |
2394 | // | 2396 | // |
2395 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2397 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2396 | if ( result != 0 ) { | 2398 | if ( result != 0 ) { |
2397 | int len = maxlen; | 2399 | int len = maxlen; |
2398 | while ( len < command.length() ) { | 2400 | while ( len < command.length() ) { |
2399 | command.insert( len , "\n" ); | 2401 | command.insert( len , "\n" ); |
2400 | len += maxlen +2; | 2402 | len += maxlen +2; |
2401 | } | 2403 | } |
2402 | 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) ; | 2404 | 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) ; |
2403 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2404 | question, | 2406 | question, |
2405 | i18n("Okay!")) ; | 2407 | i18n("Okay!")) ; |
2406 | setCaption ("KO/Pi"); | 2408 | setCaption ("KO/Pi"); |
2407 | return; | 2409 | return; |
2408 | } | 2410 | } |
2409 | setCaption ( i18n( "Copying succeed." ) ); | 2411 | setCaption ( i18n( "Copying succeed." ) ); |
2410 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2411 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { | 2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { |
2412 | // Event* e = mView->getLastSyncEvent(); | 2414 | // Event* e = mView->getLastSyncEvent(); |
2413 | // e->setReadOnly( false ); | 2415 | // e->setReadOnly( false ); |
2414 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2415 | // e->setReadOnly( true ); | 2417 | // e->setReadOnly( true ); |
2416 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2418 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2417 | command = prof->getPostSyncCommandAB(); | 2419 | command = prof->getPostSyncCommandAB(); |
2418 | int fi; | 2420 | int fi; |
2419 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2421 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2420 | QString pwd = getPassword(); | 2422 | QString pwd = getPassword(); |
2421 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2422 | 2424 | ||
2423 | } | 2425 | } |
2424 | setCaption ( i18n( "Writing back file ..." ) ); | 2426 | setCaption ( i18n( "Writing back file ..." ) ); |
2425 | result = system ( command ); | 2427 | result = system ( command ); |
2426 | qDebug("KO: Writing back file result: %d ", result); | 2428 | qDebug("KO: Writing back file result: %d ", result); |
2427 | if ( result != 0 ) { | 2429 | if ( result != 0 ) { |
2428 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2429 | return; | 2431 | return; |
2430 | } else { | 2432 | } else { |
2431 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2432 | } | 2434 | } |
2433 | } | 2435 | } |
2434 | } | 2436 | } |
2435 | return; | 2437 | return; |
2436 | } | 2438 | } |
2437 | #include <qpushbutton.h> | 2439 | #include <qpushbutton.h> |
2438 | #include <qradiobutton.h> | 2440 | #include <qradiobutton.h> |
2439 | #include <qbuttongroup.h> | 2441 | #include <qbuttongroup.h> |
2440 | void KABCore::edit_sync_options() | 2442 | void KABCore::edit_sync_options() |
2441 | { | 2443 | { |
2442 | //mDialogManager->showSyncOptions(); | 2444 | //mDialogManager->showSyncOptions(); |
2443 | //KABPrefs::instance()->mSyncAlgoPrefs | 2445 | //KABPrefs::instance()->mSyncAlgoPrefs |
2444 | QDialog dia( this, "dia", true ); | 2446 | QDialog dia( this, "dia", true ); |
2445 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2446 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2447 | QVBoxLayout lay ( &dia ); | 2449 | QVBoxLayout lay ( &dia ); |
2448 | lay.setSpacing( 2 ); | 2450 | lay.setSpacing( 2 ); |
2449 | lay.setMargin( 3 ); | 2451 | lay.setMargin( 3 ); |
2450 | lay.addWidget(&gr); | 2452 | lay.addWidget(&gr); |
2451 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2452 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2453 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2454 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2455 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2456 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2457 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2458 | QPushButton pb ( "OK", &dia); | 2460 | QPushButton pb ( "OK", &dia); |
2459 | lay.addWidget( &pb ); | 2461 | lay.addWidget( &pb ); |
2460 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2461 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | 2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { |
2462 | case 0: | 2464 | case 0: |
2463 | loc.setChecked( true); | 2465 | loc.setChecked( true); |
2464 | break; | 2466 | break; |
2465 | case 1: | 2467 | case 1: |
2466 | rem.setChecked( true ); | 2468 | rem.setChecked( true ); |
2467 | break; | 2469 | break; |
2468 | case 2: | 2470 | case 2: |
2469 | newest.setChecked( true); | 2471 | newest.setChecked( true); |
2470 | break; | 2472 | break; |
2471 | case 3: | 2473 | case 3: |
2472 | ask.setChecked( true); | 2474 | ask.setChecked( true); |
2473 | break; | 2475 | break; |
2474 | case 4: | 2476 | case 4: |
2475 | f_loc.setChecked( true); | 2477 | f_loc.setChecked( true); |
2476 | break; | 2478 | break; |
2477 | case 5: | 2479 | case 5: |
2478 | f_rem.setChecked( true); | 2480 | f_rem.setChecked( true); |
2479 | break; | 2481 | break; |
2480 | case 6: | 2482 | case 6: |
2481 | // both.setChecked( true); | 2483 | // both.setChecked( true); |
2482 | break; | 2484 | break; |
2483 | default: | 2485 | default: |
2484 | break; | 2486 | break; |
2485 | } | 2487 | } |
2486 | if ( dia.exec() ) { | 2488 | if ( dia.exec() ) { |
2487 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2488 | } | 2490 | } |
2489 | 2491 | ||
2490 | 2492 | ||
2491 | } | 2493 | } |
2492 | QString KABCore::getPassword( ) | 2494 | QString KABCore::getPassword( ) |
2493 | { | 2495 | { |
2494 | QString retfile = ""; | 2496 | QString retfile = ""; |
2495 | QDialog dia ( this, "input-dialog", true ); | 2497 | QDialog dia ( this, "input-dialog", true ); |
2496 | QLineEdit lab ( &dia ); | 2498 | QLineEdit lab ( &dia ); |
2497 | lab.setEchoMode( QLineEdit::Password ); | 2499 | lab.setEchoMode( QLineEdit::Password ); |
2498 | QVBoxLayout lay( &dia ); | 2500 | QVBoxLayout lay( &dia ); |
2499 | lay.setMargin(7); | 2501 | lay.setMargin(7); |
2500 | lay.setSpacing(7); | 2502 | lay.setSpacing(7); |
2501 | lay.addWidget( &lab); | 2503 | lay.addWidget( &lab); |
2502 | dia.setFixedSize( 230,50 ); | 2504 | dia.setFixedSize( 230,50 ); |
2503 | dia.setCaption( i18n("Enter password") ); | 2505 | dia.setCaption( i18n("Enter password") ); |
2504 | QPushButton pb ( "OK", &dia); | 2506 | QPushButton pb ( "OK", &dia); |
2505 | lay.addWidget( &pb ); | 2507 | lay.addWidget( &pb ); |
2506 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2507 | dia.show(); | 2509 | dia.show(); |
2508 | int res = dia.exec(); | 2510 | int res = dia.exec(); |
2509 | if ( res ) | 2511 | if ( res ) |
2510 | retfile = lab.text(); | 2512 | retfile = lab.text(); |
2511 | dia.hide(); | 2513 | dia.hide(); |
2512 | qApp->processEvents(); | 2514 | qApp->processEvents(); |
2513 | return retfile; | 2515 | return retfile; |
2514 | 2516 | ||
2515 | } | 2517 | } |
2516 | #include <libkcal/syncdefines.h> | 2518 | #include <libkcal/syncdefines.h> |
2517 | 2519 | ||
2518 | KABC::Addressee KABCore::getLastSyncAddressee() | 2520 | KABC::Addressee KABCore::getLastSyncAddressee() |
2519 | { | 2521 | { |
2520 | Addressee lse; | 2522 | Addressee lse; |
2521 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2522 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2523 | if (lse.isEmpty()) { | 2525 | if (lse.isEmpty()) { |
2524 | lse.setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 2526 | lse.setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
2525 | QString sum = ""; | 2527 | QString sum = ""; |
2526 | if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 2528 | if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
2527 | sum = "E: "; | 2529 | sum = "E: "; |
2528 | lse.setFamilyName(sum+mCurrentSyncDevice + i18n(" - sync event")); | 2530 | lse.setFamilyName(sum+mCurrentSyncDevice + i18n(" - sync event")); |
2529 | lse.setRevision( mLastAddressbookSync ); | 2531 | lse.setRevision( mLastAddressbookSync ); |
2530 | lse.setCategories( i18n("SyncEvent") ); | 2532 | lse.setCategories( i18n("SyncEvent") ); |
2531 | mAddressBook->insertAddressee( lse ); | 2533 | mAddressBook->insertAddressee( lse ); |
2532 | } | 2534 | } |
2533 | return lse; | 2535 | return lse; |
2534 | } | 2536 | } |
2535 | 2537 | ||
2536 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2538 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2537 | { | 2539 | { |
2538 | bool syncOK = true; | 2540 | bool syncOK = true; |
2539 | int addedAddressee = 0; | 2541 | int addedAddressee = 0; |
2540 | int addedAddresseeR = 0; | 2542 | int addedAddresseeR = 0; |
2541 | int deletedAddresseeR = 0; | 2543 | int deletedAddresseeR = 0; |
2542 | int deletedAddresseeL = 0; | 2544 | int deletedAddresseeL = 0; |
2543 | int changedLocal = 0; | 2545 | int changedLocal = 0; |
2544 | int changedRemote = 0; | 2546 | int changedRemote = 0; |
2545 | //QPtrList<Addressee> el = local->rawAddressees(); | 2547 | //QPtrList<Addressee> el = local->rawAddressees(); |
2546 | Addressee addresseeR; | 2548 | Addressee addresseeR; |
2547 | QString uid; | 2549 | QString uid; |
2548 | int take; | 2550 | int take; |
2549 | Addressee addresseeL; | 2551 | Addressee addresseeL; |
2550 | Addressee addresseeRSync; | 2552 | Addressee addresseeRSync; |
2551 | Addressee addresseeLSync; | 2553 | Addressee addresseeLSync; |
2552 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2554 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2553 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2555 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2554 | bool fullDateRange = false; | 2556 | bool fullDateRange = false; |
2555 | local->resetTempSyncStat(); | 2557 | local->resetTempSyncStat(); |
2556 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2558 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2557 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2559 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2558 | addresseeLSync = getLastSyncAddressee(); | 2560 | addresseeLSync = getLastSyncAddressee(); |
2559 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2561 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2560 | if ( !addresseeR.isEmpty() ) { | 2562 | if ( !addresseeR.isEmpty() ) { |
2561 | addresseeRSync = addresseeR; | 2563 | addresseeRSync = addresseeR; |
2562 | remote->removeAddressee(addresseeR ); | 2564 | remote->removeAddressee(addresseeR ); |
2563 | 2565 | ||
2564 | } else { | 2566 | } else { |
2565 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2567 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2566 | addresseeRSync = addresseeLSync ; | 2568 | addresseeRSync = addresseeLSync ; |
2567 | } else { | 2569 | } else { |
2568 | fullDateRange = true; | 2570 | fullDateRange = true; |
2569 | Addressee newAdd; | 2571 | Addressee newAdd; |
2570 | addresseeRSync = newAdd; | 2572 | addresseeRSync = newAdd; |
2571 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2573 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2572 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2574 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2573 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2575 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2574 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2576 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2575 | } | 2577 | } |
2576 | } | 2578 | } |
2577 | if ( addresseeLSync.revision() == mLastAddressbookSync ) | 2579 | if ( addresseeLSync.revision() == mLastAddressbookSync ) |
2578 | fullDateRange = true; | 2580 | fullDateRange = true; |
2579 | if ( ! fullDateRange ) { | 2581 | if ( ! fullDateRange ) { |
2580 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2582 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2581 | 2583 | ||
2582 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2584 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2583 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2585 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2584 | fullDateRange = true; | 2586 | fullDateRange = true; |
2585 | } | 2587 | } |
2586 | } | 2588 | } |
2587 | if ( fullDateRange ) | 2589 | if ( fullDateRange ) |
2588 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2590 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2589 | else | 2591 | else |
2590 | mLastAddressbookSync = addresseeLSync.revision(); | 2592 | mLastAddressbookSync = addresseeLSync.revision(); |
2591 | // for resyncing if own file has changed | 2593 | // for resyncing if own file has changed |
2592 | // PENDING fixme later when implemented | 2594 | // PENDING fixme later when implemented |
2593 | #if 0 | 2595 | #if 0 |
2594 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2596 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2595 | mLastAddressbookSync = loadedFileVersion; | 2597 | mLastAddressbookSync = loadedFileVersion; |
2596 | qDebug("setting mLastAddressbookSync "); | 2598 | qDebug("setting mLastAddressbookSync "); |
2597 | } | 2599 | } |
2598 | #endif | 2600 | #endif |
2599 | 2601 | ||
2600 | #if 0 | ||
2601 | //qDebug("*************************** "); | 2602 | //qDebug("*************************** "); |
2602 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2603 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2603 | QPtrList<Incidence> er = remote->rawIncidences(); | 2604 | QStringList er = remote->uidList(); |
2604 | Incidence* inR = er.first(); | 2605 | Addressee inR ;//= er.first(); |
2605 | Incidence* inL; | 2606 | Addressee inL; |
2606 | QProgressBar bar( er.count(),0 ); | 2607 | QProgressBar bar( er.count(),0 ); |
2607 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2608 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2608 | 2609 | ||
2609 | int w = 300; | 2610 | int w = 300; |
2610 | if ( QApplication::desktop()->width() < 320 ) | 2611 | if ( QApplication::desktop()->width() < 320 ) |
2611 | w = 220; | 2612 | w = 220; |
2612 | int h = bar.sizeHint().height() ; | 2613 | int h = bar.sizeHint().height() ; |
2613 | int dw = QApplication::desktop()->width(); | 2614 | int dw = QApplication::desktop()->width(); |
2614 | int dh = QApplication::desktop()->height(); | 2615 | int dh = QApplication::desktop()->height(); |
2615 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2616 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2616 | bar.show(); | 2617 | bar.show(); |
2617 | int modulo = (er.count()/10)+1; | 2618 | int modulo = (er.count()/10)+1; |
2618 | int incCounter = 0; | 2619 | int incCounter = 0; |
2619 | while ( inR ) { | 2620 | while ( incCounter < er.count()) { |
2620 | if ( ! bar.isVisible() ) | 2621 | if ( ! bar.isVisible() ) |
2621 | return false; | 2622 | return false; |
2622 | if ( incCounter % modulo == 0 ) | 2623 | if ( incCounter % modulo == 0 ) |
2623 | bar.setProgress( incCounter ); | 2624 | bar.setProgress( incCounter ); |
2624 | ++incCounter; | 2625 | uid = er[ incCounter ]; |
2625 | uid = inR->uid(); | ||
2626 | bool skipIncidence = false; | 2626 | bool skipIncidence = false; |
2627 | if ( uid.left(15) == QString("last-syncAddressee-") ) | 2627 | if ( uid.left(20) == QString("last-syncAddressee-") ) |
2628 | skipIncidence = true; | 2628 | skipIncidence = true; |
2629 | QString idS; | 2629 | QString idS; |
2630 | qApp->processAddressees(); | 2630 | qApp->processEvents(); |
2631 | if ( !skipIncidence ) { | 2631 | if ( !skipIncidence ) { |
2632 | inL = local->incidence( uid ); | 2632 | inL = local->findByUid( uid ); |
2633 | if ( inL ) { // maybe conflict - same uid in both calendars | 2633 | inR = remote->findByUid( uid ); |
2634 | int maxrev = inL->revision(); | 2634 | //inL.setResource( 0 ); |
2635 | if ( maxrev < inR->revision() ) | 2635 | //inR.setResource( 0 ); |
2636 | maxrev = inR->revision(); | 2636 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2637 | if ( (take = takeAddressee( inL, inR, mode, fullDateRange )) > 0 ) { | 2637 | // pending if ( (take = takeAddressee( inL, inR, mode, fullDateRange )) > 0 ) { |
2638 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 2638 | if ( true ) { |
2639 | //qDebug("take %d %s ", take, inL.summary().latin1()); | ||
2639 | if ( take == 3 ) | 2640 | if ( take == 3 ) |
2640 | return false; | 2641 | return false; |
2641 | if ( take == 1 ) {// take local | 2642 | if ( take == 1 ) {// take local |
2642 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2643 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2643 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 2644 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2645 | local->insertAddressee( inL ); | ||
2646 | } | ||
2644 | else | 2647 | else |
2645 | idS = inR->IDStr(); | 2648 | idS = inR.IDStr(); |
2646 | remote->deleteIncidence( inR ); | 2649 | remote->removeAddressee( inR ); |
2647 | if ( inL->revision() < maxrev ) | 2650 | inR = inL; |
2648 | inL->setRevision( maxrev ); | 2651 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2649 | inR = inL->clone(); | ||
2650 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | ||
2651 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2652 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2652 | inR->setIDStr( idS ); | 2653 | inR.setIDStr( idS ); |
2653 | remote->addIncidence( inR ); | 2654 | inR.setResource( 0 ); |
2655 | remote->insertAddressee( inR ); | ||
2654 | ++changedRemote; | 2656 | ++changedRemote; |
2655 | } else { | 2657 | } else { |
2656 | if ( inR->revision() < maxrev ) | 2658 | idS = inL.IDStr(); |
2657 | inR->setRevision( maxrev ); | 2659 | local->removeAddressee( inL ); |
2658 | idS = inL->IDStr(); | 2660 | inL = inR; |
2659 | local->deleteIncidence( inL ); | 2661 | inL.setIDStr( idS ); |
2660 | inL = inR->clone(); | 2662 | inL.setResource( 0 ); |
2661 | inL->setIDStr( idS ); | 2663 | local->insertAddressee( inL ); |
2662 | local->addIncidence( inL ); | ||
2663 | ++changedLocal; | 2664 | ++changedLocal; |
2664 | } | 2665 | } |
2665 | } | 2666 | } |
2666 | } else { // no conflict | 2667 | } else { // no conflict |
2667 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2668 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2668 | QString des = addresseeLSync->description(); | 2669 | QString des = addresseeLSync.note(); |
2669 | QString pref = "e"; | 2670 | QString pref = "a"; |
2670 | if ( inR->type() == "Todo" ) | 2671 | if ( des.find(pref+ inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2671 | pref = "t"; | 2672 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2672 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | ||
2673 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | ||
2674 | //remote->deleteIncidence( inR ); | ||
2675 | ++deletedAddresseeR; | 2673 | ++deletedAddresseeR; |
2676 | } else { | 2674 | } else { |
2677 | inR->setLastModified( modifiedCalendar ); | 2675 | inR.setRevision( modifiedCalendar ); |
2678 | inL = inR->clone(); | 2676 | remote->insertAddressee( inR ); |
2679 | local->addIncidence( inL ); | 2677 | inL = inR; |
2678 | inL.setResource( 0 ); | ||
2679 | local->insertAddressee( inL ); | ||
2680 | ++addedAddressee; | 2680 | ++addedAddressee; |
2681 | } | 2681 | } |
2682 | } else { | 2682 | } else { |
2683 | if ( inR->lastModified() > mLastAddressbookSync || mode == 5 ) { | 2683 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2684 | inR->setLastModified( modifiedCalendar ); | 2684 | inR.setRevision( modifiedCalendar ); |
2685 | local->addIncidence( inR->clone() ); | 2685 | remote->insertAddressee( inR ); |
2686 | inR.setResource( 0 ); | ||
2687 | local->insertAddressee( inR ); | ||
2686 | ++addedAddressee; | 2688 | ++addedAddressee; |
2687 | } else { | 2689 | } else { |
2688 | checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2690 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2689 | remote->deleteIncidence( inR ); | 2691 | remote->removeAddressee( inR ); |
2690 | ++deletedAddresseeR; | 2692 | ++deletedAddresseeR; |
2691 | } | 2693 | } |
2692 | } | 2694 | } |
2693 | } | 2695 | } |
2694 | } | 2696 | } |
2695 | inR = er.next(); | 2697 | ++incCounter; |
2696 | } | 2698 | } |
2697 | QPtrList<Incidence> el = local->rawIncidences(); | 2699 | er.clear(); |
2698 | inL = el.first(); | 2700 | QStringList el = remote->uidList(); |
2699 | modulo = (el.count()/10)+1; | 2701 | modulo = (el.count()/10)+1; |
2700 | bar.setCaption (i18n("Add / remove addressees") ); | 2702 | bar.setCaption (i18n("Add / remove addressees") ); |
2701 | bar.setTotalSteps ( el.count() ) ; | 2703 | bar.setTotalSteps ( el.count() ) ; |
2702 | bar.show(); | 2704 | bar.show(); |
2703 | incCounter = 0; | 2705 | incCounter = 0; |
2704 | 2706 | while ( incCounter < el.count()) { | |
2705 | while ( inL ) { | ||
2706 | 2707 | ||
2707 | qApp->processAddressees(); | 2708 | qApp->processEvents(); |
2708 | if ( ! bar.isVisible() ) | 2709 | if ( ! bar.isVisible() ) |
2709 | return false; | 2710 | return false; |
2710 | if ( incCounter % modulo == 0 ) | 2711 | if ( incCounter % modulo == 0 ) |
2711 | bar.setProgress( incCounter ); | 2712 | bar.setProgress( incCounter ); |
2712 | ++incCounter; | 2713 | uid = el[ incCounter ]; |
2713 | uid = inL->uid(); | ||
2714 | bool skipIncidence = false; | 2714 | bool skipIncidence = false; |
2715 | if ( uid.left(15) == QString("last-syncAddressee-") ) | 2715 | if ( uid.left(20) == QString("last-syncAddressee-") ) |
2716 | skipIncidence = true; | 2716 | skipIncidence = true; |
2717 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 2717 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2718 | skipIncidence = true; | 2718 | skipIncidence = true; |
2719 | if ( !skipIncidence ) { | 2719 | if ( !skipIncidence ) { |
2720 | inR = remote->incidence( uid ); | 2720 | inL = local->findByUid( uid ); |
2721 | if ( ! inR ) { | 2721 | inR = remote->findByUid( uid ); |
2722 | if ( inR.isEmpty() ) { | ||
2722 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2723 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2723 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2724 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2724 | checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2725 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2725 | local->deleteIncidence( inL ); | 2726 | local->removeAddressee( inL ); |
2726 | ++deletedAddresseeL; | 2727 | ++deletedAddresseeL; |
2727 | } else { | 2728 | } else { |
2728 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 2729 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2729 | inL->removeID(mCurrentSyncDevice ); | 2730 | inL.removeID(mCurrentSyncDevice ); |
2730 | ++addedAddresseeR; | 2731 | ++addedAddresseeR; |
2731 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 2732 | //qDebug("remote added Incidence %s ", inL.summary().latin1()); |
2732 | inL->setLastModified( modifiedCalendar ); | 2733 | inL.setRevision( modifiedCalendar ); |
2733 | inR = inL->clone(); | 2734 | local->insertAddressee( inL ); |
2734 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2735 | inR = inL; |
2735 | remote->addIncidence( inR ); | 2736 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2737 | inR.setResource( 0 ); | ||
2738 | remote->insertAddressee( inR ); | ||
2736 | } | 2739 | } |
2737 | } | 2740 | } |
2738 | } else { | 2741 | } else { |
2739 | if ( inL->lastModified() < mLastAddressbookSync && mode != 4 ) { | 2742 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2740 | checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2743 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2741 | local->deleteIncidence( inL ); | 2744 | local->removeAddressee( inL ); |
2742 | ++deletedAddresseeL; | 2745 | ++deletedAddresseeL; |
2743 | } else { | 2746 | } else { |
2744 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 2747 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2745 | ++addedAddresseeR; | 2748 | ++addedAddresseeR; |
2746 | inL->setLastModified( modifiedCalendar ); | 2749 | inL.setRevision( modifiedCalendar ); |
2747 | remote->addIncidence( inL->clone() ); | 2750 | local->insertAddressee( inL ); |
2751 | inR = inL; | ||
2752 | inR.setResource( 0 ); | ||
2753 | remote->insertAddressee( inR ); | ||
2748 | } | 2754 | } |
2749 | } | 2755 | } |
2750 | } | 2756 | } |
2751 | } | 2757 | } |
2752 | } | 2758 | } |
2753 | inL = el.next(); | 2759 | ++incCounter; |
2754 | } | 2760 | } |
2761 | el.clear(); | ||
2755 | int delFut = 0; | 2762 | int delFut = 0; |
2756 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 2763 | |
2757 | er = remote->rawIncidences(); | 2764 | #if 0 |
2758 | inR = er.first(); | 2765 | |
2759 | QDateTime dt; | ||
2760 | QDateTime cur = QDateTime::currentDateTime(); | ||
2761 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | ||
2762 | while ( inR ) { | ||
2763 | if ( inR->type() == "Todo" ) { | ||
2764 | Todo * t = (Todo*)inR; | ||
2765 | if ( t->hasDueDate() ) | ||
2766 | dt = t->dtDue(); | ||
2767 | else | ||
2768 | dt = cur.addSecs( 62 ); | ||
2769 | } | ||
2770 | else if (inR->type() == "Addressee" ) { | ||
2771 | bool ok; | ||
2772 | dt = inR->getNextOccurence( cur, &ok ); | ||
2773 | if ( !ok ) | ||
2774 | dt = cur.addSecs( -62 ); | ||
2775 | } | ||
2776 | else | ||
2777 | dt = inR->dtStart(); | ||
2778 | if ( dt < cur || dt > end ) { | ||
2779 | remote->deleteIncidence( inR ); | ||
2780 | ++delFut; | ||
2781 | } | ||
2782 | inR = er.next(); | ||
2783 | } | ||
2784 | } | ||
2785 | bar.hide(); | 2766 | bar.hide(); |
2786 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2767 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2787 | addresseeLSync->setReadOnly( false ); | 2768 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2788 | addresseeLSync->setDtStart( mLastAddressbookSync ); | 2769 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2789 | addresseeRSync->setDtStart( mLastAddressbookSync ); | 2770 | addresseeRSync.setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
2790 | addresseeLSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) ); | 2771 | addresseeLSync.setLocation(i18n("Local from: ") + mCurrentSyncName ); |
2791 | addresseeRSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) ); | 2772 | addresseeLSync.setReadOnly( true ); |
2792 | addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | ||
2793 | addresseeLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | ||
2794 | addresseeLSync->setReadOnly( true ); | ||
2795 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2773 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2796 | remote->addAddressee( addresseeRSync ); | 2774 | remote->addAddressee( addresseeRSync ); |
2797 | QString mes; | 2775 | QString mes; |
2798 | 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 ); | 2776 | 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 ); |
2799 | QString delmess; | 2777 | QString delmess; |
2800 | if ( delFut ) { | 2778 | if ( delFut ) { |
2801 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 2779 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); |
2802 | mes += delmess; | 2780 | mes += delmess; |
2803 | } | 2781 | } |
2804 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 2782 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
2805 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 2783 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
2806 | } | 2784 | } |
2807 | qDebug( mes ); | 2785 | qDebug( mes ); |
2808 | mCalendar->checkAlarmForIncidence( 0, true ); | 2786 | mCalendar->checkAlarmForIncidence( 0, true ); |
2809 | return syncOK; | 2787 | return syncOK; |
2810 | #endif | 2788 | #endif |
2811 | return false; | 2789 | return false; |
2812 | } | 2790 | } |
2813 | bool KABCore::syncAB(QString filename, int mode) | 2791 | bool KABCore::syncAB(QString filename, int mode) |
2814 | { | 2792 | { |
2815 | 2793 | ||
2816 | //pending prepare addresseeview for output | 2794 | //pending prepare addresseeview for output |
2817 | //pending detect, if remote file has REV field. if not switch to external sync | 2795 | //pending detect, if remote file has REV field. if not switch to external sync |
2818 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2796 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2819 | AddressBook abLocal(filename,"syncContact"); | 2797 | AddressBook abLocal(filename,"syncContact"); |
2820 | bool syncOK = false; | 2798 | bool syncOK = false; |
2821 | if ( abLocal.load() ) { | 2799 | if ( abLocal.load() ) { |
2822 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2800 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); |
2823 | AddressBook::Iterator it; | 2801 | AddressBook::Iterator it; |
2824 | QStringList vcards; | 2802 | QStringList vcards; |
2825 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2803 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2826 | qDebug("Name %s ", (*it).familyName().latin1()); | 2804 | qDebug("Name %s ", (*it).familyName().latin1()); |
2827 | } | 2805 | } |
2828 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2806 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2829 | if ( syncOK ) { | 2807 | if ( syncOK ) { |
2830 | if ( KABPrefs::instance()->mWriteBackFile ) | 2808 | if ( KABPrefs::instance()->mWriteBackFile ) |
2831 | { | 2809 | { |
2832 | qDebug("saving remote AB "); | 2810 | qDebug("saving remote AB "); |
2833 | abLocal.saveAB(); | 2811 | abLocal.saveAB(); |
2834 | } | 2812 | } |
2835 | } | 2813 | } |
2836 | setModified(); | 2814 | setModified(); |
2837 | 2815 | ||
2838 | } | 2816 | } |
2839 | if ( syncOK ) | 2817 | if ( syncOK ) |
2840 | mViewManager->refreshView(); | 2818 | mViewManager->refreshView(); |
2841 | return syncOK; | 2819 | return syncOK; |
2842 | #if 0 | 2820 | #if 0 |
2843 | 2821 | ||
2844 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2822 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2845 | getEventViewerDialog()->setSyncMode( true ); | 2823 | getEventViewerDialog()->setSyncMode( true ); |
2846 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2824 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2847 | getEventViewerDialog()->setSyncMode( false ); | 2825 | getEventViewerDialog()->setSyncMode( false ); |
2848 | if ( syncOK ) { | 2826 | if ( syncOK ) { |
2849 | if ( KOPrefs::instance()->mWriteBackFile ) | 2827 | if ( KOPrefs::instance()->mWriteBackFile ) |
2850 | { | 2828 | { |
2851 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2829 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2852 | storage->save(); | 2830 | storage->save(); |
2853 | } | 2831 | } |
2854 | } | 2832 | } |
2855 | setModified(); | 2833 | setModified(); |
2856 | } | 2834 | } |
2857 | 2835 | ||
2858 | #endif | 2836 | #endif |
2859 | } | 2837 | } |
2860 | 2838 | ||
2861 | 2839 | ||
2862 | void KABCore::confSync() | 2840 | void KABCore::confSync() |
2863 | { | 2841 | { |
2864 | static KSyncPrefsDialog* sp = 0; | 2842 | static KSyncPrefsDialog* sp = 0; |
2865 | if ( ! sp ) { | 2843 | if ( ! sp ) { |
2866 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2844 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2867 | } | 2845 | } |
2868 | sp->usrReadConfig(); | 2846 | sp->usrReadConfig(); |
2869 | #ifndef DESKTOP_VERSION | 2847 | #ifndef DESKTOP_VERSION |
2870 | sp->showMaximized(); | 2848 | sp->showMaximized(); |
2871 | #else | 2849 | #else |
2872 | sp->show(); | 2850 | sp->show(); |
2873 | #endif | 2851 | #endif |
2874 | sp->exec(); | 2852 | sp->exec(); |
2875 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 2853 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
2876 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 2854 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
2877 | fillSyncMenu(); | 2855 | fillSyncMenu(); |
2878 | } | 2856 | } |
2879 | void KABCore::syncSharp() | 2857 | void KABCore::syncSharp() |
2880 | { | 2858 | { |
2881 | if ( mModified ) | 2859 | if ( mModified ) |
2882 | save(); | 2860 | save(); |
2883 | qDebug("pending syncSharp() "); | 2861 | qDebug("pending syncSharp() "); |
2884 | //mView->syncSharp(); | 2862 | //mView->syncSharp(); |
2885 | setModified(); | 2863 | setModified(); |
2886 | 2864 | ||
2887 | } | 2865 | } |
2888 | void KABCore::syncPhone() | 2866 | void KABCore::syncPhone() |
2889 | { | 2867 | { |
2890 | if ( mModified ) | 2868 | if ( mModified ) |
2891 | save(); | 2869 | save(); |
2892 | qDebug("pending syncPhone(); "); | 2870 | qDebug("pending syncPhone(); "); |
2893 | //mView->syncPhone(); | 2871 | //mView->syncPhone(); |
2894 | setModified(); | 2872 | setModified(); |
2895 | 2873 | ||
2896 | } | 2874 | } |