author | zautrix <zautrix> | 2004-12-05 13:41:41 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-05 13:41:41 (UTC) |
commit | 06bebf5be01898145c4f721a8d002519141e7f3b (patch) (unidiff) | |
tree | bc44d996a58a63de8c43cb5ba54d55bf1494eb5c | |
parent | 5ab47964d8b52897bb0662ef4a5fcf9604acaf6c (diff) | |
download | kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.zip kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.tar.gz kdepimpi-06bebf5be01898145c4f721a8d002519141e7f3b.tar.bz2 |
added better debug output to sync file problems
-rw-r--r-- | kaddressbook/kabcore.cpp | 8 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 15cab73..b7edccd 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,3172 +1,3178 @@ | |||
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 | /*s | 24 | /*s |
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 <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | #include "xxportselectdialog.h" | 118 | #include "xxportselectdialog.h" |
119 | 119 | ||
120 | 120 | ||
121 | #include <kresources/selectdialog.h> | 121 | #include <kresources/selectdialog.h> |
122 | #include <kmessagebox.h> | 122 | #include <kmessagebox.h> |
123 | 123 | ||
124 | #include <picture.h> | 124 | #include <picture.h> |
125 | #include <resource.h> | 125 | #include <resource.h> |
126 | 126 | ||
127 | //US#include <qsplitter.h> | 127 | //US#include <qsplitter.h> |
128 | #include <qmap.h> | 128 | #include <qmap.h> |
129 | #include <qdir.h> | 129 | #include <qdir.h> |
130 | #include <qfile.h> | 130 | #include <qfile.h> |
131 | #include <qvbox.h> | 131 | #include <qvbox.h> |
132 | #include <qlayout.h> | 132 | #include <qlayout.h> |
133 | #include <qclipboard.h> | 133 | #include <qclipboard.h> |
134 | #include <qtextstream.h> | 134 | #include <qtextstream.h> |
135 | #include <qradiobutton.h> | 135 | #include <qradiobutton.h> |
136 | #include <qbuttongroup.h> | 136 | #include <qbuttongroup.h> |
137 | 137 | ||
138 | #include <libkdepim/categoryselectdialog.h> | 138 | #include <libkdepim/categoryselectdialog.h> |
139 | #include <libkdepim/categoryeditdialog.h> | 139 | #include <libkdepim/categoryeditdialog.h> |
140 | #include <kabc/vcardconverter.h> | 140 | #include <kabc/vcardconverter.h> |
141 | 141 | ||
142 | 142 | ||
143 | #include "addresseeutil.h" | 143 | #include "addresseeutil.h" |
144 | #include "undocmds.h" | 144 | #include "undocmds.h" |
145 | #include "addresseeeditordialog.h" | 145 | #include "addresseeeditordialog.h" |
146 | #include "viewmanager.h" | 146 | #include "viewmanager.h" |
147 | #include "details/detailsviewcontainer.h" | 147 | #include "details/detailsviewcontainer.h" |
148 | #include "kabprefs.h" | 148 | #include "kabprefs.h" |
149 | #include "xxportmanager.h" | 149 | #include "xxportmanager.h" |
150 | #include "incsearchwidget.h" | 150 | #include "incsearchwidget.h" |
151 | #include "jumpbuttonbar.h" | 151 | #include "jumpbuttonbar.h" |
152 | #include "extensionmanager.h" | 152 | #include "extensionmanager.h" |
153 | #include "addresseeconfig.h" | 153 | #include "addresseeconfig.h" |
154 | #include <kcmultidialog.h> | 154 | #include <kcmultidialog.h> |
155 | 155 | ||
156 | #ifdef _WIN32_ | 156 | #ifdef _WIN32_ |
157 | 157 | ||
158 | #include "kaimportoldialog.h" | 158 | #include "kaimportoldialog.h" |
159 | #else | 159 | #else |
160 | #include <unistd.h> | 160 | #include <unistd.h> |
161 | #endif | 161 | #endif |
162 | // sync includes | 162 | // sync includes |
163 | #include <libkdepim/ksyncprofile.h> | 163 | #include <libkdepim/ksyncprofile.h> |
164 | #include <libkdepim/ksyncprefsdialog.h> | 164 | #include <libkdepim/ksyncprefsdialog.h> |
165 | 165 | ||
166 | 166 | ||
167 | class KABCatPrefs : public QDialog | 167 | class KABCatPrefs : public QDialog |
168 | { | 168 | { |
169 | public: | 169 | public: |
170 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : | 170 | KABCatPrefs( QWidget *parent=0, const char *name=0 ) : |
171 | QDialog( parent, name, true ) | 171 | QDialog( parent, name, true ) |
172 | { | 172 | { |
173 | setCaption( i18n("Manage new Categories") ); | 173 | setCaption( i18n("Manage new Categories") ); |
174 | QVBoxLayout* lay = new QVBoxLayout( this ); | 174 | QVBoxLayout* lay = new QVBoxLayout( this ); |
175 | lay->setSpacing( 3 ); | 175 | lay->setSpacing( 3 ); |
176 | lay->setMargin( 3 ); | 176 | lay->setMargin( 3 ); |
177 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 177 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
178 | lay->addWidget( lab ); | 178 | lay->addWidget( lab ); |
179 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 179 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
180 | lay->addWidget( format ); | 180 | lay->addWidget( format ); |
181 | format->setExclusive ( true ) ; | 181 | format->setExclusive ( true ) ; |
182 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 182 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
183 | new QRadioButton(i18n("Remove from addressees"), format ); | 183 | new QRadioButton(i18n("Remove from addressees"), format ); |
184 | addCatBut->setChecked( true ); | 184 | addCatBut->setChecked( true ); |
185 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 185 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
186 | lay->addWidget( ok ); | 186 | lay->addWidget( ok ); |
187 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 187 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
188 | lay->addWidget( cancel ); | 188 | lay->addWidget( cancel ); |
189 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 189 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
190 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 190 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
191 | resize( 200, 200 ); | 191 | resize( 200, 200 ); |
192 | } | 192 | } |
193 | 193 | ||
194 | bool addCat() { return addCatBut->isChecked(); } | 194 | bool addCat() { return addCatBut->isChecked(); } |
195 | private: | 195 | private: |
196 | QRadioButton* addCatBut; | 196 | QRadioButton* addCatBut; |
197 | }; | 197 | }; |
198 | 198 | ||
199 | 199 | ||
200 | 200 | ||
201 | class KAex2phonePrefs : public QDialog | 201 | class KAex2phonePrefs : public QDialog |
202 | { | 202 | { |
203 | public: | 203 | public: |
204 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 204 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
205 | QDialog( parent, name, true ) | 205 | QDialog( parent, name, true ) |
206 | { | 206 | { |
207 | setCaption( i18n("Export to phone options") ); | 207 | setCaption( i18n("Export to phone options") ); |
208 | QVBoxLayout* lay = new QVBoxLayout( this ); | 208 | QVBoxLayout* lay = new QVBoxLayout( this ); |
209 | lay->setSpacing( 3 ); | 209 | lay->setSpacing( 3 ); |
210 | lay->setMargin( 3 ); | 210 | lay->setMargin( 3 ); |
211 | QLabel *lab; | 211 | QLabel *lab; |
212 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 212 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
213 | lab->setAlignment (AlignHCenter ); | 213 | lab->setAlignment (AlignHCenter ); |
214 | QHBox* temphb; | 214 | QHBox* temphb; |
215 | temphb = new QHBox( this ); | 215 | temphb = new QHBox( this ); |
216 | new QLabel( i18n("I/O device: "), temphb ); | 216 | new QLabel( i18n("I/O device: "), temphb ); |
217 | mPhoneDevice = new QLineEdit( temphb); | 217 | mPhoneDevice = new QLineEdit( temphb); |
218 | lay->addWidget( temphb ); | 218 | lay->addWidget( temphb ); |
219 | temphb = new QHBox( this ); | 219 | temphb = new QHBox( this ); |
220 | new QLabel( i18n("Connection: "), temphb ); | 220 | new QLabel( i18n("Connection: "), temphb ); |
221 | mPhoneConnection = new QLineEdit( temphb); | 221 | mPhoneConnection = new QLineEdit( temphb); |
222 | lay->addWidget( temphb ); | 222 | lay->addWidget( temphb ); |
223 | temphb = new QHBox( this ); | 223 | temphb = new QHBox( this ); |
224 | new QLabel( i18n("Model(opt.): "), temphb ); | 224 | new QLabel( i18n("Model(opt.): "), temphb ); |
225 | mPhoneModel = new QLineEdit( temphb); | 225 | mPhoneModel = new QLineEdit( temphb); |
226 | lay->addWidget( temphb ); | 226 | lay->addWidget( temphb ); |
227 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 227 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
228 | // lay->addWidget( mWriteToSim ); | 228 | // lay->addWidget( mWriteToSim ); |
229 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 229 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
230 | lab->setAlignment (AlignHCenter ); | 230 | lab->setAlignment (AlignHCenter ); |
231 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 231 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
232 | lay->addWidget( ok ); | 232 | lay->addWidget( ok ); |
233 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 233 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
234 | lay->addWidget( cancel ); | 234 | lay->addWidget( cancel ); |
235 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 235 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
236 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 236 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
237 | resize( 220, 240 ); | 237 | resize( 220, 240 ); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | public: | 241 | public: |
242 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 242 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
243 | QCheckBox* mWriteToSim; | 243 | QCheckBox* mWriteToSim; |
244 | }; | 244 | }; |
245 | 245 | ||
246 | 246 | ||
247 | bool pasteWithNewUid = true; | 247 | bool pasteWithNewUid = true; |
248 | 248 | ||
249 | #ifdef KAB_EMBEDDED | 249 | #ifdef KAB_EMBEDDED |
250 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 250 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
251 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 251 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
252 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 252 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
253 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 253 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
254 | #else //KAB_EMBEDDED | 254 | #else //KAB_EMBEDDED |
255 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 255 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
256 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 256 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
257 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 257 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
258 | mReadWrite( readWrite ), mModified( false ) | 258 | mReadWrite( readWrite ), mModified( false ) |
259 | #endif //KAB_EMBEDDED | 259 | #endif //KAB_EMBEDDED |
260 | { | 260 | { |
261 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 261 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
262 | // syncManager->setBlockSave(false); | 262 | // syncManager->setBlockSave(false); |
263 | mMiniSplitter = 0; | 263 | mMiniSplitter = 0; |
264 | mExtensionBarSplitter = 0; | 264 | mExtensionBarSplitter = 0; |
265 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 265 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
266 | mAddressBook = KABC::StdAddressBook::self(); | 266 | mAddressBook = KABC::StdAddressBook::self(); |
267 | KABC::StdAddressBook::setAutomaticSave( false ); | 267 | KABC::StdAddressBook::setAutomaticSave( false ); |
268 | 268 | ||
269 | #ifndef KAB_EMBEDDED | 269 | #ifndef KAB_EMBEDDED |
270 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 270 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
271 | #endif //KAB_EMBEDDED | 271 | #endif //KAB_EMBEDDED |
272 | 272 | ||
273 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 273 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
274 | SLOT( addressBookChanged() ) ); | 274 | SLOT( addressBookChanged() ) ); |
275 | 275 | ||
276 | #if 0 | 276 | #if 0 |
277 | // LP moved to addressbook init method | 277 | // LP moved to addressbook init method |
278 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 278 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
279 | "X-Department", "KADDRESSBOOK" ); | 279 | "X-Department", "KADDRESSBOOK" ); |
280 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 280 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
281 | "X-Profession", "KADDRESSBOOK" ); | 281 | "X-Profession", "KADDRESSBOOK" ); |
282 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 282 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
283 | "X-AssistantsName", "KADDRESSBOOK" ); | 283 | "X-AssistantsName", "KADDRESSBOOK" ); |
284 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 284 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
285 | "X-ManagersName", "KADDRESSBOOK" ); | 285 | "X-ManagersName", "KADDRESSBOOK" ); |
286 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 286 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
287 | "X-SpousesName", "KADDRESSBOOK" ); | 287 | "X-SpousesName", "KADDRESSBOOK" ); |
288 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 288 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
289 | "X-Office", "KADDRESSBOOK" ); | 289 | "X-Office", "KADDRESSBOOK" ); |
290 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 290 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
291 | "X-IMAddress", "KADDRESSBOOK" ); | 291 | "X-IMAddress", "KADDRESSBOOK" ); |
292 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 292 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
293 | "X-Anniversary", "KADDRESSBOOK" ); | 293 | "X-Anniversary", "KADDRESSBOOK" ); |
294 | 294 | ||
295 | //US added this field to become compatible with Opie/qtopia addressbook | 295 | //US added this field to become compatible with Opie/qtopia addressbook |
296 | // values can be "female" or "male" or "". An empty field represents undefined. | 296 | // values can be "female" or "male" or "". An empty field represents undefined. |
297 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 297 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
298 | "X-Gender", "KADDRESSBOOK" ); | 298 | "X-Gender", "KADDRESSBOOK" ); |
299 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 299 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
300 | "X-Children", "KADDRESSBOOK" ); | 300 | "X-Children", "KADDRESSBOOK" ); |
301 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 301 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
302 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 302 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
303 | #endif | 303 | #endif |
304 | initGUI(); | 304 | initGUI(); |
305 | 305 | ||
306 | mIncSearchWidget->setFocus(); | 306 | mIncSearchWidget->setFocus(); |
307 | 307 | ||
308 | 308 | ||
309 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 309 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
310 | SLOT( setContactSelected( const QString& ) ) ); | 310 | SLOT( setContactSelected( const QString& ) ) ); |
311 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 311 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
312 | SLOT( executeContact( const QString& ) ) ); | 312 | SLOT( executeContact( const QString& ) ) ); |
313 | 313 | ||
314 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 314 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
315 | SLOT( deleteContacts( ) ) ); | 315 | SLOT( deleteContacts( ) ) ); |
316 | connect( mViewManager, SIGNAL( modified() ), | 316 | connect( mViewManager, SIGNAL( modified() ), |
317 | SLOT( setModified() ) ); | 317 | SLOT( setModified() ) ); |
318 | 318 | ||
319 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 319 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
320 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 320 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
321 | 321 | ||
322 | connect( mXXPortManager, SIGNAL( modified() ), | 322 | connect( mXXPortManager, SIGNAL( modified() ), |
323 | SLOT( setModified() ) ); | 323 | SLOT( setModified() ) ); |
324 | 324 | ||
325 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 325 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
326 | SLOT( incrementalSearch( const QString& ) ) ); | 326 | SLOT( incrementalSearch( const QString& ) ) ); |
327 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 327 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
328 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 328 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
329 | 329 | ||
330 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 330 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
331 | SLOT( sendMail( const QString& ) ) ); | 331 | SLOT( sendMail( const QString& ) ) ); |
332 | 332 | ||
333 | 333 | ||
334 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 334 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
335 | 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&))); | 335 | 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&))); |
336 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 336 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
337 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | 337 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); |
338 | 338 | ||
339 | 339 | ||
340 | #ifndef KAB_EMBEDDED | 340 | #ifndef KAB_EMBEDDED |
341 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 341 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
342 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 342 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
343 | 343 | ||
344 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 344 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
345 | SLOT( browse( const QString& ) ) ); | 345 | SLOT( browse( const QString& ) ) ); |
346 | 346 | ||
347 | 347 | ||
348 | mAddressBookService = new KAddressBookService( this ); | 348 | mAddressBookService = new KAddressBookService( this ); |
349 | 349 | ||
350 | #endif //KAB_EMBEDDED | 350 | #endif //KAB_EMBEDDED |
351 | 351 | ||
352 | mMessageTimer = new QTimer( this ); | 352 | mMessageTimer = new QTimer( this ); |
353 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 353 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
354 | mEditorDialog = 0; | 354 | mEditorDialog = 0; |
355 | createAddresseeEditorDialog( this ); | 355 | createAddresseeEditorDialog( this ); |
356 | setModified( false ); | 356 | setModified( false ); |
357 | mBRdisabled = false; | 357 | mBRdisabled = false; |
358 | #ifndef DESKTOP_VERSION | 358 | #ifndef DESKTOP_VERSION |
359 | infrared = 0; | 359 | infrared = 0; |
360 | #endif | 360 | #endif |
361 | //toggleBeamReceive( ); | 361 | //toggleBeamReceive( ); |
362 | //mMainWindow->toolBar()->show(); | 362 | //mMainWindow->toolBar()->show(); |
363 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi | 363 | // we have a toolbar repainting error on the Zaurus when starting KA/Pi |
364 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 364 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
365 | } | 365 | } |
366 | 366 | ||
367 | void KABCore::updateToolBar() | 367 | void KABCore::updateToolBar() |
368 | { | 368 | { |
369 | static int iii = 0; | 369 | static int iii = 0; |
370 | ++iii; | 370 | ++iii; |
371 | mMainWindow->toolBar()->repaintMe(); | 371 | mMainWindow->toolBar()->repaintMe(); |
372 | if ( iii < 5 ) | 372 | if ( iii < 5 ) |
373 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); | 373 | QTimer::singleShot( 10, this , SLOT ( updateToolBar())); |
374 | } | 374 | } |
375 | KABCore::~KABCore() | 375 | KABCore::~KABCore() |
376 | { | 376 | { |
377 | // save(); | 377 | // save(); |
378 | //saveSettings(); | 378 | //saveSettings(); |
379 | //KABPrefs::instance()->writeConfig(); | 379 | //KABPrefs::instance()->writeConfig(); |
380 | delete AddresseeConfig::instance(); | 380 | delete AddresseeConfig::instance(); |
381 | mAddressBook = 0; | 381 | mAddressBook = 0; |
382 | KABC::StdAddressBook::close(); | 382 | KABC::StdAddressBook::close(); |
383 | 383 | ||
384 | delete syncManager; | 384 | delete syncManager; |
385 | #ifndef DESKTOP_VERSION | 385 | #ifndef DESKTOP_VERSION |
386 | if ( infrared ) | 386 | if ( infrared ) |
387 | delete infrared; | 387 | delete infrared; |
388 | #endif | 388 | #endif |
389 | } | 389 | } |
390 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 390 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
391 | { | 391 | { |
392 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 392 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
393 | if ( cmsg == "setDocument(QString)" ) { | 393 | if ( cmsg == "setDocument(QString)" ) { |
394 | QDataStream stream( data, IO_ReadOnly ); | 394 | QDataStream stream( data, IO_ReadOnly ); |
395 | QString fileName; | 395 | QString fileName; |
396 | stream >> fileName; | 396 | stream >> fileName; |
397 | recieve( fileName ); | 397 | recieve( fileName ); |
398 | return; | 398 | return; |
399 | } | 399 | } |
400 | } | 400 | } |
401 | void KABCore::toggleBeamReceive( ) | 401 | void KABCore::toggleBeamReceive( ) |
402 | { | 402 | { |
403 | if ( mBRdisabled ) | 403 | if ( mBRdisabled ) |
404 | return; | 404 | return; |
405 | #ifndef DESKTOP_VERSION | 405 | #ifndef DESKTOP_VERSION |
406 | if ( infrared ) { | 406 | if ( infrared ) { |
407 | qDebug("AB disable BeamReceive "); | 407 | qDebug("AB disable BeamReceive "); |
408 | delete infrared; | 408 | delete infrared; |
409 | infrared = 0; | 409 | infrared = 0; |
410 | mActionBR->setChecked(false); | 410 | mActionBR->setChecked(false); |
411 | return; | 411 | return; |
412 | } | 412 | } |
413 | qDebug("AB enable BeamReceive "); | 413 | qDebug("AB enable BeamReceive "); |
414 | mActionBR->setChecked(true); | 414 | mActionBR->setChecked(true); |
415 | 415 | ||
416 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 416 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
417 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 417 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
418 | #endif | 418 | #endif |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | void KABCore::disableBR(bool b) | 422 | void KABCore::disableBR(bool b) |
423 | { | 423 | { |
424 | #ifndef DESKTOP_VERSION | 424 | #ifndef DESKTOP_VERSION |
425 | if ( b ) { | 425 | if ( b ) { |
426 | if ( infrared ) { | 426 | if ( infrared ) { |
427 | toggleBeamReceive( ); | 427 | toggleBeamReceive( ); |
428 | } | 428 | } |
429 | mBRdisabled = true; | 429 | mBRdisabled = true; |
430 | } else { | 430 | } else { |
431 | if ( mBRdisabled ) { | 431 | if ( mBRdisabled ) { |
432 | mBRdisabled = false; | 432 | mBRdisabled = false; |
433 | //toggleBeamReceive( ); | 433 | //toggleBeamReceive( ); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | #endif | 436 | #endif |
437 | 437 | ||
438 | } | 438 | } |
439 | void KABCore::recieve( QString fn ) | 439 | void KABCore::recieve( QString fn ) |
440 | { | 440 | { |
441 | //qDebug("KABCore::recieve "); | 441 | //qDebug("KABCore::recieve "); |
442 | int count = mAddressBook->importFromFile( fn, true ); | 442 | int count = mAddressBook->importFromFile( fn, true ); |
443 | if ( count ) | 443 | if ( count ) |
444 | setModified( true ); | 444 | setModified( true ); |
445 | mViewManager->refreshView(); | 445 | mViewManager->refreshView(); |
446 | message(i18n("%1 contact(s) received!").arg( count )); | 446 | message(i18n("%1 contact(s) received!").arg( count )); |
447 | topLevelWidget()->showMaximized(); | 447 | topLevelWidget()->showMaximized(); |
448 | topLevelWidget()->raise(); | 448 | topLevelWidget()->raise(); |
449 | } | 449 | } |
450 | void KABCore::restoreSettings() | 450 | void KABCore::restoreSettings() |
451 | { | 451 | { |
452 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 452 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
453 | 453 | ||
454 | bool state; | 454 | bool state; |
455 | 455 | ||
456 | if (mMultipleViewsAtOnce) | 456 | if (mMultipleViewsAtOnce) |
457 | state = KABPrefs::instance()->mDetailsPageVisible; | 457 | state = KABPrefs::instance()->mDetailsPageVisible; |
458 | else | 458 | else |
459 | state = false; | 459 | state = false; |
460 | 460 | ||
461 | mActionDetails->setChecked( state ); | 461 | mActionDetails->setChecked( state ); |
462 | setDetailsVisible( state ); | 462 | setDetailsVisible( state ); |
463 | 463 | ||
464 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 464 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
465 | 465 | ||
466 | mActionJumpBar->setChecked( state ); | 466 | mActionJumpBar->setChecked( state ); |
467 | setJumpButtonBarVisible( state ); | 467 | setJumpButtonBarVisible( state ); |
468 | /*US | 468 | /*US |
469 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 469 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
470 | if ( splitterSize.count() == 0 ) { | 470 | if ( splitterSize.count() == 0 ) { |
471 | splitterSize.append( width() / 2 ); | 471 | splitterSize.append( width() / 2 ); |
472 | splitterSize.append( width() / 2 ); | 472 | splitterSize.append( width() / 2 ); |
473 | } | 473 | } |
474 | mMiniSplitter->setSizes( splitterSize ); | 474 | mMiniSplitter->setSizes( splitterSize ); |
475 | if ( mExtensionBarSplitter ) { | 475 | if ( mExtensionBarSplitter ) { |
476 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 476 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
477 | if ( splitterSize.count() == 0 ) { | 477 | if ( splitterSize.count() == 0 ) { |
478 | splitterSize.append( width() / 2 ); | 478 | splitterSize.append( width() / 2 ); |
479 | splitterSize.append( width() / 2 ); | 479 | splitterSize.append( width() / 2 ); |
480 | } | 480 | } |
481 | mExtensionBarSplitter->setSizes( splitterSize ); | 481 | mExtensionBarSplitter->setSizes( splitterSize ); |
482 | 482 | ||
483 | } | 483 | } |
484 | */ | 484 | */ |
485 | mViewManager->restoreSettings(); | 485 | mViewManager->restoreSettings(); |
486 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 486 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
487 | mExtensionManager->restoreSettings(); | 487 | mExtensionManager->restoreSettings(); |
488 | #ifdef DESKTOP_VERSION | 488 | #ifdef DESKTOP_VERSION |
489 | int wid = width(); | 489 | int wid = width(); |
490 | if ( wid < 10 ) | 490 | if ( wid < 10 ) |
491 | wid = 400; | 491 | wid = 400; |
492 | #else | 492 | #else |
493 | int wid = QApplication::desktop()->width(); | 493 | int wid = QApplication::desktop()->width(); |
494 | if ( wid < 640 ) | 494 | if ( wid < 640 ) |
495 | wid = QApplication::desktop()->height(); | 495 | wid = QApplication::desktop()->height(); |
496 | #endif | 496 | #endif |
497 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 497 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
498 | if ( true /*splitterSize.count() == 0*/ ) { | 498 | if ( true /*splitterSize.count() == 0*/ ) { |
499 | splitterSize.append( wid / 2 ); | 499 | splitterSize.append( wid / 2 ); |
500 | splitterSize.append( wid / 2 ); | 500 | splitterSize.append( wid / 2 ); |
501 | } | 501 | } |
502 | mMiniSplitter->setSizes( splitterSize ); | 502 | mMiniSplitter->setSizes( splitterSize ); |
503 | if ( mExtensionBarSplitter ) { | 503 | if ( mExtensionBarSplitter ) { |
504 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 504 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
505 | if ( true /*splitterSize.count() == 0*/ ) { | 505 | if ( true /*splitterSize.count() == 0*/ ) { |
506 | splitterSize.append( wid / 2 ); | 506 | splitterSize.append( wid / 2 ); |
507 | splitterSize.append( wid / 2 ); | 507 | splitterSize.append( wid / 2 ); |
508 | } | 508 | } |
509 | mExtensionBarSplitter->setSizes( splitterSize ); | 509 | mExtensionBarSplitter->setSizes( splitterSize ); |
510 | 510 | ||
511 | } | 511 | } |
512 | 512 | ||
513 | 513 | ||
514 | } | 514 | } |
515 | 515 | ||
516 | void KABCore::saveSettings() | 516 | void KABCore::saveSettings() |
517 | { | 517 | { |
518 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 518 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
519 | if ( mExtensionBarSplitter ) | 519 | if ( mExtensionBarSplitter ) |
520 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 520 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
521 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 521 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
522 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 522 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
523 | #ifndef KAB_EMBEDDED | 523 | #ifndef KAB_EMBEDDED |
524 | 524 | ||
525 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 525 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
526 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 526 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
527 | #endif //KAB_EMBEDDED | 527 | #endif //KAB_EMBEDDED |
528 | mExtensionManager->saveSettings(); | 528 | mExtensionManager->saveSettings(); |
529 | mViewManager->saveSettings(); | 529 | mViewManager->saveSettings(); |
530 | 530 | ||
531 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 531 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
532 | } | 532 | } |
533 | 533 | ||
534 | KABC::AddressBook *KABCore::addressBook() const | 534 | KABC::AddressBook *KABCore::addressBook() const |
535 | { | 535 | { |
536 | return mAddressBook; | 536 | return mAddressBook; |
537 | } | 537 | } |
538 | 538 | ||
539 | KConfig *KABCore::config() | 539 | KConfig *KABCore::config() |
540 | { | 540 | { |
541 | #ifndef KAB_EMBEDDED | 541 | #ifndef KAB_EMBEDDED |
542 | return KABPrefs::instance()->config(); | 542 | return KABPrefs::instance()->config(); |
543 | #else //KAB_EMBEDDED | 543 | #else //KAB_EMBEDDED |
544 | return KABPrefs::instance()->getConfig(); | 544 | return KABPrefs::instance()->getConfig(); |
545 | #endif //KAB_EMBEDDED | 545 | #endif //KAB_EMBEDDED |
546 | } | 546 | } |
547 | 547 | ||
548 | KActionCollection *KABCore::actionCollection() const | 548 | KActionCollection *KABCore::actionCollection() const |
549 | { | 549 | { |
550 | return mGUIClient->actionCollection(); | 550 | return mGUIClient->actionCollection(); |
551 | } | 551 | } |
552 | 552 | ||
553 | KABC::Field *KABCore::currentSearchField() const | 553 | KABC::Field *KABCore::currentSearchField() const |
554 | { | 554 | { |
555 | if (mIncSearchWidget) | 555 | if (mIncSearchWidget) |
556 | return mIncSearchWidget->currentField(); | 556 | return mIncSearchWidget->currentField(); |
557 | else | 557 | else |
558 | return 0; | 558 | return 0; |
559 | } | 559 | } |
560 | 560 | ||
561 | QStringList KABCore::selectedUIDs() const | 561 | QStringList KABCore::selectedUIDs() const |
562 | { | 562 | { |
563 | return mViewManager->selectedUids(); | 563 | return mViewManager->selectedUids(); |
564 | } | 564 | } |
565 | 565 | ||
566 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 566 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
567 | { | 567 | { |
568 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 568 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
569 | 569 | ||
570 | QPtrList<KRES::Resource> kresResources; | 570 | QPtrList<KRES::Resource> kresResources; |
571 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 571 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
572 | KABC::Resource *resource; | 572 | KABC::Resource *resource; |
573 | while ( ( resource = resIt.current() ) != 0 ) { | 573 | while ( ( resource = resIt.current() ) != 0 ) { |
574 | ++resIt; | 574 | ++resIt; |
575 | if ( !resource->readOnly() ) { | 575 | if ( !resource->readOnly() ) { |
576 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 576 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
577 | if ( res ) | 577 | if ( res ) |
578 | kresResources.append( res ); | 578 | kresResources.append( res ); |
579 | } | 579 | } |
580 | } | 580 | } |
581 | 581 | ||
582 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 582 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
583 | return static_cast<KABC::Resource*>( res ); | 583 | return static_cast<KABC::Resource*>( res ); |
584 | } | 584 | } |
585 | 585 | ||
586 | #ifndef KAB_EMBEDDED | 586 | #ifndef KAB_EMBEDDED |
587 | KAboutData *KABCore::createAboutData() | 587 | KAboutData *KABCore::createAboutData() |
588 | #else //KAB_EMBEDDED | 588 | #else //KAB_EMBEDDED |
589 | void KABCore::createAboutData() | 589 | void KABCore::createAboutData() |
590 | #endif //KAB_EMBEDDED | 590 | #endif //KAB_EMBEDDED |
591 | { | 591 | { |
592 | #ifndef KAB_EMBEDDED | 592 | #ifndef KAB_EMBEDDED |
593 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 593 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
594 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 594 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
595 | KAboutData::License_GPL_V2, | 595 | KAboutData::License_GPL_V2, |
596 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 596 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
597 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 597 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
598 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 598 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
599 | about->addAuthor( "Cornelius Schumacher", | 599 | about->addAuthor( "Cornelius Schumacher", |
600 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 600 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
601 | "schumacher@kde.org" ); | 601 | "schumacher@kde.org" ); |
602 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 602 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
603 | "mpilone@slac.com" ); | 603 | "mpilone@slac.com" ); |
604 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 604 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
605 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 605 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
606 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 606 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
607 | "michel@klaralvdalens-datakonsult.se" ); | 607 | "michel@klaralvdalens-datakonsult.se" ); |
608 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 608 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
609 | "hansen@kde.org" ); | 609 | "hansen@kde.org" ); |
610 | 610 | ||
611 | return about; | 611 | return about; |
612 | #endif //KAB_EMBEDDED | 612 | #endif //KAB_EMBEDDED |
613 | 613 | ||
614 | QString version; | 614 | QString version; |
615 | #include <../version> | 615 | #include <../version> |
616 | QMessageBox::about( this, "About KAddressbook/Pi", | 616 | QMessageBox::about( this, "About KAddressbook/Pi", |
617 | "KAddressbook/Platform-independent\n" | 617 | "KAddressbook/Platform-independent\n" |
618 | "(KA/Pi) " +version + " - " + | 618 | "(KA/Pi) " +version + " - " + |
619 | #ifdef DESKTOP_VERSION | 619 | #ifdef DESKTOP_VERSION |
620 | "Desktop Edition\n" | 620 | "Desktop Edition\n" |
621 | #else | 621 | #else |
622 | "PDA-Edition\n" | 622 | "PDA-Edition\n" |
623 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 623 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
624 | #endif | 624 | #endif |
625 | 625 | ||
626 | "(c) 2004 Ulf Schenk\n" | 626 | "(c) 2004 Ulf Schenk\n" |
627 | "(c) 2004 Lutz Rogowski\n" | 627 | "(c) 2004 Lutz Rogowski\n" |
628 | "(c) 1997-2003, The KDE PIM Team\n" | 628 | "(c) 1997-2003, The KDE PIM Team\n" |
629 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 629 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
630 | "Don Sanders Original author\n" | 630 | "Don Sanders Original author\n" |
631 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 631 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
632 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 632 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
633 | "Greg Stern DCOP interface\n" | 633 | "Greg Stern DCOP interface\n" |
634 | "Mark Westcot Contact pinning\n" | 634 | "Mark Westcot Contact pinning\n" |
635 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 635 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
636 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 636 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
637 | #ifdef _WIN32_ | 637 | #ifdef _WIN32_ |
638 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 638 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
639 | #endif | 639 | #endif |
640 | ); | 640 | ); |
641 | } | 641 | } |
642 | 642 | ||
643 | void KABCore::setContactSelected( const QString &uid ) | 643 | void KABCore::setContactSelected( const QString &uid ) |
644 | { | 644 | { |
645 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 645 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
646 | if ( !mDetails->isHidden() ) | 646 | if ( !mDetails->isHidden() ) |
647 | mDetails->setAddressee( addr ); | 647 | mDetails->setAddressee( addr ); |
648 | 648 | ||
649 | if ( !addr.isEmpty() ) { | 649 | if ( !addr.isEmpty() ) { |
650 | emit contactSelected( addr.formattedName() ); | 650 | emit contactSelected( addr.formattedName() ); |
651 | KABC::Picture pic = addr.photo(); | 651 | KABC::Picture pic = addr.photo(); |
652 | if ( pic.isIntern() ) { | 652 | if ( pic.isIntern() ) { |
653 | //US emit contactSelected( pic.data() ); | 653 | //US emit contactSelected( pic.data() ); |
654 | //US instead use: | 654 | //US instead use: |
655 | QPixmap px; | 655 | QPixmap px; |
656 | if (pic.data().isNull() != true) | 656 | if (pic.data().isNull() != true) |
657 | { | 657 | { |
658 | px.convertFromImage(pic.data()); | 658 | px.convertFromImage(pic.data()); |
659 | } | 659 | } |
660 | 660 | ||
661 | emit contactSelected( px ); | 661 | emit contactSelected( px ); |
662 | } | 662 | } |
663 | } | 663 | } |
664 | 664 | ||
665 | 665 | ||
666 | mExtensionManager->setSelectionChanged(); | 666 | mExtensionManager->setSelectionChanged(); |
667 | 667 | ||
668 | // update the actions | 668 | // update the actions |
669 | bool selected = !uid.isEmpty(); | 669 | bool selected = !uid.isEmpty(); |
670 | 670 | ||
671 | if ( mReadWrite ) { | 671 | if ( mReadWrite ) { |
672 | mActionCut->setEnabled( selected ); | 672 | mActionCut->setEnabled( selected ); |
673 | mActionPaste->setEnabled( selected ); | 673 | mActionPaste->setEnabled( selected ); |
674 | } | 674 | } |
675 | 675 | ||
676 | mActionCopy->setEnabled( selected ); | 676 | mActionCopy->setEnabled( selected ); |
677 | mActionDelete->setEnabled( selected ); | 677 | mActionDelete->setEnabled( selected ); |
678 | mActionEditAddressee->setEnabled( selected ); | 678 | mActionEditAddressee->setEnabled( selected ); |
679 | mActionMail->setEnabled( selected ); | 679 | mActionMail->setEnabled( selected ); |
680 | mActionMailVCard->setEnabled( selected ); | 680 | mActionMailVCard->setEnabled( selected ); |
681 | //if (mActionBeam) | 681 | //if (mActionBeam) |
682 | //mActionBeam->setEnabled( selected ); | 682 | //mActionBeam->setEnabled( selected ); |
683 | mActionWhoAmI->setEnabled( selected ); | 683 | mActionWhoAmI->setEnabled( selected ); |
684 | } | 684 | } |
685 | 685 | ||
686 | void KABCore::sendMail() | 686 | void KABCore::sendMail() |
687 | { | 687 | { |
688 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 688 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
689 | } | 689 | } |
690 | 690 | ||
691 | void KABCore::sendMail( const QString& emaillist ) | 691 | void KABCore::sendMail( const QString& emaillist ) |
692 | { | 692 | { |
693 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 693 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
694 | if (emaillist.contains(",") > 0) | 694 | if (emaillist.contains(",") > 0) |
695 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 695 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
696 | else | 696 | else |
697 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 697 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
698 | } | 698 | } |
699 | 699 | ||
700 | 700 | ||
701 | 701 | ||
702 | void KABCore::mailVCard() | 702 | void KABCore::mailVCard() |
703 | { | 703 | { |
704 | QStringList uids = mViewManager->selectedUids(); | 704 | QStringList uids = mViewManager->selectedUids(); |
705 | if ( !uids.isEmpty() ) | 705 | if ( !uids.isEmpty() ) |
706 | mailVCard( uids ); | 706 | mailVCard( uids ); |
707 | } | 707 | } |
708 | 708 | ||
709 | void KABCore::mailVCard( const QStringList& uids ) | 709 | void KABCore::mailVCard( const QStringList& uids ) |
710 | { | 710 | { |
711 | QStringList urls; | 711 | QStringList urls; |
712 | 712 | ||
713 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 713 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
714 | 714 | ||
715 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 715 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
716 | 716 | ||
717 | 717 | ||
718 | 718 | ||
719 | QDir().mkdir( dirName, true ); | 719 | QDir().mkdir( dirName, true ); |
720 | 720 | ||
721 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 721 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
722 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 722 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
723 | 723 | ||
724 | if ( a.isEmpty() ) | 724 | if ( a.isEmpty() ) |
725 | continue; | 725 | continue; |
726 | 726 | ||
727 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 727 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
728 | 728 | ||
729 | QString fileName = dirName + "/" + name; | 729 | QString fileName = dirName + "/" + name; |
730 | 730 | ||
731 | QFile outFile(fileName); | 731 | QFile outFile(fileName); |
732 | 732 | ||
733 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 733 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
734 | KABC::VCardConverter converter; | 734 | KABC::VCardConverter converter; |
735 | QString vcard; | 735 | QString vcard; |
736 | 736 | ||
737 | converter.addresseeToVCard( a, vcard ); | 737 | converter.addresseeToVCard( a, vcard ); |
738 | 738 | ||
739 | QTextStream t( &outFile ); // use a text stream | 739 | QTextStream t( &outFile ); // use a text stream |
740 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 740 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
741 | t << vcard; | 741 | t << vcard; |
742 | 742 | ||
743 | outFile.close(); | 743 | outFile.close(); |
744 | 744 | ||
745 | urls.append( fileName ); | 745 | urls.append( fileName ); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | 748 | ||
749 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 749 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
750 | 750 | ||
751 | 751 | ||
752 | /*US | 752 | /*US |
753 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 753 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
754 | QString::null, // subject | 754 | QString::null, // subject |
755 | QString::null, // body | 755 | QString::null, // body |
756 | QString::null, | 756 | QString::null, |
757 | urls ); // attachments | 757 | urls ); // attachments |
758 | */ | 758 | */ |
759 | 759 | ||
760 | } | 760 | } |
761 | 761 | ||
762 | /** | 762 | /** |
763 | Beams the "WhoAmI contact. | 763 | Beams the "WhoAmI contact. |
764 | */ | 764 | */ |
765 | void KABCore::beamMySelf() | 765 | void KABCore::beamMySelf() |
766 | { | 766 | { |
767 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 767 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
768 | if (!a.isEmpty()) | 768 | if (!a.isEmpty()) |
769 | { | 769 | { |
770 | QStringList uids; | 770 | QStringList uids; |
771 | uids << a.uid(); | 771 | uids << a.uid(); |
772 | 772 | ||
773 | beamVCard(uids); | 773 | beamVCard(uids); |
774 | } else { | 774 | } else { |
775 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 775 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
776 | 776 | ||
777 | 777 | ||
778 | } | 778 | } |
779 | } | 779 | } |
780 | void KABCore::updateMainWindow() | 780 | void KABCore::updateMainWindow() |
781 | { | 781 | { |
782 | 782 | ||
783 | mMainWindow->showMaximized(); | 783 | mMainWindow->showMaximized(); |
784 | mMainWindow->update(); | 784 | mMainWindow->update(); |
785 | } | 785 | } |
786 | void KABCore::resizeEvent(QResizeEvent* e ) | 786 | void KABCore::resizeEvent(QResizeEvent* e ) |
787 | { | 787 | { |
788 | if ( !mMiniSplitter ) | 788 | if ( !mMiniSplitter ) |
789 | return; | 789 | return; |
790 | if ( QApplication::desktop()->width() >= 480 ) { | 790 | if ( QApplication::desktop()->width() >= 480 ) { |
791 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 | 791 | if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 |
792 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { | 792 | if ( mMiniSplitter->orientation() == Qt::Vertical ) { |
793 | mMiniSplitter->setOrientation( Qt::Horizontal); | 793 | mMiniSplitter->setOrientation( Qt::Horizontal); |
794 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 794 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
795 | if ( QApplication::desktop()->width() <= 640 ) { | 795 | if ( QApplication::desktop()->width() <= 640 ) { |
796 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 796 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
797 | mViewManager->getFilterAction()->setComboWidth( 150 ); | 797 | mViewManager->getFilterAction()->setComboWidth( 150 ); |
798 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 798 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
799 | } | 799 | } |
800 | } | 800 | } |
801 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 | 801 | } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 |
802 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { | 802 | if ( mMiniSplitter->orientation() == Qt::Horizontal ) { |
803 | mMiniSplitter->setOrientation( Qt::Vertical ); | 803 | mMiniSplitter->setOrientation( Qt::Vertical ); |
804 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 804 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
805 | if ( QApplication::desktop()->width() <= 640 ) { | 805 | if ( QApplication::desktop()->width() <= 640 ) { |
806 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); | 806 | //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); |
807 | mMainWindow->showMinimized(); | 807 | mMainWindow->showMinimized(); |
808 | mViewManager->getFilterAction()->setComboWidth( 0 ); | 808 | mViewManager->getFilterAction()->setComboWidth( 0 ); |
809 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); | 809 | QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); |
810 | } | 810 | } |
811 | } | 811 | } |
812 | } | 812 | } |
813 | } | 813 | } |
814 | 814 | ||
815 | } | 815 | } |
816 | void KABCore::export2phone() | 816 | void KABCore::export2phone() |
817 | { | 817 | { |
818 | 818 | ||
819 | QStringList uids; | 819 | QStringList uids; |
820 | XXPortSelectDialog dlg( this, false, this ); | 820 | XXPortSelectDialog dlg( this, false, this ); |
821 | if ( dlg.exec() ) | 821 | if ( dlg.exec() ) |
822 | uids = dlg.uids(); | 822 | uids = dlg.uids(); |
823 | else | 823 | else |
824 | return; | 824 | return; |
825 | if ( uids.isEmpty() ) | 825 | if ( uids.isEmpty() ) |
826 | return; | 826 | return; |
827 | // qDebug("count %d ", uids.count()); | 827 | // qDebug("count %d ", uids.count()); |
828 | 828 | ||
829 | KAex2phonePrefs ex2phone; | 829 | KAex2phonePrefs ex2phone; |
830 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 830 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
831 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 831 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
832 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 832 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
833 | 833 | ||
834 | if ( !ex2phone.exec() ) { | 834 | if ( !ex2phone.exec() ) { |
835 | return; | 835 | return; |
836 | } | 836 | } |
837 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 837 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
838 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 838 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
839 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 839 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
840 | 840 | ||
841 | 841 | ||
842 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 842 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
843 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 843 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
844 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 844 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
845 | 845 | ||
846 | QString fileName = getPhoneFile(); | 846 | QString fileName = getPhoneFile(); |
847 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 847 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
848 | return; | 848 | return; |
849 | 849 | ||
850 | message(i18n("Exporting to phone...")); | 850 | message(i18n("Exporting to phone...")); |
851 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 851 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
852 | 852 | ||
853 | } | 853 | } |
854 | QString KABCore::getPhoneFile() | 854 | QString KABCore::getPhoneFile() |
855 | { | 855 | { |
856 | #ifdef DESKTOP_VERSION | 856 | #ifdef DESKTOP_VERSION |
857 | return locateLocal("tmp", "phonefile.vcf"); | 857 | return locateLocal("tmp", "phonefile.vcf"); |
858 | #else | 858 | #else |
859 | return "/tmp/phonefile.vcf"; | 859 | return "/tmp/phonefile.vcf"; |
860 | #endif | 860 | #endif |
861 | 861 | ||
862 | } | 862 | } |
863 | void KABCore::writeToPhone( ) | 863 | void KABCore::writeToPhone( ) |
864 | { | 864 | { |
865 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 865 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
866 | message(i18n("Export to phone finished!")); | 866 | message(i18n("Export to phone finished!")); |
867 | else | 867 | else |
868 | qDebug(i18n("Error exporting to phone")); | 868 | qDebug(i18n("Error exporting to phone")); |
869 | } | 869 | } |
870 | void KABCore::beamVCard() | 870 | void KABCore::beamVCard() |
871 | { | 871 | { |
872 | QStringList uids; | 872 | QStringList uids; |
873 | XXPortSelectDialog dlg( this, false, this ); | 873 | XXPortSelectDialog dlg( this, false, this ); |
874 | if ( dlg.exec() ) | 874 | if ( dlg.exec() ) |
875 | uids = dlg.uids(); | 875 | uids = dlg.uids(); |
876 | else | 876 | else |
877 | return; | 877 | return; |
878 | if ( uids.isEmpty() ) | 878 | if ( uids.isEmpty() ) |
879 | return; | 879 | return; |
880 | beamVCard( uids ); | 880 | beamVCard( uids ); |
881 | } | 881 | } |
882 | 882 | ||
883 | 883 | ||
884 | void KABCore::beamVCard(const QStringList& uids) | 884 | void KABCore::beamVCard(const QStringList& uids) |
885 | { | 885 | { |
886 | 886 | ||
887 | // LR: we should use the /tmp dir on the Zaurus, | 887 | // LR: we should use the /tmp dir on the Zaurus, |
888 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 888 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
889 | 889 | ||
890 | #ifdef DESKTOP_VERSION | 890 | #ifdef DESKTOP_VERSION |
891 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 891 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
892 | #else | 892 | #else |
893 | QString fileName = "/tmp/kapibeamfile.vcf"; | 893 | QString fileName = "/tmp/kapibeamfile.vcf"; |
894 | #endif | 894 | #endif |
895 | 895 | ||
896 | KABC::VCardConverter converter; | 896 | KABC::VCardConverter converter; |
897 | QString description; | 897 | QString description; |
898 | QString datastream; | 898 | QString datastream; |
899 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 899 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
900 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 900 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
901 | 901 | ||
902 | if ( a.isEmpty() ) | 902 | if ( a.isEmpty() ) |
903 | continue; | 903 | continue; |
904 | 904 | ||
905 | if (description.isEmpty()) | 905 | if (description.isEmpty()) |
906 | description = a.formattedName(); | 906 | description = a.formattedName(); |
907 | 907 | ||
908 | QString vcard; | 908 | QString vcard; |
909 | converter.addresseeToVCard( a, vcard ); | 909 | converter.addresseeToVCard( a, vcard ); |
910 | int start = 0; | 910 | int start = 0; |
911 | int next; | 911 | int next; |
912 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 912 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
913 | int semi = vcard.find(";", next); | 913 | int semi = vcard.find(";", next); |
914 | int dopp = vcard.find(":", next); | 914 | int dopp = vcard.find(":", next); |
915 | int sep; | 915 | int sep; |
916 | if ( semi < dopp && semi >= 0 ) | 916 | if ( semi < dopp && semi >= 0 ) |
917 | sep = semi ; | 917 | sep = semi ; |
918 | else | 918 | else |
919 | sep = dopp; | 919 | sep = dopp; |
920 | datastream +=vcard.mid( start, next - start); | 920 | datastream +=vcard.mid( start, next - start); |
921 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 921 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
922 | start = sep; | 922 | start = sep; |
923 | } | 923 | } |
924 | datastream += vcard.mid( start,vcard.length() ); | 924 | datastream += vcard.mid( start,vcard.length() ); |
925 | } | 925 | } |
926 | #ifndef DESKTOP_VERSION | 926 | #ifndef DESKTOP_VERSION |
927 | QFile outFile(fileName); | 927 | QFile outFile(fileName); |
928 | if ( outFile.open(IO_WriteOnly) ) { | 928 | if ( outFile.open(IO_WriteOnly) ) { |
929 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 929 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
930 | QTextStream t( &outFile ); // use a text stream | 930 | QTextStream t( &outFile ); // use a text stream |
931 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 931 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
932 | t.setEncoding( QTextStream::Latin1 ); | 932 | t.setEncoding( QTextStream::Latin1 ); |
933 | t <<datastream.latin1(); | 933 | t <<datastream.latin1(); |
934 | outFile.close(); | 934 | outFile.close(); |
935 | Ir *ir = new Ir( this ); | 935 | Ir *ir = new Ir( this ); |
936 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 936 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
937 | ir->send( fileName, description, "text/x-vCard" ); | 937 | ir->send( fileName, description, "text/x-vCard" ); |
938 | } else { | 938 | } else { |
939 | qDebug("Error open temp beam file "); | 939 | qDebug("Error open temp beam file "); |
940 | return; | 940 | return; |
941 | } | 941 | } |
942 | #endif | 942 | #endif |
943 | 943 | ||
944 | } | 944 | } |
945 | 945 | ||
946 | void KABCore::beamDone( Ir *ir ) | 946 | void KABCore::beamDone( Ir *ir ) |
947 | { | 947 | { |
948 | #ifndef DESKTOP_VERSION | 948 | #ifndef DESKTOP_VERSION |
949 | delete ir; | 949 | delete ir; |
950 | #endif | 950 | #endif |
951 | topLevelWidget()->raise(); | 951 | topLevelWidget()->raise(); |
952 | message( i18n("Beaming finished!") ); | 952 | message( i18n("Beaming finished!") ); |
953 | } | 953 | } |
954 | 954 | ||
955 | 955 | ||
956 | void KABCore::browse( const QString& url ) | 956 | void KABCore::browse( const QString& url ) |
957 | { | 957 | { |
958 | #ifndef KAB_EMBEDDED | 958 | #ifndef KAB_EMBEDDED |
959 | kapp->invokeBrowser( url ); | 959 | kapp->invokeBrowser( url ); |
960 | #else //KAB_EMBEDDED | 960 | #else //KAB_EMBEDDED |
961 | qDebug("KABCore::browse must be fixed"); | 961 | qDebug("KABCore::browse must be fixed"); |
962 | #endif //KAB_EMBEDDED | 962 | #endif //KAB_EMBEDDED |
963 | } | 963 | } |
964 | 964 | ||
965 | void KABCore::selectAllContacts() | 965 | void KABCore::selectAllContacts() |
966 | { | 966 | { |
967 | mViewManager->setSelected( QString::null, true ); | 967 | mViewManager->setSelected( QString::null, true ); |
968 | } | 968 | } |
969 | 969 | ||
970 | void KABCore::deleteContacts() | 970 | void KABCore::deleteContacts() |
971 | { | 971 | { |
972 | QStringList uidList = mViewManager->selectedUids(); | 972 | QStringList uidList = mViewManager->selectedUids(); |
973 | deleteContacts( uidList ); | 973 | deleteContacts( uidList ); |
974 | } | 974 | } |
975 | 975 | ||
976 | void KABCore::deleteContacts( const QStringList &uids ) | 976 | void KABCore::deleteContacts( const QStringList &uids ) |
977 | { | 977 | { |
978 | if ( uids.count() > 0 ) { | 978 | if ( uids.count() > 0 ) { |
979 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 979 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
980 | UndoStack::instance()->push( command ); | 980 | UndoStack::instance()->push( command ); |
981 | RedoStack::instance()->clear(); | 981 | RedoStack::instance()->clear(); |
982 | 982 | ||
983 | // now if we deleted anything, refresh | 983 | // now if we deleted anything, refresh |
984 | setContactSelected( QString::null ); | 984 | setContactSelected( QString::null ); |
985 | setModified( true ); | 985 | setModified( true ); |
986 | } | 986 | } |
987 | } | 987 | } |
988 | 988 | ||
989 | void KABCore::copyContacts() | 989 | void KABCore::copyContacts() |
990 | { | 990 | { |
991 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 991 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
992 | 992 | ||
993 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 993 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
994 | 994 | ||
995 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 995 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
996 | 996 | ||
997 | QClipboard *cb = QApplication::clipboard(); | 997 | QClipboard *cb = QApplication::clipboard(); |
998 | cb->setText( clipText ); | 998 | cb->setText( clipText ); |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | void KABCore::cutContacts() | 1001 | void KABCore::cutContacts() |
1002 | { | 1002 | { |
1003 | QStringList uidList = mViewManager->selectedUids(); | 1003 | QStringList uidList = mViewManager->selectedUids(); |
1004 | 1004 | ||
1005 | //US if ( uidList.size() > 0 ) { | 1005 | //US if ( uidList.size() > 0 ) { |
1006 | if ( uidList.count() > 0 ) { | 1006 | if ( uidList.count() > 0 ) { |
1007 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 1007 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
1008 | UndoStack::instance()->push( command ); | 1008 | UndoStack::instance()->push( command ); |
1009 | RedoStack::instance()->clear(); | 1009 | RedoStack::instance()->clear(); |
1010 | 1010 | ||
1011 | setModified( true ); | 1011 | setModified( true ); |
1012 | } | 1012 | } |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | void KABCore::pasteContacts() | 1015 | void KABCore::pasteContacts() |
1016 | { | 1016 | { |
1017 | QClipboard *cb = QApplication::clipboard(); | 1017 | QClipboard *cb = QApplication::clipboard(); |
1018 | 1018 | ||
1019 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 1019 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
1020 | 1020 | ||
1021 | pasteContacts( list ); | 1021 | pasteContacts( list ); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 1024 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
1025 | { | 1025 | { |
1026 | KABC::Resource *resource = requestResource( this ); | 1026 | KABC::Resource *resource = requestResource( this ); |
1027 | KABC::Addressee::List::Iterator it; | 1027 | KABC::Addressee::List::Iterator it; |
1028 | for ( it = list.begin(); it != list.end(); ++it ) | 1028 | for ( it = list.begin(); it != list.end(); ++it ) |
1029 | (*it).setResource( resource ); | 1029 | (*it).setResource( resource ); |
1030 | 1030 | ||
1031 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 1031 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
1032 | UndoStack::instance()->push( command ); | 1032 | UndoStack::instance()->push( command ); |
1033 | RedoStack::instance()->clear(); | 1033 | RedoStack::instance()->clear(); |
1034 | 1034 | ||
1035 | setModified( true ); | 1035 | setModified( true ); |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | void KABCore::setWhoAmI() | 1038 | void KABCore::setWhoAmI() |
1039 | { | 1039 | { |
1040 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1040 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1041 | 1041 | ||
1042 | if ( addrList.count() > 1 ) { | 1042 | if ( addrList.count() > 1 ) { |
1043 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 1043 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
1044 | return; | 1044 | return; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 1047 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
1048 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 1048 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
1049 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 1049 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
1050 | } | 1050 | } |
1051 | void KABCore::editCategories() | 1051 | void KABCore::editCategories() |
1052 | { | 1052 | { |
1053 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); | 1053 | KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); |
1054 | dlg.exec(); | 1054 | dlg.exec(); |
1055 | } | 1055 | } |
1056 | void KABCore::setCategories() | 1056 | void KABCore::setCategories() |
1057 | { | 1057 | { |
1058 | 1058 | ||
1059 | QStringList uids; | 1059 | QStringList uids; |
1060 | XXPortSelectDialog dlgx( this, false, this ); | 1060 | XXPortSelectDialog dlgx( this, false, this ); |
1061 | if ( dlgx.exec() ) | 1061 | if ( dlgx.exec() ) |
1062 | uids = dlgx.uids(); | 1062 | uids = dlgx.uids(); |
1063 | else | 1063 | else |
1064 | return; | 1064 | return; |
1065 | if ( uids.isEmpty() ) | 1065 | if ( uids.isEmpty() ) |
1066 | return; | 1066 | return; |
1067 | // qDebug("count %d ", uids.count()); | 1067 | // qDebug("count %d ", uids.count()); |
1068 | 1068 | ||
1069 | 1069 | ||
1070 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 1070 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
1071 | if ( !dlg.exec() ) { | 1071 | if ( !dlg.exec() ) { |
1072 | message( i18n("Setting categories cancelled") ); | 1072 | message( i18n("Setting categories cancelled") ); |
1073 | return; | 1073 | return; |
1074 | } | 1074 | } |
1075 | bool merge = false; | 1075 | bool merge = false; |
1076 | QString msg = i18n( "Merge with existing categories?" ); | 1076 | QString msg = i18n( "Merge with existing categories?" ); |
1077 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 1077 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
1078 | merge = true; | 1078 | merge = true; |
1079 | 1079 | ||
1080 | message( i18n("Setting categories ... please wait!") ); | 1080 | message( i18n("Setting categories ... please wait!") ); |
1081 | QStringList categories = dlg.selectedCategories(); | 1081 | QStringList categories = dlg.selectedCategories(); |
1082 | 1082 | ||
1083 | //QStringList uids = mViewManager->selectedUids(); | 1083 | //QStringList uids = mViewManager->selectedUids(); |
1084 | QStringList::Iterator it; | 1084 | QStringList::Iterator it; |
1085 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1085 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1086 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1086 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1087 | if ( !addr.isEmpty() ) { | 1087 | if ( !addr.isEmpty() ) { |
1088 | if ( !merge ) | 1088 | if ( !merge ) |
1089 | addr.setCategories( categories ); | 1089 | addr.setCategories( categories ); |
1090 | else { | 1090 | else { |
1091 | QStringList addrCategories = addr.categories(); | 1091 | QStringList addrCategories = addr.categories(); |
1092 | QStringList::Iterator catIt; | 1092 | QStringList::Iterator catIt; |
1093 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1093 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1094 | if ( !addrCategories.contains( *catIt ) ) | 1094 | if ( !addrCategories.contains( *catIt ) ) |
1095 | addrCategories.append( *catIt ); | 1095 | addrCategories.append( *catIt ); |
1096 | } | 1096 | } |
1097 | addr.setCategories( addrCategories ); | 1097 | addr.setCategories( addrCategories ); |
1098 | } | 1098 | } |
1099 | mAddressBook->insertAddressee( addr ); | 1099 | mAddressBook->insertAddressee( addr ); |
1100 | } | 1100 | } |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | if ( uids.count() > 0 ) | 1103 | if ( uids.count() > 0 ) |
1104 | setModified( true ); | 1104 | setModified( true ); |
1105 | message( i18n("Setting categories completed!") ); | 1105 | message( i18n("Setting categories completed!") ); |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1108 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1109 | { | 1109 | { |
1110 | mIncSearchWidget->setFields( fields ); | 1110 | mIncSearchWidget->setFields( fields ); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | void KABCore::incrementalSearch( const QString& text ) | 1113 | void KABCore::incrementalSearch( const QString& text ) |
1114 | { | 1114 | { |
1115 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1115 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1116 | } | 1116 | } |
1117 | 1117 | ||
1118 | void KABCore::setModified() | 1118 | void KABCore::setModified() |
1119 | { | 1119 | { |
1120 | setModified( true ); | 1120 | setModified( true ); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | void KABCore::setModifiedWOrefresh() | 1123 | void KABCore::setModifiedWOrefresh() |
1124 | { | 1124 | { |
1125 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1125 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1126 | mModified = true; | 1126 | mModified = true; |
1127 | mActionSave->setEnabled( mModified ); | 1127 | mActionSave->setEnabled( mModified ); |
1128 | #ifdef DESKTOP_VERSION | 1128 | #ifdef DESKTOP_VERSION |
1129 | mDetails->refreshView(); | 1129 | mDetails->refreshView(); |
1130 | #endif | 1130 | #endif |
1131 | 1131 | ||
1132 | } | 1132 | } |
1133 | void KABCore::setModified( bool modified ) | 1133 | void KABCore::setModified( bool modified ) |
1134 | { | 1134 | { |
1135 | mModified = modified; | 1135 | mModified = modified; |
1136 | mActionSave->setEnabled( mModified ); | 1136 | mActionSave->setEnabled( mModified ); |
1137 | 1137 | ||
1138 | if ( modified ) | 1138 | if ( modified ) |
1139 | mJumpButtonBar->recreateButtons(); | 1139 | mJumpButtonBar->recreateButtons(); |
1140 | 1140 | ||
1141 | mViewManager->refreshView(); | 1141 | mViewManager->refreshView(); |
1142 | mDetails->refreshView(); | 1142 | mDetails->refreshView(); |
1143 | 1143 | ||
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | bool KABCore::modified() const | 1146 | bool KABCore::modified() const |
1147 | { | 1147 | { |
1148 | return mModified; | 1148 | return mModified; |
1149 | } | 1149 | } |
1150 | 1150 | ||
1151 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1151 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1152 | { | 1152 | { |
1153 | 1153 | ||
1154 | Command *command = 0; | 1154 | Command *command = 0; |
1155 | QString uid; | 1155 | QString uid; |
1156 | 1156 | ||
1157 | // check if it exists already | 1157 | // check if it exists already |
1158 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1158 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1159 | if ( origAddr.isEmpty() ) | 1159 | if ( origAddr.isEmpty() ) |
1160 | command = new PwNewCommand( mAddressBook, addr ); | 1160 | command = new PwNewCommand( mAddressBook, addr ); |
1161 | else { | 1161 | else { |
1162 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1162 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1163 | uid = addr.uid(); | 1163 | uid = addr.uid(); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | UndoStack::instance()->push( command ); | 1166 | UndoStack::instance()->push( command ); |
1167 | RedoStack::instance()->clear(); | 1167 | RedoStack::instance()->clear(); |
1168 | 1168 | ||
1169 | setModified( true ); | 1169 | setModified( true ); |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | void KABCore::newContact() | 1172 | void KABCore::newContact() |
1173 | { | 1173 | { |
1174 | 1174 | ||
1175 | 1175 | ||
1176 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1176 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1177 | 1177 | ||
1178 | QPtrList<KRES::Resource> kresResources; | 1178 | QPtrList<KRES::Resource> kresResources; |
1179 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1179 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1180 | KABC::Resource *resource; | 1180 | KABC::Resource *resource; |
1181 | while ( ( resource = it.current() ) != 0 ) { | 1181 | while ( ( resource = it.current() ) != 0 ) { |
1182 | ++it; | 1182 | ++it; |
1183 | if ( !resource->readOnly() ) { | 1183 | if ( !resource->readOnly() ) { |
1184 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1184 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1185 | if ( res ) | 1185 | if ( res ) |
1186 | kresResources.append( res ); | 1186 | kresResources.append( res ); |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1190 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1191 | resource = static_cast<KABC::Resource*>( res ); | 1191 | resource = static_cast<KABC::Resource*>( res ); |
1192 | 1192 | ||
1193 | if ( resource ) { | 1193 | if ( resource ) { |
1194 | KABC::Addressee addr; | 1194 | KABC::Addressee addr; |
1195 | addr.setResource( resource ); | 1195 | addr.setResource( resource ); |
1196 | mEditorDialog->setAddressee( addr ); | 1196 | mEditorDialog->setAddressee( addr ); |
1197 | KApplication::execDialog ( mEditorDialog ); | 1197 | KApplication::execDialog ( mEditorDialog ); |
1198 | 1198 | ||
1199 | } else | 1199 | } else |
1200 | return; | 1200 | return; |
1201 | 1201 | ||
1202 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1202 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1203 | 1203 | ||
1204 | 1204 | ||
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | void KABCore::addEmail( QString aStr ) | 1207 | void KABCore::addEmail( QString aStr ) |
1208 | { | 1208 | { |
1209 | #ifndef KAB_EMBEDDED | 1209 | #ifndef KAB_EMBEDDED |
1210 | QString fullName, email; | 1210 | QString fullName, email; |
1211 | 1211 | ||
1212 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1212 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1213 | 1213 | ||
1214 | // Try to lookup the addressee matching the email address | 1214 | // Try to lookup the addressee matching the email address |
1215 | bool found = false; | 1215 | bool found = false; |
1216 | QStringList emailList; | 1216 | QStringList emailList; |
1217 | KABC::AddressBook::Iterator it; | 1217 | KABC::AddressBook::Iterator it; |
1218 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1218 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1219 | emailList = (*it).emails(); | 1219 | emailList = (*it).emails(); |
1220 | if ( emailList.contains( email ) > 0 ) { | 1220 | if ( emailList.contains( email ) > 0 ) { |
1221 | found = true; | 1221 | found = true; |
1222 | (*it).setNameFromString( fullName ); | 1222 | (*it).setNameFromString( fullName ); |
1223 | editContact( (*it).uid() ); | 1223 | editContact( (*it).uid() ); |
1224 | } | 1224 | } |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | if ( !found ) { | 1227 | if ( !found ) { |
1228 | KABC::Addressee addr; | 1228 | KABC::Addressee addr; |
1229 | addr.setNameFromString( fullName ); | 1229 | addr.setNameFromString( fullName ); |
1230 | addr.insertEmail( email, true ); | 1230 | addr.insertEmail( email, true ); |
1231 | 1231 | ||
1232 | mAddressBook->insertAddressee( addr ); | 1232 | mAddressBook->insertAddressee( addr ); |
1233 | mViewManager->refreshView( addr.uid() ); | 1233 | mViewManager->refreshView( addr.uid() ); |
1234 | editContact( addr.uid() ); | 1234 | editContact( addr.uid() ); |
1235 | } | 1235 | } |
1236 | #else //KAB_EMBEDDED | 1236 | #else //KAB_EMBEDDED |
1237 | qDebug("KABCore::addEmail finsih method"); | 1237 | qDebug("KABCore::addEmail finsih method"); |
1238 | #endif //KAB_EMBEDDED | 1238 | #endif //KAB_EMBEDDED |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1241 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1242 | { | 1242 | { |
1243 | mXXPortManager->importVCard( url, showPreview ); | 1243 | mXXPortManager->importVCard( url, showPreview ); |
1244 | } | 1244 | } |
1245 | void KABCore::importFromOL() | 1245 | void KABCore::importFromOL() |
1246 | { | 1246 | { |
1247 | #ifdef _WIN32_ | 1247 | #ifdef _WIN32_ |
1248 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1248 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1249 | idgl->exec(); | 1249 | idgl->exec(); |
1250 | KABC::Addressee::List list = idgl->getAddressList(); | 1250 | KABC::Addressee::List list = idgl->getAddressList(); |
1251 | if ( list.count() > 0 ) { | 1251 | if ( list.count() > 0 ) { |
1252 | KABC::Addressee::List listNew; | 1252 | KABC::Addressee::List listNew; |
1253 | KABC::Addressee::List listExisting; | 1253 | KABC::Addressee::List listExisting; |
1254 | KABC::Addressee::List::Iterator it; | 1254 | KABC::Addressee::List::Iterator it; |
1255 | KABC::AddressBook::Iterator iter; | 1255 | KABC::AddressBook::Iterator iter; |
1256 | for ( it = list.begin(); it != list.end(); ++it ) { | 1256 | for ( it = list.begin(); it != list.end(); ++it ) { |
1257 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1257 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1258 | listNew.append( (*it) ); | 1258 | listNew.append( (*it) ); |
1259 | else | 1259 | else |
1260 | listExisting.append( (*it) ); | 1260 | listExisting.append( (*it) ); |
1261 | } | 1261 | } |
1262 | if ( listExisting.count() > 0 ) | 1262 | if ( listExisting.count() > 0 ) |
1263 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1263 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1264 | if ( listNew.count() > 0 ) { | 1264 | if ( listNew.count() > 0 ) { |
1265 | pasteWithNewUid = false; | 1265 | pasteWithNewUid = false; |
1266 | pasteContacts( listNew ); | 1266 | pasteContacts( listNew ); |
1267 | pasteWithNewUid = true; | 1267 | pasteWithNewUid = true; |
1268 | } | 1268 | } |
1269 | } | 1269 | } |
1270 | delete idgl; | 1270 | delete idgl; |
1271 | #endif | 1271 | #endif |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1274 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1275 | { | 1275 | { |
1276 | mXXPortManager->importVCard( vCard, showPreview ); | 1276 | mXXPortManager->importVCard( vCard, showPreview ); |
1277 | } | 1277 | } |
1278 | 1278 | ||
1279 | //US added a second method without defaultparameter | 1279 | //US added a second method without defaultparameter |
1280 | void KABCore::editContact2() { | 1280 | void KABCore::editContact2() { |
1281 | editContact( QString::null ); | 1281 | editContact( QString::null ); |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | void KABCore::editContact( const QString &uid ) | 1284 | void KABCore::editContact( const QString &uid ) |
1285 | { | 1285 | { |
1286 | 1286 | ||
1287 | if ( mExtensionManager->isQuickEditVisible() ) | 1287 | if ( mExtensionManager->isQuickEditVisible() ) |
1288 | return; | 1288 | return; |
1289 | 1289 | ||
1290 | // First, locate the contact entry | 1290 | // First, locate the contact entry |
1291 | QString localUID = uid; | 1291 | QString localUID = uid; |
1292 | if ( localUID.isNull() ) { | 1292 | if ( localUID.isNull() ) { |
1293 | QStringList uidList = mViewManager->selectedUids(); | 1293 | QStringList uidList = mViewManager->selectedUids(); |
1294 | if ( uidList.count() > 0 ) | 1294 | if ( uidList.count() > 0 ) |
1295 | localUID = *( uidList.at( 0 ) ); | 1295 | localUID = *( uidList.at( 0 ) ); |
1296 | } | 1296 | } |
1297 | 1297 | ||
1298 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1298 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1299 | if ( !addr.isEmpty() ) { | 1299 | if ( !addr.isEmpty() ) { |
1300 | mEditorDialog->setAddressee( addr ); | 1300 | mEditorDialog->setAddressee( addr ); |
1301 | KApplication::execDialog ( mEditorDialog ); | 1301 | KApplication::execDialog ( mEditorDialog ); |
1302 | } | 1302 | } |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | /** | 1305 | /** |
1306 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1306 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1307 | the method will try to find a selected addressee in the view. | 1307 | the method will try to find a selected addressee in the view. |
1308 | */ | 1308 | */ |
1309 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1309 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1310 | { | 1310 | { |
1311 | if ( mMultipleViewsAtOnce ) | 1311 | if ( mMultipleViewsAtOnce ) |
1312 | { | 1312 | { |
1313 | editContact( uid ); | 1313 | editContact( uid ); |
1314 | } | 1314 | } |
1315 | else | 1315 | else |
1316 | { | 1316 | { |
1317 | setDetailsVisible( true ); | 1317 | setDetailsVisible( true ); |
1318 | mActionDetails->setChecked(true); | 1318 | mActionDetails->setChecked(true); |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | } | 1321 | } |
1322 | 1322 | ||
1323 | void KABCore::save() | 1323 | void KABCore::save() |
1324 | { | 1324 | { |
1325 | if (syncManager->blockSave()) | 1325 | if (syncManager->blockSave()) |
1326 | return; | 1326 | return; |
1327 | if ( !mModified ) | 1327 | if ( !mModified ) |
1328 | return; | 1328 | return; |
1329 | 1329 | ||
1330 | syncManager->setBlockSave(true); | 1330 | syncManager->setBlockSave(true); |
1331 | QString text = i18n( "There was an error while attempting to save\n the " | 1331 | QString text = i18n( "There was an error while attempting to save\n the " |
1332 | "address book. Please check that some \nother application is " | 1332 | "address book. Please check that some \nother application is " |
1333 | "not using it. " ); | 1333 | "not using it. " ); |
1334 | message(i18n("Saving addressbook ... ")); | 1334 | message(i18n("Saving addressbook ... ")); |
1335 | #ifndef KAB_EMBEDDED | 1335 | #ifndef KAB_EMBEDDED |
1336 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1336 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1337 | if ( !b || !b->save() ) { | 1337 | if ( !b || !b->save() ) { |
1338 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1338 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1339 | } | 1339 | } |
1340 | #else //KAB_EMBEDDED | 1340 | #else //KAB_EMBEDDED |
1341 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1341 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1342 | if ( !b || !b->save() ) { | 1342 | if ( !b || !b->save() ) { |
1343 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1343 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1344 | } | 1344 | } |
1345 | #endif //KAB_EMBEDDED | 1345 | #endif //KAB_EMBEDDED |
1346 | 1346 | ||
1347 | message(i18n("Addressbook saved!")); | 1347 | message(i18n("Addressbook saved!")); |
1348 | setModified( false ); | 1348 | setModified( false ); |
1349 | syncManager->setBlockSave(false); | 1349 | syncManager->setBlockSave(false); |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | 1352 | ||
1353 | void KABCore::undo() | 1353 | void KABCore::undo() |
1354 | { | 1354 | { |
1355 | UndoStack::instance()->undo(); | 1355 | UndoStack::instance()->undo(); |
1356 | 1356 | ||
1357 | // Refresh the view | 1357 | // Refresh the view |
1358 | mViewManager->refreshView(); | 1358 | mViewManager->refreshView(); |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | void KABCore::redo() | 1361 | void KABCore::redo() |
1362 | { | 1362 | { |
1363 | RedoStack::instance()->redo(); | 1363 | RedoStack::instance()->redo(); |
1364 | 1364 | ||
1365 | // Refresh the view | 1365 | // Refresh the view |
1366 | mViewManager->refreshView(); | 1366 | mViewManager->refreshView(); |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1369 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1370 | { | 1370 | { |
1371 | if (mMultipleViewsAtOnce) | 1371 | if (mMultipleViewsAtOnce) |
1372 | { | 1372 | { |
1373 | if ( visible ) | 1373 | if ( visible ) |
1374 | mJumpButtonBar->show(); | 1374 | mJumpButtonBar->show(); |
1375 | else | 1375 | else |
1376 | mJumpButtonBar->hide(); | 1376 | mJumpButtonBar->hide(); |
1377 | } | 1377 | } |
1378 | else | 1378 | else |
1379 | { | 1379 | { |
1380 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1380 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1381 | if (mViewManager->isVisible()) | 1381 | if (mViewManager->isVisible()) |
1382 | { | 1382 | { |
1383 | if ( visible ) | 1383 | if ( visible ) |
1384 | mJumpButtonBar->show(); | 1384 | mJumpButtonBar->show(); |
1385 | else | 1385 | else |
1386 | mJumpButtonBar->hide(); | 1386 | mJumpButtonBar->hide(); |
1387 | } | 1387 | } |
1388 | else | 1388 | else |
1389 | { | 1389 | { |
1390 | mJumpButtonBar->hide(); | 1390 | mJumpButtonBar->hide(); |
1391 | } | 1391 | } |
1392 | } | 1392 | } |
1393 | } | 1393 | } |
1394 | 1394 | ||
1395 | 1395 | ||
1396 | void KABCore::setDetailsToState() | 1396 | void KABCore::setDetailsToState() |
1397 | { | 1397 | { |
1398 | setDetailsVisible( mActionDetails->isChecked() ); | 1398 | setDetailsVisible( mActionDetails->isChecked() ); |
1399 | } | 1399 | } |
1400 | void KABCore::setDetailsToggle() | 1400 | void KABCore::setDetailsToggle() |
1401 | { | 1401 | { |
1402 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | 1402 | mActionDetails->setChecked( !mActionDetails->isChecked() ); |
1403 | setDetailsToState(); | 1403 | setDetailsToState(); |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | 1406 | ||
1407 | 1407 | ||
1408 | void KABCore::setDetailsVisible( bool visible ) | 1408 | void KABCore::setDetailsVisible( bool visible ) |
1409 | { | 1409 | { |
1410 | if (visible && mDetails->isHidden()) | 1410 | if (visible && mDetails->isHidden()) |
1411 | { | 1411 | { |
1412 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1412 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1413 | if ( addrList.count() > 0 ) | 1413 | if ( addrList.count() > 0 ) |
1414 | mDetails->setAddressee( addrList[ 0 ] ); | 1414 | mDetails->setAddressee( addrList[ 0 ] ); |
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1417 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1418 | // the listview and the detailview. We do that by changing the splitbar size. | 1418 | // the listview and the detailview. We do that by changing the splitbar size. |
1419 | if (mMultipleViewsAtOnce) | 1419 | if (mMultipleViewsAtOnce) |
1420 | { | 1420 | { |
1421 | if ( visible ) | 1421 | if ( visible ) |
1422 | mDetails->show(); | 1422 | mDetails->show(); |
1423 | else | 1423 | else |
1424 | mDetails->hide(); | 1424 | mDetails->hide(); |
1425 | } | 1425 | } |
1426 | else | 1426 | else |
1427 | { | 1427 | { |
1428 | if ( visible ) { | 1428 | if ( visible ) { |
1429 | mViewManager->hide(); | 1429 | mViewManager->hide(); |
1430 | mDetails->show(); | 1430 | mDetails->show(); |
1431 | mIncSearchWidget->setFocus(); | 1431 | mIncSearchWidget->setFocus(); |
1432 | } | 1432 | } |
1433 | else { | 1433 | else { |
1434 | mViewManager->show(); | 1434 | mViewManager->show(); |
1435 | mDetails->hide(); | 1435 | mDetails->hide(); |
1436 | mViewManager->setFocusAV(); | 1436 | mViewManager->setFocusAV(); |
1437 | } | 1437 | } |
1438 | setJumpButtonBarVisible( !visible ); | 1438 | setJumpButtonBarVisible( !visible ); |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | } | 1441 | } |
1442 | 1442 | ||
1443 | void KABCore::extensionChanged( int id ) | 1443 | void KABCore::extensionChanged( int id ) |
1444 | { | 1444 | { |
1445 | //change the details view only for non desktop systems | 1445 | //change the details view only for non desktop systems |
1446 | #ifndef DESKTOP_VERSION | 1446 | #ifndef DESKTOP_VERSION |
1447 | 1447 | ||
1448 | if (id == 0) | 1448 | if (id == 0) |
1449 | { | 1449 | { |
1450 | //the user disabled the extension. | 1450 | //the user disabled the extension. |
1451 | 1451 | ||
1452 | if (mMultipleViewsAtOnce) | 1452 | if (mMultipleViewsAtOnce) |
1453 | { // enable detailsview again | 1453 | { // enable detailsview again |
1454 | setDetailsVisible( true ); | 1454 | setDetailsVisible( true ); |
1455 | mActionDetails->setChecked( true ); | 1455 | mActionDetails->setChecked( true ); |
1456 | } | 1456 | } |
1457 | else | 1457 | else |
1458 | { //go back to the listview | 1458 | { //go back to the listview |
1459 | setDetailsVisible( false ); | 1459 | setDetailsVisible( false ); |
1460 | mActionDetails->setChecked( false ); | 1460 | mActionDetails->setChecked( false ); |
1461 | mActionDetails->setEnabled(true); | 1461 | mActionDetails->setEnabled(true); |
1462 | } | 1462 | } |
1463 | 1463 | ||
1464 | } | 1464 | } |
1465 | else | 1465 | else |
1466 | { | 1466 | { |
1467 | //the user enabled the extension. | 1467 | //the user enabled the extension. |
1468 | setDetailsVisible( false ); | 1468 | setDetailsVisible( false ); |
1469 | mActionDetails->setChecked( false ); | 1469 | mActionDetails->setChecked( false ); |
1470 | 1470 | ||
1471 | if (!mMultipleViewsAtOnce) | 1471 | if (!mMultipleViewsAtOnce) |
1472 | { | 1472 | { |
1473 | mActionDetails->setEnabled(false); | 1473 | mActionDetails->setEnabled(false); |
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | mExtensionManager->setSelectionChanged(); | 1476 | mExtensionManager->setSelectionChanged(); |
1477 | 1477 | ||
1478 | } | 1478 | } |
1479 | 1479 | ||
1480 | #endif// DESKTOP_VERSION | 1480 | #endif// DESKTOP_VERSION |
1481 | 1481 | ||
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | 1484 | ||
1485 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1485 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1486 | { | 1486 | { |
1487 | 1487 | ||
1488 | if ( list.count() != 0 ) { | 1488 | if ( list.count() != 0 ) { |
1489 | KABC::Addressee::List::ConstIterator it; | 1489 | KABC::Addressee::List::ConstIterator it; |
1490 | for ( it = list.begin(); it != list.end(); ++it ) | 1490 | for ( it = list.begin(); it != list.end(); ++it ) |
1491 | mAddressBook->insertAddressee( *it ); | 1491 | mAddressBook->insertAddressee( *it ); |
1492 | if ( list.count() > 1 ) | 1492 | if ( list.count() > 1 ) |
1493 | setModified(); | 1493 | setModified(); |
1494 | else | 1494 | else |
1495 | setModifiedWOrefresh(); | 1495 | setModifiedWOrefresh(); |
1496 | } | 1496 | } |
1497 | if ( list.count() == 0 ) | 1497 | if ( list.count() == 0 ) |
1498 | mViewManager->refreshView(); | 1498 | mViewManager->refreshView(); |
1499 | else | 1499 | else |
1500 | mViewManager->refreshView( list[ 0 ].uid() ); | 1500 | mViewManager->refreshView( list[ 0 ].uid() ); |
1501 | 1501 | ||
1502 | 1502 | ||
1503 | 1503 | ||
1504 | } | 1504 | } |
1505 | 1505 | ||
1506 | QString KABCore::getNameByPhone( const QString &phone ) | 1506 | QString KABCore::getNameByPhone( const QString &phone ) |
1507 | { | 1507 | { |
1508 | #ifndef KAB_EMBEDDED | 1508 | #ifndef KAB_EMBEDDED |
1509 | QRegExp r( "[/*/-/ ]" ); | 1509 | QRegExp r( "[/*/-/ ]" ); |
1510 | QString localPhone( phone ); | 1510 | QString localPhone( phone ); |
1511 | 1511 | ||
1512 | bool found = false; | 1512 | bool found = false; |
1513 | QString ownerName = ""; | 1513 | QString ownerName = ""; |
1514 | KABC::AddressBook::Iterator iter; | 1514 | KABC::AddressBook::Iterator iter; |
1515 | KABC::PhoneNumber::List::Iterator phoneIter; | 1515 | KABC::PhoneNumber::List::Iterator phoneIter; |
1516 | KABC::PhoneNumber::List phoneList; | 1516 | KABC::PhoneNumber::List phoneList; |
1517 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1517 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1518 | phoneList = (*iter).phoneNumbers(); | 1518 | phoneList = (*iter).phoneNumbers(); |
1519 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1519 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1520 | ++phoneIter) { | 1520 | ++phoneIter) { |
1521 | // Get rid of separator chars so just the numbers are compared. | 1521 | // Get rid of separator chars so just the numbers are compared. |
1522 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1522 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1523 | ownerName = (*iter).formattedName(); | 1523 | ownerName = (*iter).formattedName(); |
1524 | found = true; | 1524 | found = true; |
1525 | } | 1525 | } |
1526 | } | 1526 | } |
1527 | } | 1527 | } |
1528 | 1528 | ||
1529 | return ownerName; | 1529 | return ownerName; |
1530 | #else //KAB_EMBEDDED | 1530 | #else //KAB_EMBEDDED |
1531 | qDebug("KABCore::getNameByPhone finsih method"); | 1531 | qDebug("KABCore::getNameByPhone finsih method"); |
1532 | return ""; | 1532 | return ""; |
1533 | #endif //KAB_EMBEDDED | 1533 | #endif //KAB_EMBEDDED |
1534 | 1534 | ||
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | void KABCore::openConfigDialog() | 1537 | void KABCore::openConfigDialog() |
1538 | { | 1538 | { |
1539 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1539 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1540 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1540 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1541 | ConfigureDialog->addModule(kabcfg ); | 1541 | ConfigureDialog->addModule(kabcfg ); |
1542 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1542 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1543 | ConfigureDialog->addModule(kdelibcfg ); | 1543 | ConfigureDialog->addModule(kdelibcfg ); |
1544 | 1544 | ||
1545 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1545 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1546 | this, SLOT( configurationChanged() ) ); | 1546 | this, SLOT( configurationChanged() ) ); |
1547 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1547 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1548 | this, SLOT( configurationChanged() ) ); | 1548 | this, SLOT( configurationChanged() ) ); |
1549 | saveSettings(); | 1549 | saveSettings(); |
1550 | #ifndef DESKTOP_VERSION | 1550 | #ifndef DESKTOP_VERSION |
1551 | ConfigureDialog->showMaximized(); | 1551 | ConfigureDialog->showMaximized(); |
1552 | #endif | 1552 | #endif |
1553 | if ( ConfigureDialog->exec() ) | 1553 | if ( ConfigureDialog->exec() ) |
1554 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1554 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1555 | delete ConfigureDialog; | 1555 | delete ConfigureDialog; |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | void KABCore::openLDAPDialog() | 1558 | void KABCore::openLDAPDialog() |
1559 | { | 1559 | { |
1560 | #ifndef KAB_EMBEDDED | 1560 | #ifndef KAB_EMBEDDED |
1561 | if ( !mLdapSearchDialog ) { | 1561 | if ( !mLdapSearchDialog ) { |
1562 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1562 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1563 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1563 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1564 | SLOT( refreshView() ) ); | 1564 | SLOT( refreshView() ) ); |
1565 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1565 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1566 | SLOT( setModified() ) ); | 1566 | SLOT( setModified() ) ); |
1567 | } else | 1567 | } else |
1568 | mLdapSearchDialog->restoreSettings(); | 1568 | mLdapSearchDialog->restoreSettings(); |
1569 | 1569 | ||
1570 | if ( mLdapSearchDialog->isOK() ) | 1570 | if ( mLdapSearchDialog->isOK() ) |
1571 | mLdapSearchDialog->exec(); | 1571 | mLdapSearchDialog->exec(); |
1572 | #else //KAB_EMBEDDED | 1572 | #else //KAB_EMBEDDED |
1573 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1573 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1574 | #endif //KAB_EMBEDDED | 1574 | #endif //KAB_EMBEDDED |
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | void KABCore::print() | 1577 | void KABCore::print() |
1578 | { | 1578 | { |
1579 | #ifndef KAB_EMBEDDED | 1579 | #ifndef KAB_EMBEDDED |
1580 | KPrinter printer; | 1580 | KPrinter printer; |
1581 | if ( !printer.setup( this ) ) | 1581 | if ( !printer.setup( this ) ) |
1582 | return; | 1582 | return; |
1583 | 1583 | ||
1584 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1584 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1585 | mViewManager->selectedUids(), this ); | 1585 | mViewManager->selectedUids(), this ); |
1586 | 1586 | ||
1587 | wizard.exec(); | 1587 | wizard.exec(); |
1588 | #else //KAB_EMBEDDED | 1588 | #else //KAB_EMBEDDED |
1589 | qDebug("KABCore::print() finsih method"); | 1589 | qDebug("KABCore::print() finsih method"); |
1590 | #endif //KAB_EMBEDDED | 1590 | #endif //KAB_EMBEDDED |
1591 | 1591 | ||
1592 | } | 1592 | } |
1593 | 1593 | ||
1594 | 1594 | ||
1595 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1595 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1596 | { | 1596 | { |
1597 | if ( mGUIClient ) | 1597 | if ( mGUIClient ) |
1598 | mGUIClient->insertChildClient( client ); | 1598 | mGUIClient->insertChildClient( client ); |
1599 | else | 1599 | else |
1600 | KMessageBox::error( this, "no KXMLGUICLient"); | 1600 | KMessageBox::error( this, "no KXMLGUICLient"); |
1601 | } | 1601 | } |
1602 | 1602 | ||
1603 | 1603 | ||
1604 | void KABCore::configurationChanged() | 1604 | void KABCore::configurationChanged() |
1605 | { | 1605 | { |
1606 | mExtensionManager->reconfigure(); | 1606 | mExtensionManager->reconfigure(); |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | void KABCore::addressBookChanged() | 1609 | void KABCore::addressBookChanged() |
1610 | { | 1610 | { |
1611 | /*US | 1611 | /*US |
1612 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1612 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1613 | while ( it.current() ) { | 1613 | while ( it.current() ) { |
1614 | if ( it.current()->dirty() ) { | 1614 | if ( it.current()->dirty() ) { |
1615 | QString text = i18n( "Data has been changed externally. Unsaved " | 1615 | QString text = i18n( "Data has been changed externally. Unsaved " |
1616 | "changes will be lost." ); | 1616 | "changes will be lost." ); |
1617 | KMessageBox::information( this, text ); | 1617 | KMessageBox::information( this, text ); |
1618 | } | 1618 | } |
1619 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1619 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1620 | ++it; | 1620 | ++it; |
1621 | } | 1621 | } |
1622 | */ | 1622 | */ |
1623 | if (mEditorDialog) | 1623 | if (mEditorDialog) |
1624 | { | 1624 | { |
1625 | if (mEditorDialog->dirty()) | 1625 | if (mEditorDialog->dirty()) |
1626 | { | 1626 | { |
1627 | QString text = i18n( "Data has been changed externally. Unsaved " | 1627 | QString text = i18n( "Data has been changed externally. Unsaved " |
1628 | "changes will be lost." ); | 1628 | "changes will be lost." ); |
1629 | KMessageBox::information( this, text ); | 1629 | KMessageBox::information( this, text ); |
1630 | } | 1630 | } |
1631 | QString currentuid = mEditorDialog->addressee().uid(); | 1631 | QString currentuid = mEditorDialog->addressee().uid(); |
1632 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1632 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1633 | } | 1633 | } |
1634 | mViewManager->refreshView(); | 1634 | mViewManager->refreshView(); |
1635 | // mDetails->refreshView(); | 1635 | // mDetails->refreshView(); |
1636 | 1636 | ||
1637 | 1637 | ||
1638 | } | 1638 | } |
1639 | 1639 | ||
1640 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1640 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1641 | const char *name ) | 1641 | const char *name ) |
1642 | { | 1642 | { |
1643 | 1643 | ||
1644 | if ( mEditorDialog == 0 ) { | 1644 | if ( mEditorDialog == 0 ) { |
1645 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1645 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1646 | name ? name : "editorDialog" ); | 1646 | name ? name : "editorDialog" ); |
1647 | 1647 | ||
1648 | 1648 | ||
1649 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1649 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1650 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1650 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1651 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1651 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1652 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1652 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | return mEditorDialog; | 1655 | return mEditorDialog; |
1656 | } | 1656 | } |
1657 | 1657 | ||
1658 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1658 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1659 | { | 1659 | { |
1660 | //mEditorDict.remove( uid ); | 1660 | //mEditorDict.remove( uid ); |
1661 | } | 1661 | } |
1662 | 1662 | ||
1663 | void KABCore::initGUI() | 1663 | void KABCore::initGUI() |
1664 | { | 1664 | { |
1665 | #ifndef KAB_EMBEDDED | 1665 | #ifndef KAB_EMBEDDED |
1666 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1666 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1667 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1667 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1668 | 1668 | ||
1669 | mExtensionBarSplitter = new QSplitter( this ); | 1669 | mExtensionBarSplitter = new QSplitter( this ); |
1670 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1670 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1671 | 1671 | ||
1672 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1672 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1673 | 1673 | ||
1674 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1674 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1675 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1675 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1676 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1676 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1677 | SLOT( incrementalSearch( const QString& ) ) ); | 1677 | SLOT( incrementalSearch( const QString& ) ) ); |
1678 | 1678 | ||
1679 | mViewManager = new ViewManager( this, viewSpace ); | 1679 | mViewManager = new ViewManager( this, viewSpace ); |
1680 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1680 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1681 | 1681 | ||
1682 | mDetails = new ViewContainer( mDetailsSplitter ); | 1682 | mDetails = new ViewContainer( mDetailsSplitter ); |
1683 | 1683 | ||
1684 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1684 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1685 | 1685 | ||
1686 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1686 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1687 | 1687 | ||
1688 | topLayout->addWidget( mExtensionBarSplitter ); | 1688 | topLayout->addWidget( mExtensionBarSplitter ); |
1689 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1689 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1690 | topLayout->addWidget( mJumpButtonBar ); | 1690 | topLayout->addWidget( mJumpButtonBar ); |
1691 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1691 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1692 | 1692 | ||
1693 | mXXPortManager = new XXPortManager( this, this ); | 1693 | mXXPortManager = new XXPortManager( this, this ); |
1694 | 1694 | ||
1695 | #else //KAB_EMBEDDED | 1695 | #else //KAB_EMBEDDED |
1696 | //US initialize viewMenu before settingup viewmanager. | 1696 | //US initialize viewMenu before settingup viewmanager. |
1697 | // Viewmanager needs this menu to plugin submenues. | 1697 | // Viewmanager needs this menu to plugin submenues. |
1698 | viewMenu = new QPopupMenu( this ); | 1698 | viewMenu = new QPopupMenu( this ); |
1699 | settingsMenu = new QPopupMenu( this ); | 1699 | settingsMenu = new QPopupMenu( this ); |
1700 | //filterMenu = new QPopupMenu( this ); | 1700 | //filterMenu = new QPopupMenu( this ); |
1701 | ImportMenu = new QPopupMenu( this ); | 1701 | ImportMenu = new QPopupMenu( this ); |
1702 | ExportMenu = new QPopupMenu( this ); | 1702 | ExportMenu = new QPopupMenu( this ); |
1703 | syncMenu = new QPopupMenu( this ); | 1703 | syncMenu = new QPopupMenu( this ); |
1704 | changeMenu= new QPopupMenu( this ); | 1704 | changeMenu= new QPopupMenu( this ); |
1705 | beamMenu= new QPopupMenu( this ); | 1705 | beamMenu= new QPopupMenu( this ); |
1706 | 1706 | ||
1707 | //US since we have no splitter for the embedded system, setup | 1707 | //US since we have no splitter for the embedded system, setup |
1708 | // a layout with two frames. One left and one right. | 1708 | // a layout with two frames. One left and one right. |
1709 | 1709 | ||
1710 | QBoxLayout *topLayout; | 1710 | QBoxLayout *topLayout; |
1711 | 1711 | ||
1712 | // = new QHBoxLayout( this ); | 1712 | // = new QHBoxLayout( this ); |
1713 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1713 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1714 | 1714 | ||
1715 | // QWidget *mainBox = new QWidget( this ); | 1715 | // QWidget *mainBox = new QWidget( this ); |
1716 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1716 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1717 | 1717 | ||
1718 | #ifdef DESKTOP_VERSION | 1718 | #ifdef DESKTOP_VERSION |
1719 | topLayout = new QHBoxLayout( this ); | 1719 | topLayout = new QHBoxLayout( this ); |
1720 | 1720 | ||
1721 | 1721 | ||
1722 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1722 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1723 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1723 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1724 | 1724 | ||
1725 | topLayout->addWidget(mMiniSplitter ); | 1725 | topLayout->addWidget(mMiniSplitter ); |
1726 | 1726 | ||
1727 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1727 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1728 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1728 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1729 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1729 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1730 | mDetails = new ViewContainer( mMiniSplitter ); | 1730 | mDetails = new ViewContainer( mMiniSplitter ); |
1731 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1731 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1732 | #else | 1732 | #else |
1733 | if ( QApplication::desktop()->width() > 480 ) { | 1733 | if ( QApplication::desktop()->width() > 480 ) { |
1734 | topLayout = new QHBoxLayout( this ); | 1734 | topLayout = new QHBoxLayout( this ); |
1735 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1735 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1736 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1736 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1737 | } else { | 1737 | } else { |
1738 | 1738 | ||
1739 | topLayout = new QHBoxLayout( this ); | 1739 | topLayout = new QHBoxLayout( this ); |
1740 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1740 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1741 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1741 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1742 | } | 1742 | } |
1743 | 1743 | ||
1744 | topLayout->addWidget(mMiniSplitter ); | 1744 | topLayout->addWidget(mMiniSplitter ); |
1745 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1745 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1746 | mDetails = new ViewContainer( mMiniSplitter ); | 1746 | mDetails = new ViewContainer( mMiniSplitter ); |
1747 | 1747 | ||
1748 | 1748 | ||
1749 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1749 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1750 | #endif | 1750 | #endif |
1751 | //eh->hide(); | 1751 | //eh->hide(); |
1752 | // topLayout->addWidget(mExtensionManager ); | 1752 | // topLayout->addWidget(mExtensionManager ); |
1753 | 1753 | ||
1754 | 1754 | ||
1755 | /*US | 1755 | /*US |
1756 | #ifndef KAB_NOSPLITTER | 1756 | #ifndef KAB_NOSPLITTER |
1757 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1757 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1758 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1758 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1759 | topLayout->setSpacing( 10 ); | 1759 | topLayout->setSpacing( 10 ); |
1760 | 1760 | ||
1761 | mDetailsSplitter = new QSplitter( this ); | 1761 | mDetailsSplitter = new QSplitter( this ); |
1762 | 1762 | ||
1763 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1763 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1764 | 1764 | ||
1765 | mViewManager = new ViewManager( this, viewSpace ); | 1765 | mViewManager = new ViewManager( this, viewSpace ); |
1766 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1766 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1767 | 1767 | ||
1768 | mDetails = new ViewContainer( mDetailsSplitter ); | 1768 | mDetails = new ViewContainer( mDetailsSplitter ); |
1769 | 1769 | ||
1770 | topLayout->addWidget( mDetailsSplitter ); | 1770 | topLayout->addWidget( mDetailsSplitter ); |
1771 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1771 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1772 | #else //KAB_NOSPLITTER | 1772 | #else //KAB_NOSPLITTER |
1773 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1773 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1774 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1774 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1775 | topLayout->setSpacing( 10 ); | 1775 | topLayout->setSpacing( 10 ); |
1776 | 1776 | ||
1777 | // mDetailsSplitter = new QSplitter( this ); | 1777 | // mDetailsSplitter = new QSplitter( this ); |
1778 | 1778 | ||
1779 | QVBox *viewSpace = new QVBox( this ); | 1779 | QVBox *viewSpace = new QVBox( this ); |
1780 | 1780 | ||
1781 | mViewManager = new ViewManager( this, viewSpace ); | 1781 | mViewManager = new ViewManager( this, viewSpace ); |
1782 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1782 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1783 | 1783 | ||
1784 | mDetails = new ViewContainer( this ); | 1784 | mDetails = new ViewContainer( this ); |
1785 | 1785 | ||
1786 | topLayout->addWidget( viewSpace ); | 1786 | topLayout->addWidget( viewSpace ); |
1787 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1787 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1788 | topLayout->addWidget( mDetails ); | 1788 | topLayout->addWidget( mDetails ); |
1789 | #endif //KAB_NOSPLITTER | 1789 | #endif //KAB_NOSPLITTER |
1790 | */ | 1790 | */ |
1791 | 1791 | ||
1792 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1792 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1793 | syncManager->setBlockSave(false); | 1793 | syncManager->setBlockSave(false); |
1794 | 1794 | ||
1795 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1795 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1796 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1796 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1797 | syncManager->setDefaultFileName( sentSyncFile()); | 1797 | QString sync_file = sentSyncFile(); |
1798 | qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); | ||
1799 | syncManager->setDefaultFileName( sync_file ); | ||
1798 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1800 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1799 | 1801 | ||
1800 | #endif //KAB_EMBEDDED | 1802 | #endif //KAB_EMBEDDED |
1801 | initActions(); | 1803 | initActions(); |
1802 | 1804 | ||
1803 | #ifdef KAB_EMBEDDED | 1805 | #ifdef KAB_EMBEDDED |
1804 | addActionsManually(); | 1806 | addActionsManually(); |
1805 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1807 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1806 | mXXPortManager = new XXPortManager( this, this ); | 1808 | mXXPortManager = new XXPortManager( this, this ); |
1807 | 1809 | ||
1808 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1810 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1809 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1811 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1810 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1812 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1811 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1813 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1812 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1814 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1813 | // mIncSearchWidget->hide(); | 1815 | // mIncSearchWidget->hide(); |
1814 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1816 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1815 | SLOT( incrementalSearch( const QString& ) ) ); | 1817 | SLOT( incrementalSearch( const QString& ) ) ); |
1816 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1818 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1817 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1819 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1818 | 1820 | ||
1819 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1821 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1820 | 1822 | ||
1821 | topLayout->addWidget( mJumpButtonBar ); | 1823 | topLayout->addWidget( mJumpButtonBar ); |
1822 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1824 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1823 | 1825 | ||
1824 | // mMainWindow->getIconToolBar()->raise(); | 1826 | // mMainWindow->getIconToolBar()->raise(); |
1825 | 1827 | ||
1826 | #endif //KAB_EMBEDDED | 1828 | #endif //KAB_EMBEDDED |
1827 | 1829 | ||
1828 | } | 1830 | } |
1829 | void KABCore::initActions() | 1831 | void KABCore::initActions() |
1830 | { | 1832 | { |
1831 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1833 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1832 | 1834 | ||
1833 | #ifndef KAB_EMBEDDED | 1835 | #ifndef KAB_EMBEDDED |
1834 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1836 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1835 | SLOT( clipboardDataChanged() ) ); | 1837 | SLOT( clipboardDataChanged() ) ); |
1836 | #endif //KAB_EMBEDDED | 1838 | #endif //KAB_EMBEDDED |
1837 | 1839 | ||
1838 | // file menu | 1840 | // file menu |
1839 | if ( mIsPart ) { | 1841 | if ( mIsPart ) { |
1840 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1842 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1841 | SLOT( sendMail() ), actionCollection(), | 1843 | SLOT( sendMail() ), actionCollection(), |
1842 | "kaddressbook_mail" ); | 1844 | "kaddressbook_mail" ); |
1843 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1845 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1844 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1846 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1845 | 1847 | ||
1846 | } else { | 1848 | } else { |
1847 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1849 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1848 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1850 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1849 | } | 1851 | } |
1850 | 1852 | ||
1851 | 1853 | ||
1852 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1854 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1853 | SLOT( save() ), actionCollection(), "file_sync" ); | 1855 | SLOT( save() ), actionCollection(), "file_sync" ); |
1854 | 1856 | ||
1855 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1857 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1856 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1858 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1857 | 1859 | ||
1858 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1860 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1859 | this, SLOT( mailVCard() ), | 1861 | this, SLOT( mailVCard() ), |
1860 | actionCollection(), "file_mail_vcard"); | 1862 | actionCollection(), "file_mail_vcard"); |
1861 | 1863 | ||
1862 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, | 1864 | mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, |
1863 | SLOT( export2phone() ), actionCollection(), | 1865 | SLOT( export2phone() ), actionCollection(), |
1864 | "kaddressbook_ex2phone" ); | 1866 | "kaddressbook_ex2phone" ); |
1865 | 1867 | ||
1866 | mActionBeamVCard = 0; | 1868 | mActionBeamVCard = 0; |
1867 | mActionBeam = 0; | 1869 | mActionBeam = 0; |
1868 | 1870 | ||
1869 | #ifndef DESKTOP_VERSION | 1871 | #ifndef DESKTOP_VERSION |
1870 | if ( Ir::supported() ) { | 1872 | if ( Ir::supported() ) { |
1871 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, | 1873 | mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, |
1872 | SLOT( beamVCard() ), actionCollection(), | 1874 | SLOT( beamVCard() ), actionCollection(), |
1873 | "kaddressbook_beam_vcard" ); | 1875 | "kaddressbook_beam_vcard" ); |
1874 | 1876 | ||
1875 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1877 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1876 | SLOT( beamMySelf() ), actionCollection(), | 1878 | SLOT( beamMySelf() ), actionCollection(), |
1877 | "kaddressbook_beam_myself" ); | 1879 | "kaddressbook_beam_myself" ); |
1878 | } | 1880 | } |
1879 | #endif | 1881 | #endif |
1880 | 1882 | ||
1881 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1883 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1882 | this, SLOT( editContact2() ), | 1884 | this, SLOT( editContact2() ), |
1883 | actionCollection(), "file_properties" ); | 1885 | actionCollection(), "file_properties" ); |
1884 | 1886 | ||
1885 | #ifdef KAB_EMBEDDED | 1887 | #ifdef KAB_EMBEDDED |
1886 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1888 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1887 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1889 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1888 | mMainWindow, SLOT( exit() ), | 1890 | mMainWindow, SLOT( exit() ), |
1889 | actionCollection(), "quit" ); | 1891 | actionCollection(), "quit" ); |
1890 | #endif //KAB_EMBEDDED | 1892 | #endif //KAB_EMBEDDED |
1891 | 1893 | ||
1892 | // edit menu | 1894 | // edit menu |
1893 | if ( mIsPart ) { | 1895 | if ( mIsPart ) { |
1894 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1896 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1895 | SLOT( copyContacts() ), actionCollection(), | 1897 | SLOT( copyContacts() ), actionCollection(), |
1896 | "kaddressbook_copy" ); | 1898 | "kaddressbook_copy" ); |
1897 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1899 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1898 | SLOT( cutContacts() ), actionCollection(), | 1900 | SLOT( cutContacts() ), actionCollection(), |
1899 | "kaddressbook_cut" ); | 1901 | "kaddressbook_cut" ); |
1900 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1902 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1901 | SLOT( pasteContacts() ), actionCollection(), | 1903 | SLOT( pasteContacts() ), actionCollection(), |
1902 | "kaddressbook_paste" ); | 1904 | "kaddressbook_paste" ); |
1903 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1905 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1904 | SLOT( selectAllContacts() ), actionCollection(), | 1906 | SLOT( selectAllContacts() ), actionCollection(), |
1905 | "kaddressbook_select_all" ); | 1907 | "kaddressbook_select_all" ); |
1906 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1908 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1907 | SLOT( undo() ), actionCollection(), | 1909 | SLOT( undo() ), actionCollection(), |
1908 | "kaddressbook_undo" ); | 1910 | "kaddressbook_undo" ); |
1909 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1911 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1910 | this, SLOT( redo() ), actionCollection(), | 1912 | this, SLOT( redo() ), actionCollection(), |
1911 | "kaddressbook_redo" ); | 1913 | "kaddressbook_redo" ); |
1912 | } else { | 1914 | } else { |
1913 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1915 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1914 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1916 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1915 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1917 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1916 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1918 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1917 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1919 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1918 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1920 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1919 | } | 1921 | } |
1920 | 1922 | ||
1921 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1923 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1922 | Key_Delete, this, SLOT( deleteContacts() ), | 1924 | Key_Delete, this, SLOT( deleteContacts() ), |
1923 | actionCollection(), "edit_delete" ); | 1925 | actionCollection(), "edit_delete" ); |
1924 | 1926 | ||
1925 | mActionUndo->setEnabled( false ); | 1927 | mActionUndo->setEnabled( false ); |
1926 | mActionRedo->setEnabled( false ); | 1928 | mActionRedo->setEnabled( false ); |
1927 | 1929 | ||
1928 | // settings menu | 1930 | // settings menu |
1929 | #ifdef KAB_EMBEDDED | 1931 | #ifdef KAB_EMBEDDED |
1930 | //US special menuentry to configure the addressbook resources. On KDE | 1932 | //US special menuentry to configure the addressbook resources. On KDE |
1931 | // you do that through the control center !!! | 1933 | // you do that through the control center !!! |
1932 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1934 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1933 | SLOT( configureResources() ), actionCollection(), | 1935 | SLOT( configureResources() ), actionCollection(), |
1934 | "kaddressbook_configure_resources" ); | 1936 | "kaddressbook_configure_resources" ); |
1935 | #endif //KAB_EMBEDDED | 1937 | #endif //KAB_EMBEDDED |
1936 | 1938 | ||
1937 | if ( mIsPart ) { | 1939 | if ( mIsPart ) { |
1938 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1940 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1939 | SLOT( openConfigDialog() ), actionCollection(), | 1941 | SLOT( openConfigDialog() ), actionCollection(), |
1940 | "kaddressbook_configure" ); | 1942 | "kaddressbook_configure" ); |
1941 | 1943 | ||
1942 | //US not implemented yet | 1944 | //US not implemented yet |
1943 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1945 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1944 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1946 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1945 | // "kaddressbook_configure_shortcuts" ); | 1947 | // "kaddressbook_configure_shortcuts" ); |
1946 | #ifdef KAB_EMBEDDED | 1948 | #ifdef KAB_EMBEDDED |
1947 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1949 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1948 | mActionConfigureToolbars->setEnabled( false ); | 1950 | mActionConfigureToolbars->setEnabled( false ); |
1949 | #endif //KAB_EMBEDDED | 1951 | #endif //KAB_EMBEDDED |
1950 | 1952 | ||
1951 | } else { | 1953 | } else { |
1952 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1954 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1953 | 1955 | ||
1954 | //US not implemented yet | 1956 | //US not implemented yet |
1955 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1957 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1956 | } | 1958 | } |
1957 | 1959 | ||
1958 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1960 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1959 | actionCollection(), "options_show_jump_bar" ); | 1961 | actionCollection(), "options_show_jump_bar" ); |
1960 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1962 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1961 | 1963 | ||
1962 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1964 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1963 | actionCollection(), "options_show_details" ); | 1965 | actionCollection(), "options_show_details" ); |
1964 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1966 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1965 | 1967 | ||
1966 | 1968 | ||
1967 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1969 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1968 | SLOT( toggleBeamReceive() ), actionCollection(), | 1970 | SLOT( toggleBeamReceive() ), actionCollection(), |
1969 | "kaddressbook_beam_rec" ); | 1971 | "kaddressbook_beam_rec" ); |
1970 | 1972 | ||
1971 | 1973 | ||
1972 | // misc | 1974 | // misc |
1973 | // only enable LDAP lookup if we can handle the protocol | 1975 | // only enable LDAP lookup if we can handle the protocol |
1974 | #ifndef KAB_EMBEDDED | 1976 | #ifndef KAB_EMBEDDED |
1975 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1977 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1976 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1978 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1977 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1979 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1978 | "ldap_lookup" ); | 1980 | "ldap_lookup" ); |
1979 | } | 1981 | } |
1980 | #else //KAB_EMBEDDED | 1982 | #else //KAB_EMBEDDED |
1981 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1983 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1982 | #endif //KAB_EMBEDDED | 1984 | #endif //KAB_EMBEDDED |
1983 | 1985 | ||
1984 | 1986 | ||
1985 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1987 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1986 | SLOT( setWhoAmI() ), actionCollection(), | 1988 | SLOT( setWhoAmI() ), actionCollection(), |
1987 | "set_personal" ); | 1989 | "set_personal" ); |
1988 | 1990 | ||
1989 | 1991 | ||
1990 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1992 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1991 | SLOT( setCategories() ), actionCollection(), | 1993 | SLOT( setCategories() ), actionCollection(), |
1992 | "edit_set_categories" ); | 1994 | "edit_set_categories" ); |
1993 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, | 1995 | mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, |
1994 | SLOT( editCategories() ), actionCollection(), | 1996 | SLOT( editCategories() ), actionCollection(), |
1995 | "edit__categories" ); | 1997 | "edit__categories" ); |
1996 | 1998 | ||
1997 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1999 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1998 | SLOT( removeVoice() ), actionCollection(), | 2000 | SLOT( removeVoice() ), actionCollection(), |
1999 | "remove_voice" ); | 2001 | "remove_voice" ); |
2000 | 2002 | ||
2001 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, | 2003 | mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, |
2002 | SLOT( manageCategories() ), actionCollection(), | 2004 | SLOT( manageCategories() ), actionCollection(), |
2003 | "remove_voice" ); | 2005 | "remove_voice" ); |
2004 | 2006 | ||
2005 | 2007 | ||
2006 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 2008 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
2007 | SLOT( importFromOL() ), actionCollection(), | 2009 | SLOT( importFromOL() ), actionCollection(), |
2008 | "import_OL" ); | 2010 | "import_OL" ); |
2009 | #ifdef KAB_EMBEDDED | 2011 | #ifdef KAB_EMBEDDED |
2010 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 2012 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
2011 | this, SLOT( showLicence() ), actionCollection(), | 2013 | this, SLOT( showLicence() ), actionCollection(), |
2012 | "licence_about_data" ); | 2014 | "licence_about_data" ); |
2013 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 2015 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
2014 | this, SLOT( faq() ), actionCollection(), | 2016 | this, SLOT( faq() ), actionCollection(), |
2015 | "faq_about_data" ); | 2017 | "faq_about_data" ); |
2016 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 2018 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
2017 | this, SLOT( whatsnew() ), actionCollection(), | 2019 | this, SLOT( whatsnew() ), actionCollection(), |
2018 | "wn" ); | 2020 | "wn" ); |
2019 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 2021 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
2020 | this, SLOT( synchowto() ), actionCollection(), | 2022 | this, SLOT( synchowto() ), actionCollection(), |
2021 | "sync" ); | 2023 | "sync" ); |
2022 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, | 2024 | mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, |
2023 | this, SLOT( kdesynchowto() ), actionCollection(), | 2025 | this, SLOT( kdesynchowto() ), actionCollection(), |
2024 | "kdesync" ); | 2026 | "kdesync" ); |
2025 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, | 2027 | mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, |
2026 | this, SLOT( multisynchowto() ), actionCollection(), | 2028 | this, SLOT( multisynchowto() ), actionCollection(), |
2027 | "multisync" ); | 2029 | "multisync" ); |
2028 | 2030 | ||
2029 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 2031 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
2030 | this, SLOT( createAboutData() ), actionCollection(), | 2032 | this, SLOT( createAboutData() ), actionCollection(), |
2031 | "kaddressbook_about_data" ); | 2033 | "kaddressbook_about_data" ); |
2032 | #endif //KAB_EMBEDDED | 2034 | #endif //KAB_EMBEDDED |
2033 | 2035 | ||
2034 | clipboardDataChanged(); | 2036 | clipboardDataChanged(); |
2035 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2037 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2036 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 2038 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
2037 | } | 2039 | } |
2038 | 2040 | ||
2039 | //US we need this function, to plug all actions into the correct menues. | 2041 | //US we need this function, to plug all actions into the correct menues. |
2040 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 2042 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
2041 | void KABCore::addActionsManually() | 2043 | void KABCore::addActionsManually() |
2042 | { | 2044 | { |
2043 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 2045 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
2044 | 2046 | ||
2045 | #ifdef KAB_EMBEDDED | 2047 | #ifdef KAB_EMBEDDED |
2046 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 2048 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
2047 | QPopupMenu *editMenu = new QPopupMenu( this ); | 2049 | QPopupMenu *editMenu = new QPopupMenu( this ); |
2048 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 2050 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
2049 | 2051 | ||
2050 | KToolBar* tb = mMainWindow->toolBar(); | 2052 | KToolBar* tb = mMainWindow->toolBar(); |
2051 | 2053 | ||
2052 | #ifndef DESKTOP_VERSION | 2054 | #ifndef DESKTOP_VERSION |
2053 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 2055 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
2054 | #endif | 2056 | #endif |
2055 | QMenuBar* mb = mMainWindow->menuBar(); | 2057 | QMenuBar* mb = mMainWindow->menuBar(); |
2056 | 2058 | ||
2057 | //US setup menubar. | 2059 | //US setup menubar. |
2058 | //Disable the following block if you do not want to have a menubar. | 2060 | //Disable the following block if you do not want to have a menubar. |
2059 | mb->insertItem( i18n("&File"), fileMenu ); | 2061 | mb->insertItem( i18n("&File"), fileMenu ); |
2060 | mb->insertItem( i18n("&Edit"), editMenu ); | 2062 | mb->insertItem( i18n("&Edit"), editMenu ); |
2061 | mb->insertItem( i18n("&View"), viewMenu ); | 2063 | mb->insertItem( i18n("&View"), viewMenu ); |
2062 | mb->insertItem( i18n("&Settings"), settingsMenu ); | 2064 | mb->insertItem( i18n("&Settings"), settingsMenu ); |
2063 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 2065 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
2064 | //mb->insertItem( i18n("&Change"), changeMenu ); | 2066 | //mb->insertItem( i18n("&Change"), changeMenu ); |
2065 | mb->insertItem( i18n("&Help"), helpMenu ); | 2067 | mb->insertItem( i18n("&Help"), helpMenu ); |
2066 | mIncSearchWidget = new IncSearchWidget( tb ); | 2068 | mIncSearchWidget = new IncSearchWidget( tb ); |
2067 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 2069 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
2068 | #ifndef DESKTOP_VERSION | 2070 | #ifndef DESKTOP_VERSION |
2069 | } else { | 2071 | } else { |
2070 | //US setup toolbar | 2072 | //US setup toolbar |
2071 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 2073 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
2072 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 2074 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
2073 | menuBarTB->insertItem( "ME", popupBarTB); | 2075 | menuBarTB->insertItem( "ME", popupBarTB); |
2074 | tb->insertWidget(-1, 0, menuBarTB); | 2076 | tb->insertWidget(-1, 0, menuBarTB); |
2075 | mIncSearchWidget = new IncSearchWidget( tb ); | 2077 | mIncSearchWidget = new IncSearchWidget( tb ); |
2076 | 2078 | ||
2077 | tb->enableMoving(false); | 2079 | tb->enableMoving(false); |
2078 | popupBarTB->insertItem( i18n("&File"), fileMenu ); | 2080 | popupBarTB->insertItem( i18n("&File"), fileMenu ); |
2079 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); | 2081 | popupBarTB->insertItem( i18n("&Edit"), editMenu ); |
2080 | popupBarTB->insertItem( i18n("&View"), viewMenu ); | 2082 | popupBarTB->insertItem( i18n("&View"), viewMenu ); |
2081 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); | 2083 | popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); |
2082 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 2084 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
2083 | mViewManager->getFilterAction()->plug ( popupBarTB); | 2085 | mViewManager->getFilterAction()->plug ( popupBarTB); |
2084 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); | 2086 | //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); |
2085 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); | 2087 | popupBarTB->insertItem( i18n("&Help"), helpMenu ); |
2086 | if (QApplication::desktop()->width() > 320 ) { | 2088 | if (QApplication::desktop()->width() > 320 ) { |
2087 | // mViewManager->getFilterAction()->plug ( tb); | 2089 | // mViewManager->getFilterAction()->plug ( tb); |
2088 | } | 2090 | } |
2089 | } | 2091 | } |
2090 | #endif | 2092 | #endif |
2091 | // mActionQuit->plug ( mMainWindow->toolBar()); | 2093 | // mActionQuit->plug ( mMainWindow->toolBar()); |
2092 | 2094 | ||
2093 | 2095 | ||
2094 | 2096 | ||
2095 | //US Now connect the actions with the menue entries. | 2097 | //US Now connect the actions with the menue entries. |
2096 | mActionPrint->plug( fileMenu ); | 2098 | mActionPrint->plug( fileMenu ); |
2097 | mActionMail->plug( fileMenu ); | 2099 | mActionMail->plug( fileMenu ); |
2098 | fileMenu->insertSeparator(); | 2100 | fileMenu->insertSeparator(); |
2099 | 2101 | ||
2100 | mActionNewContact->plug( fileMenu ); | 2102 | mActionNewContact->plug( fileMenu ); |
2101 | mActionNewContact->plug( tb ); | 2103 | mActionNewContact->plug( tb ); |
2102 | 2104 | ||
2103 | mActionEditAddressee->plug( fileMenu ); | 2105 | mActionEditAddressee->plug( fileMenu ); |
2104 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 2106 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
2105 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 2107 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
2106 | mActionEditAddressee->plug( tb ); | 2108 | mActionEditAddressee->plug( tb ); |
2107 | 2109 | ||
2108 | fileMenu->insertSeparator(); | 2110 | fileMenu->insertSeparator(); |
2109 | mActionSave->plug( fileMenu ); | 2111 | mActionSave->plug( fileMenu ); |
2110 | fileMenu->insertItem( "&Import", ImportMenu ); | 2112 | fileMenu->insertItem( "&Import", ImportMenu ); |
2111 | fileMenu->insertItem( "&Export", ExportMenu ); | 2113 | fileMenu->insertItem( "&Export", ExportMenu ); |
2112 | fileMenu->insertItem( i18n("&Change"), changeMenu ); | 2114 | fileMenu->insertItem( i18n("&Change"), changeMenu ); |
2113 | #ifndef DESKTOP_VERSION | 2115 | #ifndef DESKTOP_VERSION |
2114 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); | 2116 | if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); |
2115 | #endif | 2117 | #endif |
2116 | 2118 | ||
2117 | fileMenu->insertSeparator(); | 2119 | fileMenu->insertSeparator(); |
2118 | mActionMailVCard->plug( fileMenu ); | 2120 | mActionMailVCard->plug( fileMenu ); |
2119 | #ifndef DESKTOP_VERSION | 2121 | #ifndef DESKTOP_VERSION |
2120 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); | 2122 | if ( Ir::supported() ) mActionBR->plug( beamMenu ); |
2121 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); | 2123 | if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); |
2122 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); | 2124 | if ( Ir::supported() ) mActionBeam->plug( beamMenu ); |
2123 | #endif | 2125 | #endif |
2124 | fileMenu->insertSeparator(); | 2126 | fileMenu->insertSeparator(); |
2125 | mActionQuit->plug( fileMenu ); | 2127 | mActionQuit->plug( fileMenu ); |
2126 | #ifdef _WIN32_ | 2128 | #ifdef _WIN32_ |
2127 | mActionImportOL->plug( ImportMenu ); | 2129 | mActionImportOL->plug( ImportMenu ); |
2128 | #endif | 2130 | #endif |
2129 | // edit menu | 2131 | // edit menu |
2130 | mActionUndo->plug( editMenu ); | 2132 | mActionUndo->plug( editMenu ); |
2131 | mActionRedo->plug( editMenu ); | 2133 | mActionRedo->plug( editMenu ); |
2132 | editMenu->insertSeparator(); | 2134 | editMenu->insertSeparator(); |
2133 | mActionCut->plug( editMenu ); | 2135 | mActionCut->plug( editMenu ); |
2134 | mActionCopy->plug( editMenu ); | 2136 | mActionCopy->plug( editMenu ); |
2135 | mActionPaste->plug( editMenu ); | 2137 | mActionPaste->plug( editMenu ); |
2136 | mActionDelete->plug( editMenu ); | 2138 | mActionDelete->plug( editMenu ); |
2137 | editMenu->insertSeparator(); | 2139 | editMenu->insertSeparator(); |
2138 | mActionSelectAll->plug( editMenu ); | 2140 | mActionSelectAll->plug( editMenu ); |
2139 | 2141 | ||
2140 | mActionRemoveVoice->plug( changeMenu ); | 2142 | mActionRemoveVoice->plug( changeMenu ); |
2141 | // settings menu | 2143 | // settings menu |
2142 | //US special menuentry to configure the addressbook resources. On KDE | 2144 | //US special menuentry to configure the addressbook resources. On KDE |
2143 | // you do that through the control center !!! | 2145 | // you do that through the control center !!! |
2144 | mActionConfigResources->plug( settingsMenu ); | 2146 | mActionConfigResources->plug( settingsMenu ); |
2145 | settingsMenu->insertSeparator(); | 2147 | settingsMenu->insertSeparator(); |
2146 | 2148 | ||
2147 | mActionConfigKAddressbook->plug( settingsMenu ); | 2149 | mActionConfigKAddressbook->plug( settingsMenu ); |
2148 | 2150 | ||
2149 | if ( mIsPart ) { | 2151 | if ( mIsPart ) { |
2150 | //US not implemented yet | 2152 | //US not implemented yet |
2151 | //mActionConfigShortcuts->plug( settingsMenu ); | 2153 | //mActionConfigShortcuts->plug( settingsMenu ); |
2152 | //mActionConfigureToolbars->plug( settingsMenu ); | 2154 | //mActionConfigureToolbars->plug( settingsMenu ); |
2153 | 2155 | ||
2154 | } else { | 2156 | } else { |
2155 | //US not implemented yet | 2157 | //US not implemented yet |
2156 | //mActionKeyBindings->plug( settingsMenu ); | 2158 | //mActionKeyBindings->plug( settingsMenu ); |
2157 | } | 2159 | } |
2158 | 2160 | ||
2159 | settingsMenu->insertSeparator(); | 2161 | settingsMenu->insertSeparator(); |
2160 | 2162 | ||
2161 | mActionJumpBar->plug( settingsMenu ); | 2163 | mActionJumpBar->plug( settingsMenu ); |
2162 | mActionDetails->plug( settingsMenu ); | 2164 | mActionDetails->plug( settingsMenu ); |
2163 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2165 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2164 | mActionDetails->plug( tb ); | 2166 | mActionDetails->plug( tb ); |
2165 | settingsMenu->insertSeparator(); | 2167 | settingsMenu->insertSeparator(); |
2166 | #ifndef DESKTOP_VERSION | 2168 | #ifndef DESKTOP_VERSION |
2167 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); | 2169 | if ( Ir::supported() ) mActionBR->plug(settingsMenu ); |
2168 | #endif | 2170 | #endif |
2169 | settingsMenu->insertSeparator(); | 2171 | settingsMenu->insertSeparator(); |
2170 | 2172 | ||
2171 | mActionWhoAmI->plug( settingsMenu ); | 2173 | mActionWhoAmI->plug( settingsMenu ); |
2172 | mActionEditCategories->plug( settingsMenu ); | 2174 | mActionEditCategories->plug( settingsMenu ); |
2173 | mActionEditCategories->plug( changeMenu ); | 2175 | mActionEditCategories->plug( changeMenu ); |
2174 | mActionCategories->plug( changeMenu ); | 2176 | mActionCategories->plug( changeMenu ); |
2175 | mActionManageCategories->plug( changeMenu ); | 2177 | mActionManageCategories->plug( changeMenu ); |
2176 | 2178 | ||
2177 | mActionCategories->plug( settingsMenu ); | 2179 | mActionCategories->plug( settingsMenu ); |
2178 | mActionManageCategories->plug( settingsMenu ); | 2180 | mActionManageCategories->plug( settingsMenu ); |
2179 | 2181 | ||
2180 | 2182 | ||
2181 | mActionWN->plug( helpMenu ); | 2183 | mActionWN->plug( helpMenu ); |
2182 | mActionSyncHowto->plug( helpMenu ); | 2184 | mActionSyncHowto->plug( helpMenu ); |
2183 | mActionKdeSyncHowto->plug( helpMenu ); | 2185 | mActionKdeSyncHowto->plug( helpMenu ); |
2184 | mActionMultiSyncHowto->plug( helpMenu ); | 2186 | mActionMultiSyncHowto->plug( helpMenu ); |
2185 | mActionFaq->plug( helpMenu ); | 2187 | mActionFaq->plug( helpMenu ); |
2186 | mActionLicence->plug( helpMenu ); | 2188 | mActionLicence->plug( helpMenu ); |
2187 | mActionAboutKAddressbook->plug( helpMenu ); | 2189 | mActionAboutKAddressbook->plug( helpMenu ); |
2188 | 2190 | ||
2189 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2191 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2190 | 2192 | ||
2191 | mActionSave->plug( tb ); | 2193 | mActionSave->plug( tb ); |
2192 | mViewManager->getFilterAction()->plug ( tb); | 2194 | mViewManager->getFilterAction()->plug ( tb); |
2193 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2195 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2194 | mActionUndo->plug( tb ); | 2196 | mActionUndo->plug( tb ); |
2195 | mActionDelete->plug( tb ); | 2197 | mActionDelete->plug( tb ); |
2196 | mActionRedo->plug( tb ); | 2198 | mActionRedo->plug( tb ); |
2197 | } | 2199 | } |
2198 | } else { | 2200 | } else { |
2199 | mActionSave->plug( tb ); | 2201 | mActionSave->plug( tb ); |
2200 | tb->enableMoving(false); | 2202 | tb->enableMoving(false); |
2201 | } | 2203 | } |
2202 | //mActionQuit->plug ( tb ); | 2204 | //mActionQuit->plug ( tb ); |
2203 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2205 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2204 | 2206 | ||
2205 | //US link the searchwidget first to this. | 2207 | //US link the searchwidget first to this. |
2206 | // The real linkage to the toolbar happens later. | 2208 | // The real linkage to the toolbar happens later. |
2207 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2209 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2208 | //US tb->insertItem( mIncSearchWidget ); | 2210 | //US tb->insertItem( mIncSearchWidget ); |
2209 | /*US | 2211 | /*US |
2210 | mIncSearchWidget = new IncSearchWidget( tb ); | 2212 | mIncSearchWidget = new IncSearchWidget( tb ); |
2211 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2213 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2212 | SLOT( incrementalSearch( const QString& ) ) ); | 2214 | SLOT( incrementalSearch( const QString& ) ) ); |
2213 | 2215 | ||
2214 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2216 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2215 | 2217 | ||
2216 | //US topLayout->addWidget( mJumpButtonBar ); | 2218 | //US topLayout->addWidget( mJumpButtonBar ); |
2217 | this->layout()->add( mJumpButtonBar ); | 2219 | this->layout()->add( mJumpButtonBar ); |
2218 | */ | 2220 | */ |
2219 | 2221 | ||
2220 | #endif //KAB_EMBEDDED | 2222 | #endif //KAB_EMBEDDED |
2221 | 2223 | ||
2222 | mActionExport2phone->plug( ExportMenu ); | 2224 | mActionExport2phone->plug( ExportMenu ); |
2223 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2225 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2224 | syncManager->fillSyncMenu(); | 2226 | syncManager->fillSyncMenu(); |
2225 | 2227 | ||
2226 | } | 2228 | } |
2227 | void KABCore::showLicence() | 2229 | void KABCore::showLicence() |
2228 | { | 2230 | { |
2229 | KApplication::showLicence(); | 2231 | KApplication::showLicence(); |
2230 | } | 2232 | } |
2231 | 2233 | ||
2232 | void KABCore::manageCategories( ) | 2234 | void KABCore::manageCategories( ) |
2233 | { | 2235 | { |
2234 | KABCatPrefs* cp = new KABCatPrefs(); | 2236 | KABCatPrefs* cp = new KABCatPrefs(); |
2235 | cp->show(); | 2237 | cp->show(); |
2236 | int w =cp->sizeHint().width() ; | 2238 | int w =cp->sizeHint().width() ; |
2237 | int h = cp->sizeHint().height() ; | 2239 | int h = cp->sizeHint().height() ; |
2238 | int dw = QApplication::desktop()->width(); | 2240 | int dw = QApplication::desktop()->width(); |
2239 | int dh = QApplication::desktop()->height(); | 2241 | int dh = QApplication::desktop()->height(); |
2240 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2242 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2241 | if ( !cp->exec() ) { | 2243 | if ( !cp->exec() ) { |
2242 | delete cp; | 2244 | delete cp; |
2243 | return; | 2245 | return; |
2244 | } | 2246 | } |
2245 | int count = 0; | 2247 | int count = 0; |
2246 | message( i18n("Please wait, processing categories...")); | 2248 | message( i18n("Please wait, processing categories...")); |
2247 | if ( cp->addCat() ) { | 2249 | if ( cp->addCat() ) { |
2248 | KABC::AddressBook::Iterator it; | 2250 | KABC::AddressBook::Iterator it; |
2249 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2251 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2250 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2252 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2251 | QStringList catIncList = (*it).categories(); | 2253 | QStringList catIncList = (*it).categories(); |
2252 | int i; | 2254 | int i; |
2253 | for( i = 0; i< catIncList.count(); ++i ) { | 2255 | for( i = 0; i< catIncList.count(); ++i ) { |
2254 | if ( !catList.contains (catIncList[i])) { | 2256 | if ( !catList.contains (catIncList[i])) { |
2255 | catList.append( catIncList[i] ); | 2257 | catList.append( catIncList[i] ); |
2256 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2258 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2257 | ++count; | 2259 | ++count; |
2258 | } | 2260 | } |
2259 | } | 2261 | } |
2260 | } | 2262 | } |
2261 | catList.sort(); | 2263 | catList.sort(); |
2262 | KABPrefs::instance()->mCustomCategories = catList; | 2264 | KABPrefs::instance()->mCustomCategories = catList; |
2263 | KABPrefs::instance()->writeConfig(); | 2265 | KABPrefs::instance()->writeConfig(); |
2264 | message(QString::number( count )+ i18n(" categories added to list! ")); | 2266 | message(QString::number( count )+ i18n(" categories added to list! ")); |
2265 | } else { | 2267 | } else { |
2266 | QStringList catList = KABPrefs::instance()->mCustomCategories; | 2268 | QStringList catList = KABPrefs::instance()->mCustomCategories; |
2267 | QStringList catIncList; | 2269 | QStringList catIncList; |
2268 | QStringList newCatList; | 2270 | QStringList newCatList; |
2269 | KABC::AddressBook::Iterator it; | 2271 | KABC::AddressBook::Iterator it; |
2270 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2272 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2271 | QStringList catIncList = (*it).categories(); | 2273 | QStringList catIncList = (*it).categories(); |
2272 | int i; | 2274 | int i; |
2273 | if ( catIncList.count() ) { | 2275 | if ( catIncList.count() ) { |
2274 | newCatList.clear(); | 2276 | newCatList.clear(); |
2275 | for( i = 0; i< catIncList.count(); ++i ) { | 2277 | for( i = 0; i< catIncList.count(); ++i ) { |
2276 | if ( catList.contains (catIncList[i])) { | 2278 | if ( catList.contains (catIncList[i])) { |
2277 | newCatList.append( catIncList[i] ); | 2279 | newCatList.append( catIncList[i] ); |
2278 | } | 2280 | } |
2279 | } | 2281 | } |
2280 | newCatList.sort(); | 2282 | newCatList.sort(); |
2281 | (*it).setCategories( newCatList ); | 2283 | (*it).setCategories( newCatList ); |
2282 | mAddressBook->insertAddressee( (*it) ); | 2284 | mAddressBook->insertAddressee( (*it) ); |
2283 | } | 2285 | } |
2284 | } | 2286 | } |
2285 | setModified( true ); | 2287 | setModified( true ); |
2286 | mViewManager->refreshView(); | 2288 | mViewManager->refreshView(); |
2287 | mDetails->refreshView(); | 2289 | mDetails->refreshView(); |
2288 | message( i18n("Removing categories done!")); | 2290 | message( i18n("Removing categories done!")); |
2289 | } | 2291 | } |
2290 | delete cp; | 2292 | delete cp; |
2291 | } | 2293 | } |
2292 | void KABCore::removeVoice() | 2294 | void KABCore::removeVoice() |
2293 | { | 2295 | { |
2294 | 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 ) | 2296 | 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 ) |
2295 | return; | 2297 | return; |
2296 | KABC::Addressee::List list; | 2298 | KABC::Addressee::List list; |
2297 | XXPortSelectDialog dlg( this, false, this ); | 2299 | XXPortSelectDialog dlg( this, false, this ); |
2298 | if ( dlg.exec() ) | 2300 | if ( dlg.exec() ) |
2299 | list = dlg.contacts(); | 2301 | list = dlg.contacts(); |
2300 | else | 2302 | else |
2301 | return; | 2303 | return; |
2302 | KABC::Addressee::List::Iterator it; | 2304 | KABC::Addressee::List::Iterator it; |
2303 | for ( it = list.begin(); it != list.end(); ++it ) { | 2305 | for ( it = list.begin(); it != list.end(); ++it ) { |
2304 | if ( (*it).removeVoice() ) | 2306 | if ( (*it).removeVoice() ) |
2305 | contactModified((*it) ); | 2307 | contactModified((*it) ); |
2306 | } | 2308 | } |
2307 | } | 2309 | } |
2308 | 2310 | ||
2309 | 2311 | ||
2310 | 2312 | ||
2311 | void KABCore::clipboardDataChanged() | 2313 | void KABCore::clipboardDataChanged() |
2312 | { | 2314 | { |
2313 | 2315 | ||
2314 | if ( mReadWrite ) | 2316 | if ( mReadWrite ) |
2315 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2317 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2316 | 2318 | ||
2317 | } | 2319 | } |
2318 | 2320 | ||
2319 | void KABCore::updateActionMenu() | 2321 | void KABCore::updateActionMenu() |
2320 | { | 2322 | { |
2321 | UndoStack *undo = UndoStack::instance(); | 2323 | UndoStack *undo = UndoStack::instance(); |
2322 | RedoStack *redo = RedoStack::instance(); | 2324 | RedoStack *redo = RedoStack::instance(); |
2323 | 2325 | ||
2324 | if ( undo->isEmpty() ) | 2326 | if ( undo->isEmpty() ) |
2325 | mActionUndo->setText( i18n( "Undo" ) ); | 2327 | mActionUndo->setText( i18n( "Undo" ) ); |
2326 | else | 2328 | else |
2327 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2329 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2328 | 2330 | ||
2329 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2331 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2330 | 2332 | ||
2331 | if ( !redo->top() ) | 2333 | if ( !redo->top() ) |
2332 | mActionRedo->setText( i18n( "Redo" ) ); | 2334 | mActionRedo->setText( i18n( "Redo" ) ); |
2333 | else | 2335 | else |
2334 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2336 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2335 | 2337 | ||
2336 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2338 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2337 | } | 2339 | } |
2338 | 2340 | ||
2339 | void KABCore::configureKeyBindings() | 2341 | void KABCore::configureKeyBindings() |
2340 | { | 2342 | { |
2341 | #ifndef KAB_EMBEDDED | 2343 | #ifndef KAB_EMBEDDED |
2342 | KKeyDialog::configure( actionCollection(), true ); | 2344 | KKeyDialog::configure( actionCollection(), true ); |
2343 | #else //KAB_EMBEDDED | 2345 | #else //KAB_EMBEDDED |
2344 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2346 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2345 | #endif //KAB_EMBEDDED | 2347 | #endif //KAB_EMBEDDED |
2346 | } | 2348 | } |
2347 | 2349 | ||
2348 | #ifdef KAB_EMBEDDED | 2350 | #ifdef KAB_EMBEDDED |
2349 | void KABCore::configureResources() | 2351 | void KABCore::configureResources() |
2350 | { | 2352 | { |
2351 | KRES::KCMKResources dlg( this, "" , 0 ); | 2353 | KRES::KCMKResources dlg( this, "" , 0 ); |
2352 | 2354 | ||
2353 | if ( !dlg.exec() ) | 2355 | if ( !dlg.exec() ) |
2354 | return; | 2356 | return; |
2355 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2357 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2356 | } | 2358 | } |
2357 | #endif //KAB_EMBEDDED | 2359 | #endif //KAB_EMBEDDED |
2358 | 2360 | ||
2359 | 2361 | ||
2360 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2362 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2361 | * for the attendees list of an event. | 2363 | * for the attendees list of an event. |
2362 | */ | 2364 | */ |
2363 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2365 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2364 | { | 2366 | { |
2365 | QStringList nameList; | 2367 | QStringList nameList; |
2366 | QStringList emailList; | 2368 | QStringList emailList; |
2367 | QStringList uidList; | 2369 | QStringList uidList; |
2368 | 2370 | ||
2369 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2371 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2370 | uint i=0; | 2372 | uint i=0; |
2371 | for (i=0; i < list.count(); i++) | 2373 | for (i=0; i < list.count(); i++) |
2372 | { | 2374 | { |
2373 | nameList.append(list[i].realName()); | 2375 | nameList.append(list[i].realName()); |
2374 | emailList.append(list[i].preferredEmail()); | 2376 | emailList.append(list[i].preferredEmail()); |
2375 | uidList.append(list[i].uid()); | 2377 | uidList.append(list[i].uid()); |
2376 | } | 2378 | } |
2377 | 2379 | ||
2378 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2380 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2379 | 2381 | ||
2380 | } | 2382 | } |
2381 | 2383 | ||
2382 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2384 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2383 | * to put them into the calendar. | 2385 | * to put them into the calendar. |
2384 | */ | 2386 | */ |
2385 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2387 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2386 | { | 2388 | { |
2387 | // qDebug("KABCore::requestForBirthdayList"); | 2389 | // qDebug("KABCore::requestForBirthdayList"); |
2388 | QStringList birthdayList; | 2390 | QStringList birthdayList; |
2389 | QStringList anniversaryList; | 2391 | QStringList anniversaryList; |
2390 | QStringList realNameList; | 2392 | QStringList realNameList; |
2391 | QStringList preferredEmailList; | 2393 | QStringList preferredEmailList; |
2392 | QStringList assembledNameList; | 2394 | QStringList assembledNameList; |
2393 | QStringList uidList; | 2395 | QStringList uidList; |
2394 | 2396 | ||
2395 | KABC::AddressBook::Iterator it; | 2397 | KABC::AddressBook::Iterator it; |
2396 | 2398 | ||
2397 | int count = 0; | 2399 | int count = 0; |
2398 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2400 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2399 | ++count; | 2401 | ++count; |
2400 | } | 2402 | } |
2401 | QProgressBar bar(count,0 ); | 2403 | QProgressBar bar(count,0 ); |
2402 | int w = 300; | 2404 | int w = 300; |
2403 | if ( QApplication::desktop()->width() < 320 ) | 2405 | if ( QApplication::desktop()->width() < 320 ) |
2404 | w = 220; | 2406 | w = 220; |
2405 | int h = bar.sizeHint().height() ; | 2407 | int h = bar.sizeHint().height() ; |
2406 | int dw = QApplication::desktop()->width(); | 2408 | int dw = QApplication::desktop()->width(); |
2407 | int dh = QApplication::desktop()->height(); | 2409 | int dh = QApplication::desktop()->height(); |
2408 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2410 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2409 | bar.show(); | 2411 | bar.show(); |
2410 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2412 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2411 | qApp->processEvents(); | 2413 | qApp->processEvents(); |
2412 | 2414 | ||
2413 | QDate bday; | 2415 | QDate bday; |
2414 | QString anni; | 2416 | QString anni; |
2415 | QString formattedbday; | 2417 | QString formattedbday; |
2416 | 2418 | ||
2417 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2419 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2418 | { | 2420 | { |
2419 | if ( ! bar.isVisible() ) | 2421 | if ( ! bar.isVisible() ) |
2420 | return; | 2422 | return; |
2421 | bar.setProgress( count++ ); | 2423 | bar.setProgress( count++ ); |
2422 | qApp->processEvents(); | 2424 | qApp->processEvents(); |
2423 | bday = (*it).birthday().date(); | 2425 | bday = (*it).birthday().date(); |
2424 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2426 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2425 | 2427 | ||
2426 | if ( bday.isValid() || !anni.isEmpty()) | 2428 | if ( bday.isValid() || !anni.isEmpty()) |
2427 | { | 2429 | { |
2428 | if (bday.isValid()) | 2430 | if (bday.isValid()) |
2429 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2431 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2430 | else | 2432 | else |
2431 | formattedbday = "NOTVALID"; | 2433 | formattedbday = "NOTVALID"; |
2432 | if (anni.isEmpty()) | 2434 | if (anni.isEmpty()) |
2433 | anni = "INVALID"; | 2435 | anni = "INVALID"; |
2434 | 2436 | ||
2435 | birthdayList.append(formattedbday); | 2437 | birthdayList.append(formattedbday); |
2436 | anniversaryList.append(anni); //should be ISODate | 2438 | anniversaryList.append(anni); //should be ISODate |
2437 | realNameList.append((*it).realName()); | 2439 | realNameList.append((*it).realName()); |
2438 | preferredEmailList.append((*it).preferredEmail()); | 2440 | preferredEmailList.append((*it).preferredEmail()); |
2439 | assembledNameList.append((*it).assembledName()); | 2441 | assembledNameList.append((*it).assembledName()); |
2440 | uidList.append((*it).uid()); | 2442 | uidList.append((*it).uid()); |
2441 | 2443 | ||
2442 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2444 | //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2443 | } | 2445 | } |
2444 | } | 2446 | } |
2445 | 2447 | ||
2446 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2448 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2447 | 2449 | ||
2448 | } | 2450 | } |
2449 | 2451 | ||
2450 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2452 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2451 | */ | 2453 | */ |
2452 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2454 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2453 | { | 2455 | { |
2454 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2456 | //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2455 | 2457 | ||
2456 | QString foundUid = QString::null; | 2458 | QString foundUid = QString::null; |
2457 | if ( ! uid.isEmpty() ) { | 2459 | if ( ! uid.isEmpty() ) { |
2458 | Addressee adrr = mAddressBook->findByUid( uid ); | 2460 | Addressee adrr = mAddressBook->findByUid( uid ); |
2459 | if ( !adrr.isEmpty() ) { | 2461 | if ( !adrr.isEmpty() ) { |
2460 | foundUid = uid; | 2462 | foundUid = uid; |
2461 | } | 2463 | } |
2462 | if ( email == "sendbacklist" ) { | 2464 | if ( email == "sendbacklist" ) { |
2463 | //qDebug("ssssssssssssssssssssssend "); | 2465 | //qDebug("ssssssssssssssssssssssend "); |
2464 | QStringList nameList; | 2466 | QStringList nameList; |
2465 | QStringList emailList; | 2467 | QStringList emailList; |
2466 | QStringList uidList; | 2468 | QStringList uidList; |
2467 | nameList.append(adrr.realName()); | 2469 | nameList.append(adrr.realName()); |
2468 | emailList = adrr.emails(); | 2470 | emailList = adrr.emails(); |
2469 | uidList.append( adrr.preferredEmail()); | 2471 | uidList.append( adrr.preferredEmail()); |
2470 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2472 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2471 | return; | 2473 | return; |
2472 | } | 2474 | } |
2473 | 2475 | ||
2474 | } | 2476 | } |
2475 | 2477 | ||
2476 | if ( email == "sendbacklist" ) | 2478 | if ( email == "sendbacklist" ) |
2477 | return; | 2479 | return; |
2478 | if (foundUid.isEmpty()) | 2480 | if (foundUid.isEmpty()) |
2479 | { | 2481 | { |
2480 | //find the uid of the person first | 2482 | //find the uid of the person first |
2481 | Addressee::List namelist; | 2483 | Addressee::List namelist; |
2482 | Addressee::List emaillist; | 2484 | Addressee::List emaillist; |
2483 | 2485 | ||
2484 | if (!name.isEmpty()) | 2486 | if (!name.isEmpty()) |
2485 | namelist = mAddressBook->findByName( name ); | 2487 | namelist = mAddressBook->findByName( name ); |
2486 | 2488 | ||
2487 | if (!email.isEmpty()) | 2489 | if (!email.isEmpty()) |
2488 | emaillist = mAddressBook->findByEmail( email ); | 2490 | emaillist = mAddressBook->findByEmail( email ); |
2489 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2491 | //qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2490 | //check if we have a match in Namelist and Emaillist | 2492 | //check if we have a match in Namelist and Emaillist |
2491 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2493 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2492 | foundUid = emaillist[0].uid(); | 2494 | foundUid = emaillist[0].uid(); |
2493 | } | 2495 | } |
2494 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2496 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2495 | foundUid = namelist[0].uid(); | 2497 | foundUid = namelist[0].uid(); |
2496 | else | 2498 | else |
2497 | { | 2499 | { |
2498 | for (int i = 0; i < namelist.count(); i++) | 2500 | for (int i = 0; i < namelist.count(); i++) |
2499 | { | 2501 | { |
2500 | for (int j = 0; j < emaillist.count(); j++) | 2502 | for (int j = 0; j < emaillist.count(); j++) |
2501 | { | 2503 | { |
2502 | if (namelist[i] == emaillist[j]) | 2504 | if (namelist[i] == emaillist[j]) |
2503 | { | 2505 | { |
2504 | foundUid = namelist[i].uid(); | 2506 | foundUid = namelist[i].uid(); |
2505 | } | 2507 | } |
2506 | } | 2508 | } |
2507 | } | 2509 | } |
2508 | } | 2510 | } |
2509 | } | 2511 | } |
2510 | else | 2512 | else |
2511 | { | 2513 | { |
2512 | foundUid = uid; | 2514 | foundUid = uid; |
2513 | } | 2515 | } |
2514 | 2516 | ||
2515 | if (!foundUid.isEmpty()) | 2517 | if (!foundUid.isEmpty()) |
2516 | { | 2518 | { |
2517 | 2519 | ||
2518 | // raise Ka/Pi if it is in the background | 2520 | // raise Ka/Pi if it is in the background |
2519 | #ifndef DESKTOP_VERSION | 2521 | #ifndef DESKTOP_VERSION |
2520 | #ifndef KORG_NODCOP | 2522 | #ifndef KORG_NODCOP |
2521 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2523 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2522 | #endif | 2524 | #endif |
2523 | #endif | 2525 | #endif |
2524 | 2526 | ||
2525 | mMainWindow->showMaximized(); | 2527 | mMainWindow->showMaximized(); |
2526 | mMainWindow-> raise(); | 2528 | mMainWindow-> raise(); |
2527 | 2529 | ||
2528 | mViewManager->setSelected( "", false); | 2530 | mViewManager->setSelected( "", false); |
2529 | mViewManager->refreshView( "" ); | 2531 | mViewManager->refreshView( "" ); |
2530 | mViewManager->setSelected( foundUid, true ); | 2532 | mViewManager->setSelected( foundUid, true ); |
2531 | mViewManager->refreshView( foundUid ); | 2533 | mViewManager->refreshView( foundUid ); |
2532 | 2534 | ||
2533 | if ( !mMultipleViewsAtOnce ) | 2535 | if ( !mMultipleViewsAtOnce ) |
2534 | { | 2536 | { |
2535 | setDetailsVisible( true ); | 2537 | setDetailsVisible( true ); |
2536 | mActionDetails->setChecked(true); | 2538 | mActionDetails->setChecked(true); |
2537 | } | 2539 | } |
2538 | } | 2540 | } |
2539 | } | 2541 | } |
2540 | 2542 | ||
2541 | void KABCore::whatsnew() | 2543 | void KABCore::whatsnew() |
2542 | { | 2544 | { |
2543 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2545 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2544 | } | 2546 | } |
2545 | void KABCore::synchowto() | 2547 | void KABCore::synchowto() |
2546 | { | 2548 | { |
2547 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2549 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2548 | } | 2550 | } |
2549 | void KABCore::kdesynchowto() | 2551 | void KABCore::kdesynchowto() |
2550 | { | 2552 | { |
2551 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); | 2553 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); |
2552 | } | 2554 | } |
2553 | void KABCore::multisynchowto() | 2555 | void KABCore::multisynchowto() |
2554 | { | 2556 | { |
2555 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); | 2557 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); |
2556 | } | 2558 | } |
2557 | void KABCore::faq() | 2559 | void KABCore::faq() |
2558 | { | 2560 | { |
2559 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2561 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2560 | } | 2562 | } |
2561 | 2563 | ||
2562 | #include <libkcal/syncdefines.h> | 2564 | #include <libkcal/syncdefines.h> |
2563 | 2565 | ||
2564 | KABC::Addressee KABCore::getLastSyncAddressee() | 2566 | KABC::Addressee KABCore::getLastSyncAddressee() |
2565 | { | 2567 | { |
2566 | Addressee lse; | 2568 | Addressee lse; |
2567 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2569 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2568 | 2570 | ||
2569 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2571 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2570 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2572 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2571 | if (lse.isEmpty()) { | 2573 | if (lse.isEmpty()) { |
2572 | qDebug("Creating new last-syncAddressee "); | 2574 | qDebug("Creating new last-syncAddressee "); |
2573 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2575 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2574 | QString sum = ""; | 2576 | QString sum = ""; |
2575 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2577 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2576 | sum = "E: "; | 2578 | sum = "E: "; |
2577 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2579 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2578 | lse.setRevision( mLastAddressbookSync ); | 2580 | lse.setRevision( mLastAddressbookSync ); |
2579 | lse.setCategories( i18n("SyncEvent") ); | 2581 | lse.setCategories( i18n("SyncEvent") ); |
2580 | mAddressBook->insertAddressee( lse ); | 2582 | mAddressBook->insertAddressee( lse ); |
2581 | } | 2583 | } |
2582 | return lse; | 2584 | return lse; |
2583 | } | 2585 | } |
2584 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2586 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2585 | { | 2587 | { |
2586 | 2588 | ||
2587 | //void setZaurusId(int id); | 2589 | //void setZaurusId(int id); |
2588 | // int zaurusId() const; | 2590 | // int zaurusId() const; |
2589 | // void setZaurusUid(int id); | 2591 | // void setZaurusUid(int id); |
2590 | // int zaurusUid() const; | 2592 | // int zaurusUid() const; |
2591 | // void setZaurusStat(int id); | 2593 | // void setZaurusStat(int id); |
2592 | // int zaurusStat() const; | 2594 | // int zaurusStat() const; |
2593 | // 0 equal | 2595 | // 0 equal |
2594 | // 1 take local | 2596 | // 1 take local |
2595 | // 2 take remote | 2597 | // 2 take remote |
2596 | // 3 cancel | 2598 | // 3 cancel |
2597 | QDateTime lastSync = mLastAddressbookSync; | 2599 | QDateTime lastSync = mLastAddressbookSync; |
2598 | QDateTime localMod = local->revision(); | 2600 | QDateTime localMod = local->revision(); |
2599 | QDateTime remoteMod = remote->revision(); | 2601 | QDateTime remoteMod = remote->revision(); |
2600 | 2602 | ||
2601 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2603 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2602 | 2604 | ||
2603 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2605 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2604 | bool remCh, locCh; | 2606 | bool remCh, locCh; |
2605 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2607 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2606 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2608 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2607 | locCh = ( localMod > mLastAddressbookSync ); | 2609 | locCh = ( localMod > mLastAddressbookSync ); |
2608 | if ( !remCh && ! locCh ) { | 2610 | if ( !remCh && ! locCh ) { |
2609 | //qDebug("both not changed "); | 2611 | //qDebug("both not changed "); |
2610 | lastSync = localMod.addDays(1); | 2612 | lastSync = localMod.addDays(1); |
2611 | if ( mode <= SYNC_PREF_ASK ) | 2613 | if ( mode <= SYNC_PREF_ASK ) |
2612 | return 0; | 2614 | return 0; |
2613 | } else { | 2615 | } else { |
2614 | if ( locCh ) { | 2616 | if ( locCh ) { |
2615 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2617 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2616 | lastSync = localMod.addDays( -1 ); | 2618 | lastSync = localMod.addDays( -1 ); |
2617 | if ( !remCh ) | 2619 | if ( !remCh ) |
2618 | remoteMod =( lastSync.addDays( -1 ) ); | 2620 | remoteMod =( lastSync.addDays( -1 ) ); |
2619 | } else { | 2621 | } else { |
2620 | //qDebug(" not loc changed "); | 2622 | //qDebug(" not loc changed "); |
2621 | lastSync = localMod.addDays( 1 ); | 2623 | lastSync = localMod.addDays( 1 ); |
2622 | if ( remCh ) { | 2624 | if ( remCh ) { |
2623 | //qDebug("rem changed "); | 2625 | //qDebug("rem changed "); |
2624 | remoteMod =( lastSync.addDays( 1 ) ); | 2626 | remoteMod =( lastSync.addDays( 1 ) ); |
2625 | } | 2627 | } |
2626 | 2628 | ||
2627 | } | 2629 | } |
2628 | } | 2630 | } |
2629 | full = true; | 2631 | full = true; |
2630 | if ( mode < SYNC_PREF_ASK ) | 2632 | if ( mode < SYNC_PREF_ASK ) |
2631 | mode = SYNC_PREF_ASK; | 2633 | mode = SYNC_PREF_ASK; |
2632 | } else { | 2634 | } else { |
2633 | if ( localMod == remoteMod ) | 2635 | if ( localMod == remoteMod ) |
2634 | return 0; | 2636 | return 0; |
2635 | 2637 | ||
2636 | } | 2638 | } |
2637 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); | 2639 | //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); |
2638 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); | 2640 | //qDebug("lastsync %s ", lastSync.toString().latin1() ); |
2639 | //full = true; //debug only | 2641 | //full = true; //debug only |
2640 | if ( full ) { | 2642 | if ( full ) { |
2641 | bool equ = ( (*local) == (*remote) ); | 2643 | bool equ = ( (*local) == (*remote) ); |
2642 | if ( equ ) { | 2644 | if ( equ ) { |
2643 | //qDebug("equal "); | 2645 | //qDebug("equal "); |
2644 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2646 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2645 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2647 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2646 | } | 2648 | } |
2647 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2649 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2648 | return 0; | 2650 | return 0; |
2649 | 2651 | ||
2650 | }//else //debug only | 2652 | }//else //debug only |
2651 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2653 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2652 | } | 2654 | } |
2653 | int result; | 2655 | int result; |
2654 | bool localIsNew; | 2656 | bool localIsNew; |
2655 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2657 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2656 | 2658 | ||
2657 | if ( full && mode < SYNC_PREF_NEWEST ) | 2659 | if ( full && mode < SYNC_PREF_NEWEST ) |
2658 | mode = SYNC_PREF_ASK; | 2660 | mode = SYNC_PREF_ASK; |
2659 | 2661 | ||
2660 | switch( mode ) { | 2662 | switch( mode ) { |
2661 | case SYNC_PREF_LOCAL: | 2663 | case SYNC_PREF_LOCAL: |
2662 | if ( lastSync > remoteMod ) | 2664 | if ( lastSync > remoteMod ) |
2663 | return 1; | 2665 | return 1; |
2664 | if ( lastSync > localMod ) | 2666 | if ( lastSync > localMod ) |
2665 | return 2; | 2667 | return 2; |
2666 | return 1; | 2668 | return 1; |
2667 | break; | 2669 | break; |
2668 | case SYNC_PREF_REMOTE: | 2670 | case SYNC_PREF_REMOTE: |
2669 | if ( lastSync > remoteMod ) | 2671 | if ( lastSync > remoteMod ) |
2670 | return 1; | 2672 | return 1; |
2671 | if ( lastSync > localMod ) | 2673 | if ( lastSync > localMod ) |
2672 | return 2; | 2674 | return 2; |
2673 | return 2; | 2675 | return 2; |
2674 | break; | 2676 | break; |
2675 | case SYNC_PREF_NEWEST: | 2677 | case SYNC_PREF_NEWEST: |
2676 | if ( localMod > remoteMod ) | 2678 | if ( localMod > remoteMod ) |
2677 | return 1; | 2679 | return 1; |
2678 | else | 2680 | else |
2679 | return 2; | 2681 | return 2; |
2680 | break; | 2682 | break; |
2681 | case SYNC_PREF_ASK: | 2683 | case SYNC_PREF_ASK: |
2682 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2684 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2683 | if ( lastSync > remoteMod ) | 2685 | if ( lastSync > remoteMod ) |
2684 | return 1; | 2686 | return 1; |
2685 | if ( lastSync > localMod ) | 2687 | if ( lastSync > localMod ) |
2686 | return 2; | 2688 | return 2; |
2687 | localIsNew = localMod >= remoteMod; | 2689 | localIsNew = localMod >= remoteMod; |
2688 | //qDebug("conflict! ************************************** "); | 2690 | //qDebug("conflict! ************************************** "); |
2689 | { | 2691 | { |
2690 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2692 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2691 | result = acd.executeD(localIsNew); | 2693 | result = acd.executeD(localIsNew); |
2692 | return result; | 2694 | return result; |
2693 | } | 2695 | } |
2694 | break; | 2696 | break; |
2695 | case SYNC_PREF_FORCE_LOCAL: | 2697 | case SYNC_PREF_FORCE_LOCAL: |
2696 | return 1; | 2698 | return 1; |
2697 | break; | 2699 | break; |
2698 | case SYNC_PREF_FORCE_REMOTE: | 2700 | case SYNC_PREF_FORCE_REMOTE: |
2699 | return 2; | 2701 | return 2; |
2700 | break; | 2702 | break; |
2701 | 2703 | ||
2702 | default: | 2704 | default: |
2703 | // SYNC_PREF_TAKE_BOTH not implemented | 2705 | // SYNC_PREF_TAKE_BOTH not implemented |
2704 | break; | 2706 | break; |
2705 | } | 2707 | } |
2706 | return 0; | 2708 | return 0; |
2707 | } | 2709 | } |
2708 | 2710 | ||
2709 | 2711 | ||
2710 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2712 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2711 | { | 2713 | { |
2712 | bool syncOK = true; | 2714 | bool syncOK = true; |
2713 | int addedAddressee = 0; | 2715 | int addedAddressee = 0; |
2714 | int addedAddresseeR = 0; | 2716 | int addedAddresseeR = 0; |
2715 | int deletedAddresseeR = 0; | 2717 | int deletedAddresseeR = 0; |
2716 | int deletedAddresseeL = 0; | 2718 | int deletedAddresseeL = 0; |
2717 | int changedLocal = 0; | 2719 | int changedLocal = 0; |
2718 | int changedRemote = 0; | 2720 | int changedRemote = 0; |
2719 | 2721 | ||
2720 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2722 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2721 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2723 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2722 | 2724 | ||
2723 | //QPtrList<Addressee> el = local->rawAddressees(); | 2725 | //QPtrList<Addressee> el = local->rawAddressees(); |
2724 | Addressee addresseeR; | 2726 | Addressee addresseeR; |
2725 | QString uid; | 2727 | QString uid; |
2726 | int take; | 2728 | int take; |
2727 | Addressee addresseeL; | 2729 | Addressee addresseeL; |
2728 | Addressee addresseeRSync; | 2730 | Addressee addresseeRSync; |
2729 | Addressee addresseeLSync; | 2731 | Addressee addresseeLSync; |
2730 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2732 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2731 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2733 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2732 | bool fullDateRange = false; | 2734 | bool fullDateRange = false; |
2733 | local->resetTempSyncStat(); | 2735 | local->resetTempSyncStat(); |
2734 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2736 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2735 | if ( syncManager->syncWithDesktop() ) { | 2737 | if ( syncManager->syncWithDesktop() ) { |
2736 | // remote->removeSyncInfo( QString());//remove all info | 2738 | // remote->removeSyncInfo( QString());//remove all info |
2737 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2739 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2738 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2740 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2739 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2741 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2740 | } else { | 2742 | } else { |
2741 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2743 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2742 | } | 2744 | } |
2743 | } | 2745 | } |
2744 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2746 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2745 | addresseeLSync = getLastSyncAddressee(); | 2747 | addresseeLSync = getLastSyncAddressee(); |
2746 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2748 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2747 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2749 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2748 | if ( !addresseeR.isEmpty() ) { | 2750 | if ( !addresseeR.isEmpty() ) { |
2749 | addresseeRSync = addresseeR; | 2751 | addresseeRSync = addresseeR; |
2750 | remote->removeAddressee(addresseeR ); | 2752 | remote->removeAddressee(addresseeR ); |
2751 | 2753 | ||
2752 | } else { | 2754 | } else { |
2753 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2755 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2754 | addresseeRSync = addresseeLSync ; | 2756 | addresseeRSync = addresseeLSync ; |
2755 | } else { | 2757 | } else { |
2756 | //qDebug("FULLDATE 1"); | 2758 | //qDebug("FULLDATE 1"); |
2757 | fullDateRange = true; | 2759 | fullDateRange = true; |
2758 | Addressee newAdd; | 2760 | Addressee newAdd; |
2759 | addresseeRSync = newAdd; | 2761 | addresseeRSync = newAdd; |
2760 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2762 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2761 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2763 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2762 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2764 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2763 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2765 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2764 | } | 2766 | } |
2765 | } | 2767 | } |
2766 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2768 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2767 | // qDebug("FULLDATE 2"); | 2769 | // qDebug("FULLDATE 2"); |
2768 | fullDateRange = true; | 2770 | fullDateRange = true; |
2769 | } | 2771 | } |
2770 | if ( ! fullDateRange ) { | 2772 | if ( ! fullDateRange ) { |
2771 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2773 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2772 | 2774 | ||
2773 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2775 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2774 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2776 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2775 | fullDateRange = true; | 2777 | fullDateRange = true; |
2776 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2778 | //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2777 | } | 2779 | } |
2778 | } | 2780 | } |
2779 | // fullDateRange = true; // debug only! | 2781 | // fullDateRange = true; // debug only! |
2780 | if ( fullDateRange ) | 2782 | if ( fullDateRange ) |
2781 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2783 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2782 | else | 2784 | else |
2783 | mLastAddressbookSync = addresseeLSync.revision(); | 2785 | mLastAddressbookSync = addresseeLSync.revision(); |
2784 | // for resyncing if own file has changed | 2786 | // for resyncing if own file has changed |
2785 | // PENDING fixme later when implemented | 2787 | // PENDING fixme later when implemented |
2786 | #if 0 | 2788 | #if 0 |
2787 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2789 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2788 | mLastAddressbookSync = loadedFileVersion; | 2790 | mLastAddressbookSync = loadedFileVersion; |
2789 | qDebug("setting mLastAddressbookSync "); | 2791 | qDebug("setting mLastAddressbookSync "); |
2790 | } | 2792 | } |
2791 | #endif | 2793 | #endif |
2792 | 2794 | ||
2793 | //qDebug("*************************** "); | 2795 | //qDebug("*************************** "); |
2794 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2796 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2795 | QStringList er = remote->uidList(); | 2797 | QStringList er = remote->uidList(); |
2796 | Addressee inR ;//= er.first(); | 2798 | Addressee inR ;//= er.first(); |
2797 | Addressee inL; | 2799 | Addressee inL; |
2798 | 2800 | ||
2799 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2801 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2800 | 2802 | ||
2801 | int modulo = (er.count()/10)+1; | 2803 | int modulo = (er.count()/10)+1; |
2802 | int incCounter = 0; | 2804 | int incCounter = 0; |
2803 | while ( incCounter < er.count()) { | 2805 | while ( incCounter < er.count()) { |
2804 | if (syncManager->isProgressBarCanceled()) | 2806 | if (syncManager->isProgressBarCanceled()) |
2805 | return false; | 2807 | return false; |
2806 | if ( incCounter % modulo == 0 ) | 2808 | if ( incCounter % modulo == 0 ) |
2807 | syncManager->showProgressBar(incCounter); | 2809 | syncManager->showProgressBar(incCounter); |
2808 | 2810 | ||
2809 | uid = er[ incCounter ]; | 2811 | uid = er[ incCounter ]; |
2810 | bool skipIncidence = false; | 2812 | bool skipIncidence = false; |
2811 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2813 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2812 | skipIncidence = true; | 2814 | skipIncidence = true; |
2813 | QString idS,OidS; | 2815 | QString idS,OidS; |
2814 | qApp->processEvents(); | 2816 | qApp->processEvents(); |
2815 | if ( !skipIncidence ) { | 2817 | if ( !skipIncidence ) { |
2816 | inL = local->findByUid( uid ); | 2818 | inL = local->findByUid( uid ); |
2817 | inR = remote->findByUid( uid ); | 2819 | inR = remote->findByUid( uid ); |
2818 | //inL.setResource( 0 ); | 2820 | //inL.setResource( 0 ); |
2819 | //inR.setResource( 0 ); | 2821 | //inR.setResource( 0 ); |
2820 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2822 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2821 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2823 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2822 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { | 2824 | if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { |
2823 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2825 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2824 | if ( take == 3 ) | 2826 | if ( take == 3 ) |
2825 | return false; | 2827 | return false; |
2826 | if ( take == 1 ) {// take local ********************** | 2828 | if ( take == 1 ) {// take local ********************** |
2827 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2829 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2828 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2830 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2829 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2831 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2830 | local->insertAddressee( inL, false ); | 2832 | local->insertAddressee( inL, false ); |
2831 | idS = inR.externalUID(); | 2833 | idS = inR.externalUID(); |
2832 | OidS = inR.originalExternalUID(); | 2834 | OidS = inR.originalExternalUID(); |
2833 | } | 2835 | } |
2834 | else | 2836 | else |
2835 | idS = inR.IDStr(); | 2837 | idS = inR.IDStr(); |
2836 | remote->removeAddressee( inR ); | 2838 | remote->removeAddressee( inR ); |
2837 | inR = inL; | 2839 | inR = inL; |
2838 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2840 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2839 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2841 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2840 | inR.setOriginalExternalUID( OidS ); | 2842 | inR.setOriginalExternalUID( OidS ); |
2841 | inR.setExternalUID( idS ); | 2843 | inR.setExternalUID( idS ); |
2842 | if ( syncManager->syncWithDesktop() ) { | 2844 | if ( syncManager->syncWithDesktop() ) { |
2843 | inR.setIDStr("changed" ); | 2845 | inR.setIDStr("changed" ); |
2844 | } | 2846 | } |
2845 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2847 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2846 | } else { | 2848 | } else { |
2847 | inR.setIDStr( idS ); | 2849 | inR.setIDStr( idS ); |
2848 | } | 2850 | } |
2849 | inR.setResource( 0 ); | 2851 | inR.setResource( 0 ); |
2850 | remote->insertAddressee( inR , false); | 2852 | remote->insertAddressee( inR , false); |
2851 | ++changedRemote; | 2853 | ++changedRemote; |
2852 | } else { // take == 2 take remote ********************** | 2854 | } else { // take == 2 take remote ********************** |
2853 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2855 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2854 | if ( inR.revision().date().year() < 2004 ) | 2856 | if ( inR.revision().date().year() < 2004 ) |
2855 | inR.setRevision( modifiedCalendar ); | 2857 | inR.setRevision( modifiedCalendar ); |
2856 | } | 2858 | } |
2857 | idS = inL.IDStr(); | 2859 | idS = inL.IDStr(); |
2858 | local->removeAddressee( inL ); | 2860 | local->removeAddressee( inL ); |
2859 | inL = inR; | 2861 | inL = inR; |
2860 | inL.setIDStr( idS ); | 2862 | inL.setIDStr( idS ); |
2861 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2863 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2862 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2864 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2863 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2865 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2864 | } | 2866 | } |
2865 | inL.setResource( 0 ); | 2867 | inL.setResource( 0 ); |
2866 | local->insertAddressee( inL , false ); | 2868 | local->insertAddressee( inL , false ); |
2867 | ++changedLocal; | 2869 | ++changedLocal; |
2868 | } | 2870 | } |
2869 | } | 2871 | } |
2870 | } | 2872 | } |
2871 | } else { // no conflict ********** add or delete remote | 2873 | } else { // no conflict ********** add or delete remote |
2872 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2874 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2873 | QString des = addresseeLSync.note(); | 2875 | QString des = addresseeLSync.note(); |
2874 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2876 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2875 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2877 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2876 | remote->insertAddressee( inR, false ); | 2878 | remote->insertAddressee( inR, false ); |
2877 | ++deletedAddresseeR; | 2879 | ++deletedAddresseeR; |
2878 | } else { | 2880 | } else { |
2879 | inR.setRevision( modifiedCalendar ); | 2881 | inR.setRevision( modifiedCalendar ); |
2880 | remote->insertAddressee( inR, false ); | 2882 | remote->insertAddressee( inR, false ); |
2881 | inL = inR; | 2883 | inL = inR; |
2882 | inL.setIDStr( ":" ); | 2884 | inL.setIDStr( ":" ); |
2883 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2885 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2884 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2886 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2885 | inL.setResource( 0 ); | 2887 | inL.setResource( 0 ); |
2886 | local->insertAddressee( inL , false); | 2888 | local->insertAddressee( inL , false); |
2887 | ++addedAddressee; | 2889 | ++addedAddressee; |
2888 | } | 2890 | } |
2889 | } else { | 2891 | } else { |
2890 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2892 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2891 | inR.setRevision( modifiedCalendar ); | 2893 | inR.setRevision( modifiedCalendar ); |
2892 | remote->insertAddressee( inR, false ); | 2894 | remote->insertAddressee( inR, false ); |
2893 | inR.setResource( 0 ); | 2895 | inR.setResource( 0 ); |
2894 | local->insertAddressee( inR, false ); | 2896 | local->insertAddressee( inR, false ); |
2895 | ++addedAddressee; | 2897 | ++addedAddressee; |
2896 | } else { | 2898 | } else { |
2897 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2899 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2898 | remote->removeAddressee( inR ); | 2900 | remote->removeAddressee( inR ); |
2899 | ++deletedAddresseeR; | 2901 | ++deletedAddresseeR; |
2900 | } | 2902 | } |
2901 | } | 2903 | } |
2902 | } | 2904 | } |
2903 | } | 2905 | } |
2904 | ++incCounter; | 2906 | ++incCounter; |
2905 | } | 2907 | } |
2906 | er.clear(); | 2908 | er.clear(); |
2907 | QStringList el = local->uidList(); | 2909 | QStringList el = local->uidList(); |
2908 | modulo = (el.count()/10)+1; | 2910 | modulo = (el.count()/10)+1; |
2909 | 2911 | ||
2910 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2912 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2911 | incCounter = 0; | 2913 | incCounter = 0; |
2912 | while ( incCounter < el.count()) { | 2914 | while ( incCounter < el.count()) { |
2913 | qApp->processEvents(); | 2915 | qApp->processEvents(); |
2914 | if (syncManager->isProgressBarCanceled()) | 2916 | if (syncManager->isProgressBarCanceled()) |
2915 | return false; | 2917 | return false; |
2916 | if ( incCounter % modulo == 0 ) | 2918 | if ( incCounter % modulo == 0 ) |
2917 | syncManager->showProgressBar(incCounter); | 2919 | syncManager->showProgressBar(incCounter); |
2918 | uid = el[ incCounter ]; | 2920 | uid = el[ incCounter ]; |
2919 | bool skipIncidence = false; | 2921 | bool skipIncidence = false; |
2920 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2922 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2921 | skipIncidence = true; | 2923 | skipIncidence = true; |
2922 | if ( !skipIncidence ) { | 2924 | if ( !skipIncidence ) { |
2923 | inL = local->findByUid( uid ); | 2925 | inL = local->findByUid( uid ); |
2924 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2926 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2925 | inR = remote->findByUid( uid ); | 2927 | inR = remote->findByUid( uid ); |
2926 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local | 2928 | if ( inR.isEmpty() ) { // no conflict ********** add or delete local |
2927 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2929 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2928 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2930 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2929 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2931 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2930 | local->removeAddressee( inL ); | 2932 | local->removeAddressee( inL ); |
2931 | ++deletedAddresseeL; | 2933 | ++deletedAddresseeL; |
2932 | } else { | 2934 | } else { |
2933 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2935 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2934 | inL.removeID(mCurrentSyncDevice ); | 2936 | inL.removeID(mCurrentSyncDevice ); |
2935 | ++addedAddresseeR; | 2937 | ++addedAddresseeR; |
2936 | inL.setRevision( modifiedCalendar ); | 2938 | inL.setRevision( modifiedCalendar ); |
2937 | local->insertAddressee( inL, false ); | 2939 | local->insertAddressee( inL, false ); |
2938 | inR = inL; | 2940 | inR = inL; |
2939 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2941 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2940 | inR.setResource( 0 ); | 2942 | inR.setResource( 0 ); |
2941 | remote->insertAddressee( inR, false ); | 2943 | remote->insertAddressee( inR, false ); |
2942 | } | 2944 | } |
2943 | } | 2945 | } |
2944 | } else { | 2946 | } else { |
2945 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2947 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2946 | //qDebug("data %s ", inL.revision().toString().latin1()); | 2948 | //qDebug("data %s ", inL.revision().toString().latin1()); |
2947 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2949 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2948 | local->removeAddressee( inL ); | 2950 | local->removeAddressee( inL ); |
2949 | ++deletedAddresseeL; | 2951 | ++deletedAddresseeL; |
2950 | } else { | 2952 | } else { |
2951 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2953 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2952 | ++addedAddresseeR; | 2954 | ++addedAddresseeR; |
2953 | inL.setRevision( modifiedCalendar ); | 2955 | inL.setRevision( modifiedCalendar ); |
2954 | local->insertAddressee( inL, false ); | 2956 | local->insertAddressee( inL, false ); |
2955 | inR = inL; | 2957 | inR = inL; |
2956 | inR.setIDStr( ":" ); | 2958 | inR.setIDStr( ":" ); |
2957 | inR.setResource( 0 ); | 2959 | inR.setResource( 0 ); |
2958 | remote->insertAddressee( inR, false ); | 2960 | remote->insertAddressee( inR, false ); |
2959 | } | 2961 | } |
2960 | } | 2962 | } |
2961 | } | 2963 | } |
2962 | } | 2964 | } |
2963 | } | 2965 | } |
2964 | } | 2966 | } |
2965 | ++incCounter; | 2967 | ++incCounter; |
2966 | } | 2968 | } |
2967 | el.clear(); | 2969 | el.clear(); |
2968 | syncManager->hideProgressBar(); | 2970 | syncManager->hideProgressBar(); |
2969 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2971 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2970 | // get rid of micro seconds | 2972 | // get rid of micro seconds |
2971 | QTime t = mLastAddressbookSync.time(); | 2973 | QTime t = mLastAddressbookSync.time(); |
2972 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2974 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2973 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2975 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2974 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2976 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2975 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2977 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2976 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2978 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2977 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2979 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2978 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2980 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2979 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2981 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2980 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2982 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2981 | addresseeRSync.setNote( "" ) ; | 2983 | addresseeRSync.setNote( "" ) ; |
2982 | addresseeLSync.setNote( "" ); | 2984 | addresseeLSync.setNote( "" ); |
2983 | 2985 | ||
2984 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2986 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2985 | remote->insertAddressee( addresseeRSync, false ); | 2987 | remote->insertAddressee( addresseeRSync, false ); |
2986 | local->insertAddressee( addresseeLSync, false ); | 2988 | local->insertAddressee( addresseeLSync, false ); |
2987 | QString mes; | 2989 | QString mes; |
2988 | 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 ); | 2990 | 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 ); |
2989 | qDebug( mes ); | 2991 | qDebug( mes ); |
2990 | mes = i18n("Local addressbook changed!\n") +mes; | 2992 | mes = i18n("Local addressbook changed!\n") +mes; |
2991 | if ( syncManager->mShowSyncSummary ) { | 2993 | if ( syncManager->mShowSyncSummary ) { |
2992 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 2994 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
2993 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { | 2995 | i18n("KA/Pi Synchronization"),i18n("Write back"))) { |
2994 | qDebug("cancelled "); | 2996 | qDebug("cancelled "); |
2995 | return false; | 2997 | return false; |
2996 | } | 2998 | } |
2997 | } | 2999 | } |
2998 | return syncOK; | 3000 | return syncOK; |
2999 | } | 3001 | } |
3000 | 3002 | ||
3001 | 3003 | ||
3002 | //this is a overwritten callbackmethods from the syncinterface | 3004 | //this is a overwritten callbackmethods from the syncinterface |
3003 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 3005 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
3004 | { | 3006 | { |
3005 | 3007 | ||
3006 | //pending prepare addresseeview for output | 3008 | //pending prepare addresseeview for output |
3007 | //pending detect, if remote file has REV field. if not switch to external sync | 3009 | //pending detect, if remote file has REV field. if not switch to external sync |
3008 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 3010 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
3011 | if ( manager != syncManager ) | ||
3012 | qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); | ||
3009 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3013 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3010 | 3014 | ||
3011 | AddressBook abLocal(filename,"syncContact"); | 3015 | AddressBook abLocal(filename,"syncContact"); |
3012 | bool syncOK = false; | 3016 | bool syncOK = false; |
3013 | if ( abLocal.load() ) { | 3017 | if ( abLocal.load() ) { |
3014 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 3018 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
3015 | bool external = false; | 3019 | bool external = false; |
3016 | bool isXML = false; | 3020 | bool isXML = false; |
3017 | if ( filename.right(4) == ".xml") { | 3021 | if ( filename.right(4) == ".xml") { |
3018 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3022 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3019 | isXML = true; | 3023 | isXML = true; |
3020 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3024 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3021 | } else { | 3025 | } else { |
3022 | external = !manager->mIsKapiFile; | 3026 | external = !manager->mIsKapiFile; |
3023 | if ( external ) { | 3027 | if ( external ) { |
3024 | qDebug("Setting vcf mode to external "); | 3028 | qDebug("Setting vcf mode to external "); |
3025 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3029 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3026 | AddressBook::Iterator it; | 3030 | AddressBook::Iterator it; |
3027 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3031 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3028 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 3032 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
3029 | (*it).computeCsum( mCurrentSyncDevice ); | 3033 | (*it).computeCsum( mCurrentSyncDevice ); |
3030 | } | 3034 | } |
3031 | } | 3035 | } |
3032 | } | 3036 | } |
3033 | //AddressBook::Iterator it; | 3037 | //AddressBook::Iterator it; |
3034 | //QStringList vcards; | 3038 | //QStringList vcards; |
3035 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 3039 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
3036 | // qDebug("Name %s ", (*it).familyName().latin1()); | 3040 | // qDebug("Name %s ", (*it).familyName().latin1()); |
3037 | //} | 3041 | //} |
3038 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 3042 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
3039 | if ( syncOK ) { | 3043 | if ( syncOK ) { |
3040 | if ( syncManager->mWriteBackFile ) | 3044 | if ( syncManager->mWriteBackFile ) |
3041 | { | 3045 | { |
3042 | if ( external ) | 3046 | if ( external ) |
3043 | abLocal.removeSyncAddressees( !isXML); | 3047 | abLocal.removeSyncAddressees( !isXML); |
3044 | qDebug("Saving remote AB "); | 3048 | qDebug("Saving remote AB "); |
3045 | if ( ! abLocal.saveAB()) | 3049 | if ( ! abLocal.saveAB()) |
3046 | qDebug("Error writing back AB to file "); | 3050 | qDebug("Error writing back AB to file "); |
3047 | if ( external ) { | 3051 | if ( external ) { |
3048 | // afterwrite processing | 3052 | // afterwrite processing |
3049 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 3053 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
3050 | } | 3054 | } |
3051 | } | 3055 | } |
3052 | } | 3056 | } |
3053 | setModified(); | 3057 | setModified(); |
3054 | 3058 | ||
3055 | } | 3059 | } |
3056 | abLocal.removeResources(); | 3060 | abLocal.removeResources(); |
3057 | if ( syncOK ) | 3061 | if ( syncOK ) |
3058 | mViewManager->refreshView(); | 3062 | mViewManager->refreshView(); |
3059 | return syncOK; | 3063 | return syncOK; |
3060 | 3064 | ||
3061 | } | 3065 | } |
3062 | void KABCore::removeSyncInfo( QString syncProfile) | 3066 | void KABCore::removeSyncInfo( QString syncProfile) |
3063 | { | 3067 | { |
3064 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 3068 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
3065 | mAddressBook->removeSyncInfo( syncProfile ); | 3069 | mAddressBook->removeSyncInfo( syncProfile ); |
3066 | setModified(); | 3070 | setModified(); |
3067 | } | 3071 | } |
3068 | 3072 | ||
3069 | 3073 | ||
3070 | //this is a overwritten callbackmethods from the syncinterface | 3074 | //this is a overwritten callbackmethods from the syncinterface |
3071 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 3075 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
3072 | { | 3076 | { |
3073 | if ( resource == "phone" ) | 3077 | if ( resource == "phone" ) |
3074 | return syncPhone(); | 3078 | return syncPhone(); |
3075 | disableBR( true ); | 3079 | disableBR( true ); |
3080 | if ( manager != syncManager ) | ||
3081 | qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); | ||
3076 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 3082 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
3077 | 3083 | ||
3078 | AddressBook abLocal( resource,"syncContact"); | 3084 | AddressBook abLocal( resource,"syncContact"); |
3079 | bool syncOK = false; | 3085 | bool syncOK = false; |
3080 | if ( abLocal.load() ) { | 3086 | if ( abLocal.load() ) { |
3081 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3087 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3082 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3088 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3083 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 3089 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
3084 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3090 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3085 | if ( syncOK ) { | 3091 | if ( syncOK ) { |
3086 | if ( syncManager->mWriteBackFile ) { | 3092 | if ( syncManager->mWriteBackFile ) { |
3087 | abLocal.removeSyncAddressees( false ); | 3093 | abLocal.removeSyncAddressees( false ); |
3088 | abLocal.saveAB(); | 3094 | abLocal.saveAB(); |
3089 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3095 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3090 | } | 3096 | } |
3091 | } else | 3097 | } else |
3092 | message( i18n("Sync cancelled or failed.") ); | 3098 | message( i18n("Sync cancelled or failed.") ); |
3093 | setModified(); | 3099 | setModified(); |
3094 | } | 3100 | } |
3095 | abLocal.removeResources(); | 3101 | abLocal.removeResources(); |
3096 | if ( syncOK ) | 3102 | if ( syncOK ) |
3097 | mViewManager->refreshView(); | 3103 | mViewManager->refreshView(); |
3098 | disableBR( false ); | 3104 | disableBR( false ); |
3099 | return syncOK; | 3105 | return syncOK; |
3100 | 3106 | ||
3101 | } | 3107 | } |
3102 | void KABCore::message( QString m ) | 3108 | void KABCore::message( QString m ) |
3103 | { | 3109 | { |
3104 | topLevelWidget()->setCaption( m ); | 3110 | topLevelWidget()->setCaption( m ); |
3105 | mMessageTimer->start( 15000, true ); | 3111 | mMessageTimer->start( 15000, true ); |
3106 | } | 3112 | } |
3107 | bool KABCore::syncPhone() | 3113 | bool KABCore::syncPhone() |
3108 | { | 3114 | { |
3109 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 3115 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
3110 | QString fileName = getPhoneFile(); | 3116 | QString fileName = getPhoneFile(); |
3111 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 3117 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
3112 | message(i18n("Phone access failed!")); | 3118 | message(i18n("Phone access failed!")); |
3113 | return false; | 3119 | return false; |
3114 | } | 3120 | } |
3115 | AddressBook abLocal( fileName,"syncContact"); | 3121 | AddressBook abLocal( fileName,"syncContact"); |
3116 | bool syncOK = false; | 3122 | bool syncOK = false; |
3117 | { | 3123 | { |
3118 | abLocal.importFromFile( fileName ); | 3124 | abLocal.importFromFile( fileName ); |
3119 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 3125 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
3120 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 3126 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
3121 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 3127 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
3122 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 3128 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
3123 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 3129 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
3124 | if ( syncOK ) { | 3130 | if ( syncOK ) { |
3125 | if ( syncManager->mWriteBackFile ) { | 3131 | if ( syncManager->mWriteBackFile ) { |
3126 | abLocal.removeSyncAddressees( true ); | 3132 | abLocal.removeSyncAddressees( true ); |
3127 | abLocal.saveABphone( fileName ); | 3133 | abLocal.saveABphone( fileName ); |
3128 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 3134 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
3129 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 3135 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
3130 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 3136 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
3131 | } | 3137 | } |
3132 | } | 3138 | } |
3133 | setModified(); | 3139 | setModified(); |
3134 | } | 3140 | } |
3135 | abLocal.removeResources(); | 3141 | abLocal.removeResources(); |
3136 | if ( syncOK ) | 3142 | if ( syncOK ) |
3137 | mViewManager->refreshView(); | 3143 | mViewManager->refreshView(); |
3138 | return syncOK; | 3144 | return syncOK; |
3139 | } | 3145 | } |
3140 | void KABCore::getFile( bool success ) | 3146 | void KABCore::getFile( bool success ) |
3141 | { | 3147 | { |
3142 | if ( ! success ) { | 3148 | if ( ! success ) { |
3143 | message( i18n("Error receiving file. Nothing changed!") ); | 3149 | message( i18n("Error receiving file. Nothing changed!") ); |
3144 | return; | 3150 | return; |
3145 | } | 3151 | } |
3146 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 3152 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
3147 | if ( count ) | 3153 | if ( count ) |
3148 | setModified( true ); | 3154 | setModified( true ); |
3149 | message( i18n("Pi-Sync successful!") ); | 3155 | message( i18n("Pi-Sync successful!") ); |
3150 | mViewManager->refreshView(); | 3156 | mViewManager->refreshView(); |
3151 | } | 3157 | } |
3152 | void KABCore::syncFileRequest() | 3158 | void KABCore::syncFileRequest() |
3153 | { | 3159 | { |
3154 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 3160 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
3155 | syncManager->slotSyncMenu( 999 ); | 3161 | syncManager->slotSyncMenu( 999 ); |
3156 | } | 3162 | } |
3157 | mAddressBook->export2File( sentSyncFile() ); | 3163 | mAddressBook->export2File( sentSyncFile() ); |
3158 | } | 3164 | } |
3159 | QString KABCore::sentSyncFile() | 3165 | QString KABCore::sentSyncFile() |
3160 | { | 3166 | { |
3161 | #ifdef DESKTOP_VERSION | 3167 | #ifdef DESKTOP_VERSION |
3162 | return locateLocal( "tmp", "copysyncab.vcf" ); | 3168 | return locateLocal( "tmp", "copysyncab.vcf" ); |
3163 | #else | 3169 | #else |
3164 | return QString( "/tmp/copysyncab.vcf" ); | 3170 | return QString( "/tmp/copysyncab.vcf" ); |
3165 | #endif | 3171 | #endif |
3166 | } | 3172 | } |
3167 | 3173 | ||
3168 | void KABCore::setCaptionBack() | 3174 | void KABCore::setCaptionBack() |
3169 | { | 3175 | { |
3170 | mMessageTimer->stop(); | 3176 | mMessageTimer->stop(); |
3171 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 3177 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
3172 | } | 3178 | } |
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index c12ba1c..7c53948 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp | |||
@@ -1,1472 +1,1472 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KDE-Pim/Pi. | 2 | This file is part of KDE-Pim/Pi. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library 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 GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | // $Id$ | 21 | // $Id$ |
22 | 22 | ||
23 | #include "ksyncmanager.h" | 23 | #include "ksyncmanager.h" |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | 31 | ||
32 | #include "ksyncprofile.h" | 32 | #include "ksyncprofile.h" |
33 | #include "ksyncprefsdialog.h" | 33 | #include "ksyncprefsdialog.h" |
34 | #include "kpimprefs.h" | 34 | #include "kpimprefs.h" |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <qdir.h> | 37 | #include <qdir.h> |
38 | #include <qprogressbar.h> | 38 | #include <qprogressbar.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
41 | #include <qradiobutton.h> | 41 | #include <qradiobutton.h> |
42 | #include <qbuttongroup.h> | 42 | #include <qbuttongroup.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qapplication.h> | 45 | #include <qapplication.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qlabel.h> | 50 | #include <qlabel.h> |
51 | #include <qcheckbox.h> | 51 | #include <qcheckbox.h> |
52 | 52 | ||
53 | #include <klocale.h> | 53 | #include <klocale.h> |
54 | #include <kglobal.h> | 54 | #include <kglobal.h> |
55 | #include <kconfig.h> | 55 | #include <kconfig.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | 57 | ||
58 | QDateTime KSyncManager::mRequestedSyncEvent; | 58 | QDateTime KSyncManager::mRequestedSyncEvent; |
59 | 59 | ||
60 | 60 | ||
61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) | 61 | KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) |
62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) | 62 | : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) |
63 | { | 63 | { |
64 | mServerSocket = 0; | 64 | mServerSocket = 0; |
65 | bar = new QProgressBar ( 1, 0 ); | 65 | bar = new QProgressBar ( 1, 0 ); |
66 | bar->setCaption (""); | 66 | bar->setCaption (""); |
67 | 67 | ||
68 | int w = 300; | 68 | int w = 300; |
69 | if ( QApplication::desktop()->width() < 320 ) | 69 | if ( QApplication::desktop()->width() < 320 ) |
70 | w = 220; | 70 | w = 220; |
71 | int h = bar->sizeHint().height() ; | 71 | int h = bar->sizeHint().height() ; |
72 | int dw = QApplication::desktop()->width(); | 72 | int dw = QApplication::desktop()->width(); |
73 | int dh = QApplication::desktop()->height(); | 73 | int dh = QApplication::desktop()->height(); |
74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 74 | bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
75 | if ( mPrefs->mPassiveSyncAutoStart ) | 75 | if ( mPrefs->mPassiveSyncAutoStart ) |
76 | enableQuick( false ); | 76 | enableQuick( false ); |
77 | 77 | ||
78 | } | 78 | } |
79 | 79 | ||
80 | KSyncManager::~KSyncManager() | 80 | KSyncManager::~KSyncManager() |
81 | { | 81 | { |
82 | delete bar; | 82 | delete bar; |
83 | } | 83 | } |
84 | 84 | ||
85 | 85 | ||
86 | void KSyncManager::fillSyncMenu() | 86 | void KSyncManager::fillSyncMenu() |
87 | { | 87 | { |
88 | if ( mSyncMenu->count() ) | 88 | if ( mSyncMenu->count() ) |
89 | mSyncMenu->clear(); | 89 | mSyncMenu->clear(); |
90 | 90 | ||
91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); | 91 | mSyncMenu->insertItem( i18n("Configure..."), 0 ); |
92 | mSyncMenu->insertSeparator(); | 92 | mSyncMenu->insertSeparator(); |
93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); | 93 | QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); |
94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); | 94 | mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); |
95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); | 95 | clearMenu->insertItem( i18n("For all profiles"), 1 ); |
96 | clearMenu->insertSeparator(); | 96 | clearMenu->insertSeparator(); |
97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); | 97 | connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); |
98 | mSyncMenu->insertSeparator(); | 98 | mSyncMenu->insertSeparator(); |
99 | if ( mServerSocket == 0 ) { | 99 | if ( mServerSocket == 0 ) { |
100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 100 | mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
101 | } else { | 101 | } else { |
102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 102 | mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
103 | } | 103 | } |
104 | mSyncMenu->insertSeparator(); | 104 | mSyncMenu->insertSeparator(); |
105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); | 105 | mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); |
106 | mSyncMenu->insertSeparator(); | 106 | mSyncMenu->insertSeparator(); |
107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 107 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
108 | config.setGroup("General"); | 108 | config.setGroup("General"); |
109 | QStringList prof = config.readListEntry("SyncProfileNames"); | 109 | QStringList prof = config.readListEntry("SyncProfileNames"); |
110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 110 | mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
111 | if ( prof.count() < 2 ) { | 111 | if ( prof.count() < 2 ) { |
112 | prof.clear(); | 112 | prof.clear(); |
113 | QString externalName; | 113 | QString externalName; |
114 | #ifdef DESKTOP_VERSION | 114 | #ifdef DESKTOP_VERSION |
115 | #ifdef _WIN32_ | 115 | #ifdef _WIN32_ |
116 | externalName = "OutLook(not_implemented)"; | 116 | externalName = "OutLook(not_implemented)"; |
117 | #else | 117 | #else |
118 | externalName = "KDE_Desktop"; | 118 | externalName = "KDE_Desktop"; |
119 | #endif | 119 | #endif |
120 | #else | 120 | #else |
121 | externalName = "Sharp_DTM"; | 121 | externalName = "Sharp_DTM"; |
122 | #endif | 122 | #endif |
123 | prof << externalName; | 123 | prof << externalName; |
124 | prof << i18n("Local_file"); | 124 | prof << i18n("Local_file"); |
125 | prof << i18n("Last_file"); | 125 | prof << i18n("Last_file"); |
126 | KSyncProfile* temp = new KSyncProfile (); | 126 | KSyncProfile* temp = new KSyncProfile (); |
127 | temp->setName( prof[0] ); | 127 | temp->setName( prof[0] ); |
128 | temp->writeConfig(&config); | 128 | temp->writeConfig(&config); |
129 | temp->setName( prof[1] ); | 129 | temp->setName( prof[1] ); |
130 | temp->writeConfig(&config); | 130 | temp->writeConfig(&config); |
131 | temp->setName( prof[2] ); | 131 | temp->setName( prof[2] ); |
132 | temp->writeConfig(&config); | 132 | temp->writeConfig(&config); |
133 | config.setGroup("General"); | 133 | config.setGroup("General"); |
134 | config.writeEntry("SyncProfileNames",prof); | 134 | config.writeEntry("SyncProfileNames",prof); |
135 | config.writeEntry("ExternSyncProfiles",externalName); | 135 | config.writeEntry("ExternSyncProfiles",externalName); |
136 | config.sync(); | 136 | config.sync(); |
137 | delete temp; | 137 | delete temp; |
138 | } | 138 | } |
139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 139 | mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
140 | mSyncProfileNames = prof; | 140 | mSyncProfileNames = prof; |
141 | unsigned int i; | 141 | unsigned int i; |
142 | for ( i = 0; i < prof.count(); ++i ) { | 142 | for ( i = 0; i < prof.count(); ++i ) { |
143 | mSyncMenu->insertItem( prof[i], 1000+i ); | 143 | mSyncMenu->insertItem( prof[i], 1000+i ); |
144 | clearMenu->insertItem( prof[i], 1000+i ); | 144 | clearMenu->insertItem( prof[i], 1000+i ); |
145 | if ( i == 2 ) | 145 | if ( i == 2 ) |
146 | mSyncMenu->insertSeparator(); | 146 | mSyncMenu->insertSeparator(); |
147 | } | 147 | } |
148 | QDir app_dir; | 148 | QDir app_dir; |
149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available | 149 | //US do not display SharpDTM if app is pwmpi, or no sharpfiles available |
150 | if ( mTargetApp == PWMPI) { | 150 | if ( mTargetApp == PWMPI) { |
151 | mSyncMenu->removeItem( 1000 ); | 151 | mSyncMenu->removeItem( 1000 ); |
152 | clearMenu->removeItem( 1000 ); | 152 | clearMenu->removeItem( 1000 ); |
153 | } | 153 | } |
154 | #ifndef DESKTOP_VERSION | 154 | #ifndef DESKTOP_VERSION |
155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 155 | else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
156 | mSyncMenu->removeItem( 1000 ); | 156 | mSyncMenu->removeItem( 1000 ); |
157 | clearMenu->removeItem( 1000 ); | 157 | clearMenu->removeItem( 1000 ); |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
160 | mSyncMenu->removeItem( 1002 ); | 160 | mSyncMenu->removeItem( 1002 ); |
161 | clearMenu->removeItem( 1002 ); | 161 | clearMenu->removeItem( 1002 ); |
162 | } | 162 | } |
163 | void KSyncManager::slotClearMenu( int action ) | 163 | void KSyncManager::slotClearMenu( int action ) |
164 | { | 164 | { |
165 | QString syncDevice; | 165 | QString syncDevice; |
166 | if ( action > 999 ) { | 166 | if ( action > 999 ) { |
167 | syncDevice = mSyncProfileNames[action - 1000] ; | 167 | syncDevice = mSyncProfileNames[action - 1000] ; |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | int result = 0; | 172 | int result = 0; |
173 | QString sd; | 173 | QString sd; |
174 | if ( syncDevice.isEmpty() ) | 174 | if ( syncDevice.isEmpty() ) |
175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); | 175 | sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); |
176 | else | 176 | else |
177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); | 177 | sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); |
178 | 178 | ||
179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, | 179 | result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, |
180 | 0, 1 ); | 180 | 0, 1 ); |
181 | if ( result ) | 181 | if ( result ) |
182 | return; | 182 | return; |
183 | mImplementation->removeSyncInfo( syncDevice ); | 183 | mImplementation->removeSyncInfo( syncDevice ); |
184 | } | 184 | } |
185 | void KSyncManager::slotSyncMenu( int action ) | 185 | void KSyncManager::slotSyncMenu( int action ) |
186 | { | 186 | { |
187 | qDebug("syncaction %d ", action); | 187 | qDebug("syncaction %d ", action); |
188 | if ( action == 5000 ) | 188 | if ( action == 5000 ) |
189 | return; | 189 | return; |
190 | mSyncWithDesktop = false; | 190 | mSyncWithDesktop = false; |
191 | if ( action == 0 ) { | 191 | if ( action == 0 ) { |
192 | 192 | ||
193 | // seems to be a Qt2 event handling bug | 193 | // seems to be a Qt2 event handling bug |
194 | // syncmenu.clear causes a segfault at first time | 194 | // syncmenu.clear causes a segfault at first time |
195 | // when we call it after the main event loop, it is ok | 195 | // when we call it after the main event loop, it is ok |
196 | // same behaviour when calling OM/Pi via QCOP for the first time | 196 | // same behaviour when calling OM/Pi via QCOP for the first time |
197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 197 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
198 | //confSync(); | 198 | //confSync(); |
199 | 199 | ||
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | if ( action == 1 ) { | 202 | if ( action == 1 ) { |
203 | multiSync( true ); | 203 | multiSync( true ); |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | if ( action == 2 ) { | 206 | if ( action == 2 ) { |
207 | enableQuick(); | 207 | enableQuick(); |
208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 208 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
209 | return; | 209 | return; |
210 | } | 210 | } |
211 | if ( action == 3 ) { | 211 | if ( action == 3 ) { |
212 | delete mServerSocket; | 212 | delete mServerSocket; |
213 | mServerSocket = 0; | 213 | mServerSocket = 0; |
214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 214 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | if (blockSave()) | 218 | if (blockSave()) |
219 | return; | 219 | return; |
220 | 220 | ||
221 | setBlockSave(true); | 221 | setBlockSave(true); |
222 | bool silent = false; | 222 | bool silent = false; |
223 | if ( action == 999 ) { | 223 | if ( action == 999 ) { |
224 | //special mode for silent syncing | 224 | //special mode for silent syncing |
225 | action = 1000; | 225 | action = 1000; |
226 | silent = true; | 226 | silent = true; |
227 | } | 227 | } |
228 | 228 | ||
229 | mCurrentSyncProfile = action - 1000 ; | 229 | mCurrentSyncProfile = action - 1000 ; |
230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; | 230 | mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; |
231 | mCurrentSyncName = mLocalMachineName ; | 231 | mCurrentSyncName = mLocalMachineName ; |
232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 232 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
233 | KSyncProfile* temp = new KSyncProfile (); | 233 | KSyncProfile* temp = new KSyncProfile (); |
234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); | 234 | temp->setName(mSyncProfileNames[mCurrentSyncProfile]); |
235 | temp->readConfig(&config); | 235 | temp->readConfig(&config); |
236 | if (silent) { | 236 | if (silent) { |
237 | mAskForPreferences = false; | 237 | mAskForPreferences = false; |
238 | mShowSyncSummary = false; | 238 | mShowSyncSummary = false; |
239 | mWriteBackFile = true; | 239 | mWriteBackFile = true; |
240 | mSyncAlgoPrefs = 2;// take newest | 240 | mSyncAlgoPrefs = 2;// take newest |
241 | } | 241 | } |
242 | else { | 242 | else { |
243 | mAskForPreferences = temp->getAskForPreferences(); | 243 | mAskForPreferences = temp->getAskForPreferences(); |
244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); | 244 | mShowSyncSummary = temp->getShowSummaryAfterSync(); |
245 | mWriteBackFile = temp->getWriteBackFile(); | 245 | mWriteBackFile = temp->getWriteBackFile(); |
246 | mSyncAlgoPrefs = temp->getSyncPrefs(); | 246 | mSyncAlgoPrefs = temp->getSyncPrefs(); |
247 | } | 247 | } |
248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 248 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
249 | mIsKapiFile = temp->getIsKapiFile(); | 249 | mIsKapiFile = temp->getIsKapiFile(); |
250 | mWriteBackInFuture = 0; | 250 | mWriteBackInFuture = 0; |
251 | if ( temp->getWriteBackFuture() ) | 251 | if ( temp->getWriteBackFuture() ) |
252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 252 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
253 | 253 | ||
254 | if ( action == 1000 ) { | 254 | if ( action == 1000 ) { |
255 | mIsKapiFile = false; | 255 | mIsKapiFile = false; |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | syncKDE(); | 257 | syncKDE(); |
258 | #else | 258 | #else |
259 | syncSharp(); | 259 | syncSharp(); |
260 | #endif | 260 | #endif |
261 | 261 | ||
262 | } else if ( action == 1001 ) { | 262 | } else if ( action == 1001 ) { |
263 | syncLocalFile(); | 263 | syncLocalFile(); |
264 | 264 | ||
265 | } else if ( action == 1002 ) { | 265 | } else if ( action == 1002 ) { |
266 | mWriteBackFile = false; | 266 | mWriteBackFile = false; |
267 | mAskForPreferences = false; | 267 | mAskForPreferences = false; |
268 | mShowSyncSummary = false; | 268 | mShowSyncSummary = false; |
269 | mSyncAlgoPrefs = 3; | 269 | mSyncAlgoPrefs = 3; |
270 | quickSyncLocalFile(); | 270 | quickSyncLocalFile(); |
271 | 271 | ||
272 | } else if ( action >= 1003 ) { | 272 | } else if ( action >= 1003 ) { |
273 | if ( temp->getIsLocalFileSync() ) { | 273 | if ( temp->getIsLocalFileSync() ) { |
274 | switch(mTargetApp) | 274 | switch(mTargetApp) |
275 | { | 275 | { |
276 | case (KAPI): | 276 | case (KAPI): |
277 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 277 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
278 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 278 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
279 | break; | 279 | break; |
280 | case (KOPI): | 280 | case (KOPI): |
281 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 281 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
282 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 282 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
283 | break; | 283 | break; |
284 | case (PWMPI): | 284 | case (PWMPI): |
285 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 285 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
286 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 286 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
287 | break; | 287 | break; |
288 | default: | 288 | default: |
289 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 289 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
290 | break; | 290 | break; |
291 | 291 | ||
292 | } | 292 | } |
293 | } else { | 293 | } else { |
294 | if ( temp->getIsPhoneSync() ) { | 294 | if ( temp->getIsPhoneSync() ) { |
295 | mPhoneDevice = temp->getPhoneDevice( ) ; | 295 | mPhoneDevice = temp->getPhoneDevice( ) ; |
296 | mPhoneConnection = temp->getPhoneConnection( ); | 296 | mPhoneConnection = temp->getPhoneConnection( ); |
297 | mPhoneModel = temp->getPhoneModel( ); | 297 | mPhoneModel = temp->getPhoneModel( ); |
298 | syncPhone(); | 298 | syncPhone(); |
299 | } else if ( temp->getIsPiSync() ) { | 299 | } else if ( temp->getIsPiSync() ) { |
300 | if ( mTargetApp == KAPI ) { | 300 | if ( mTargetApp == KAPI ) { |
301 | mPassWordPiSync = temp->getRemotePwAB(); | 301 | mPassWordPiSync = temp->getRemotePwAB(); |
302 | mActiveSyncPort = temp->getRemotePortAB(); | 302 | mActiveSyncPort = temp->getRemotePortAB(); |
303 | mActiveSyncIP = temp->getRemoteIPAB(); | 303 | mActiveSyncIP = temp->getRemoteIPAB(); |
304 | } else if ( mTargetApp == KOPI ) { | 304 | } else if ( mTargetApp == KOPI ) { |
305 | mPassWordPiSync = temp->getRemotePw(); | 305 | mPassWordPiSync = temp->getRemotePw(); |
306 | mActiveSyncPort = temp->getRemotePort(); | 306 | mActiveSyncPort = temp->getRemotePort(); |
307 | mActiveSyncIP = temp->getRemoteIP(); | 307 | mActiveSyncIP = temp->getRemoteIP(); |
308 | } else { | 308 | } else { |
309 | mPassWordPiSync = temp->getRemotePwPWM(); | 309 | mPassWordPiSync = temp->getRemotePwPWM(); |
310 | mActiveSyncPort = temp->getRemotePortPWM(); | 310 | mActiveSyncPort = temp->getRemotePortPWM(); |
311 | mActiveSyncIP = temp->getRemoteIPPWM(); | 311 | mActiveSyncIP = temp->getRemoteIPPWM(); |
312 | } | 312 | } |
313 | syncPi(); | 313 | syncPi(); |
314 | while ( !mPisyncFinished ) { | 314 | while ( !mPisyncFinished ) { |
315 | //qDebug("waiting "); | 315 | //qDebug("waiting "); |
316 | qApp->processEvents(); | 316 | qApp->processEvents(); |
317 | } | 317 | } |
318 | } else | 318 | } else |
319 | syncRemote( temp ); | 319 | syncRemote( temp ); |
320 | 320 | ||
321 | } | 321 | } |
322 | } | 322 | } |
323 | delete temp; | 323 | delete temp; |
324 | setBlockSave(false); | 324 | setBlockSave(false); |
325 | } | 325 | } |
326 | 326 | ||
327 | void KSyncManager::enableQuick( bool ask ) | 327 | void KSyncManager::enableQuick( bool ask ) |
328 | { | 328 | { |
329 | bool autoStart; | 329 | bool autoStart; |
330 | bool changed = false; | 330 | bool changed = false; |
331 | if ( ask ) { | 331 | if ( ask ) { |
332 | QDialog dia ( 0, "input-dialog", true ); | 332 | QDialog dia ( 0, "input-dialog", true ); |
333 | QLineEdit lab ( &dia ); | 333 | QLineEdit lab ( &dia ); |
334 | QVBoxLayout lay( &dia ); | 334 | QVBoxLayout lay( &dia ); |
335 | lab.setText( mPrefs->mPassiveSyncPort ); | 335 | lab.setText( mPrefs->mPassiveSyncPort ); |
336 | lay.setMargin(7); | 336 | lay.setMargin(7); |
337 | lay.setSpacing(7); | 337 | lay.setSpacing(7); |
338 | int po = 9197+mTargetApp; | 338 | int po = 9197+mTargetApp; |
339 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); | 339 | QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); |
340 | lay.addWidget( &label); | 340 | lay.addWidget( &label); |
341 | lay.addWidget( &lab); | 341 | lay.addWidget( &lab); |
342 | 342 | ||
343 | QLineEdit lepw ( &dia ); | 343 | QLineEdit lepw ( &dia ); |
344 | lepw.setText( mPrefs->mPassiveSyncPw ); | 344 | lepw.setText( mPrefs->mPassiveSyncPw ); |
345 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 345 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
346 | lay.addWidget( &label2); | 346 | lay.addWidget( &label2); |
347 | lay.addWidget( &lepw); | 347 | lay.addWidget( &lepw); |
348 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); | 348 | QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); |
349 | lay.addWidget( &autostart); | 349 | lay.addWidget( &autostart); |
350 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); | 350 | autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); |
351 | #ifdef DESKTOP_VERSION | 351 | #ifdef DESKTOP_VERSION |
352 | #ifdef _WIN32_ | 352 | #ifdef _WIN32_ |
353 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); | 353 | QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); |
354 | syncdesktop.hide();// not implemented! | 354 | syncdesktop.hide();// not implemented! |
355 | #else | 355 | #else |
356 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); | 356 | QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); |
357 | #endif | 357 | #endif |
358 | lay.addWidget( &syncdesktop); | 358 | lay.addWidget( &syncdesktop); |
359 | #else | 359 | #else |
360 | mPrefs->mPassiveSyncWithDesktop = false; | 360 | mPrefs->mPassiveSyncWithDesktop = false; |
361 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); | 361 | QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); |
362 | syncdesktop.hide(); | 362 | syncdesktop.hide(); |
363 | #endif | 363 | #endif |
364 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); | 364 | syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); |
365 | 365 | ||
366 | dia.setFixedSize( 230,120 ); | 366 | dia.setFixedSize( 230,120 ); |
367 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 367 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
368 | QPushButton pb ( "OK", &dia); | 368 | QPushButton pb ( "OK", &dia); |
369 | lay.addWidget( &pb ); | 369 | lay.addWidget( &pb ); |
370 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 370 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
371 | dia.show(); | 371 | dia.show(); |
372 | if ( ! dia.exec() ) | 372 | if ( ! dia.exec() ) |
373 | return; | 373 | return; |
374 | dia.hide(); | 374 | dia.hide(); |
375 | qApp->processEvents(); | 375 | qApp->processEvents(); |
376 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { | 376 | if ( mPrefs->mPassiveSyncPw != lepw.text() ) { |
377 | changed = true; | 377 | changed = true; |
378 | mPrefs->mPassiveSyncPw = lepw.text(); | 378 | mPrefs->mPassiveSyncPw = lepw.text(); |
379 | } | 379 | } |
380 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { | 380 | if ( mPrefs->mPassiveSyncPort != lab.text() ) { |
381 | mPrefs->mPassiveSyncPort = lab.text(); | 381 | mPrefs->mPassiveSyncPort = lab.text(); |
382 | changed = true; | 382 | changed = true; |
383 | } | 383 | } |
384 | autoStart = autostart.isChecked(); | 384 | autoStart = autostart.isChecked(); |
385 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { | 385 | if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { |
386 | changed = true; | 386 | changed = true; |
387 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); | 387 | mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); |
388 | } | 388 | } |
389 | } | 389 | } |
390 | else | 390 | else |
391 | autoStart = mPrefs->mPassiveSyncAutoStart; | 391 | autoStart = mPrefs->mPassiveSyncAutoStart; |
392 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) | 392 | if ( autoStart != mPrefs->mPassiveSyncAutoStart ) |
393 | changed = true; | 393 | changed = true; |
394 | bool ok; | 394 | bool ok; |
395 | mPrefs->mPassiveSyncAutoStart = false; | 395 | mPrefs->mPassiveSyncAutoStart = false; |
396 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); | 396 | Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); |
397 | if ( ! ok ) { | 397 | if ( ! ok ) { |
398 | KMessageBox::information( 0, i18n("No valid port")); | 398 | KMessageBox::information( 0, i18n("No valid port")); |
399 | return; | 399 | return; |
400 | } | 400 | } |
401 | //qDebug("port %d ", port); | 401 | //qDebug("port %d ", port); |
402 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); | 402 | mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); |
403 | mServerSocket->setFileName( defaultFileName() ); | 403 | mServerSocket->setFileName( defaultFileName() );//bbb |
404 | //qDebug("connected "); | 404 | //qDebug("connected "); |
405 | if ( !mServerSocket->ok() ) { | 405 | if ( !mServerSocket->ok() ) { |
406 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); | 406 | KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); |
407 | delete mServerSocket; | 407 | delete mServerSocket; |
408 | mServerSocket = 0; | 408 | mServerSocket = 0; |
409 | return; | 409 | return; |
410 | } | 410 | } |
411 | mPrefs->mPassiveSyncAutoStart = autoStart; | 411 | mPrefs->mPassiveSyncAutoStart = autoStart; |
412 | if ( changed ) { | 412 | if ( changed ) { |
413 | mPrefs->writeConfig(); | 413 | mPrefs->writeConfig(); |
414 | } | 414 | } |
415 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); | 415 | connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); |
416 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); | 416 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); |
417 | } | 417 | } |
418 | 418 | ||
419 | void KSyncManager::syncLocalFile() | 419 | void KSyncManager::syncLocalFile() |
420 | { | 420 | { |
421 | 421 | ||
422 | QString fn =mPrefs->mLastSyncedLocalFile; | 422 | QString fn =mPrefs->mLastSyncedLocalFile; |
423 | QString ext; | 423 | QString ext; |
424 | 424 | ||
425 | switch(mTargetApp) | 425 | switch(mTargetApp) |
426 | { | 426 | { |
427 | case (KAPI): | 427 | case (KAPI): |
428 | ext = "(*.vcf)"; | 428 | ext = "(*.vcf)"; |
429 | break; | 429 | break; |
430 | case (KOPI): | 430 | case (KOPI): |
431 | ext = "(*.ics/*.vcs)"; | 431 | ext = "(*.ics/*.vcs)"; |
432 | break; | 432 | break; |
433 | case (PWMPI): | 433 | case (PWMPI): |
434 | ext = "(*.pwm)"; | 434 | ext = "(*.pwm)"; |
435 | break; | 435 | break; |
436 | default: | 436 | default: |
437 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); | 437 | qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); |
438 | break; | 438 | break; |
439 | 439 | ||
440 | } | 440 | } |
441 | 441 | ||
442 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); | 442 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); |
443 | if ( fn == "" ) | 443 | if ( fn == "" ) |
444 | return; | 444 | return; |
445 | if ( syncWithFile( fn, false ) ) { | 445 | if ( syncWithFile( fn, false ) ) { |
446 | qDebug("syncLocalFile() successful "); | 446 | qDebug("syncLocalFile() successful "); |
447 | } | 447 | } |
448 | 448 | ||
449 | } | 449 | } |
450 | 450 | ||
451 | bool KSyncManager::syncWithFile( QString fn , bool quick ) | 451 | bool KSyncManager::syncWithFile( QString fn , bool quick ) |
452 | { | 452 | { |
453 | bool ret = false; | 453 | bool ret = false; |
454 | QFileInfo info; | 454 | QFileInfo info; |
455 | info.setFile( fn ); | 455 | info.setFile( fn ); |
456 | QString mess; | 456 | QString mess; |
457 | bool loadbup = true; | 457 | bool loadbup = true; |
458 | if ( !info. exists() ) { | 458 | if ( !info. exists() ) { |
459 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 459 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
460 | int result = QMessageBox::warning( mParent, i18n("Warning!"), | 460 | int result = QMessageBox::warning( mParent, i18n("Warning!"), |
461 | mess ); | 461 | mess ); |
462 | return ret; | 462 | return ret; |
463 | } | 463 | } |
464 | int result = 0; | 464 | int result = 0; |
465 | if ( !quick ) { | 465 | if ( !quick ) { |
466 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 466 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
467 | result = QMessageBox::warning( mParent, i18n("Warning!"), | 467 | result = QMessageBox::warning( mParent, i18n("Warning!"), |
468 | mess, | 468 | mess, |
469 | i18n("Sync"), i18n("Cancel"), 0, | 469 | i18n("Sync"), i18n("Cancel"), 0, |
470 | 0, 1 ); | 470 | 0, 1 ); |
471 | if ( result ) | 471 | if ( result ) |
472 | return false; | 472 | return false; |
473 | } | 473 | } |
474 | if ( mAskForPreferences ) | 474 | if ( mAskForPreferences ) |
475 | if ( !edit_sync_options()) { | 475 | if ( !edit_sync_options()) { |
476 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 476 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
477 | return false; | 477 | return false; |
478 | } | 478 | } |
479 | if ( result == 0 ) { | 479 | if ( result == 0 ) { |
480 | //qDebug("Now sycing ... "); | 480 | //qDebug("Now sycing ... "); |
481 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) | 481 | if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) |
482 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); | 482 | mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); |
483 | else | 483 | else |
484 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 484 | mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
485 | if ( ! quick ) | 485 | if ( ! quick ) |
486 | mPrefs->mLastSyncedLocalFile = fn; | 486 | mPrefs->mLastSyncedLocalFile = fn; |
487 | } | 487 | } |
488 | return ret; | 488 | return ret; |
489 | } | 489 | } |
490 | 490 | ||
491 | void KSyncManager::quickSyncLocalFile() | 491 | void KSyncManager::quickSyncLocalFile() |
492 | { | 492 | { |
493 | 493 | ||
494 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { | 494 | if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { |
495 | qDebug("quick syncLocalFile() successful "); | 495 | qDebug("quick syncLocalFile() successful "); |
496 | 496 | ||
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | void KSyncManager::multiSync( bool askforPrefs ) | 500 | void KSyncManager::multiSync( bool askforPrefs ) |
501 | { | 501 | { |
502 | if (blockSave()) | 502 | if (blockSave()) |
503 | return; | 503 | return; |
504 | setBlockSave(true); | 504 | setBlockSave(true); |
505 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 505 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
506 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), | 506 | if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), |
507 | question, | 507 | question, |
508 | i18n("Yes"), i18n("No"), | 508 | i18n("Yes"), i18n("No"), |
509 | 0, 0 ) != 0 ) { | 509 | 0, 0 ) != 0 ) { |
510 | setBlockSave(false); | 510 | setBlockSave(false); |
511 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); | 511 | mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); |
512 | return; | 512 | return; |
513 | } | 513 | } |
514 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 514 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
515 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; | 515 | mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; |
516 | if ( askforPrefs ) { | 516 | if ( askforPrefs ) { |
517 | if ( !edit_sync_options()) { | 517 | if ( !edit_sync_options()) { |
518 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); | 518 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); |
519 | return; | 519 | return; |
520 | } | 520 | } |
521 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; | 521 | mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; |
522 | } | 522 | } |
523 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); | 523 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); |
524 | qApp->processEvents(); | 524 | qApp->processEvents(); |
525 | int num = ringSync() ; | 525 | int num = ringSync() ; |
526 | if ( num > 1 ) | 526 | if ( num > 1 ) |
527 | ringSync(); | 527 | ringSync(); |
528 | setBlockSave(false); | 528 | setBlockSave(false); |
529 | if ( num ) | 529 | if ( num ) |
530 | emit save(); | 530 | emit save(); |
531 | if ( num ) | 531 | if ( num ) |
532 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); | 532 | mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); |
533 | else | 533 | else |
534 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 534 | mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
535 | return; | 535 | return; |
536 | } | 536 | } |
537 | 537 | ||
538 | int KSyncManager::ringSync() | 538 | int KSyncManager::ringSync() |
539 | { | 539 | { |
540 | 540 | ||
541 | int syncedProfiles = 0; | 541 | int syncedProfiles = 0; |
542 | unsigned int i; | 542 | unsigned int i; |
543 | QTime timer; | 543 | QTime timer; |
544 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 544 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
545 | QStringList syncProfileNames = mSyncProfileNames; | 545 | QStringList syncProfileNames = mSyncProfileNames; |
546 | KSyncProfile* temp = new KSyncProfile (); | 546 | KSyncProfile* temp = new KSyncProfile (); |
547 | mAskForPreferences = false; | 547 | mAskForPreferences = false; |
548 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 548 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
549 | mCurrentSyncProfile = i; | 549 | mCurrentSyncProfile = i; |
550 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 550 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
551 | temp->readConfig(&config); | 551 | temp->readConfig(&config); |
552 | 552 | ||
553 | bool includeInRingSync; | 553 | bool includeInRingSync; |
554 | switch(mTargetApp) | 554 | switch(mTargetApp) |
555 | { | 555 | { |
556 | case (KAPI): | 556 | case (KAPI): |
557 | includeInRingSync = temp->getIncludeInRingSyncAB(); | 557 | includeInRingSync = temp->getIncludeInRingSyncAB(); |
558 | break; | 558 | break; |
559 | case (KOPI): | 559 | case (KOPI): |
560 | includeInRingSync = temp->getIncludeInRingSync(); | 560 | includeInRingSync = temp->getIncludeInRingSync(); |
561 | break; | 561 | break; |
562 | case (PWMPI): | 562 | case (PWMPI): |
563 | includeInRingSync = temp->getIncludeInRingSyncPWM(); | 563 | includeInRingSync = temp->getIncludeInRingSyncPWM(); |
564 | break; | 564 | break; |
565 | default: | 565 | default: |
566 | qDebug("KSyncManager::ringSync: invalid apptype selected"); | 566 | qDebug("KSyncManager::ringSync: invalid apptype selected"); |
567 | break; | 567 | break; |
568 | 568 | ||
569 | } | 569 | } |
570 | 570 | ||
571 | 571 | ||
572 | if ( includeInRingSync && ( i < 1 || i > 2 )) { | 572 | if ( includeInRingSync && ( i < 1 || i > 2 )) { |
573 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 573 | mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
574 | ++syncedProfiles; | 574 | ++syncedProfiles; |
575 | mSyncWithDesktop = false; | 575 | mSyncWithDesktop = false; |
576 | // mAskForPreferences = temp->getAskForPreferences(); | 576 | // mAskForPreferences = temp->getAskForPreferences(); |
577 | mWriteBackFile = temp->getWriteBackFile(); | 577 | mWriteBackFile = temp->getWriteBackFile(); |
578 | mWriteBackExistingOnly = temp->getWriteBackExisting(); | 578 | mWriteBackExistingOnly = temp->getWriteBackExisting(); |
579 | mIsKapiFile = temp->getIsKapiFile(); | 579 | mIsKapiFile = temp->getIsKapiFile(); |
580 | mWriteBackInFuture = 0; | 580 | mWriteBackInFuture = 0; |
581 | if ( temp->getWriteBackFuture() ) | 581 | if ( temp->getWriteBackFuture() ) |
582 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 582 | mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
583 | mShowSyncSummary = false; | 583 | mShowSyncSummary = false; |
584 | mCurrentSyncDevice = syncProfileNames[i] ; | 584 | mCurrentSyncDevice = syncProfileNames[i] ; |
585 | mCurrentSyncName = mLocalMachineName; | 585 | mCurrentSyncName = mLocalMachineName; |
586 | if ( i == 0 ) { | 586 | if ( i == 0 ) { |
587 | mIsKapiFile = false; | 587 | mIsKapiFile = false; |
588 | #ifdef DESKTOP_VERSION | 588 | #ifdef DESKTOP_VERSION |
589 | syncKDE(); | 589 | syncKDE(); |
590 | #else | 590 | #else |
591 | syncSharp(); | 591 | syncSharp(); |
592 | #endif | 592 | #endif |
593 | } else { | 593 | } else { |
594 | if ( temp->getIsLocalFileSync() ) { | 594 | if ( temp->getIsLocalFileSync() ) { |
595 | switch(mTargetApp) | 595 | switch(mTargetApp) |
596 | { | 596 | { |
597 | case (KAPI): | 597 | case (KAPI): |
598 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 598 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
599 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 599 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
600 | break; | 600 | break; |
601 | case (KOPI): | 601 | case (KOPI): |
602 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 602 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
603 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); | 603 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); |
604 | break; | 604 | break; |
605 | case (PWMPI): | 605 | case (PWMPI): |
606 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) | 606 | if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) |
607 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); | 607 | mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); |
608 | break; | 608 | break; |
609 | default: | 609 | default: |
610 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 610 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
611 | break; | 611 | break; |
612 | } | 612 | } |
613 | } else { | 613 | } else { |
614 | if ( temp->getIsPhoneSync() ) { | 614 | if ( temp->getIsPhoneSync() ) { |
615 | mPhoneDevice = temp->getPhoneDevice( ) ; | 615 | mPhoneDevice = temp->getPhoneDevice( ) ; |
616 | mPhoneConnection = temp->getPhoneConnection( ); | 616 | mPhoneConnection = temp->getPhoneConnection( ); |
617 | mPhoneModel = temp->getPhoneModel( ); | 617 | mPhoneModel = temp->getPhoneModel( ); |
618 | syncPhone(); | 618 | syncPhone(); |
619 | } else if ( temp->getIsPiSync() ) { | 619 | } else if ( temp->getIsPiSync() ) { |
620 | if ( mTargetApp == KAPI ) { | 620 | if ( mTargetApp == KAPI ) { |
621 | mPassWordPiSync = temp->getRemotePwAB(); | 621 | mPassWordPiSync = temp->getRemotePwAB(); |
622 | mActiveSyncPort = temp->getRemotePortAB(); | 622 | mActiveSyncPort = temp->getRemotePortAB(); |
623 | mActiveSyncIP = temp->getRemoteIPAB(); | 623 | mActiveSyncIP = temp->getRemoteIPAB(); |
624 | } else if ( mTargetApp == KOPI ) { | 624 | } else if ( mTargetApp == KOPI ) { |
625 | mPassWordPiSync = temp->getRemotePw(); | 625 | mPassWordPiSync = temp->getRemotePw(); |
626 | mActiveSyncPort = temp->getRemotePort(); | 626 | mActiveSyncPort = temp->getRemotePort(); |
627 | mActiveSyncIP = temp->getRemoteIP(); | 627 | mActiveSyncIP = temp->getRemoteIP(); |
628 | } else { | 628 | } else { |
629 | mPassWordPiSync = temp->getRemotePwPWM(); | 629 | mPassWordPiSync = temp->getRemotePwPWM(); |
630 | mActiveSyncPort = temp->getRemotePortPWM(); | 630 | mActiveSyncPort = temp->getRemotePortPWM(); |
631 | mActiveSyncIP = temp->getRemoteIPPWM(); | 631 | mActiveSyncIP = temp->getRemoteIPPWM(); |
632 | } | 632 | } |
633 | syncPi(); | 633 | syncPi(); |
634 | while ( !mPisyncFinished ) { | 634 | while ( !mPisyncFinished ) { |
635 | //qDebug("waiting "); | 635 | //qDebug("waiting "); |
636 | qApp->processEvents(); | 636 | qApp->processEvents(); |
637 | } | 637 | } |
638 | timer.start(); | 638 | timer.start(); |
639 | while ( timer.elapsed () < 2000 ) { | 639 | while ( timer.elapsed () < 2000 ) { |
640 | qApp->processEvents(); | 640 | qApp->processEvents(); |
641 | } | 641 | } |
642 | } else | 642 | } else |
643 | syncRemote( temp, false ); | 643 | syncRemote( temp, false ); |
644 | 644 | ||
645 | } | 645 | } |
646 | } | 646 | } |
647 | timer.start(); | 647 | timer.start(); |
648 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); | 648 | mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); |
649 | while ( timer.elapsed () < 2000 ) { | 649 | while ( timer.elapsed () < 2000 ) { |
650 | qApp->processEvents(); | 650 | qApp->processEvents(); |
651 | #ifndef _WIN32_ | 651 | #ifndef _WIN32_ |
652 | sleep (1); | 652 | sleep (1); |
653 | #endif | 653 | #endif |
654 | } | 654 | } |
655 | 655 | ||
656 | } | 656 | } |
657 | 657 | ||
658 | } | 658 | } |
659 | delete temp; | 659 | delete temp; |
660 | return syncedProfiles; | 660 | return syncedProfiles; |
661 | } | 661 | } |
662 | 662 | ||
663 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) | 663 | void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) |
664 | { | 664 | { |
665 | QString question; | 665 | QString question; |
666 | if ( ask ) { | 666 | if ( ask ) { |
667 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 667 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
668 | if ( QMessageBox::information( mParent, i18n("Sync"), | 668 | if ( QMessageBox::information( mParent, i18n("Sync"), |
669 | question, | 669 | question, |
670 | i18n("Yes"), i18n("No"), | 670 | i18n("Yes"), i18n("No"), |
671 | 0, 0 ) != 0 ) | 671 | 0, 0 ) != 0 ) |
672 | return; | 672 | return; |
673 | } | 673 | } |
674 | 674 | ||
675 | QString preCommand; | 675 | QString preCommand; |
676 | QString localTempFile; | 676 | QString localTempFile; |
677 | QString postCommand; | 677 | QString postCommand; |
678 | 678 | ||
679 | switch(mTargetApp) | 679 | switch(mTargetApp) |
680 | { | 680 | { |
681 | case (KAPI): | 681 | case (KAPI): |
682 | preCommand = prof->getPreSyncCommandAB(); | 682 | preCommand = prof->getPreSyncCommandAB(); |
683 | postCommand = prof->getPostSyncCommandAB(); | 683 | postCommand = prof->getPostSyncCommandAB(); |
684 | localTempFile = prof->getLocalTempFileAB(); | 684 | localTempFile = prof->getLocalTempFileAB(); |
685 | break; | 685 | break; |
686 | case (KOPI): | 686 | case (KOPI): |
687 | preCommand = prof->getPreSyncCommand(); | 687 | preCommand = prof->getPreSyncCommand(); |
688 | postCommand = prof->getPostSyncCommand(); | 688 | postCommand = prof->getPostSyncCommand(); |
689 | localTempFile = prof->getLocalTempFile(); | 689 | localTempFile = prof->getLocalTempFile(); |
690 | break; | 690 | break; |
691 | case (PWMPI): | 691 | case (PWMPI): |
692 | preCommand = prof->getPreSyncCommandPWM(); | 692 | preCommand = prof->getPreSyncCommandPWM(); |
693 | postCommand = prof->getPostSyncCommandPWM(); | 693 | postCommand = prof->getPostSyncCommandPWM(); |
694 | localTempFile = prof->getLocalTempFilePWM(); | 694 | localTempFile = prof->getLocalTempFilePWM(); |
695 | break; | 695 | break; |
696 | default: | 696 | default: |
697 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); | 697 | qDebug("KSyncManager::syncRemote: invalid apptype selected"); |
698 | break; | 698 | break; |
699 | } | 699 | } |
700 | 700 | ||
701 | 701 | ||
702 | int fi; | 702 | int fi; |
703 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { | 703 | if ( (fi = preCommand.find("$PWD$")) > 0 ) { |
704 | QString pwd = getPassword(); | 704 | QString pwd = getPassword(); |
705 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); | 705 | preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); |
706 | 706 | ||
707 | } | 707 | } |
708 | int maxlen = 30; | 708 | int maxlen = 30; |
709 | if ( QApplication::desktop()->width() > 320 ) | 709 | if ( QApplication::desktop()->width() > 320 ) |
710 | maxlen += 25; | 710 | maxlen += 25; |
711 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); | 711 | mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); |
712 | int fileSize = 0; | 712 | int fileSize = 0; |
713 | int result = system ( preCommand ); | 713 | int result = system ( preCommand ); |
714 | // 0 : okay | 714 | // 0 : okay |
715 | // 256: no such file or dir | 715 | // 256: no such file or dir |
716 | // | 716 | // |
717 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); | 717 | qDebug("Sync: Remote copy result(0 = okay): %d ",result ); |
718 | if ( result != 0 ) { | 718 | if ( result != 0 ) { |
719 | unsigned int len = maxlen; | 719 | unsigned int len = maxlen; |
720 | while ( len < preCommand.length() ) { | 720 | while ( len < preCommand.length() ) { |
721 | preCommand.insert( len , "\n" ); | 721 | preCommand.insert( len , "\n" ); |
722 | len += maxlen +2; | 722 | len += maxlen +2; |
723 | } | 723 | } |
724 | 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 (preCommand) ; | 724 | 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 (preCommand) ; |
725 | QMessageBox::information( mParent, i18n("Sync - ERROR"), | 725 | QMessageBox::information( mParent, i18n("Sync - ERROR"), |
726 | question, | 726 | question, |
727 | i18n("Okay!")) ; | 727 | i18n("Okay!")) ; |
728 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); | 728 | mParent->topLevelWidget()->setCaption ("KDE-Pim"); |
729 | return; | 729 | return; |
730 | } | 730 | } |
731 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); | 731 | mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); |
732 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 732 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
733 | 733 | ||
734 | if ( syncWithFile( localTempFile, true ) ) { | 734 | if ( syncWithFile( localTempFile, true ) ) { |
735 | 735 | ||
736 | if ( mWriteBackFile ) { | 736 | if ( mWriteBackFile ) { |
737 | int fi; | 737 | int fi; |
738 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { | 738 | if ( (fi = postCommand.find("$PWD$")) > 0 ) { |
739 | QString pwd = getPassword(); | 739 | QString pwd = getPassword(); |
740 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); | 740 | postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); |
741 | 741 | ||
742 | } | 742 | } |
743 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); | 743 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); |
744 | result = system ( postCommand ); | 744 | result = system ( postCommand ); |
745 | qDebug("Sync:Writing back file result: %d ", result); | 745 | qDebug("Sync:Writing back file result: %d ", result); |
746 | if ( result != 0 ) { | 746 | if ( result != 0 ) { |
747 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 747 | mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
748 | return; | 748 | return; |
749 | } else { | 749 | } else { |
750 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 750 | mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
751 | } | 751 | } |
752 | } | 752 | } |
753 | } | 753 | } |
754 | return; | 754 | return; |
755 | } | 755 | } |
756 | bool KSyncManager::edit_pisync_options() | 756 | bool KSyncManager::edit_pisync_options() |
757 | { | 757 | { |
758 | QDialog dia( mParent, "dia", true ); | 758 | QDialog dia( mParent, "dia", true ); |
759 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); | 759 | dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); |
760 | QVBoxLayout lay ( &dia ); | 760 | QVBoxLayout lay ( &dia ); |
761 | lay.setSpacing( 5 ); | 761 | lay.setSpacing( 5 ); |
762 | lay.setMargin( 3 ); | 762 | lay.setMargin( 3 ); |
763 | QLabel lab1 ( i18n("Password for remote access:"), &dia); | 763 | QLabel lab1 ( i18n("Password for remote access:"), &dia); |
764 | lay.addWidget( &lab1 ); | 764 | lay.addWidget( &lab1 ); |
765 | QLineEdit le1 (&dia ); | 765 | QLineEdit le1 (&dia ); |
766 | lay.addWidget( &le1 ); | 766 | lay.addWidget( &le1 ); |
767 | QLabel lab2 ( i18n("Remote IP address:"), &dia); | 767 | QLabel lab2 ( i18n("Remote IP address:"), &dia); |
768 | lay.addWidget( &lab2 ); | 768 | lay.addWidget( &lab2 ); |
769 | QLineEdit le2 (&dia ); | 769 | QLineEdit le2 (&dia ); |
770 | lay.addWidget( &le2 ); | 770 | lay.addWidget( &le2 ); |
771 | QLabel lab3 ( i18n("Remote port number:"), &dia); | 771 | QLabel lab3 ( i18n("Remote port number:"), &dia); |
772 | lay.addWidget( &lab3 ); | 772 | lay.addWidget( &lab3 ); |
773 | QLineEdit le3 (&dia ); | 773 | QLineEdit le3 (&dia ); |
774 | lay.addWidget( &le3 ); | 774 | lay.addWidget( &le3 ); |
775 | QPushButton pb ( "OK", &dia); | 775 | QPushButton pb ( "OK", &dia); |
776 | lay.addWidget( &pb ); | 776 | lay.addWidget( &pb ); |
777 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 777 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
778 | le1.setText( mPassWordPiSync ); | 778 | le1.setText( mPassWordPiSync ); |
779 | le2.setText( mActiveSyncIP ); | 779 | le2.setText( mActiveSyncIP ); |
780 | le3.setText( mActiveSyncPort ); | 780 | le3.setText( mActiveSyncPort ); |
781 | if ( dia.exec() ) { | 781 | if ( dia.exec() ) { |
782 | mPassWordPiSync = le1.text(); | 782 | mPassWordPiSync = le1.text(); |
783 | mActiveSyncPort = le3.text(); | 783 | mActiveSyncPort = le3.text(); |
784 | mActiveSyncIP = le2.text(); | 784 | mActiveSyncIP = le2.text(); |
785 | return true; | 785 | return true; |
786 | } | 786 | } |
787 | return false; | 787 | return false; |
788 | } | 788 | } |
789 | bool KSyncManager::edit_sync_options() | 789 | bool KSyncManager::edit_sync_options() |
790 | { | 790 | { |
791 | 791 | ||
792 | QDialog dia( mParent, "dia", true ); | 792 | QDialog dia( mParent, "dia", true ); |
793 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 793 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
794 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 794 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
795 | QVBoxLayout lay ( &dia ); | 795 | QVBoxLayout lay ( &dia ); |
796 | lay.setSpacing( 2 ); | 796 | lay.setSpacing( 2 ); |
797 | lay.setMargin( 3 ); | 797 | lay.setMargin( 3 ); |
798 | lay.addWidget(&gr); | 798 | lay.addWidget(&gr); |
799 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 799 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
800 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 800 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
801 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 801 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
802 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 802 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
803 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 803 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
804 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 804 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
805 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 805 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
806 | QPushButton pb ( "OK", &dia); | 806 | QPushButton pb ( "OK", &dia); |
807 | lay.addWidget( &pb ); | 807 | lay.addWidget( &pb ); |
808 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 808 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
809 | switch ( mSyncAlgoPrefs ) { | 809 | switch ( mSyncAlgoPrefs ) { |
810 | case 0: | 810 | case 0: |
811 | loc.setChecked( true); | 811 | loc.setChecked( true); |
812 | break; | 812 | break; |
813 | case 1: | 813 | case 1: |
814 | rem.setChecked( true ); | 814 | rem.setChecked( true ); |
815 | break; | 815 | break; |
816 | case 2: | 816 | case 2: |
817 | newest.setChecked( true); | 817 | newest.setChecked( true); |
818 | break; | 818 | break; |
819 | case 3: | 819 | case 3: |
820 | ask.setChecked( true); | 820 | ask.setChecked( true); |
821 | break; | 821 | break; |
822 | case 4: | 822 | case 4: |
823 | f_loc.setChecked( true); | 823 | f_loc.setChecked( true); |
824 | break; | 824 | break; |
825 | case 5: | 825 | case 5: |
826 | f_rem.setChecked( true); | 826 | f_rem.setChecked( true); |
827 | break; | 827 | break; |
828 | case 6: | 828 | case 6: |
829 | // both.setChecked( true); | 829 | // both.setChecked( true); |
830 | break; | 830 | break; |
831 | default: | 831 | default: |
832 | break; | 832 | break; |
833 | } | 833 | } |
834 | if ( dia.exec() ) { | 834 | if ( dia.exec() ) { |
835 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 835 | mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
836 | return true; | 836 | return true; |
837 | } | 837 | } |
838 | return false; | 838 | return false; |
839 | } | 839 | } |
840 | 840 | ||
841 | QString KSyncManager::getPassword( ) | 841 | QString KSyncManager::getPassword( ) |
842 | { | 842 | { |
843 | QString retfile = ""; | 843 | QString retfile = ""; |
844 | QDialog dia ( mParent, "input-dialog", true ); | 844 | QDialog dia ( mParent, "input-dialog", true ); |
845 | QLineEdit lab ( &dia ); | 845 | QLineEdit lab ( &dia ); |
846 | lab.setEchoMode( QLineEdit::Password ); | 846 | lab.setEchoMode( QLineEdit::Password ); |
847 | QVBoxLayout lay( &dia ); | 847 | QVBoxLayout lay( &dia ); |
848 | lay.setMargin(7); | 848 | lay.setMargin(7); |
849 | lay.setSpacing(7); | 849 | lay.setSpacing(7); |
850 | lay.addWidget( &lab); | 850 | lay.addWidget( &lab); |
851 | dia.setFixedSize( 230,50 ); | 851 | dia.setFixedSize( 230,50 ); |
852 | dia.setCaption( i18n("Enter password") ); | 852 | dia.setCaption( i18n("Enter password") ); |
853 | QPushButton pb ( "OK", &dia); | 853 | QPushButton pb ( "OK", &dia); |
854 | lay.addWidget( &pb ); | 854 | lay.addWidget( &pb ); |
855 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 855 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
856 | dia.show(); | 856 | dia.show(); |
857 | int res = dia.exec(); | 857 | int res = dia.exec(); |
858 | if ( res ) | 858 | if ( res ) |
859 | retfile = lab.text(); | 859 | retfile = lab.text(); |
860 | dia.hide(); | 860 | dia.hide(); |
861 | qApp->processEvents(); | 861 | qApp->processEvents(); |
862 | return retfile; | 862 | return retfile; |
863 | 863 | ||
864 | } | 864 | } |
865 | 865 | ||
866 | 866 | ||
867 | void KSyncManager::confSync() | 867 | void KSyncManager::confSync() |
868 | { | 868 | { |
869 | static KSyncPrefsDialog* sp = 0; | 869 | static KSyncPrefsDialog* sp = 0; |
870 | if ( ! sp ) { | 870 | if ( ! sp ) { |
871 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); | 871 | sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); |
872 | } | 872 | } |
873 | sp->usrReadConfig(); | 873 | sp->usrReadConfig(); |
874 | #ifndef DESKTOP_VERSION | 874 | #ifndef DESKTOP_VERSION |
875 | sp->showMaximized(); | 875 | sp->showMaximized(); |
876 | #else | 876 | #else |
877 | sp->show(); | 877 | sp->show(); |
878 | #endif | 878 | #endif |
879 | sp->exec(); | 879 | sp->exec(); |
880 | QStringList oldSyncProfileNames = mSyncProfileNames; | 880 | QStringList oldSyncProfileNames = mSyncProfileNames; |
881 | mSyncProfileNames = sp->getSyncProfileNames(); | 881 | mSyncProfileNames = sp->getSyncProfileNames(); |
882 | mLocalMachineName = sp->getLocalMachineName (); | 882 | mLocalMachineName = sp->getLocalMachineName (); |
883 | int ii; | 883 | int ii; |
884 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { | 884 | for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { |
885 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) | 885 | if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) |
886 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); | 886 | mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); |
887 | } | 887 | } |
888 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 888 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
889 | } | 889 | } |
890 | void KSyncManager::syncKDE() | 890 | void KSyncManager::syncKDE() |
891 | { | 891 | { |
892 | mSyncWithDesktop = true; | 892 | mSyncWithDesktop = true; |
893 | emit save(); | 893 | emit save(); |
894 | switch(mTargetApp) | 894 | switch(mTargetApp) |
895 | { | 895 | { |
896 | case (KAPI): | 896 | case (KAPI): |
897 | { | 897 | { |
898 | #ifdef DESKTOP_VERSION | 898 | #ifdef DESKTOP_VERSION |
899 | QString command = qApp->applicationDirPath () + "/kdeabdump"; | 899 | QString command = qApp->applicationDirPath () + "/kdeabdump"; |
900 | #else | 900 | #else |
901 | QString command = "kdeabdump"; | 901 | QString command = "kdeabdump"; |
902 | #endif | 902 | #endif |
903 | if ( ! QFile::exists ( command ) ) | 903 | if ( ! QFile::exists ( command ) ) |
904 | command = "kdeabdump"; | 904 | command = "kdeabdump"; |
905 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; | 905 | QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; |
906 | system ( command.latin1()); | 906 | system ( command.latin1()); |
907 | if ( syncWithFile( fileName,true ) ) { | 907 | if ( syncWithFile( fileName,true ) ) { |
908 | if ( mWriteBackFile ) { | 908 | if ( mWriteBackFile ) { |
909 | command += " --read"; | 909 | command += " --read"; |
910 | system ( command.latin1()); | 910 | system ( command.latin1()); |
911 | } | 911 | } |
912 | } | 912 | } |
913 | 913 | ||
914 | } | 914 | } |
915 | break; | 915 | break; |
916 | case (KOPI): | 916 | case (KOPI): |
917 | { | 917 | { |
918 | #ifdef DESKTOP_VERSION | 918 | #ifdef DESKTOP_VERSION |
919 | QString command = qApp->applicationDirPath () + "/kdecaldump"; | 919 | QString command = qApp->applicationDirPath () + "/kdecaldump"; |
920 | #else | 920 | #else |
921 | QString command = "kdecaldump"; | 921 | QString command = "kdecaldump"; |
922 | #endif | 922 | #endif |
923 | if ( ! QFile::exists ( command ) ) | 923 | if ( ! QFile::exists ( command ) ) |
924 | command = "kdecaldump"; | 924 | command = "kdecaldump"; |
925 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 925 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
926 | system ( command.latin1()); | 926 | system ( command.latin1()); |
927 | if ( syncWithFile( fileName,true ) ) { | 927 | if ( syncWithFile( fileName,true ) ) { |
928 | if ( mWriteBackFile ) { | 928 | if ( mWriteBackFile ) { |
929 | command += " --read"; | 929 | command += " --read"; |
930 | system ( command.latin1()); | 930 | system ( command.latin1()); |
931 | } | 931 | } |
932 | } | 932 | } |
933 | 933 | ||
934 | } | 934 | } |
935 | break; | 935 | break; |
936 | case (PWMPI): | 936 | case (PWMPI): |
937 | 937 | ||
938 | break; | 938 | break; |
939 | default: | 939 | default: |
940 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); | 940 | qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); |
941 | break; | 941 | break; |
942 | 942 | ||
943 | } | 943 | } |
944 | } | 944 | } |
945 | 945 | ||
946 | void KSyncManager::syncSharp() | 946 | void KSyncManager::syncSharp() |
947 | { | 947 | { |
948 | 948 | ||
949 | if ( ! syncExternalApplication("sharp") ) | 949 | if ( ! syncExternalApplication("sharp") ) |
950 | qDebug("ERROR sync sharp "); | 950 | qDebug("ERROR sync sharp "); |
951 | } | 951 | } |
952 | 952 | ||
953 | bool KSyncManager::syncExternalApplication(QString resource) | 953 | bool KSyncManager::syncExternalApplication(QString resource) |
954 | { | 954 | { |
955 | 955 | ||
956 | emit save(); | 956 | emit save(); |
957 | 957 | ||
958 | if ( mAskForPreferences ) | 958 | if ( mAskForPreferences ) |
959 | if ( !edit_sync_options()) { | 959 | if ( !edit_sync_options()) { |
960 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 960 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
961 | return false; | 961 | return false; |
962 | } | 962 | } |
963 | 963 | ||
964 | qDebug("Sync extern %s", resource.latin1()); | 964 | qDebug("Sync extern %s", resource.latin1()); |
965 | 965 | ||
966 | bool syncOK = mImplementation->syncExternal(this, resource); | 966 | bool syncOK = mImplementation->syncExternal(this, resource); |
967 | 967 | ||
968 | return syncOK; | 968 | return syncOK; |
969 | 969 | ||
970 | } | 970 | } |
971 | 971 | ||
972 | void KSyncManager::syncPhone() | 972 | void KSyncManager::syncPhone() |
973 | { | 973 | { |
974 | 974 | ||
975 | syncExternalApplication("phone"); | 975 | syncExternalApplication("phone"); |
976 | 976 | ||
977 | } | 977 | } |
978 | 978 | ||
979 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) | 979 | void KSyncManager::showProgressBar(int percentage, QString caption, int total) |
980 | { | 980 | { |
981 | if (!bar->isVisible()) | 981 | if (!bar->isVisible()) |
982 | { | 982 | { |
983 | bar->setCaption (caption); | 983 | bar->setCaption (caption); |
984 | bar->setTotalSteps ( total ) ; | 984 | bar->setTotalSteps ( total ) ; |
985 | 985 | ||
986 | bar->show(); | 986 | bar->show(); |
987 | } | 987 | } |
988 | 988 | ||
989 | bar->setProgress( percentage ); | 989 | bar->setProgress( percentage ); |
990 | } | 990 | } |
991 | 991 | ||
992 | void KSyncManager::hideProgressBar() | 992 | void KSyncManager::hideProgressBar() |
993 | { | 993 | { |
994 | bar->hide(); | 994 | bar->hide(); |
995 | } | 995 | } |
996 | 996 | ||
997 | bool KSyncManager::isProgressBarCanceled() | 997 | bool KSyncManager::isProgressBarCanceled() |
998 | { | 998 | { |
999 | return !bar->isVisible(); | 999 | return !bar->isVisible(); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | QString KSyncManager::syncFileName() | 1002 | QString KSyncManager::syncFileName() |
1003 | { | 1003 | { |
1004 | 1004 | ||
1005 | QString fn = "tempfile"; | 1005 | QString fn = "tempfile"; |
1006 | switch(mTargetApp) | 1006 | switch(mTargetApp) |
1007 | { | 1007 | { |
1008 | case (KAPI): | 1008 | case (KAPI): |
1009 | fn = "tempsyncab.vcf"; | 1009 | fn = "tempsyncab.vcf"; |
1010 | break; | 1010 | break; |
1011 | case (KOPI): | 1011 | case (KOPI): |
1012 | fn = "tempsynccal.ics"; | 1012 | fn = "tempsynccal.ics"; |
1013 | break; | 1013 | break; |
1014 | case (PWMPI): | 1014 | case (PWMPI): |
1015 | fn = "tempsyncpw.pwm"; | 1015 | fn = "tempsyncpw.pwm"; |
1016 | break; | 1016 | break; |
1017 | default: | 1017 | default: |
1018 | break; | 1018 | break; |
1019 | } | 1019 | } |
1020 | #ifdef _WIN32_ | 1020 | #ifdef _WIN32_ |
1021 | return locateLocal( "tmp", fn ); | 1021 | return locateLocal( "tmp", fn ); |
1022 | #else | 1022 | #else |
1023 | return (QString( "/tmp/" )+ fn ); | 1023 | return (QString( "/tmp/" )+ fn ); |
1024 | #endif | 1024 | #endif |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | void KSyncManager::syncPi() | 1027 | void KSyncManager::syncPi() |
1028 | { | 1028 | { |
1029 | mIsKapiFile = true; | 1029 | mIsKapiFile = true; |
1030 | mPisyncFinished = false; | 1030 | mPisyncFinished = false; |
1031 | qApp->processEvents(); | 1031 | qApp->processEvents(); |
1032 | if ( mAskForPreferences ) | 1032 | if ( mAskForPreferences ) |
1033 | if ( !edit_pisync_options()) { | 1033 | if ( !edit_pisync_options()) { |
1034 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); | 1034 | mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); |
1035 | return; | 1035 | return; |
1036 | } | 1036 | } |
1037 | bool ok; | 1037 | bool ok; |
1038 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); | 1038 | Q_UINT16 port = mActiveSyncPort.toUInt(&ok); |
1039 | if ( ! ok ) { | 1039 | if ( ! ok ) { |
1040 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 1040 | mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
1041 | return; | 1041 | return; |
1042 | } | 1042 | } |
1043 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); | 1043 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); |
1044 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 1044 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
1045 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); | 1045 | mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); |
1046 | commandSocket->readFile( syncFileName() ); | 1046 | commandSocket->readFile( syncFileName() ); |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) | 1049 | void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) |
1050 | { | 1050 | { |
1051 | //enum { success, errorW, errorR, quiet }; | 1051 | //enum { success, errorW, errorR, quiet }; |
1052 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { | 1052 | if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { |
1053 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); | 1053 | mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); |
1054 | delete s; | 1054 | delete s; |
1055 | if ( state == KCommandSocket::errorR ) { | 1055 | if ( state == KCommandSocket::errorR ) { |
1056 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1056 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1057 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1057 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1058 | commandSocket->sendStop(); | 1058 | commandSocket->sendStop(); |
1059 | } | 1059 | } |
1060 | mPisyncFinished = true; | 1060 | mPisyncFinished = true; |
1061 | return; | 1061 | return; |
1062 | 1062 | ||
1063 | } else if ( state == KCommandSocket::errorW ) { | 1063 | } else if ( state == KCommandSocket::errorW ) { |
1064 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); | 1064 | mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); |
1065 | mPisyncFinished = true; | 1065 | mPisyncFinished = true; |
1066 | 1066 | ||
1067 | } else if ( state == KCommandSocket::successR ) { | 1067 | } else if ( state == KCommandSocket::successR ) { |
1068 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 1068 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
1069 | 1069 | ||
1070 | } else if ( state == KCommandSocket::successW ) { | 1070 | } else if ( state == KCommandSocket::successW ) { |
1071 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1071 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1072 | mPisyncFinished = true; | 1072 | mPisyncFinished = true; |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | delete s; | 1075 | delete s; |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | void KSyncManager::readFileFromSocket() | 1078 | void KSyncManager::readFileFromSocket() |
1079 | { | 1079 | { |
1080 | QString fileName = syncFileName(); | 1080 | QString fileName = syncFileName(); |
1081 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); | 1081 | mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); |
1082 | if ( ! syncWithFile( fileName , true ) ) { | 1082 | if ( ! syncWithFile( fileName , true ) ) { |
1083 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); | 1083 | mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); |
1084 | mPisyncFinished = true; | 1084 | mPisyncFinished = true; |
1085 | return; | 1085 | return; |
1086 | } | 1086 | } |
1087 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); | 1087 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); |
1088 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 1088 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
1089 | if ( mWriteBackFile ) | 1089 | if ( mWriteBackFile ) |
1090 | commandSocket->writeFile( fileName ); | 1090 | commandSocket->writeFile( fileName ); |
1091 | else { | 1091 | else { |
1092 | commandSocket->sendStop(); | 1092 | commandSocket->sendStop(); |
1093 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); | 1093 | mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); |
1094 | mPisyncFinished = true; | 1094 | mPisyncFinished = true; |
1095 | } | 1095 | } |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 1098 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
1099 | { | 1099 | { |
1100 | mPassWord = pw; | 1100 | mPassWord = pw; |
1101 | mSocket = 0; | 1101 | mSocket = 0; |
1102 | mSyncActionDialog = 0; | 1102 | mSyncActionDialog = 0; |
1103 | blockRC = false; | 1103 | blockRC = false; |
1104 | }; | 1104 | }; |
1105 | 1105 | ||
1106 | void KServerSocket::newConnection ( int socket ) | 1106 | void KServerSocket::newConnection ( int socket ) |
1107 | { | 1107 | { |
1108 | // qDebug("KServerSocket:New connection %d ", socket); | 1108 | // qDebug("KServerSocket:New connection %d ", socket); |
1109 | if ( mSocket ) { | 1109 | if ( mSocket ) { |
1110 | qDebug("KServerSocket::newConnection Socket deleted! "); | 1110 | qDebug("KServerSocket::newConnection Socket deleted! "); |
1111 | delete mSocket; | 1111 | delete mSocket; |
1112 | mSocket = 0; | 1112 | mSocket = 0; |
1113 | } | 1113 | } |
1114 | mSocket = new QSocket( this ); | 1114 | mSocket = new QSocket( this ); |
1115 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 1115 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
1116 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 1116 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
1117 | mSocket->setSocket( socket ); | 1117 | mSocket->setSocket( socket ); |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | void KServerSocket::discardClient() | 1120 | void KServerSocket::discardClient() |
1121 | { | 1121 | { |
1122 | //qDebug(" KServerSocket::discardClient()"); | 1122 | //qDebug(" KServerSocket::discardClient()"); |
1123 | if ( mSocket ) { | 1123 | if ( mSocket ) { |
1124 | delete mSocket; | 1124 | delete mSocket; |
1125 | mSocket = 0; | 1125 | mSocket = 0; |
1126 | } | 1126 | } |
1127 | //emit endConnect(); | 1127 | //emit endConnect(); |
1128 | } | 1128 | } |
1129 | void KServerSocket::readClient() | 1129 | void KServerSocket::readClient() |
1130 | { | 1130 | { |
1131 | if ( blockRC ) | 1131 | if ( blockRC ) |
1132 | return; | 1132 | return; |
1133 | if ( mSocket == 0 ) { | 1133 | if ( mSocket == 0 ) { |
1134 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 1134 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
1135 | return; | 1135 | return; |
1136 | } | 1136 | } |
1137 | //qDebug("KServerSocket::readClient()"); | 1137 | //qDebug("KServerSocket::readClient()"); |
1138 | if ( mSocket->canReadLine() ) { | 1138 | if ( mSocket->canReadLine() ) { |
1139 | QString line = mSocket->readLine(); | 1139 | QString line = mSocket->readLine(); |
1140 | //qDebug("KServerSocket readline: %s ", line.latin1()); | 1140 | //qDebug("KServerSocket readline: %s ", line.latin1()); |
1141 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 1141 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
1142 | if ( tokens[0] == "GET" ) { | 1142 | if ( tokens[0] == "GET" ) { |
1143 | if ( tokens[1] == mPassWord ) { | 1143 | if ( tokens[1] == mPassWord ) { |
1144 | //emit sendFile( mSocket ); | 1144 | //emit sendFile( mSocket ); |
1145 | bool ok = false; | 1145 | bool ok = false; |
1146 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); | 1146 | QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); |
1147 | if ( ok ) { | 1147 | if ( ok ) { |
1148 | KSyncManager::mRequestedSyncEvent = dt; | 1148 | KSyncManager::mRequestedSyncEvent = dt; |
1149 | } | 1149 | } |
1150 | else | 1150 | else |
1151 | KSyncManager::mRequestedSyncEvent = QDateTime(); | 1151 | KSyncManager::mRequestedSyncEvent = QDateTime(); |
1152 | send_file(); | 1152 | send_file(); |
1153 | } | 1153 | } |
1154 | else { | 1154 | else { |
1155 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); | 1155 | KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); |
1156 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1156 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1157 | } | 1157 | } |
1158 | } | 1158 | } |
1159 | if ( tokens[0] == "PUT" ) { | 1159 | if ( tokens[0] == "PUT" ) { |
1160 | if ( tokens[1] == mPassWord ) { | 1160 | if ( tokens[1] == mPassWord ) { |
1161 | //emit getFile( mSocket ); | 1161 | //emit getFile( mSocket ); |
1162 | blockRC = true; | 1162 | blockRC = true; |
1163 | get_file(); | 1163 | get_file(); |
1164 | } | 1164 | } |
1165 | else { | 1165 | else { |
1166 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); | 1166 | KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); |
1167 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 1167 | //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
1168 | } | 1168 | } |
1169 | } | 1169 | } |
1170 | if ( tokens[0] == "STOP" ) { | 1170 | if ( tokens[0] == "STOP" ) { |
1171 | //emit endConnect(); | 1171 | //emit endConnect(); |
1172 | end_connect(); | 1172 | end_connect(); |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | } | 1175 | } |
1176 | void KServerSocket::end_connect() | 1176 | void KServerSocket::end_connect() |
1177 | { | 1177 | { |
1178 | delete mSyncActionDialog; | 1178 | delete mSyncActionDialog; |
1179 | mSyncActionDialog = 0; | 1179 | mSyncActionDialog = 0; |
1180 | } | 1180 | } |
1181 | void KServerSocket::send_file() | 1181 | void KServerSocket::send_file() |
1182 | { | 1182 | { |
1183 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 1183 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
1184 | if ( mSyncActionDialog ) | 1184 | if ( mSyncActionDialog ) |
1185 | delete mSyncActionDialog; | 1185 | delete mSyncActionDialog; |
1186 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 1186 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
1187 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 1187 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
1188 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 1188 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
1189 | label->setAlignment ( Qt::AlignHCenter ); | 1189 | label->setAlignment ( Qt::AlignHCenter ); |
1190 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 1190 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
1191 | lay->addWidget( label); | 1191 | lay->addWidget( label); |
1192 | lay->setMargin(7); | 1192 | lay->setMargin(7); |
1193 | lay->setSpacing(7); | 1193 | lay->setSpacing(7); |
1194 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1194 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1195 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); | 1195 | int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); |
1196 | if ( secs < 0 ) | 1196 | if ( secs < 0 ) |
1197 | secs = secs * (-1); | 1197 | secs = secs * (-1); |
1198 | if ( secs > 30 ) | 1198 | if ( secs > 30 ) |
1199 | //if ( true ) | 1199 | //if ( true ) |
1200 | { | 1200 | { |
1201 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); | 1201 | QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); |
1202 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1202 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1203 | label->setAlignment ( Qt::AlignHCenter ); | 1203 | label->setAlignment ( Qt::AlignHCenter ); |
1204 | lay->addWidget( label); | 1204 | lay->addWidget( label); |
1205 | if ( secs > 180 ) | 1205 | if ( secs > 180 ) |
1206 | { | 1206 | { |
1207 | if ( secs > 300 ) { | 1207 | if ( secs > 300 ) { |
1208 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { | 1208 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { |
1209 | qDebug("cancelled "); | 1209 | qDebug("cancelled "); |
1210 | return ; | 1210 | return ; |
1211 | } | 1211 | } |
1212 | } | 1212 | } |
1213 | QFont f = label->font(); | 1213 | QFont f = label->font(); |
1214 | f.setPointSize ( f.pointSize() *2 ); | 1214 | f.setPointSize ( f.pointSize() *2 ); |
1215 | f. setBold (true ); | 1215 | f. setBold (true ); |
1216 | QLabel* label = new QLabel( warning, mSyncActionDialog ); | 1216 | QLabel* label = new QLabel( warning, mSyncActionDialog ); |
1217 | label->setFont( f ); | 1217 | label->setFont( f ); |
1218 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); | 1218 | warning = i18n("ADJUST\nYOUR\nCLOCKS!"); |
1219 | label->setText( warning ); | 1219 | label->setText( warning ); |
1220 | label->setAlignment ( Qt::AlignHCenter ); | 1220 | label->setAlignment ( Qt::AlignHCenter ); |
1221 | lay->addWidget( label); | 1221 | lay->addWidget( label); |
1222 | mSyncActionDialog->setFixedSize( 230, 300); | 1222 | mSyncActionDialog->setFixedSize( 230, 300); |
1223 | } else { | 1223 | } else { |
1224 | mSyncActionDialog->setFixedSize( 230, 200); | 1224 | mSyncActionDialog->setFixedSize( 230, 200); |
1225 | } | 1225 | } |
1226 | } else { | 1226 | } else { |
1227 | mSyncActionDialog->setFixedSize( 230, 120); | 1227 | mSyncActionDialog->setFixedSize( 230, 120); |
1228 | } | 1228 | } |
1229 | } else | 1229 | } else |
1230 | mSyncActionDialog->setFixedSize( 230, 120); | 1230 | mSyncActionDialog->setFixedSize( 230, 120); |
1231 | mSyncActionDialog->show(); | 1231 | mSyncActionDialog->show(); |
1232 | mSyncActionDialog->raise(); | 1232 | mSyncActionDialog->raise(); |
1233 | emit request_file(); | 1233 | emit request_file(); |
1234 | qApp->processEvents(); | 1234 | qApp->processEvents(); |
1235 | QString fileName = mFileName; | 1235 | QString fileName = mFileName; |
1236 | QFile file( fileName ); | 1236 | QFile file( fileName ); |
1237 | if (!file.open( IO_ReadOnly ) ) { | 1237 | if (!file.open( IO_ReadOnly ) ) { |
1238 | delete mSyncActionDialog; | 1238 | delete mSyncActionDialog; |
1239 | mSyncActionDialog = 0; | 1239 | mSyncActionDialog = 0; |
1240 | qDebug("KSS::error open file "); | 1240 | qDebug("KSS::error open sync file: %s ", fileName.latin1()); |
1241 | mSocket->close(); | 1241 | mSocket->close(); |
1242 | if ( mSocket->state() == QSocket::Idle ) | 1242 | if ( mSocket->state() == QSocket::Idle ) |
1243 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1243 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1244 | return ; | 1244 | return ; |
1245 | 1245 | ||
1246 | } | 1246 | } |
1247 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 1247 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
1248 | QTextStream ts( &file ); | 1248 | QTextStream ts( &file ); |
1249 | ts.setEncoding( QTextStream::Latin1 ); | 1249 | ts.setEncoding( QTextStream::Latin1 ); |
1250 | 1250 | ||
1251 | QTextStream os( mSocket ); | 1251 | QTextStream os( mSocket ); |
1252 | os.setEncoding( QTextStream::Latin1 ); | 1252 | os.setEncoding( QTextStream::Latin1 ); |
1253 | while ( ! ts.atEnd() ) { | 1253 | while ( ! ts.atEnd() ) { |
1254 | os << ts.readLine() << "\r\n"; | 1254 | os << ts.readLine() << "\r\n"; |
1255 | } | 1255 | } |
1256 | //os << ts.read(); | 1256 | //os << ts.read(); |
1257 | file.close(); | 1257 | file.close(); |
1258 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 1258 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
1259 | mSocket->close(); | 1259 | mSocket->close(); |
1260 | if ( mSocket->state() == QSocket::Idle ) | 1260 | if ( mSocket->state() == QSocket::Idle ) |
1261 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1261 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1262 | } | 1262 | } |
1263 | void KServerSocket::get_file() | 1263 | void KServerSocket::get_file() |
1264 | { | 1264 | { |
1265 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 1265 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
1266 | 1266 | ||
1267 | piTime.start(); | 1267 | piTime.start(); |
1268 | piFileString = ""; | 1268 | piFileString = ""; |
1269 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 1269 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | 1272 | ||
1273 | void KServerSocket::readBackFileFromSocket() | 1273 | void KServerSocket::readBackFileFromSocket() |
1274 | { | 1274 | { |
1275 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 1275 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
1276 | while ( mSocket->canReadLine () ) { | 1276 | while ( mSocket->canReadLine () ) { |
1277 | piTime.restart(); | 1277 | piTime.restart(); |
1278 | QString line = mSocket->readLine (); | 1278 | QString line = mSocket->readLine (); |
1279 | piFileString += line; | 1279 | piFileString += line; |
1280 | //qDebug("readline: %s ", line.latin1()); | 1280 | //qDebug("readline: %s ", line.latin1()); |
1281 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 1281 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
1282 | 1282 | ||
1283 | } | 1283 | } |
1284 | if ( piTime.elapsed () < 3000 ) { | 1284 | if ( piTime.elapsed () < 3000 ) { |
1285 | // wait for more | 1285 | // wait for more |
1286 | //qDebug("waitformore "); | 1286 | //qDebug("waitformore "); |
1287 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 1287 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
1288 | return; | 1288 | return; |
1289 | } | 1289 | } |
1290 | QString fileName = mFileName; | 1290 | QString fileName = mFileName; |
1291 | QFile file ( fileName ); | 1291 | QFile file ( fileName ); |
1292 | if (!file.open( IO_WriteOnly ) ) { | 1292 | if (!file.open( IO_WriteOnly ) ) { |
1293 | delete mSyncActionDialog; | 1293 | delete mSyncActionDialog; |
1294 | mSyncActionDialog = 0; | 1294 | mSyncActionDialog = 0; |
1295 | qDebug("KSS:Error open read back file "); | 1295 | qDebug("KSS:Error open read back file "); |
1296 | piFileString = ""; | 1296 | piFileString = ""; |
1297 | emit file_received( false ); | 1297 | emit file_received( false ); |
1298 | blockRC = false; | 1298 | blockRC = false; |
1299 | return ; | 1299 | return ; |
1300 | 1300 | ||
1301 | } | 1301 | } |
1302 | 1302 | ||
1303 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1303 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1304 | QTextStream ts ( &file ); | 1304 | QTextStream ts ( &file ); |
1305 | ts.setEncoding( QTextStream::Latin1 ); | 1305 | ts.setEncoding( QTextStream::Latin1 ); |
1306 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 1306 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
1307 | ts << piFileString; | 1307 | ts << piFileString; |
1308 | mSocket->close(); | 1308 | mSocket->close(); |
1309 | if ( mSocket->state() == QSocket::Idle ) | 1309 | if ( mSocket->state() == QSocket::Idle ) |
1310 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 1310 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
1311 | file.close(); | 1311 | file.close(); |
1312 | piFileString = ""; | 1312 | piFileString = ""; |
1313 | emit file_received( true ); | 1313 | emit file_received( true ); |
1314 | delete mSyncActionDialog; | 1314 | delete mSyncActionDialog; |
1315 | mSyncActionDialog = 0; | 1315 | mSyncActionDialog = 0; |
1316 | blockRC = false; | 1316 | blockRC = false; |
1317 | 1317 | ||
1318 | } | 1318 | } |
1319 | 1319 | ||
1320 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 1320 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
1321 | { | 1321 | { |
1322 | mPassWord = password; | 1322 | mPassWord = password; |
1323 | mSocket = 0; | 1323 | mSocket = 0; |
1324 | mPort = port; | 1324 | mPort = port; |
1325 | mHost = host; | 1325 | mHost = host; |
1326 | 1326 | ||
1327 | mRetVal = quiet; | 1327 | mRetVal = quiet; |
1328 | mTimerSocket = new QTimer ( this ); | 1328 | mTimerSocket = new QTimer ( this ); |
1329 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 1329 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
1330 | } | 1330 | } |
1331 | void KCommandSocket::readFile( QString fn ) | 1331 | void KCommandSocket::readFile( QString fn ) |
1332 | { | 1332 | { |
1333 | if ( !mSocket ) { | 1333 | if ( !mSocket ) { |
1334 | mSocket = new QSocket( this ); | 1334 | mSocket = new QSocket( this ); |
1335 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 1335 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
1336 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1336 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1337 | } | 1337 | } |
1338 | mFileString = ""; | 1338 | mFileString = ""; |
1339 | mFileName = fn; | 1339 | mFileName = fn; |
1340 | mFirst = true; | 1340 | mFirst = true; |
1341 | mSocket->connectToHost( mHost, mPort ); | 1341 | mSocket->connectToHost( mHost, mPort ); |
1342 | QTextStream os( mSocket ); | 1342 | QTextStream os( mSocket ); |
1343 | os.setEncoding( QTextStream::Latin1 ); | 1343 | os.setEncoding( QTextStream::Latin1 ); |
1344 | 1344 | ||
1345 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); | 1345 | QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); |
1346 | os << "GET " << mPassWord << curDt <<"\r\n"; | 1346 | os << "GET " << mPassWord << curDt <<"\r\n"; |
1347 | mTimerSocket->start( 20000 ); | 1347 | mTimerSocket->start( 20000 ); |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | void KCommandSocket::writeFile( QString fileName ) | 1350 | void KCommandSocket::writeFile( QString fileName ) |
1351 | { | 1351 | { |
1352 | if ( !mSocket ) { | 1352 | if ( !mSocket ) { |
1353 | mSocket = new QSocket( this ); | 1353 | mSocket = new QSocket( this ); |
1354 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1354 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1355 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 1355 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
1356 | } | 1356 | } |
1357 | mFileName = fileName ; | 1357 | mFileName = fileName ; |
1358 | mSocket->connectToHost( mHost, mPort ); | 1358 | mSocket->connectToHost( mHost, mPort ); |
1359 | } | 1359 | } |
1360 | void KCommandSocket::writeFileToSocket() | 1360 | void KCommandSocket::writeFileToSocket() |
1361 | { | 1361 | { |
1362 | QFile file2( mFileName ); | 1362 | QFile file2( mFileName ); |
1363 | if (!file2.open( IO_ReadOnly ) ) { | 1363 | if (!file2.open( IO_ReadOnly ) ) { |
1364 | mRetVal= errorW; | 1364 | mRetVal= errorW; |
1365 | mSocket->close(); | 1365 | mSocket->close(); |
1366 | if ( mSocket->state() == QSocket::Idle ) | 1366 | if ( mSocket->state() == QSocket::Idle ) |
1367 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1367 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1368 | return ; | 1368 | return ; |
1369 | } | 1369 | } |
1370 | QTextStream ts2( &file2 ); | 1370 | QTextStream ts2( &file2 ); |
1371 | ts2.setEncoding( QTextStream::Latin1 ); | 1371 | ts2.setEncoding( QTextStream::Latin1 ); |
1372 | QTextStream os2( mSocket ); | 1372 | QTextStream os2( mSocket ); |
1373 | os2.setEncoding( QTextStream::Latin1 ); | 1373 | os2.setEncoding( QTextStream::Latin1 ); |
1374 | os2 << "PUT " << mPassWord << "\r\n";; | 1374 | os2 << "PUT " << mPassWord << "\r\n";; |
1375 | while ( ! ts2.atEnd() ) { | 1375 | while ( ! ts2.atEnd() ) { |
1376 | os2 << ts2.readLine() << "\r\n"; | 1376 | os2 << ts2.readLine() << "\r\n"; |
1377 | } | 1377 | } |
1378 | mRetVal= successW; | 1378 | mRetVal= successW; |
1379 | file2.close(); | 1379 | file2.close(); |
1380 | mSocket->close(); | 1380 | mSocket->close(); |
1381 | if ( mSocket->state() == QSocket::Idle ) | 1381 | if ( mSocket->state() == QSocket::Idle ) |
1382 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1382 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1383 | } | 1383 | } |
1384 | void KCommandSocket::sendStop() | 1384 | void KCommandSocket::sendStop() |
1385 | { | 1385 | { |
1386 | if ( !mSocket ) { | 1386 | if ( !mSocket ) { |
1387 | mSocket = new QSocket( this ); | 1387 | mSocket = new QSocket( this ); |
1388 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1388 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1389 | } | 1389 | } |
1390 | mSocket->connectToHost( mHost, mPort ); | 1390 | mSocket->connectToHost( mHost, mPort ); |
1391 | QTextStream os2( mSocket ); | 1391 | QTextStream os2( mSocket ); |
1392 | os2.setEncoding( QTextStream::Latin1 ); | 1392 | os2.setEncoding( QTextStream::Latin1 ); |
1393 | os2 << "STOP\r\n"; | 1393 | os2 << "STOP\r\n"; |
1394 | mSocket->close(); | 1394 | mSocket->close(); |
1395 | if ( mSocket->state() == QSocket::Idle ) | 1395 | if ( mSocket->state() == QSocket::Idle ) |
1396 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 1396 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | void KCommandSocket::startReadFileFromSocket() | 1399 | void KCommandSocket::startReadFileFromSocket() |
1400 | { | 1400 | { |
1401 | if ( ! mFirst ) | 1401 | if ( ! mFirst ) |
1402 | return; | 1402 | return; |
1403 | mFirst = false; | 1403 | mFirst = false; |
1404 | mTimerSocket->stop(); | 1404 | mTimerSocket->stop(); |
1405 | mFileString = ""; | 1405 | mFileString = ""; |
1406 | mTime.start(); | 1406 | mTime.start(); |
1407 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 1407 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
1408 | 1408 | ||
1409 | } | 1409 | } |
1410 | void KCommandSocket::readFileFromSocket() | 1410 | void KCommandSocket::readFileFromSocket() |
1411 | { | 1411 | { |
1412 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 1412 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
1413 | while ( mSocket->canReadLine () ) { | 1413 | while ( mSocket->canReadLine () ) { |
1414 | mTime.restart(); | 1414 | mTime.restart(); |
1415 | QString line = mSocket->readLine (); | 1415 | QString line = mSocket->readLine (); |
1416 | mFileString += line; | 1416 | mFileString += line; |
1417 | //qDebug("readline: %s ", line.latin1()); | 1417 | //qDebug("readline: %s ", line.latin1()); |
1418 | } | 1418 | } |
1419 | if ( mTime.elapsed () < 3000 ) { | 1419 | if ( mTime.elapsed () < 3000 ) { |
1420 | // wait for more | 1420 | // wait for more |
1421 | //qDebug("waitformore "); | 1421 | //qDebug("waitformore "); |
1422 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 1422 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
1423 | return; | 1423 | return; |
1424 | } | 1424 | } |
1425 | QString fileName = mFileName; | 1425 | QString fileName = mFileName; |
1426 | QFile file ( fileName ); | 1426 | QFile file ( fileName ); |
1427 | if (!file.open( IO_WriteOnly ) ) { | 1427 | if (!file.open( IO_WriteOnly ) ) { |
1428 | mFileString = ""; | 1428 | mFileString = ""; |
1429 | mRetVal = errorR; | 1429 | mRetVal = errorR; |
1430 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); | 1430 | qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); |
1431 | deleteSocket(); | 1431 | deleteSocket(); |
1432 | return ; | 1432 | return ; |
1433 | 1433 | ||
1434 | } | 1434 | } |
1435 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1435 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1436 | QTextStream ts ( &file ); | 1436 | QTextStream ts ( &file ); |
1437 | ts.setEncoding( QTextStream::Latin1 ); | 1437 | ts.setEncoding( QTextStream::Latin1 ); |
1438 | ts << mFileString; | 1438 | ts << mFileString; |
1439 | file.close(); | 1439 | file.close(); |
1440 | mFileString = ""; | 1440 | mFileString = ""; |
1441 | mRetVal = successR; | 1441 | mRetVal = successR; |
1442 | mSocket->close(); | 1442 | mSocket->close(); |
1443 | // if state is not idle, deleteSocket(); is called via | 1443 | // if state is not idle, deleteSocket(); is called via |
1444 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 1444 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
1445 | if ( mSocket->state() == QSocket::Idle ) | 1445 | if ( mSocket->state() == QSocket::Idle ) |
1446 | deleteSocket(); | 1446 | deleteSocket(); |
1447 | } | 1447 | } |
1448 | 1448 | ||
1449 | void KCommandSocket::deleteSocket() | 1449 | void KCommandSocket::deleteSocket() |
1450 | { | 1450 | { |
1451 | //qDebug("KCommandSocket::deleteSocket() "); | 1451 | //qDebug("KCommandSocket::deleteSocket() "); |
1452 | if ( mTimerSocket->isActive () ) { | 1452 | if ( mTimerSocket->isActive () ) { |
1453 | mTimerSocket->stop(); | 1453 | mTimerSocket->stop(); |
1454 | mRetVal = errorTO; | 1454 | mRetVal = errorTO; |
1455 | qDebug("Connection to remote host timed out"); | 1455 | qDebug("Connection to remote host timed out"); |
1456 | if ( mSocket ) { | 1456 | if ( mSocket ) { |
1457 | mSocket->close(); | 1457 | mSocket->close(); |
1458 | //if ( mSocket->state() == QSocket::Idle ) | 1458 | //if ( mSocket->state() == QSocket::Idle ) |
1459 | // deleteSocket(); | 1459 | // deleteSocket(); |
1460 | delete mSocket; | 1460 | delete mSocket; |
1461 | mSocket = 0; | 1461 | mSocket = 0; |
1462 | } | 1462 | } |
1463 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 1463 | KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
1464 | emit commandFinished( this, mRetVal ); | 1464 | emit commandFinished( this, mRetVal ); |
1465 | return; | 1465 | return; |
1466 | } | 1466 | } |
1467 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 1467 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
1468 | if ( mSocket) | 1468 | if ( mSocket) |
1469 | delete mSocket; | 1469 | delete mSocket; |
1470 | mSocket = 0; | 1470 | mSocket = 0; |
1471 | emit commandFinished( this, mRetVal ); | 1471 | emit commandFinished( this, mRetVal ); |
1472 | } | 1472 | } |