author | zautrix <zautrix> | 2004-10-27 22:35:41 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-27 22:35:41 (UTC) |
commit | 5afbc6ae0908ce12fd5abb1c4eadf9c61a01503c (patch) (unidiff) | |
tree | 914ce70d7e5a1afcd2da0c2fda34b959d65d0462 | |
parent | 9c88346fc757fd1dc54b3fca151a2a610159d8cf (diff) | |
download | kdepimpi-5afbc6ae0908ce12fd5abb1c4eadf9c61a01503c.zip kdepimpi-5afbc6ae0908ce12fd5abb1c4eadf9c61a01503c.tar.gz kdepimpi-5afbc6ae0908ce12fd5abb1c4eadf9c61a01503c.tar.bz2 |
pwm close fix
-rw-r--r-- | kaddressbook/kabcore.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 1 | ||||
-rw-r--r-- | libkdepim/externalapphandler.cpp | 6 | ||||
-rw-r--r-- | libkdepim/externalapphandler.h | 1 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwminit.cpp | 10 |
5 files changed, 24 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 4964a6c..d1dcb6e 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2938 +1,2944 @@ | |||
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 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | 134 | ||
135 | #include <libkdepim/categoryselectdialog.h> | 135 | #include <libkdepim/categoryselectdialog.h> |
136 | #include <kabc/vcardconverter.h> | 136 | #include <kabc/vcardconverter.h> |
137 | 137 | ||
138 | 138 | ||
139 | #include "addresseeutil.h" | 139 | #include "addresseeutil.h" |
140 | #include "undocmds.h" | 140 | #include "undocmds.h" |
141 | #include "addresseeeditordialog.h" | 141 | #include "addresseeeditordialog.h" |
142 | #include "viewmanager.h" | 142 | #include "viewmanager.h" |
143 | #include "details/detailsviewcontainer.h" | 143 | #include "details/detailsviewcontainer.h" |
144 | #include "kabprefs.h" | 144 | #include "kabprefs.h" |
145 | #include "xxportmanager.h" | 145 | #include "xxportmanager.h" |
146 | #include "incsearchwidget.h" | 146 | #include "incsearchwidget.h" |
147 | #include "jumpbuttonbar.h" | 147 | #include "jumpbuttonbar.h" |
148 | #include "extensionmanager.h" | 148 | #include "extensionmanager.h" |
149 | #include "addresseeconfig.h" | 149 | #include "addresseeconfig.h" |
150 | #include <kcmultidialog.h> | 150 | #include <kcmultidialog.h> |
151 | 151 | ||
152 | #ifdef _WIN32_ | 152 | #ifdef _WIN32_ |
153 | 153 | ||
154 | #include "kaimportoldialog.h" | 154 | #include "kaimportoldialog.h" |
155 | #else | 155 | #else |
156 | #include <unistd.h> | 156 | #include <unistd.h> |
157 | #endif | 157 | #endif |
158 | // sync includes | 158 | // sync includes |
159 | #include <libkdepim/ksyncprofile.h> | 159 | #include <libkdepim/ksyncprofile.h> |
160 | #include <libkdepim/ksyncprefsdialog.h> | 160 | #include <libkdepim/ksyncprefsdialog.h> |
161 | 161 | ||
162 | class KAex2phonePrefs : public QDialog | 162 | class KAex2phonePrefs : public QDialog |
163 | { | 163 | { |
164 | public: | 164 | public: |
165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
166 | QDialog( parent, name, true ) | 166 | QDialog( parent, name, true ) |
167 | { | 167 | { |
168 | setCaption( i18n("Export to phone options") ); | 168 | setCaption( i18n("Export to phone options") ); |
169 | QVBoxLayout* lay = new QVBoxLayout( this ); | 169 | QVBoxLayout* lay = new QVBoxLayout( this ); |
170 | lay->setSpacing( 3 ); | 170 | lay->setSpacing( 3 ); |
171 | lay->setMargin( 3 ); | 171 | lay->setMargin( 3 ); |
172 | QLabel *lab; | 172 | QLabel *lab; |
173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
174 | lab->setAlignment (AlignHCenter ); | 174 | lab->setAlignment (AlignHCenter ); |
175 | QHBox* temphb; | 175 | QHBox* temphb; |
176 | temphb = new QHBox( this ); | 176 | temphb = new QHBox( this ); |
177 | new QLabel( i18n("I/O device: "), temphb ); | 177 | new QLabel( i18n("I/O device: "), temphb ); |
178 | mPhoneDevice = new QLineEdit( temphb); | 178 | mPhoneDevice = new QLineEdit( temphb); |
179 | lay->addWidget( temphb ); | 179 | lay->addWidget( temphb ); |
180 | temphb = new QHBox( this ); | 180 | temphb = new QHBox( this ); |
181 | new QLabel( i18n("Connection: "), temphb ); | 181 | new QLabel( i18n("Connection: "), temphb ); |
182 | mPhoneConnection = new QLineEdit( temphb); | 182 | mPhoneConnection = new QLineEdit( temphb); |
183 | lay->addWidget( temphb ); | 183 | lay->addWidget( temphb ); |
184 | temphb = new QHBox( this ); | 184 | temphb = new QHBox( this ); |
185 | new QLabel( i18n("Model(opt.): "), temphb ); | 185 | new QLabel( i18n("Model(opt.): "), temphb ); |
186 | mPhoneModel = new QLineEdit( temphb); | 186 | mPhoneModel = new QLineEdit( temphb); |
187 | lay->addWidget( temphb ); | 187 | lay->addWidget( temphb ); |
188 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 188 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
189 | // lay->addWidget( mWriteToSim ); | 189 | // lay->addWidget( mWriteToSim ); |
190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
191 | lab->setAlignment (AlignHCenter ); | 191 | lab->setAlignment (AlignHCenter ); |
192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
193 | lay->addWidget( ok ); | 193 | lay->addWidget( ok ); |
194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
195 | lay->addWidget( cancel ); | 195 | lay->addWidget( cancel ); |
196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
198 | resize( 220, 240 ); | 198 | resize( 220, 240 ); |
199 | 199 | ||
200 | } | 200 | } |
201 | 201 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | 207 | ||
208 | bool pasteWithNewUid = true; | 208 | bool pasteWithNewUid = true; |
209 | 209 | ||
210 | #ifdef KAB_EMBEDDED | 210 | #ifdef KAB_EMBEDDED |
211 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 211 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
212 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 212 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
213 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 213 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
214 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 214 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
215 | #else //KAB_EMBEDDED | 215 | #else //KAB_EMBEDDED |
216 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 216 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
217 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 217 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
218 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 218 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
219 | mReadWrite( readWrite ), mModified( false ) | 219 | mReadWrite( readWrite ), mModified( false ) |
220 | #endif //KAB_EMBEDDED | 220 | #endif //KAB_EMBEDDED |
221 | { | 221 | { |
222 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 222 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
223 | // syncManager->setBlockSave(false); | 223 | // syncManager->setBlockSave(false); |
224 | mExtensionBarSplitter = 0; | 224 | mExtensionBarSplitter = 0; |
225 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 225 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | 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&))); | 295 | 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&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); | ||
297 | 298 | ||
298 | 299 | ||
299 | #ifndef KAB_EMBEDDED | 300 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 301 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 302 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 303 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 304 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 305 | SLOT( browse( const QString& ) ) ); |
305 | 306 | ||
306 | 307 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 308 | mAddressBookService = new KAddressBookService( this ); |
308 | 309 | ||
309 | #endif //KAB_EMBEDDED | 310 | #endif //KAB_EMBEDDED |
310 | 311 | ||
311 | mMessageTimer = new QTimer( this ); | 312 | mMessageTimer = new QTimer( this ); |
312 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); | 313 | connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); |
313 | mEditorDialog = 0; | 314 | mEditorDialog = 0; |
314 | createAddresseeEditorDialog( this ); | 315 | createAddresseeEditorDialog( this ); |
315 | setModified( false ); | 316 | setModified( false ); |
316 | mBRdisabled = false; | 317 | mBRdisabled = false; |
317 | #ifndef DESKTOP_VERSION | 318 | #ifndef DESKTOP_VERSION |
318 | infrared = 0; | 319 | infrared = 0; |
319 | #endif | 320 | #endif |
320 | //toggleBeamReceive( ); | 321 | //toggleBeamReceive( ); |
321 | } | 322 | } |
322 | 323 | ||
323 | KABCore::~KABCore() | 324 | KABCore::~KABCore() |
324 | { | 325 | { |
325 | // save(); | 326 | // save(); |
326 | //saveSettings(); | 327 | //saveSettings(); |
327 | //KABPrefs::instance()->writeConfig(); | 328 | //KABPrefs::instance()->writeConfig(); |
328 | delete AddresseeConfig::instance(); | 329 | delete AddresseeConfig::instance(); |
329 | mAddressBook = 0; | 330 | mAddressBook = 0; |
330 | KABC::StdAddressBook::close(); | 331 | KABC::StdAddressBook::close(); |
331 | 332 | ||
332 | delete syncManager; | 333 | delete syncManager; |
333 | #ifndef DESKTOP_VERSION | 334 | #ifndef DESKTOP_VERSION |
334 | if ( infrared ) | 335 | if ( infrared ) |
335 | delete infrared; | 336 | delete infrared; |
336 | #endif | 337 | #endif |
337 | } | 338 | } |
338 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) | 339 | void KABCore::receive( const QCString& cmsg, const QByteArray& data ) |
339 | { | 340 | { |
340 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); | 341 | qDebug("KA: QCOP message received: %s ", cmsg.data() ); |
341 | if ( cmsg == "setDocument(QString)" ) { | 342 | if ( cmsg == "setDocument(QString)" ) { |
342 | QDataStream stream( data, IO_ReadOnly ); | 343 | QDataStream stream( data, IO_ReadOnly ); |
343 | QString fileName; | 344 | QString fileName; |
344 | stream >> fileName; | 345 | stream >> fileName; |
345 | recieve( fileName ); | 346 | recieve( fileName ); |
346 | return; | 347 | return; |
347 | } | 348 | } |
348 | } | 349 | } |
349 | void KABCore::toggleBeamReceive( ) | 350 | void KABCore::toggleBeamReceive( ) |
350 | { | 351 | { |
351 | if ( mBRdisabled ) | 352 | if ( mBRdisabled ) |
352 | return; | 353 | return; |
353 | #ifndef DESKTOP_VERSION | 354 | #ifndef DESKTOP_VERSION |
354 | if ( infrared ) { | 355 | if ( infrared ) { |
355 | qDebug("AB disable BeamReceive "); | 356 | qDebug("AB disable BeamReceive "); |
356 | delete infrared; | 357 | delete infrared; |
357 | infrared = 0; | 358 | infrared = 0; |
358 | mActionBR->setChecked(false); | 359 | mActionBR->setChecked(false); |
359 | return; | 360 | return; |
360 | } | 361 | } |
361 | qDebug("AB enable BeamReceive "); | 362 | qDebug("AB enable BeamReceive "); |
362 | mActionBR->setChecked(true); | 363 | mActionBR->setChecked(true); |
363 | 364 | ||
364 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; | 365 | infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; |
365 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); | 366 | QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); |
366 | #endif | 367 | #endif |
367 | } | 368 | } |
368 | 369 | ||
369 | 370 | ||
370 | void KABCore::disableBR(bool b) | 371 | void KABCore::disableBR(bool b) |
371 | { | 372 | { |
372 | #ifndef DESKTOP_VERSION | 373 | #ifndef DESKTOP_VERSION |
373 | if ( b ) { | 374 | if ( b ) { |
374 | if ( infrared ) { | 375 | if ( infrared ) { |
375 | toggleBeamReceive( ); | 376 | toggleBeamReceive( ); |
376 | } | 377 | } |
377 | mBRdisabled = true; | 378 | mBRdisabled = true; |
378 | } else { | 379 | } else { |
379 | if ( mBRdisabled ) { | 380 | if ( mBRdisabled ) { |
380 | mBRdisabled = false; | 381 | mBRdisabled = false; |
381 | //toggleBeamReceive( ); | 382 | //toggleBeamReceive( ); |
382 | } | 383 | } |
383 | } | 384 | } |
384 | #endif | 385 | #endif |
385 | 386 | ||
386 | } | 387 | } |
387 | void KABCore::recieve( QString fn ) | 388 | void KABCore::recieve( QString fn ) |
388 | { | 389 | { |
389 | //qDebug("KABCore::recieve "); | 390 | //qDebug("KABCore::recieve "); |
390 | int count = mAddressBook->importFromFile( fn, true ); | 391 | int count = mAddressBook->importFromFile( fn, true ); |
391 | if ( count ) | 392 | if ( count ) |
392 | setModified( true ); | 393 | setModified( true ); |
393 | mViewManager->refreshView(); | 394 | mViewManager->refreshView(); |
394 | message(i18n("%1 contact(s) received!").arg( count )); | 395 | message(i18n("%1 contact(s) received!").arg( count )); |
395 | topLevelWidget()->showMaximized(); | 396 | topLevelWidget()->showMaximized(); |
396 | topLevelWidget()->raise(); | 397 | topLevelWidget()->raise(); |
397 | } | 398 | } |
398 | void KABCore::restoreSettings() | 399 | void KABCore::restoreSettings() |
399 | { | 400 | { |
400 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 401 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
401 | 402 | ||
402 | bool state; | 403 | bool state; |
403 | 404 | ||
404 | if (mMultipleViewsAtOnce) | 405 | if (mMultipleViewsAtOnce) |
405 | state = KABPrefs::instance()->mDetailsPageVisible; | 406 | state = KABPrefs::instance()->mDetailsPageVisible; |
406 | else | 407 | else |
407 | state = false; | 408 | state = false; |
408 | 409 | ||
409 | mActionDetails->setChecked( state ); | 410 | mActionDetails->setChecked( state ); |
410 | setDetailsVisible( state ); | 411 | setDetailsVisible( state ); |
411 | 412 | ||
412 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 413 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
413 | 414 | ||
414 | mActionJumpBar->setChecked( state ); | 415 | mActionJumpBar->setChecked( state ); |
415 | setJumpButtonBarVisible( state ); | 416 | setJumpButtonBarVisible( state ); |
416 | /*US | 417 | /*US |
417 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 418 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
418 | if ( splitterSize.count() == 0 ) { | 419 | if ( splitterSize.count() == 0 ) { |
419 | splitterSize.append( width() / 2 ); | 420 | splitterSize.append( width() / 2 ); |
420 | splitterSize.append( width() / 2 ); | 421 | splitterSize.append( width() / 2 ); |
421 | } | 422 | } |
422 | mMiniSplitter->setSizes( splitterSize ); | 423 | mMiniSplitter->setSizes( splitterSize ); |
423 | if ( mExtensionBarSplitter ) { | 424 | if ( mExtensionBarSplitter ) { |
424 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 425 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
425 | if ( splitterSize.count() == 0 ) { | 426 | if ( splitterSize.count() == 0 ) { |
426 | splitterSize.append( width() / 2 ); | 427 | splitterSize.append( width() / 2 ); |
427 | splitterSize.append( width() / 2 ); | 428 | splitterSize.append( width() / 2 ); |
428 | } | 429 | } |
429 | mExtensionBarSplitter->setSizes( splitterSize ); | 430 | mExtensionBarSplitter->setSizes( splitterSize ); |
430 | 431 | ||
431 | } | 432 | } |
432 | */ | 433 | */ |
433 | mViewManager->restoreSettings(); | 434 | mViewManager->restoreSettings(); |
434 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 435 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
435 | mExtensionManager->restoreSettings(); | 436 | mExtensionManager->restoreSettings(); |
436 | #ifdef DESKTOP_VERSION | 437 | #ifdef DESKTOP_VERSION |
437 | int wid = width(); | 438 | int wid = width(); |
438 | if ( wid < 10 ) | 439 | if ( wid < 10 ) |
439 | wid = 400; | 440 | wid = 400; |
440 | #else | 441 | #else |
441 | int wid = QApplication::desktop()->width(); | 442 | int wid = QApplication::desktop()->width(); |
442 | if ( wid < 640 ) | 443 | if ( wid < 640 ) |
443 | wid = QApplication::desktop()->height(); | 444 | wid = QApplication::desktop()->height(); |
444 | #endif | 445 | #endif |
445 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 446 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
446 | if ( true /*splitterSize.count() == 0*/ ) { | 447 | if ( true /*splitterSize.count() == 0*/ ) { |
447 | splitterSize.append( wid / 2 ); | 448 | splitterSize.append( wid / 2 ); |
448 | splitterSize.append( wid / 2 ); | 449 | splitterSize.append( wid / 2 ); |
449 | } | 450 | } |
450 | mMiniSplitter->setSizes( splitterSize ); | 451 | mMiniSplitter->setSizes( splitterSize ); |
451 | if ( mExtensionBarSplitter ) { | 452 | if ( mExtensionBarSplitter ) { |
452 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 453 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
453 | if ( true /*splitterSize.count() == 0*/ ) { | 454 | if ( true /*splitterSize.count() == 0*/ ) { |
454 | splitterSize.append( wid / 2 ); | 455 | splitterSize.append( wid / 2 ); |
455 | splitterSize.append( wid / 2 ); | 456 | splitterSize.append( wid / 2 ); |
456 | } | 457 | } |
457 | mExtensionBarSplitter->setSizes( splitterSize ); | 458 | mExtensionBarSplitter->setSizes( splitterSize ); |
458 | 459 | ||
459 | } | 460 | } |
460 | 461 | ||
461 | 462 | ||
462 | } | 463 | } |
463 | 464 | ||
464 | void KABCore::saveSettings() | 465 | void KABCore::saveSettings() |
465 | { | 466 | { |
466 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 467 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
467 | if ( mExtensionBarSplitter ) | 468 | if ( mExtensionBarSplitter ) |
468 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 469 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
469 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 470 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
470 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 471 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
471 | #ifndef KAB_EMBEDDED | 472 | #ifndef KAB_EMBEDDED |
472 | 473 | ||
473 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 474 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
474 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 475 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
475 | #endif //KAB_EMBEDDED | 476 | #endif //KAB_EMBEDDED |
476 | mExtensionManager->saveSettings(); | 477 | mExtensionManager->saveSettings(); |
477 | mViewManager->saveSettings(); | 478 | mViewManager->saveSettings(); |
478 | 479 | ||
479 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 480 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
480 | } | 481 | } |
481 | 482 | ||
482 | KABC::AddressBook *KABCore::addressBook() const | 483 | KABC::AddressBook *KABCore::addressBook() const |
483 | { | 484 | { |
484 | return mAddressBook; | 485 | return mAddressBook; |
485 | } | 486 | } |
486 | 487 | ||
487 | KConfig *KABCore::config() | 488 | KConfig *KABCore::config() |
488 | { | 489 | { |
489 | #ifndef KAB_EMBEDDED | 490 | #ifndef KAB_EMBEDDED |
490 | return KABPrefs::instance()->config(); | 491 | return KABPrefs::instance()->config(); |
491 | #else //KAB_EMBEDDED | 492 | #else //KAB_EMBEDDED |
492 | return KABPrefs::instance()->getConfig(); | 493 | return KABPrefs::instance()->getConfig(); |
493 | #endif //KAB_EMBEDDED | 494 | #endif //KAB_EMBEDDED |
494 | } | 495 | } |
495 | 496 | ||
496 | KActionCollection *KABCore::actionCollection() const | 497 | KActionCollection *KABCore::actionCollection() const |
497 | { | 498 | { |
498 | return mGUIClient->actionCollection(); | 499 | return mGUIClient->actionCollection(); |
499 | } | 500 | } |
500 | 501 | ||
501 | KABC::Field *KABCore::currentSearchField() const | 502 | KABC::Field *KABCore::currentSearchField() const |
502 | { | 503 | { |
503 | if (mIncSearchWidget) | 504 | if (mIncSearchWidget) |
504 | return mIncSearchWidget->currentField(); | 505 | return mIncSearchWidget->currentField(); |
505 | else | 506 | else |
506 | return 0; | 507 | return 0; |
507 | } | 508 | } |
508 | 509 | ||
509 | QStringList KABCore::selectedUIDs() const | 510 | QStringList KABCore::selectedUIDs() const |
510 | { | 511 | { |
511 | return mViewManager->selectedUids(); | 512 | return mViewManager->selectedUids(); |
512 | } | 513 | } |
513 | 514 | ||
514 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 515 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
515 | { | 516 | { |
516 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 517 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
517 | 518 | ||
518 | QPtrList<KRES::Resource> kresResources; | 519 | QPtrList<KRES::Resource> kresResources; |
519 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 520 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
520 | KABC::Resource *resource; | 521 | KABC::Resource *resource; |
521 | while ( ( resource = resIt.current() ) != 0 ) { | 522 | while ( ( resource = resIt.current() ) != 0 ) { |
522 | ++resIt; | 523 | ++resIt; |
523 | if ( !resource->readOnly() ) { | 524 | if ( !resource->readOnly() ) { |
524 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 525 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
525 | if ( res ) | 526 | if ( res ) |
526 | kresResources.append( res ); | 527 | kresResources.append( res ); |
527 | } | 528 | } |
528 | } | 529 | } |
529 | 530 | ||
530 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 531 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
531 | return static_cast<KABC::Resource*>( res ); | 532 | return static_cast<KABC::Resource*>( res ); |
532 | } | 533 | } |
533 | 534 | ||
534 | #ifndef KAB_EMBEDDED | 535 | #ifndef KAB_EMBEDDED |
535 | KAboutData *KABCore::createAboutData() | 536 | KAboutData *KABCore::createAboutData() |
536 | #else //KAB_EMBEDDED | 537 | #else //KAB_EMBEDDED |
537 | void KABCore::createAboutData() | 538 | void KABCore::createAboutData() |
538 | #endif //KAB_EMBEDDED | 539 | #endif //KAB_EMBEDDED |
539 | { | 540 | { |
540 | #ifndef KAB_EMBEDDED | 541 | #ifndef KAB_EMBEDDED |
541 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 542 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
542 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 543 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
543 | KAboutData::License_GPL_V2, | 544 | KAboutData::License_GPL_V2, |
544 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 545 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
545 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 546 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
546 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 547 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
547 | about->addAuthor( "Cornelius Schumacher", | 548 | about->addAuthor( "Cornelius Schumacher", |
548 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 549 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
549 | "schumacher@kde.org" ); | 550 | "schumacher@kde.org" ); |
550 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 551 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
551 | "mpilone@slac.com" ); | 552 | "mpilone@slac.com" ); |
552 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 553 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
553 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 554 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
554 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 555 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
555 | "michel@klaralvdalens-datakonsult.se" ); | 556 | "michel@klaralvdalens-datakonsult.se" ); |
556 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 557 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
557 | "hansen@kde.org" ); | 558 | "hansen@kde.org" ); |
558 | 559 | ||
559 | return about; | 560 | return about; |
560 | #endif //KAB_EMBEDDED | 561 | #endif //KAB_EMBEDDED |
561 | 562 | ||
562 | QString version; | 563 | QString version; |
563 | #include <../version> | 564 | #include <../version> |
564 | QMessageBox::about( this, "About KAddressbook/Pi", | 565 | QMessageBox::about( this, "About KAddressbook/Pi", |
565 | "KAddressbook/Platform-independent\n" | 566 | "KAddressbook/Platform-independent\n" |
566 | "(KA/Pi) " +version + " - " + | 567 | "(KA/Pi) " +version + " - " + |
567 | #ifdef DESKTOP_VERSION | 568 | #ifdef DESKTOP_VERSION |
568 | "Desktop Edition\n" | 569 | "Desktop Edition\n" |
569 | #else | 570 | #else |
570 | "PDA-Edition\n" | 571 | "PDA-Edition\n" |
571 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 572 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
572 | #endif | 573 | #endif |
573 | 574 | ||
574 | "(c) 2004 Ulf Schenk\n" | 575 | "(c) 2004 Ulf Schenk\n" |
575 | "(c) 2004 Lutz Rogowski\n" | 576 | "(c) 2004 Lutz Rogowski\n" |
576 | "(c) 1997-2003, The KDE PIM Team\n" | 577 | "(c) 1997-2003, The KDE PIM Team\n" |
577 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 578 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
578 | "Don Sanders Original author\n" | 579 | "Don Sanders Original author\n" |
579 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 580 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
580 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 581 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
581 | "Greg Stern DCOP interface\n" | 582 | "Greg Stern DCOP interface\n" |
582 | "Mark Westcot Contact pinning\n" | 583 | "Mark Westcot Contact pinning\n" |
583 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 584 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
584 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 585 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
585 | #ifdef _WIN32_ | 586 | #ifdef _WIN32_ |
586 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 587 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
587 | #endif | 588 | #endif |
588 | ); | 589 | ); |
589 | } | 590 | } |
590 | 591 | ||
591 | void KABCore::setContactSelected( const QString &uid ) | 592 | void KABCore::setContactSelected( const QString &uid ) |
592 | { | 593 | { |
593 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 594 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
594 | if ( !mDetails->isHidden() ) | 595 | if ( !mDetails->isHidden() ) |
595 | mDetails->setAddressee( addr ); | 596 | mDetails->setAddressee( addr ); |
596 | 597 | ||
597 | if ( !addr.isEmpty() ) { | 598 | if ( !addr.isEmpty() ) { |
598 | emit contactSelected( addr.formattedName() ); | 599 | emit contactSelected( addr.formattedName() ); |
599 | KABC::Picture pic = addr.photo(); | 600 | KABC::Picture pic = addr.photo(); |
600 | if ( pic.isIntern() ) { | 601 | if ( pic.isIntern() ) { |
601 | //US emit contactSelected( pic.data() ); | 602 | //US emit contactSelected( pic.data() ); |
602 | //US instead use: | 603 | //US instead use: |
603 | QPixmap px; | 604 | QPixmap px; |
604 | if (pic.data().isNull() != true) | 605 | if (pic.data().isNull() != true) |
605 | { | 606 | { |
606 | px.convertFromImage(pic.data()); | 607 | px.convertFromImage(pic.data()); |
607 | } | 608 | } |
608 | 609 | ||
609 | emit contactSelected( px ); | 610 | emit contactSelected( px ); |
610 | } | 611 | } |
611 | } | 612 | } |
612 | 613 | ||
613 | 614 | ||
614 | mExtensionManager->setSelectionChanged(); | 615 | mExtensionManager->setSelectionChanged(); |
615 | 616 | ||
616 | // update the actions | 617 | // update the actions |
617 | bool selected = !uid.isEmpty(); | 618 | bool selected = !uid.isEmpty(); |
618 | 619 | ||
619 | if ( mReadWrite ) { | 620 | if ( mReadWrite ) { |
620 | mActionCut->setEnabled( selected ); | 621 | mActionCut->setEnabled( selected ); |
621 | mActionPaste->setEnabled( selected ); | 622 | mActionPaste->setEnabled( selected ); |
622 | } | 623 | } |
623 | 624 | ||
624 | mActionCopy->setEnabled( selected ); | 625 | mActionCopy->setEnabled( selected ); |
625 | mActionDelete->setEnabled( selected ); | 626 | mActionDelete->setEnabled( selected ); |
626 | mActionEditAddressee->setEnabled( selected ); | 627 | mActionEditAddressee->setEnabled( selected ); |
627 | mActionMail->setEnabled( selected ); | 628 | mActionMail->setEnabled( selected ); |
628 | mActionMailVCard->setEnabled( selected ); | 629 | mActionMailVCard->setEnabled( selected ); |
629 | //if (mActionBeam) | 630 | //if (mActionBeam) |
630 | //mActionBeam->setEnabled( selected ); | 631 | //mActionBeam->setEnabled( selected ); |
631 | 632 | ||
632 | if (mActionBeamVCard) | 633 | if (mActionBeamVCard) |
633 | mActionBeamVCard->setEnabled( selected ); | 634 | mActionBeamVCard->setEnabled( selected ); |
634 | 635 | ||
635 | mActionExport2phone->setEnabled( selected ); | 636 | mActionExport2phone->setEnabled( selected ); |
636 | mActionWhoAmI->setEnabled( selected ); | 637 | mActionWhoAmI->setEnabled( selected ); |
637 | mActionCategories->setEnabled( selected ); | 638 | mActionCategories->setEnabled( selected ); |
638 | } | 639 | } |
639 | 640 | ||
640 | void KABCore::sendMail() | 641 | void KABCore::sendMail() |
641 | { | 642 | { |
642 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 643 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
643 | } | 644 | } |
644 | 645 | ||
645 | void KABCore::sendMail( const QString& emaillist ) | 646 | void KABCore::sendMail( const QString& emaillist ) |
646 | { | 647 | { |
647 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 648 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
648 | if (emaillist.contains(",") > 0) | 649 | if (emaillist.contains(",") > 0) |
649 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 650 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
650 | else | 651 | else |
651 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 652 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
652 | } | 653 | } |
653 | 654 | ||
654 | 655 | ||
655 | 656 | ||
656 | void KABCore::mailVCard() | 657 | void KABCore::mailVCard() |
657 | { | 658 | { |
658 | QStringList uids = mViewManager->selectedUids(); | 659 | QStringList uids = mViewManager->selectedUids(); |
659 | if ( !uids.isEmpty() ) | 660 | if ( !uids.isEmpty() ) |
660 | mailVCard( uids ); | 661 | mailVCard( uids ); |
661 | } | 662 | } |
662 | 663 | ||
663 | void KABCore::mailVCard( const QStringList& uids ) | 664 | void KABCore::mailVCard( const QStringList& uids ) |
664 | { | 665 | { |
665 | QStringList urls; | 666 | QStringList urls; |
666 | 667 | ||
667 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 668 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
668 | 669 | ||
669 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 670 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
670 | 671 | ||
671 | 672 | ||
672 | 673 | ||
673 | QDir().mkdir( dirName, true ); | 674 | QDir().mkdir( dirName, true ); |
674 | 675 | ||
675 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 676 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
676 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 677 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
677 | 678 | ||
678 | if ( a.isEmpty() ) | 679 | if ( a.isEmpty() ) |
679 | continue; | 680 | continue; |
680 | 681 | ||
681 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 682 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
682 | 683 | ||
683 | QString fileName = dirName + "/" + name; | 684 | QString fileName = dirName + "/" + name; |
684 | 685 | ||
685 | QFile outFile(fileName); | 686 | QFile outFile(fileName); |
686 | 687 | ||
687 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 688 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
688 | KABC::VCardConverter converter; | 689 | KABC::VCardConverter converter; |
689 | QString vcard; | 690 | QString vcard; |
690 | 691 | ||
691 | converter.addresseeToVCard( a, vcard ); | 692 | converter.addresseeToVCard( a, vcard ); |
692 | 693 | ||
693 | QTextStream t( &outFile ); // use a text stream | 694 | QTextStream t( &outFile ); // use a text stream |
694 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 695 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
695 | t << vcard; | 696 | t << vcard; |
696 | 697 | ||
697 | outFile.close(); | 698 | outFile.close(); |
698 | 699 | ||
699 | urls.append( fileName ); | 700 | urls.append( fileName ); |
700 | } | 701 | } |
701 | } | 702 | } |
702 | 703 | ||
703 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 704 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
704 | 705 | ||
705 | 706 | ||
706 | /*US | 707 | /*US |
707 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 708 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
708 | QString::null, // subject | 709 | QString::null, // subject |
709 | QString::null, // body | 710 | QString::null, // body |
710 | QString::null, | 711 | QString::null, |
711 | urls ); // attachments | 712 | urls ); // attachments |
712 | */ | 713 | */ |
713 | 714 | ||
714 | } | 715 | } |
715 | 716 | ||
716 | /** | 717 | /** |
717 | Beams the "WhoAmI contact. | 718 | Beams the "WhoAmI contact. |
718 | */ | 719 | */ |
719 | void KABCore::beamMySelf() | 720 | void KABCore::beamMySelf() |
720 | { | 721 | { |
721 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 722 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
722 | if (!a.isEmpty()) | 723 | if (!a.isEmpty()) |
723 | { | 724 | { |
724 | QStringList uids; | 725 | QStringList uids; |
725 | uids << a.uid(); | 726 | uids << a.uid(); |
726 | 727 | ||
727 | beamVCard(uids); | 728 | beamVCard(uids); |
728 | } else { | 729 | } else { |
729 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 730 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
730 | 731 | ||
731 | 732 | ||
732 | } | 733 | } |
733 | } | 734 | } |
734 | 735 | ||
735 | void KABCore::export2phone() | 736 | void KABCore::export2phone() |
736 | { | 737 | { |
737 | 738 | ||
738 | KAex2phonePrefs ex2phone; | 739 | KAex2phonePrefs ex2phone; |
739 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 740 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
740 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 741 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
741 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 742 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
742 | 743 | ||
743 | if ( !ex2phone.exec() ) { | 744 | if ( !ex2phone.exec() ) { |
744 | return; | 745 | return; |
745 | } | 746 | } |
746 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 747 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
747 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 748 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
748 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 749 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
749 | 750 | ||
750 | 751 | ||
751 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 752 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
752 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 753 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
753 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 754 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
754 | 755 | ||
755 | QStringList uids = mViewManager->selectedUids(); | 756 | QStringList uids = mViewManager->selectedUids(); |
756 | if ( uids.isEmpty() ) | 757 | if ( uids.isEmpty() ) |
757 | return; | 758 | return; |
758 | 759 | ||
759 | QString fileName = getPhoneFile(); | 760 | QString fileName = getPhoneFile(); |
760 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 761 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
761 | return; | 762 | return; |
762 | 763 | ||
763 | message(i18n("Exporting to phone...")); | 764 | message(i18n("Exporting to phone...")); |
764 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 765 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
765 | 766 | ||
766 | } | 767 | } |
767 | QString KABCore::getPhoneFile() | 768 | QString KABCore::getPhoneFile() |
768 | { | 769 | { |
769 | #ifdef DESKTOP_VERSION | 770 | #ifdef DESKTOP_VERSION |
770 | return locateLocal("tmp", "phonefile.vcf"); | 771 | return locateLocal("tmp", "phonefile.vcf"); |
771 | #else | 772 | #else |
772 | return "/tmp/phonefile.vcf"; | 773 | return "/tmp/phonefile.vcf"; |
773 | #endif | 774 | #endif |
774 | 775 | ||
775 | } | 776 | } |
776 | void KABCore::writeToPhone( ) | 777 | void KABCore::writeToPhone( ) |
777 | { | 778 | { |
778 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 779 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
779 | message(i18n("Export to phone finished!")); | 780 | message(i18n("Export to phone finished!")); |
780 | else | 781 | else |
781 | qDebug(i18n("Error exporting to phone")); | 782 | qDebug(i18n("Error exporting to phone")); |
782 | } | 783 | } |
783 | void KABCore::beamVCard() | 784 | void KABCore::beamVCard() |
784 | { | 785 | { |
785 | QStringList uids = mViewManager->selectedUids(); | 786 | QStringList uids = mViewManager->selectedUids(); |
786 | if ( !uids.isEmpty() ) | 787 | if ( !uids.isEmpty() ) |
787 | beamVCard( uids ); | 788 | beamVCard( uids ); |
788 | } | 789 | } |
789 | 790 | ||
790 | 791 | ||
791 | void KABCore::beamVCard(const QStringList& uids) | 792 | void KABCore::beamVCard(const QStringList& uids) |
792 | { | 793 | { |
793 | 794 | ||
794 | // LR: we should use the /tmp dir on the Zaurus, | 795 | // LR: we should use the /tmp dir on the Zaurus, |
795 | // because: /tmp = RAM, (HOME)/kdepim = flash memory | 796 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
796 | 797 | ||
797 | #ifdef DESKTOP_VERSION | 798 | #ifdef DESKTOP_VERSION |
798 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | 799 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); |
799 | #else | 800 | #else |
800 | QString fileName = "/tmp/kapibeamfile.vcf"; | 801 | QString fileName = "/tmp/kapibeamfile.vcf"; |
801 | #endif | 802 | #endif |
802 | 803 | ||
803 | KABC::VCardConverter converter; | 804 | KABC::VCardConverter converter; |
804 | QString description; | 805 | QString description; |
805 | QString datastream; | 806 | QString datastream; |
806 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 807 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
807 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 808 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
808 | 809 | ||
809 | if ( a.isEmpty() ) | 810 | if ( a.isEmpty() ) |
810 | continue; | 811 | continue; |
811 | 812 | ||
812 | if (description.isEmpty()) | 813 | if (description.isEmpty()) |
813 | description = a.formattedName(); | 814 | description = a.formattedName(); |
814 | 815 | ||
815 | QString vcard; | 816 | QString vcard; |
816 | converter.addresseeToVCard( a, vcard ); | 817 | converter.addresseeToVCard( a, vcard ); |
817 | int start = 0; | 818 | int start = 0; |
818 | int next; | 819 | int next; |
819 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 820 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
820 | int semi = vcard.find(";", next); | 821 | int semi = vcard.find(";", next); |
821 | int dopp = vcard.find(":", next); | 822 | int dopp = vcard.find(":", next); |
822 | int sep; | 823 | int sep; |
823 | if ( semi < dopp && semi >= 0 ) | 824 | if ( semi < dopp && semi >= 0 ) |
824 | sep = semi ; | 825 | sep = semi ; |
825 | else | 826 | else |
826 | sep = dopp; | 827 | sep = dopp; |
827 | datastream +=vcard.mid( start, next - start); | 828 | datastream +=vcard.mid( start, next - start); |
828 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 829 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
829 | start = sep; | 830 | start = sep; |
830 | } | 831 | } |
831 | datastream += vcard.mid( start,vcard.length() ); | 832 | datastream += vcard.mid( start,vcard.length() ); |
832 | } | 833 | } |
833 | #ifndef DESKTOP_VERSION | 834 | #ifndef DESKTOP_VERSION |
834 | QFile outFile(fileName); | 835 | QFile outFile(fileName); |
835 | if ( outFile.open(IO_WriteOnly) ) { | 836 | if ( outFile.open(IO_WriteOnly) ) { |
836 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 837 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
837 | QTextStream t( &outFile ); // use a text stream | 838 | QTextStream t( &outFile ); // use a text stream |
838 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 839 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
839 | t.setEncoding( QTextStream::Latin1 ); | 840 | t.setEncoding( QTextStream::Latin1 ); |
840 | t <<datastream.latin1(); | 841 | t <<datastream.latin1(); |
841 | outFile.close(); | 842 | outFile.close(); |
842 | Ir *ir = new Ir( this ); | 843 | Ir *ir = new Ir( this ); |
843 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 844 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
844 | ir->send( fileName, description, "text/x-vCard" ); | 845 | ir->send( fileName, description, "text/x-vCard" ); |
845 | } else { | 846 | } else { |
846 | qDebug("Error open temp beam file "); | 847 | qDebug("Error open temp beam file "); |
847 | return; | 848 | return; |
848 | } | 849 | } |
849 | #endif | 850 | #endif |
850 | 851 | ||
851 | } | 852 | } |
852 | 853 | ||
853 | void KABCore::beamDone( Ir *ir ) | 854 | void KABCore::beamDone( Ir *ir ) |
854 | { | 855 | { |
855 | #ifndef DESKTOP_VERSION | 856 | #ifndef DESKTOP_VERSION |
856 | delete ir; | 857 | delete ir; |
857 | #endif | 858 | #endif |
858 | topLevelWidget()->raise(); | 859 | topLevelWidget()->raise(); |
859 | message( i18n("Beaming finished!") ); | 860 | message( i18n("Beaming finished!") ); |
860 | } | 861 | } |
861 | 862 | ||
862 | 863 | ||
863 | void KABCore::browse( const QString& url ) | 864 | void KABCore::browse( const QString& url ) |
864 | { | 865 | { |
865 | #ifndef KAB_EMBEDDED | 866 | #ifndef KAB_EMBEDDED |
866 | kapp->invokeBrowser( url ); | 867 | kapp->invokeBrowser( url ); |
867 | #else //KAB_EMBEDDED | 868 | #else //KAB_EMBEDDED |
868 | qDebug("KABCore::browse must be fixed"); | 869 | qDebug("KABCore::browse must be fixed"); |
869 | #endif //KAB_EMBEDDED | 870 | #endif //KAB_EMBEDDED |
870 | } | 871 | } |
871 | 872 | ||
872 | void KABCore::selectAllContacts() | 873 | void KABCore::selectAllContacts() |
873 | { | 874 | { |
874 | mViewManager->setSelected( QString::null, true ); | 875 | mViewManager->setSelected( QString::null, true ); |
875 | } | 876 | } |
876 | 877 | ||
877 | void KABCore::deleteContacts() | 878 | void KABCore::deleteContacts() |
878 | { | 879 | { |
879 | QStringList uidList = mViewManager->selectedUids(); | 880 | QStringList uidList = mViewManager->selectedUids(); |
880 | deleteContacts( uidList ); | 881 | deleteContacts( uidList ); |
881 | } | 882 | } |
882 | 883 | ||
883 | void KABCore::deleteContacts( const QStringList &uids ) | 884 | void KABCore::deleteContacts( const QStringList &uids ) |
884 | { | 885 | { |
885 | if ( uids.count() > 0 ) { | 886 | if ( uids.count() > 0 ) { |
886 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 887 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
887 | UndoStack::instance()->push( command ); | 888 | UndoStack::instance()->push( command ); |
888 | RedoStack::instance()->clear(); | 889 | RedoStack::instance()->clear(); |
889 | 890 | ||
890 | // now if we deleted anything, refresh | 891 | // now if we deleted anything, refresh |
891 | setContactSelected( QString::null ); | 892 | setContactSelected( QString::null ); |
892 | setModified( true ); | 893 | setModified( true ); |
893 | } | 894 | } |
894 | } | 895 | } |
895 | 896 | ||
896 | void KABCore::copyContacts() | 897 | void KABCore::copyContacts() |
897 | { | 898 | { |
898 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 899 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
899 | 900 | ||
900 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 901 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
901 | 902 | ||
902 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 903 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
903 | 904 | ||
904 | QClipboard *cb = QApplication::clipboard(); | 905 | QClipboard *cb = QApplication::clipboard(); |
905 | cb->setText( clipText ); | 906 | cb->setText( clipText ); |
906 | } | 907 | } |
907 | 908 | ||
908 | void KABCore::cutContacts() | 909 | void KABCore::cutContacts() |
909 | { | 910 | { |
910 | QStringList uidList = mViewManager->selectedUids(); | 911 | QStringList uidList = mViewManager->selectedUids(); |
911 | 912 | ||
912 | //US if ( uidList.size() > 0 ) { | 913 | //US if ( uidList.size() > 0 ) { |
913 | if ( uidList.count() > 0 ) { | 914 | if ( uidList.count() > 0 ) { |
914 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 915 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
915 | UndoStack::instance()->push( command ); | 916 | UndoStack::instance()->push( command ); |
916 | RedoStack::instance()->clear(); | 917 | RedoStack::instance()->clear(); |
917 | 918 | ||
918 | setModified( true ); | 919 | setModified( true ); |
919 | } | 920 | } |
920 | } | 921 | } |
921 | 922 | ||
922 | void KABCore::pasteContacts() | 923 | void KABCore::pasteContacts() |
923 | { | 924 | { |
924 | QClipboard *cb = QApplication::clipboard(); | 925 | QClipboard *cb = QApplication::clipboard(); |
925 | 926 | ||
926 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 927 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
927 | 928 | ||
928 | pasteContacts( list ); | 929 | pasteContacts( list ); |
929 | } | 930 | } |
930 | 931 | ||
931 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 932 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
932 | { | 933 | { |
933 | KABC::Resource *resource = requestResource( this ); | 934 | KABC::Resource *resource = requestResource( this ); |
934 | KABC::Addressee::List::Iterator it; | 935 | KABC::Addressee::List::Iterator it; |
935 | for ( it = list.begin(); it != list.end(); ++it ) | 936 | for ( it = list.begin(); it != list.end(); ++it ) |
936 | (*it).setResource( resource ); | 937 | (*it).setResource( resource ); |
937 | 938 | ||
938 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 939 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
939 | UndoStack::instance()->push( command ); | 940 | UndoStack::instance()->push( command ); |
940 | RedoStack::instance()->clear(); | 941 | RedoStack::instance()->clear(); |
941 | 942 | ||
942 | setModified( true ); | 943 | setModified( true ); |
943 | } | 944 | } |
944 | 945 | ||
945 | void KABCore::setWhoAmI() | 946 | void KABCore::setWhoAmI() |
946 | { | 947 | { |
947 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 948 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
948 | 949 | ||
949 | if ( addrList.count() > 1 ) { | 950 | if ( addrList.count() > 1 ) { |
950 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 951 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
951 | return; | 952 | return; |
952 | } | 953 | } |
953 | 954 | ||
954 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 955 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
955 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 956 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
956 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 957 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
957 | } | 958 | } |
958 | 959 | ||
959 | void KABCore::setCategories() | 960 | void KABCore::setCategories() |
960 | { | 961 | { |
961 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 962 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
962 | if ( !dlg.exec() ) | 963 | if ( !dlg.exec() ) |
963 | return; | 964 | return; |
964 | 965 | ||
965 | bool merge = false; | 966 | bool merge = false; |
966 | QString msg = i18n( "Merge with existing categories?" ); | 967 | QString msg = i18n( "Merge with existing categories?" ); |
967 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 968 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
968 | merge = true; | 969 | merge = true; |
969 | 970 | ||
970 | QStringList categories = dlg.selectedCategories(); | 971 | QStringList categories = dlg.selectedCategories(); |
971 | 972 | ||
972 | QStringList uids = mViewManager->selectedUids(); | 973 | QStringList uids = mViewManager->selectedUids(); |
973 | QStringList::Iterator it; | 974 | QStringList::Iterator it; |
974 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 975 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
975 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 976 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
976 | if ( !addr.isEmpty() ) { | 977 | if ( !addr.isEmpty() ) { |
977 | if ( !merge ) | 978 | if ( !merge ) |
978 | addr.setCategories( categories ); | 979 | addr.setCategories( categories ); |
979 | else { | 980 | else { |
980 | QStringList addrCategories = addr.categories(); | 981 | QStringList addrCategories = addr.categories(); |
981 | QStringList::Iterator catIt; | 982 | QStringList::Iterator catIt; |
982 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 983 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
983 | if ( !addrCategories.contains( *catIt ) ) | 984 | if ( !addrCategories.contains( *catIt ) ) |
984 | addrCategories.append( *catIt ); | 985 | addrCategories.append( *catIt ); |
985 | } | 986 | } |
986 | addr.setCategories( addrCategories ); | 987 | addr.setCategories( addrCategories ); |
987 | } | 988 | } |
988 | 989 | ||
989 | mAddressBook->insertAddressee( addr ); | 990 | mAddressBook->insertAddressee( addr ); |
990 | } | 991 | } |
991 | } | 992 | } |
992 | 993 | ||
993 | if ( uids.count() > 0 ) | 994 | if ( uids.count() > 0 ) |
994 | setModified( true ); | 995 | setModified( true ); |
995 | } | 996 | } |
996 | 997 | ||
997 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 998 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
998 | { | 999 | { |
999 | mIncSearchWidget->setFields( fields ); | 1000 | mIncSearchWidget->setFields( fields ); |
1000 | } | 1001 | } |
1001 | 1002 | ||
1002 | void KABCore::incrementalSearch( const QString& text ) | 1003 | void KABCore::incrementalSearch( const QString& text ) |
1003 | { | 1004 | { |
1004 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1005 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1005 | } | 1006 | } |
1006 | 1007 | ||
1007 | void KABCore::setModified() | 1008 | void KABCore::setModified() |
1008 | { | 1009 | { |
1009 | setModified( true ); | 1010 | setModified( true ); |
1010 | } | 1011 | } |
1011 | 1012 | ||
1012 | void KABCore::setModifiedWOrefresh() | 1013 | void KABCore::setModifiedWOrefresh() |
1013 | { | 1014 | { |
1014 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1015 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1015 | mModified = true; | 1016 | mModified = true; |
1016 | mActionSave->setEnabled( mModified ); | 1017 | mActionSave->setEnabled( mModified ); |
1017 | #ifdef DESKTOP_VERSION | 1018 | #ifdef DESKTOP_VERSION |
1018 | mDetails->refreshView(); | 1019 | mDetails->refreshView(); |
1019 | #endif | 1020 | #endif |
1020 | 1021 | ||
1021 | } | 1022 | } |
1022 | void KABCore::setModified( bool modified ) | 1023 | void KABCore::setModified( bool modified ) |
1023 | { | 1024 | { |
1024 | mModified = modified; | 1025 | mModified = modified; |
1025 | mActionSave->setEnabled( mModified ); | 1026 | mActionSave->setEnabled( mModified ); |
1026 | 1027 | ||
1027 | if ( modified ) | 1028 | if ( modified ) |
1028 | mJumpButtonBar->recreateButtons(); | 1029 | mJumpButtonBar->recreateButtons(); |
1029 | 1030 | ||
1030 | mViewManager->refreshView(); | 1031 | mViewManager->refreshView(); |
1031 | mDetails->refreshView(); | 1032 | mDetails->refreshView(); |
1032 | 1033 | ||
1033 | } | 1034 | } |
1034 | 1035 | ||
1035 | bool KABCore::modified() const | 1036 | bool KABCore::modified() const |
1036 | { | 1037 | { |
1037 | return mModified; | 1038 | return mModified; |
1038 | } | 1039 | } |
1039 | 1040 | ||
1040 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1041 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1041 | { | 1042 | { |
1042 | 1043 | ||
1043 | Command *command = 0; | 1044 | Command *command = 0; |
1044 | QString uid; | 1045 | QString uid; |
1045 | 1046 | ||
1046 | // check if it exists already | 1047 | // check if it exists already |
1047 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1048 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1048 | if ( origAddr.isEmpty() ) | 1049 | if ( origAddr.isEmpty() ) |
1049 | command = new PwNewCommand( mAddressBook, addr ); | 1050 | command = new PwNewCommand( mAddressBook, addr ); |
1050 | else { | 1051 | else { |
1051 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1052 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1052 | uid = addr.uid(); | 1053 | uid = addr.uid(); |
1053 | } | 1054 | } |
1054 | 1055 | ||
1055 | UndoStack::instance()->push( command ); | 1056 | UndoStack::instance()->push( command ); |
1056 | RedoStack::instance()->clear(); | 1057 | RedoStack::instance()->clear(); |
1057 | 1058 | ||
1058 | setModified( true ); | 1059 | setModified( true ); |
1059 | } | 1060 | } |
1060 | 1061 | ||
1061 | void KABCore::newContact() | 1062 | void KABCore::newContact() |
1062 | { | 1063 | { |
1063 | 1064 | ||
1064 | 1065 | ||
1065 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1066 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1066 | 1067 | ||
1067 | QPtrList<KRES::Resource> kresResources; | 1068 | QPtrList<KRES::Resource> kresResources; |
1068 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1069 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1069 | KABC::Resource *resource; | 1070 | KABC::Resource *resource; |
1070 | while ( ( resource = it.current() ) != 0 ) { | 1071 | while ( ( resource = it.current() ) != 0 ) { |
1071 | ++it; | 1072 | ++it; |
1072 | if ( !resource->readOnly() ) { | 1073 | if ( !resource->readOnly() ) { |
1073 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1074 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1074 | if ( res ) | 1075 | if ( res ) |
1075 | kresResources.append( res ); | 1076 | kresResources.append( res ); |
1076 | } | 1077 | } |
1077 | } | 1078 | } |
1078 | 1079 | ||
1079 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1080 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1080 | resource = static_cast<KABC::Resource*>( res ); | 1081 | resource = static_cast<KABC::Resource*>( res ); |
1081 | 1082 | ||
1082 | if ( resource ) { | 1083 | if ( resource ) { |
1083 | KABC::Addressee addr; | 1084 | KABC::Addressee addr; |
1084 | addr.setResource( resource ); | 1085 | addr.setResource( resource ); |
1085 | mEditorDialog->setAddressee( addr ); | 1086 | mEditorDialog->setAddressee( addr ); |
1086 | KApplication::execDialog ( mEditorDialog ); | 1087 | KApplication::execDialog ( mEditorDialog ); |
1087 | 1088 | ||
1088 | } else | 1089 | } else |
1089 | return; | 1090 | return; |
1090 | 1091 | ||
1091 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1092 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1092 | 1093 | ||
1093 | 1094 | ||
1094 | } | 1095 | } |
1095 | 1096 | ||
1096 | void KABCore::addEmail( QString aStr ) | 1097 | void KABCore::addEmail( QString aStr ) |
1097 | { | 1098 | { |
1098 | #ifndef KAB_EMBEDDED | 1099 | #ifndef KAB_EMBEDDED |
1099 | QString fullName, email; | 1100 | QString fullName, email; |
1100 | 1101 | ||
1101 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1102 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1102 | 1103 | ||
1103 | // Try to lookup the addressee matching the email address | 1104 | // Try to lookup the addressee matching the email address |
1104 | bool found = false; | 1105 | bool found = false; |
1105 | QStringList emailList; | 1106 | QStringList emailList; |
1106 | KABC::AddressBook::Iterator it; | 1107 | KABC::AddressBook::Iterator it; |
1107 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1108 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1108 | emailList = (*it).emails(); | 1109 | emailList = (*it).emails(); |
1109 | if ( emailList.contains( email ) > 0 ) { | 1110 | if ( emailList.contains( email ) > 0 ) { |
1110 | found = true; | 1111 | found = true; |
1111 | (*it).setNameFromString( fullName ); | 1112 | (*it).setNameFromString( fullName ); |
1112 | editContact( (*it).uid() ); | 1113 | editContact( (*it).uid() ); |
1113 | } | 1114 | } |
1114 | } | 1115 | } |
1115 | 1116 | ||
1116 | if ( !found ) { | 1117 | if ( !found ) { |
1117 | KABC::Addressee addr; | 1118 | KABC::Addressee addr; |
1118 | addr.setNameFromString( fullName ); | 1119 | addr.setNameFromString( fullName ); |
1119 | addr.insertEmail( email, true ); | 1120 | addr.insertEmail( email, true ); |
1120 | 1121 | ||
1121 | mAddressBook->insertAddressee( addr ); | 1122 | mAddressBook->insertAddressee( addr ); |
1122 | mViewManager->refreshView( addr.uid() ); | 1123 | mViewManager->refreshView( addr.uid() ); |
1123 | editContact( addr.uid() ); | 1124 | editContact( addr.uid() ); |
1124 | } | 1125 | } |
1125 | #else //KAB_EMBEDDED | 1126 | #else //KAB_EMBEDDED |
1126 | qDebug("KABCore::addEmail finsih method"); | 1127 | qDebug("KABCore::addEmail finsih method"); |
1127 | #endif //KAB_EMBEDDED | 1128 | #endif //KAB_EMBEDDED |
1128 | } | 1129 | } |
1129 | 1130 | ||
1130 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1131 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1131 | { | 1132 | { |
1132 | mXXPortManager->importVCard( url, showPreview ); | 1133 | mXXPortManager->importVCard( url, showPreview ); |
1133 | } | 1134 | } |
1134 | void KABCore::importFromOL() | 1135 | void KABCore::importFromOL() |
1135 | { | 1136 | { |
1136 | #ifdef _WIN32_ | 1137 | #ifdef _WIN32_ |
1137 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1138 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1138 | idgl->exec(); | 1139 | idgl->exec(); |
1139 | KABC::Addressee::List list = idgl->getAddressList(); | 1140 | KABC::Addressee::List list = idgl->getAddressList(); |
1140 | if ( list.count() > 0 ) { | 1141 | if ( list.count() > 0 ) { |
1141 | KABC::Addressee::List listNew; | 1142 | KABC::Addressee::List listNew; |
1142 | KABC::Addressee::List listExisting; | 1143 | KABC::Addressee::List listExisting; |
1143 | KABC::Addressee::List::Iterator it; | 1144 | KABC::Addressee::List::Iterator it; |
1144 | KABC::AddressBook::Iterator iter; | 1145 | KABC::AddressBook::Iterator iter; |
1145 | for ( it = list.begin(); it != list.end(); ++it ) { | 1146 | for ( it = list.begin(); it != list.end(); ++it ) { |
1146 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1147 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1147 | listNew.append( (*it) ); | 1148 | listNew.append( (*it) ); |
1148 | else | 1149 | else |
1149 | listExisting.append( (*it) ); | 1150 | listExisting.append( (*it) ); |
1150 | } | 1151 | } |
1151 | if ( listExisting.count() > 0 ) | 1152 | if ( listExisting.count() > 0 ) |
1152 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1153 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1153 | if ( listNew.count() > 0 ) { | 1154 | if ( listNew.count() > 0 ) { |
1154 | pasteWithNewUid = false; | 1155 | pasteWithNewUid = false; |
1155 | pasteContacts( listNew ); | 1156 | pasteContacts( listNew ); |
1156 | pasteWithNewUid = true; | 1157 | pasteWithNewUid = true; |
1157 | } | 1158 | } |
1158 | } | 1159 | } |
1159 | delete idgl; | 1160 | delete idgl; |
1160 | #endif | 1161 | #endif |
1161 | } | 1162 | } |
1162 | 1163 | ||
1163 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1164 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1164 | { | 1165 | { |
1165 | mXXPortManager->importVCard( vCard, showPreview ); | 1166 | mXXPortManager->importVCard( vCard, showPreview ); |
1166 | } | 1167 | } |
1167 | 1168 | ||
1168 | //US added a second method without defaultparameter | 1169 | //US added a second method without defaultparameter |
1169 | void KABCore::editContact2() { | 1170 | void KABCore::editContact2() { |
1170 | editContact( QString::null ); | 1171 | editContact( QString::null ); |
1171 | } | 1172 | } |
1172 | 1173 | ||
1173 | void KABCore::editContact( const QString &uid ) | 1174 | void KABCore::editContact( const QString &uid ) |
1174 | { | 1175 | { |
1175 | 1176 | ||
1176 | if ( mExtensionManager->isQuickEditVisible() ) | 1177 | if ( mExtensionManager->isQuickEditVisible() ) |
1177 | return; | 1178 | return; |
1178 | 1179 | ||
1179 | // First, locate the contact entry | 1180 | // First, locate the contact entry |
1180 | QString localUID = uid; | 1181 | QString localUID = uid; |
1181 | if ( localUID.isNull() ) { | 1182 | if ( localUID.isNull() ) { |
1182 | QStringList uidList = mViewManager->selectedUids(); | 1183 | QStringList uidList = mViewManager->selectedUids(); |
1183 | if ( uidList.count() > 0 ) | 1184 | if ( uidList.count() > 0 ) |
1184 | localUID = *( uidList.at( 0 ) ); | 1185 | localUID = *( uidList.at( 0 ) ); |
1185 | } | 1186 | } |
1186 | 1187 | ||
1187 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1188 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1188 | if ( !addr.isEmpty() ) { | 1189 | if ( !addr.isEmpty() ) { |
1189 | mEditorDialog->setAddressee( addr ); | 1190 | mEditorDialog->setAddressee( addr ); |
1190 | KApplication::execDialog ( mEditorDialog ); | 1191 | KApplication::execDialog ( mEditorDialog ); |
1191 | } | 1192 | } |
1192 | } | 1193 | } |
1193 | 1194 | ||
1194 | /** | 1195 | /** |
1195 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1196 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1196 | the method will try to find a selected addressee in the view. | 1197 | the method will try to find a selected addressee in the view. |
1197 | */ | 1198 | */ |
1198 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1199 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1199 | { | 1200 | { |
1200 | if ( mMultipleViewsAtOnce ) | 1201 | if ( mMultipleViewsAtOnce ) |
1201 | { | 1202 | { |
1202 | editContact( uid ); | 1203 | editContact( uid ); |
1203 | } | 1204 | } |
1204 | else | 1205 | else |
1205 | { | 1206 | { |
1206 | setDetailsVisible( true ); | 1207 | setDetailsVisible( true ); |
1207 | mActionDetails->setChecked(true); | 1208 | mActionDetails->setChecked(true); |
1208 | } | 1209 | } |
1209 | 1210 | ||
1210 | } | 1211 | } |
1211 | 1212 | ||
1212 | void KABCore::save() | 1213 | void KABCore::save() |
1213 | { | 1214 | { |
1214 | if (syncManager->blockSave()) | 1215 | if (syncManager->blockSave()) |
1215 | return; | 1216 | return; |
1216 | if ( !mModified ) | 1217 | if ( !mModified ) |
1217 | return; | 1218 | return; |
1218 | 1219 | ||
1219 | syncManager->setBlockSave(true); | 1220 | syncManager->setBlockSave(true); |
1220 | QString text = i18n( "There was an error while attempting to save\n the " | 1221 | QString text = i18n( "There was an error while attempting to save\n the " |
1221 | "address book. Please check that some \nother application is " | 1222 | "address book. Please check that some \nother application is " |
1222 | "not using it. " ); | 1223 | "not using it. " ); |
1223 | message(i18n("Saving addressbook ... ")); | 1224 | message(i18n("Saving addressbook ... ")); |
1224 | #ifndef KAB_EMBEDDED | 1225 | #ifndef KAB_EMBEDDED |
1225 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1226 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1226 | if ( !b || !b->save() ) { | 1227 | if ( !b || !b->save() ) { |
1227 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1228 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1228 | } | 1229 | } |
1229 | #else //KAB_EMBEDDED | 1230 | #else //KAB_EMBEDDED |
1230 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1231 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1231 | if ( !b || !b->save() ) { | 1232 | if ( !b || !b->save() ) { |
1232 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1233 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1233 | } | 1234 | } |
1234 | #endif //KAB_EMBEDDED | 1235 | #endif //KAB_EMBEDDED |
1235 | 1236 | ||
1236 | message(i18n("Addressbook saved!")); | 1237 | message(i18n("Addressbook saved!")); |
1237 | setModified( false ); | 1238 | setModified( false ); |
1238 | syncManager->setBlockSave(false); | 1239 | syncManager->setBlockSave(false); |
1239 | } | 1240 | } |
1240 | 1241 | ||
1241 | 1242 | ||
1242 | void KABCore::undo() | 1243 | void KABCore::undo() |
1243 | { | 1244 | { |
1244 | UndoStack::instance()->undo(); | 1245 | UndoStack::instance()->undo(); |
1245 | 1246 | ||
1246 | // Refresh the view | 1247 | // Refresh the view |
1247 | mViewManager->refreshView(); | 1248 | mViewManager->refreshView(); |
1248 | } | 1249 | } |
1249 | 1250 | ||
1250 | void KABCore::redo() | 1251 | void KABCore::redo() |
1251 | { | 1252 | { |
1252 | RedoStack::instance()->redo(); | 1253 | RedoStack::instance()->redo(); |
1253 | 1254 | ||
1254 | // Refresh the view | 1255 | // Refresh the view |
1255 | mViewManager->refreshView(); | 1256 | mViewManager->refreshView(); |
1256 | } | 1257 | } |
1257 | 1258 | ||
1258 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1259 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1259 | { | 1260 | { |
1260 | if (mMultipleViewsAtOnce) | 1261 | if (mMultipleViewsAtOnce) |
1261 | { | 1262 | { |
1262 | if ( visible ) | 1263 | if ( visible ) |
1263 | mJumpButtonBar->show(); | 1264 | mJumpButtonBar->show(); |
1264 | else | 1265 | else |
1265 | mJumpButtonBar->hide(); | 1266 | mJumpButtonBar->hide(); |
1266 | } | 1267 | } |
1267 | else | 1268 | else |
1268 | { | 1269 | { |
1269 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1270 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1270 | if (mViewManager->isVisible()) | 1271 | if (mViewManager->isVisible()) |
1271 | { | 1272 | { |
1272 | if ( visible ) | 1273 | if ( visible ) |
1273 | mJumpButtonBar->show(); | 1274 | mJumpButtonBar->show(); |
1274 | else | 1275 | else |
1275 | mJumpButtonBar->hide(); | 1276 | mJumpButtonBar->hide(); |
1276 | } | 1277 | } |
1277 | else | 1278 | else |
1278 | { | 1279 | { |
1279 | mJumpButtonBar->hide(); | 1280 | mJumpButtonBar->hide(); |
1280 | } | 1281 | } |
1281 | } | 1282 | } |
1282 | } | 1283 | } |
1283 | 1284 | ||
1284 | 1285 | ||
1285 | void KABCore::setDetailsToState() | 1286 | void KABCore::setDetailsToState() |
1286 | { | 1287 | { |
1287 | setDetailsVisible( mActionDetails->isChecked() ); | 1288 | setDetailsVisible( mActionDetails->isChecked() ); |
1288 | } | 1289 | } |
1290 | void KABCore::setDetailsToggle() | ||
1291 | { | ||
1292 | mActionDetails->setChecked( !mActionDetails->isChecked() ); | ||
1293 | setDetailsToState(); | ||
1294 | } | ||
1289 | 1295 | ||
1290 | 1296 | ||
1291 | 1297 | ||
1292 | void KABCore::setDetailsVisible( bool visible ) | 1298 | void KABCore::setDetailsVisible( bool visible ) |
1293 | { | 1299 | { |
1294 | if (visible && mDetails->isHidden()) | 1300 | if (visible && mDetails->isHidden()) |
1295 | { | 1301 | { |
1296 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1302 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1297 | if ( addrList.count() > 0 ) | 1303 | if ( addrList.count() > 0 ) |
1298 | mDetails->setAddressee( addrList[ 0 ] ); | 1304 | mDetails->setAddressee( addrList[ 0 ] ); |
1299 | } | 1305 | } |
1300 | 1306 | ||
1301 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1307 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1302 | // the listview and the detailview. We do that by changing the splitbar size. | 1308 | // the listview and the detailview. We do that by changing the splitbar size. |
1303 | if (mMultipleViewsAtOnce) | 1309 | if (mMultipleViewsAtOnce) |
1304 | { | 1310 | { |
1305 | if ( visible ) | 1311 | if ( visible ) |
1306 | mDetails->show(); | 1312 | mDetails->show(); |
1307 | else | 1313 | else |
1308 | mDetails->hide(); | 1314 | mDetails->hide(); |
1309 | } | 1315 | } |
1310 | else | 1316 | else |
1311 | { | 1317 | { |
1312 | if ( visible ) { | 1318 | if ( visible ) { |
1313 | mViewManager->hide(); | 1319 | mViewManager->hide(); |
1314 | mDetails->show(); | 1320 | mDetails->show(); |
1315 | mIncSearchWidget->setFocus(); | 1321 | mIncSearchWidget->setFocus(); |
1316 | } | 1322 | } |
1317 | else { | 1323 | else { |
1318 | mViewManager->show(); | 1324 | mViewManager->show(); |
1319 | mDetails->hide(); | 1325 | mDetails->hide(); |
1320 | mViewManager->setFocusAV(); | 1326 | mViewManager->setFocusAV(); |
1321 | } | 1327 | } |
1322 | setJumpButtonBarVisible( !visible ); | 1328 | setJumpButtonBarVisible( !visible ); |
1323 | } | 1329 | } |
1324 | 1330 | ||
1325 | } | 1331 | } |
1326 | 1332 | ||
1327 | void KABCore::extensionChanged( int id ) | 1333 | void KABCore::extensionChanged( int id ) |
1328 | { | 1334 | { |
1329 | //change the details view only for non desktop systems | 1335 | //change the details view only for non desktop systems |
1330 | #ifndef DESKTOP_VERSION | 1336 | #ifndef DESKTOP_VERSION |
1331 | 1337 | ||
1332 | if (id == 0) | 1338 | if (id == 0) |
1333 | { | 1339 | { |
1334 | //the user disabled the extension. | 1340 | //the user disabled the extension. |
1335 | 1341 | ||
1336 | if (mMultipleViewsAtOnce) | 1342 | if (mMultipleViewsAtOnce) |
1337 | { // enable detailsview again | 1343 | { // enable detailsview again |
1338 | setDetailsVisible( true ); | 1344 | setDetailsVisible( true ); |
1339 | mActionDetails->setChecked( true ); | 1345 | mActionDetails->setChecked( true ); |
1340 | } | 1346 | } |
1341 | else | 1347 | else |
1342 | { //go back to the listview | 1348 | { //go back to the listview |
1343 | setDetailsVisible( false ); | 1349 | setDetailsVisible( false ); |
1344 | mActionDetails->setChecked( false ); | 1350 | mActionDetails->setChecked( false ); |
1345 | mActionDetails->setEnabled(true); | 1351 | mActionDetails->setEnabled(true); |
1346 | } | 1352 | } |
1347 | 1353 | ||
1348 | } | 1354 | } |
1349 | else | 1355 | else |
1350 | { | 1356 | { |
1351 | //the user enabled the extension. | 1357 | //the user enabled the extension. |
1352 | setDetailsVisible( false ); | 1358 | setDetailsVisible( false ); |
1353 | mActionDetails->setChecked( false ); | 1359 | mActionDetails->setChecked( false ); |
1354 | 1360 | ||
1355 | if (!mMultipleViewsAtOnce) | 1361 | if (!mMultipleViewsAtOnce) |
1356 | { | 1362 | { |
1357 | mActionDetails->setEnabled(false); | 1363 | mActionDetails->setEnabled(false); |
1358 | } | 1364 | } |
1359 | 1365 | ||
1360 | mExtensionManager->setSelectionChanged(); | 1366 | mExtensionManager->setSelectionChanged(); |
1361 | 1367 | ||
1362 | } | 1368 | } |
1363 | 1369 | ||
1364 | #endif// DESKTOP_VERSION | 1370 | #endif// DESKTOP_VERSION |
1365 | 1371 | ||
1366 | } | 1372 | } |
1367 | 1373 | ||
1368 | 1374 | ||
1369 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1375 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1370 | { | 1376 | { |
1371 | 1377 | ||
1372 | if ( list.count() != 0 ) { | 1378 | if ( list.count() != 0 ) { |
1373 | KABC::Addressee::List::ConstIterator it; | 1379 | KABC::Addressee::List::ConstIterator it; |
1374 | for ( it = list.begin(); it != list.end(); ++it ) | 1380 | for ( it = list.begin(); it != list.end(); ++it ) |
1375 | mAddressBook->insertAddressee( *it ); | 1381 | mAddressBook->insertAddressee( *it ); |
1376 | if ( list.count() > 1 ) | 1382 | if ( list.count() > 1 ) |
1377 | setModified(); | 1383 | setModified(); |
1378 | else | 1384 | else |
1379 | setModifiedWOrefresh(); | 1385 | setModifiedWOrefresh(); |
1380 | } | 1386 | } |
1381 | if ( list.count() == 0 ) | 1387 | if ( list.count() == 0 ) |
1382 | mViewManager->refreshView(); | 1388 | mViewManager->refreshView(); |
1383 | else | 1389 | else |
1384 | mViewManager->refreshView( list[ 0 ].uid() ); | 1390 | mViewManager->refreshView( list[ 0 ].uid() ); |
1385 | 1391 | ||
1386 | 1392 | ||
1387 | 1393 | ||
1388 | } | 1394 | } |
1389 | 1395 | ||
1390 | QString KABCore::getNameByPhone( const QString &phone ) | 1396 | QString KABCore::getNameByPhone( const QString &phone ) |
1391 | { | 1397 | { |
1392 | #ifndef KAB_EMBEDDED | 1398 | #ifndef KAB_EMBEDDED |
1393 | QRegExp r( "[/*/-/ ]" ); | 1399 | QRegExp r( "[/*/-/ ]" ); |
1394 | QString localPhone( phone ); | 1400 | QString localPhone( phone ); |
1395 | 1401 | ||
1396 | bool found = false; | 1402 | bool found = false; |
1397 | QString ownerName = ""; | 1403 | QString ownerName = ""; |
1398 | KABC::AddressBook::Iterator iter; | 1404 | KABC::AddressBook::Iterator iter; |
1399 | KABC::PhoneNumber::List::Iterator phoneIter; | 1405 | KABC::PhoneNumber::List::Iterator phoneIter; |
1400 | KABC::PhoneNumber::List phoneList; | 1406 | KABC::PhoneNumber::List phoneList; |
1401 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1407 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1402 | phoneList = (*iter).phoneNumbers(); | 1408 | phoneList = (*iter).phoneNumbers(); |
1403 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1409 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1404 | ++phoneIter) { | 1410 | ++phoneIter) { |
1405 | // Get rid of separator chars so just the numbers are compared. | 1411 | // Get rid of separator chars so just the numbers are compared. |
1406 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1412 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1407 | ownerName = (*iter).formattedName(); | 1413 | ownerName = (*iter).formattedName(); |
1408 | found = true; | 1414 | found = true; |
1409 | } | 1415 | } |
1410 | } | 1416 | } |
1411 | } | 1417 | } |
1412 | 1418 | ||
1413 | return ownerName; | 1419 | return ownerName; |
1414 | #else //KAB_EMBEDDED | 1420 | #else //KAB_EMBEDDED |
1415 | qDebug("KABCore::getNameByPhone finsih method"); | 1421 | qDebug("KABCore::getNameByPhone finsih method"); |
1416 | return ""; | 1422 | return ""; |
1417 | #endif //KAB_EMBEDDED | 1423 | #endif //KAB_EMBEDDED |
1418 | 1424 | ||
1419 | } | 1425 | } |
1420 | 1426 | ||
1421 | void KABCore::openConfigDialog() | 1427 | void KABCore::openConfigDialog() |
1422 | { | 1428 | { |
1423 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1429 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1424 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1430 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1425 | ConfigureDialog->addModule(kabcfg ); | 1431 | ConfigureDialog->addModule(kabcfg ); |
1426 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1432 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1427 | ConfigureDialog->addModule(kdelibcfg ); | 1433 | ConfigureDialog->addModule(kdelibcfg ); |
1428 | 1434 | ||
1429 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1435 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1430 | this, SLOT( configurationChanged() ) ); | 1436 | this, SLOT( configurationChanged() ) ); |
1431 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1437 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1432 | this, SLOT( configurationChanged() ) ); | 1438 | this, SLOT( configurationChanged() ) ); |
1433 | saveSettings(); | 1439 | saveSettings(); |
1434 | #ifndef DESKTOP_VERSION | 1440 | #ifndef DESKTOP_VERSION |
1435 | ConfigureDialog->showMaximized(); | 1441 | ConfigureDialog->showMaximized(); |
1436 | #endif | 1442 | #endif |
1437 | if ( ConfigureDialog->exec() ) | 1443 | if ( ConfigureDialog->exec() ) |
1438 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1444 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1439 | delete ConfigureDialog; | 1445 | delete ConfigureDialog; |
1440 | } | 1446 | } |
1441 | 1447 | ||
1442 | void KABCore::openLDAPDialog() | 1448 | void KABCore::openLDAPDialog() |
1443 | { | 1449 | { |
1444 | #ifndef KAB_EMBEDDED | 1450 | #ifndef KAB_EMBEDDED |
1445 | if ( !mLdapSearchDialog ) { | 1451 | if ( !mLdapSearchDialog ) { |
1446 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1452 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1447 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1453 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1448 | SLOT( refreshView() ) ); | 1454 | SLOT( refreshView() ) ); |
1449 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1455 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1450 | SLOT( setModified() ) ); | 1456 | SLOT( setModified() ) ); |
1451 | } else | 1457 | } else |
1452 | mLdapSearchDialog->restoreSettings(); | 1458 | mLdapSearchDialog->restoreSettings(); |
1453 | 1459 | ||
1454 | if ( mLdapSearchDialog->isOK() ) | 1460 | if ( mLdapSearchDialog->isOK() ) |
1455 | mLdapSearchDialog->exec(); | 1461 | mLdapSearchDialog->exec(); |
1456 | #else //KAB_EMBEDDED | 1462 | #else //KAB_EMBEDDED |
1457 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1463 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1458 | #endif //KAB_EMBEDDED | 1464 | #endif //KAB_EMBEDDED |
1459 | } | 1465 | } |
1460 | 1466 | ||
1461 | void KABCore::print() | 1467 | void KABCore::print() |
1462 | { | 1468 | { |
1463 | #ifndef KAB_EMBEDDED | 1469 | #ifndef KAB_EMBEDDED |
1464 | KPrinter printer; | 1470 | KPrinter printer; |
1465 | if ( !printer.setup( this ) ) | 1471 | if ( !printer.setup( this ) ) |
1466 | return; | 1472 | return; |
1467 | 1473 | ||
1468 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1474 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1469 | mViewManager->selectedUids(), this ); | 1475 | mViewManager->selectedUids(), this ); |
1470 | 1476 | ||
1471 | wizard.exec(); | 1477 | wizard.exec(); |
1472 | #else //KAB_EMBEDDED | 1478 | #else //KAB_EMBEDDED |
1473 | qDebug("KABCore::print() finsih method"); | 1479 | qDebug("KABCore::print() finsih method"); |
1474 | #endif //KAB_EMBEDDED | 1480 | #endif //KAB_EMBEDDED |
1475 | 1481 | ||
1476 | } | 1482 | } |
1477 | 1483 | ||
1478 | 1484 | ||
1479 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1485 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1480 | { | 1486 | { |
1481 | if ( mGUIClient ) | 1487 | if ( mGUIClient ) |
1482 | mGUIClient->insertChildClient( client ); | 1488 | mGUIClient->insertChildClient( client ); |
1483 | else | 1489 | else |
1484 | KMessageBox::error( this, "no KXMLGUICLient"); | 1490 | KMessageBox::error( this, "no KXMLGUICLient"); |
1485 | } | 1491 | } |
1486 | 1492 | ||
1487 | 1493 | ||
1488 | void KABCore::configurationChanged() | 1494 | void KABCore::configurationChanged() |
1489 | { | 1495 | { |
1490 | mExtensionManager->reconfigure(); | 1496 | mExtensionManager->reconfigure(); |
1491 | } | 1497 | } |
1492 | 1498 | ||
1493 | void KABCore::addressBookChanged() | 1499 | void KABCore::addressBookChanged() |
1494 | { | 1500 | { |
1495 | /*US | 1501 | /*US |
1496 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1502 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1497 | while ( it.current() ) { | 1503 | while ( it.current() ) { |
1498 | if ( it.current()->dirty() ) { | 1504 | if ( it.current()->dirty() ) { |
1499 | QString text = i18n( "Data has been changed externally. Unsaved " | 1505 | QString text = i18n( "Data has been changed externally. Unsaved " |
1500 | "changes will be lost." ); | 1506 | "changes will be lost." ); |
1501 | KMessageBox::information( this, text ); | 1507 | KMessageBox::information( this, text ); |
1502 | } | 1508 | } |
1503 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1509 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1504 | ++it; | 1510 | ++it; |
1505 | } | 1511 | } |
1506 | */ | 1512 | */ |
1507 | if (mEditorDialog) | 1513 | if (mEditorDialog) |
1508 | { | 1514 | { |
1509 | if (mEditorDialog->dirty()) | 1515 | if (mEditorDialog->dirty()) |
1510 | { | 1516 | { |
1511 | QString text = i18n( "Data has been changed externally. Unsaved " | 1517 | QString text = i18n( "Data has been changed externally. Unsaved " |
1512 | "changes will be lost." ); | 1518 | "changes will be lost." ); |
1513 | KMessageBox::information( this, text ); | 1519 | KMessageBox::information( this, text ); |
1514 | } | 1520 | } |
1515 | QString currentuid = mEditorDialog->addressee().uid(); | 1521 | QString currentuid = mEditorDialog->addressee().uid(); |
1516 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1522 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1517 | } | 1523 | } |
1518 | mViewManager->refreshView(); | 1524 | mViewManager->refreshView(); |
1519 | // mDetails->refreshView(); | 1525 | // mDetails->refreshView(); |
1520 | 1526 | ||
1521 | 1527 | ||
1522 | } | 1528 | } |
1523 | 1529 | ||
1524 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1530 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1525 | const char *name ) | 1531 | const char *name ) |
1526 | { | 1532 | { |
1527 | 1533 | ||
1528 | if ( mEditorDialog == 0 ) { | 1534 | if ( mEditorDialog == 0 ) { |
1529 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1535 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1530 | name ? name : "editorDialog" ); | 1536 | name ? name : "editorDialog" ); |
1531 | 1537 | ||
1532 | 1538 | ||
1533 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1539 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1534 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1540 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1535 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1541 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1536 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1542 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1537 | } | 1543 | } |
1538 | 1544 | ||
1539 | return mEditorDialog; | 1545 | return mEditorDialog; |
1540 | } | 1546 | } |
1541 | 1547 | ||
1542 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1548 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1543 | { | 1549 | { |
1544 | //mEditorDict.remove( uid ); | 1550 | //mEditorDict.remove( uid ); |
1545 | } | 1551 | } |
1546 | 1552 | ||
1547 | void KABCore::initGUI() | 1553 | void KABCore::initGUI() |
1548 | { | 1554 | { |
1549 | #ifndef KAB_EMBEDDED | 1555 | #ifndef KAB_EMBEDDED |
1550 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1556 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1551 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1557 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1552 | 1558 | ||
1553 | mExtensionBarSplitter = new QSplitter( this ); | 1559 | mExtensionBarSplitter = new QSplitter( this ); |
1554 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1560 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1555 | 1561 | ||
1556 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1562 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1557 | 1563 | ||
1558 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1564 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1559 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1565 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1560 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1566 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1561 | SLOT( incrementalSearch( const QString& ) ) ); | 1567 | SLOT( incrementalSearch( const QString& ) ) ); |
1562 | 1568 | ||
1563 | mViewManager = new ViewManager( this, viewSpace ); | 1569 | mViewManager = new ViewManager( this, viewSpace ); |
1564 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1570 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1565 | 1571 | ||
1566 | mDetails = new ViewContainer( mDetailsSplitter ); | 1572 | mDetails = new ViewContainer( mDetailsSplitter ); |
1567 | 1573 | ||
1568 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1574 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1569 | 1575 | ||
1570 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1576 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1571 | 1577 | ||
1572 | topLayout->addWidget( mExtensionBarSplitter ); | 1578 | topLayout->addWidget( mExtensionBarSplitter ); |
1573 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1579 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1574 | topLayout->addWidget( mJumpButtonBar ); | 1580 | topLayout->addWidget( mJumpButtonBar ); |
1575 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1581 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1576 | 1582 | ||
1577 | mXXPortManager = new XXPortManager( this, this ); | 1583 | mXXPortManager = new XXPortManager( this, this ); |
1578 | 1584 | ||
1579 | #else //KAB_EMBEDDED | 1585 | #else //KAB_EMBEDDED |
1580 | //US initialize viewMenu before settingup viewmanager. | 1586 | //US initialize viewMenu before settingup viewmanager. |
1581 | // Viewmanager needs this menu to plugin submenues. | 1587 | // Viewmanager needs this menu to plugin submenues. |
1582 | viewMenu = new QPopupMenu( this ); | 1588 | viewMenu = new QPopupMenu( this ); |
1583 | settingsMenu = new QPopupMenu( this ); | 1589 | settingsMenu = new QPopupMenu( this ); |
1584 | //filterMenu = new QPopupMenu( this ); | 1590 | //filterMenu = new QPopupMenu( this ); |
1585 | ImportMenu = new QPopupMenu( this ); | 1591 | ImportMenu = new QPopupMenu( this ); |
1586 | ExportMenu = new QPopupMenu( this ); | 1592 | ExportMenu = new QPopupMenu( this ); |
1587 | syncMenu = new QPopupMenu( this ); | 1593 | syncMenu = new QPopupMenu( this ); |
1588 | changeMenu= new QPopupMenu( this ); | 1594 | changeMenu= new QPopupMenu( this ); |
1589 | 1595 | ||
1590 | //US since we have no splitter for the embedded system, setup | 1596 | //US since we have no splitter for the embedded system, setup |
1591 | // a layout with two frames. One left and one right. | 1597 | // a layout with two frames. One left and one right. |
1592 | 1598 | ||
1593 | QBoxLayout *topLayout; | 1599 | QBoxLayout *topLayout; |
1594 | 1600 | ||
1595 | // = new QHBoxLayout( this ); | 1601 | // = new QHBoxLayout( this ); |
1596 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1602 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1597 | 1603 | ||
1598 | // QWidget *mainBox = new QWidget( this ); | 1604 | // QWidget *mainBox = new QWidget( this ); |
1599 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1605 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1600 | 1606 | ||
1601 | #ifdef DESKTOP_VERSION | 1607 | #ifdef DESKTOP_VERSION |
1602 | topLayout = new QHBoxLayout( this ); | 1608 | topLayout = new QHBoxLayout( this ); |
1603 | 1609 | ||
1604 | 1610 | ||
1605 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1611 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1606 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1612 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1607 | 1613 | ||
1608 | topLayout->addWidget(mMiniSplitter ); | 1614 | topLayout->addWidget(mMiniSplitter ); |
1609 | 1615 | ||
1610 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1616 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1611 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1617 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1612 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1618 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1613 | mDetails = new ViewContainer( mMiniSplitter ); | 1619 | mDetails = new ViewContainer( mMiniSplitter ); |
1614 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1620 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1615 | #else | 1621 | #else |
1616 | if ( QApplication::desktop()->width() > 480 ) { | 1622 | if ( QApplication::desktop()->width() > 480 ) { |
1617 | topLayout = new QHBoxLayout( this ); | 1623 | topLayout = new QHBoxLayout( this ); |
1618 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1624 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1619 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1625 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1620 | } else { | 1626 | } else { |
1621 | 1627 | ||
1622 | topLayout = new QHBoxLayout( this ); | 1628 | topLayout = new QHBoxLayout( this ); |
1623 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1629 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1624 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1630 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1625 | } | 1631 | } |
1626 | 1632 | ||
1627 | topLayout->addWidget(mMiniSplitter ); | 1633 | topLayout->addWidget(mMiniSplitter ); |
1628 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1634 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1629 | mDetails = new ViewContainer( mMiniSplitter ); | 1635 | mDetails = new ViewContainer( mMiniSplitter ); |
1630 | 1636 | ||
1631 | 1637 | ||
1632 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1638 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1633 | #endif | 1639 | #endif |
1634 | //eh->hide(); | 1640 | //eh->hide(); |
1635 | // topLayout->addWidget(mExtensionManager ); | 1641 | // topLayout->addWidget(mExtensionManager ); |
1636 | 1642 | ||
1637 | 1643 | ||
1638 | /*US | 1644 | /*US |
1639 | #ifndef KAB_NOSPLITTER | 1645 | #ifndef KAB_NOSPLITTER |
1640 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1646 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1641 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1647 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1642 | topLayout->setSpacing( 10 ); | 1648 | topLayout->setSpacing( 10 ); |
1643 | 1649 | ||
1644 | mDetailsSplitter = new QSplitter( this ); | 1650 | mDetailsSplitter = new QSplitter( this ); |
1645 | 1651 | ||
1646 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1652 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1647 | 1653 | ||
1648 | mViewManager = new ViewManager( this, viewSpace ); | 1654 | mViewManager = new ViewManager( this, viewSpace ); |
1649 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1655 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1650 | 1656 | ||
1651 | mDetails = new ViewContainer( mDetailsSplitter ); | 1657 | mDetails = new ViewContainer( mDetailsSplitter ); |
1652 | 1658 | ||
1653 | topLayout->addWidget( mDetailsSplitter ); | 1659 | topLayout->addWidget( mDetailsSplitter ); |
1654 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1660 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1655 | #else //KAB_NOSPLITTER | 1661 | #else //KAB_NOSPLITTER |
1656 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1662 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1657 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1663 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1658 | topLayout->setSpacing( 10 ); | 1664 | topLayout->setSpacing( 10 ); |
1659 | 1665 | ||
1660 | // mDetailsSplitter = new QSplitter( this ); | 1666 | // mDetailsSplitter = new QSplitter( this ); |
1661 | 1667 | ||
1662 | QVBox *viewSpace = new QVBox( this ); | 1668 | QVBox *viewSpace = new QVBox( this ); |
1663 | 1669 | ||
1664 | mViewManager = new ViewManager( this, viewSpace ); | 1670 | mViewManager = new ViewManager( this, viewSpace ); |
1665 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1671 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1666 | 1672 | ||
1667 | mDetails = new ViewContainer( this ); | 1673 | mDetails = new ViewContainer( this ); |
1668 | 1674 | ||
1669 | topLayout->addWidget( viewSpace ); | 1675 | topLayout->addWidget( viewSpace ); |
1670 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1676 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1671 | topLayout->addWidget( mDetails ); | 1677 | topLayout->addWidget( mDetails ); |
1672 | #endif //KAB_NOSPLITTER | 1678 | #endif //KAB_NOSPLITTER |
1673 | */ | 1679 | */ |
1674 | 1680 | ||
1675 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1681 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1676 | syncManager->setBlockSave(false); | 1682 | syncManager->setBlockSave(false); |
1677 | 1683 | ||
1678 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1684 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1679 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1685 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1680 | syncManager->setDefaultFileName( sentSyncFile()); | 1686 | syncManager->setDefaultFileName( sentSyncFile()); |
1681 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1687 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1682 | 1688 | ||
1683 | #endif //KAB_EMBEDDED | 1689 | #endif //KAB_EMBEDDED |
1684 | initActions(); | 1690 | initActions(); |
1685 | 1691 | ||
1686 | #ifdef KAB_EMBEDDED | 1692 | #ifdef KAB_EMBEDDED |
1687 | addActionsManually(); | 1693 | addActionsManually(); |
1688 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1694 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1689 | mXXPortManager = new XXPortManager( this, this ); | 1695 | mXXPortManager = new XXPortManager( this, this ); |
1690 | 1696 | ||
1691 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1697 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1692 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1698 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1693 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1699 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1694 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1700 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1695 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1701 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1696 | // mIncSearchWidget->hide(); | 1702 | // mIncSearchWidget->hide(); |
1697 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1703 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1698 | SLOT( incrementalSearch( const QString& ) ) ); | 1704 | SLOT( incrementalSearch( const QString& ) ) ); |
1699 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); | 1705 | connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); |
1700 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); | 1706 | connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); |
1701 | 1707 | ||
1702 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1708 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1703 | 1709 | ||
1704 | topLayout->addWidget( mJumpButtonBar ); | 1710 | topLayout->addWidget( mJumpButtonBar ); |
1705 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1711 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1706 | 1712 | ||
1707 | // mMainWindow->getIconToolBar()->raise(); | 1713 | // mMainWindow->getIconToolBar()->raise(); |
1708 | 1714 | ||
1709 | #endif //KAB_EMBEDDED | 1715 | #endif //KAB_EMBEDDED |
1710 | 1716 | ||
1711 | } | 1717 | } |
1712 | void KABCore::initActions() | 1718 | void KABCore::initActions() |
1713 | { | 1719 | { |
1714 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1720 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1715 | 1721 | ||
1716 | #ifndef KAB_EMBEDDED | 1722 | #ifndef KAB_EMBEDDED |
1717 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1723 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1718 | SLOT( clipboardDataChanged() ) ); | 1724 | SLOT( clipboardDataChanged() ) ); |
1719 | #endif //KAB_EMBEDDED | 1725 | #endif //KAB_EMBEDDED |
1720 | 1726 | ||
1721 | // file menu | 1727 | // file menu |
1722 | if ( mIsPart ) { | 1728 | if ( mIsPart ) { |
1723 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1729 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1724 | SLOT( sendMail() ), actionCollection(), | 1730 | SLOT( sendMail() ), actionCollection(), |
1725 | "kaddressbook_mail" ); | 1731 | "kaddressbook_mail" ); |
1726 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1732 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1727 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1733 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1728 | 1734 | ||
1729 | } else { | 1735 | } else { |
1730 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1736 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1731 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1737 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1732 | } | 1738 | } |
1733 | 1739 | ||
1734 | 1740 | ||
1735 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1741 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1736 | SLOT( save() ), actionCollection(), "file_sync" ); | 1742 | SLOT( save() ), actionCollection(), "file_sync" ); |
1737 | 1743 | ||
1738 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1744 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1739 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1745 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1740 | 1746 | ||
1741 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1747 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1742 | this, SLOT( mailVCard() ), | 1748 | this, SLOT( mailVCard() ), |
1743 | actionCollection(), "file_mail_vcard"); | 1749 | actionCollection(), "file_mail_vcard"); |
1744 | 1750 | ||
1745 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1751 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1746 | SLOT( export2phone() ), actionCollection(), | 1752 | SLOT( export2phone() ), actionCollection(), |
1747 | "kaddressbook_ex2phone" ); | 1753 | "kaddressbook_ex2phone" ); |
1748 | 1754 | ||
1749 | mActionBeamVCard = 0; | 1755 | mActionBeamVCard = 0; |
1750 | mActionBeam = 0; | 1756 | mActionBeam = 0; |
1751 | 1757 | ||
1752 | #ifndef DESKTOP_VERSION | 1758 | #ifndef DESKTOP_VERSION |
1753 | if ( Ir::supported() ) { | 1759 | if ( Ir::supported() ) { |
1754 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1760 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1755 | SLOT( beamVCard() ), actionCollection(), | 1761 | SLOT( beamVCard() ), actionCollection(), |
1756 | "kaddressbook_beam_vcard" ); | 1762 | "kaddressbook_beam_vcard" ); |
1757 | 1763 | ||
1758 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1764 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1759 | SLOT( beamMySelf() ), actionCollection(), | 1765 | SLOT( beamMySelf() ), actionCollection(), |
1760 | "kaddressbook_beam_myself" ); | 1766 | "kaddressbook_beam_myself" ); |
1761 | } | 1767 | } |
1762 | #endif | 1768 | #endif |
1763 | 1769 | ||
1764 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1770 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1765 | this, SLOT( editContact2() ), | 1771 | this, SLOT( editContact2() ), |
1766 | actionCollection(), "file_properties" ); | 1772 | actionCollection(), "file_properties" ); |
1767 | 1773 | ||
1768 | #ifdef KAB_EMBEDDED | 1774 | #ifdef KAB_EMBEDDED |
1769 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1775 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1770 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1776 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1771 | mMainWindow, SLOT( exit() ), | 1777 | mMainWindow, SLOT( exit() ), |
1772 | actionCollection(), "quit" ); | 1778 | actionCollection(), "quit" ); |
1773 | #endif //KAB_EMBEDDED | 1779 | #endif //KAB_EMBEDDED |
1774 | 1780 | ||
1775 | // edit menu | 1781 | // edit menu |
1776 | if ( mIsPart ) { | 1782 | if ( mIsPart ) { |
1777 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1783 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1778 | SLOT( copyContacts() ), actionCollection(), | 1784 | SLOT( copyContacts() ), actionCollection(), |
1779 | "kaddressbook_copy" ); | 1785 | "kaddressbook_copy" ); |
1780 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1786 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1781 | SLOT( cutContacts() ), actionCollection(), | 1787 | SLOT( cutContacts() ), actionCollection(), |
1782 | "kaddressbook_cut" ); | 1788 | "kaddressbook_cut" ); |
1783 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1789 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1784 | SLOT( pasteContacts() ), actionCollection(), | 1790 | SLOT( pasteContacts() ), actionCollection(), |
1785 | "kaddressbook_paste" ); | 1791 | "kaddressbook_paste" ); |
1786 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1792 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1787 | SLOT( selectAllContacts() ), actionCollection(), | 1793 | SLOT( selectAllContacts() ), actionCollection(), |
1788 | "kaddressbook_select_all" ); | 1794 | "kaddressbook_select_all" ); |
1789 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1795 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1790 | SLOT( undo() ), actionCollection(), | 1796 | SLOT( undo() ), actionCollection(), |
1791 | "kaddressbook_undo" ); | 1797 | "kaddressbook_undo" ); |
1792 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1798 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1793 | this, SLOT( redo() ), actionCollection(), | 1799 | this, SLOT( redo() ), actionCollection(), |
1794 | "kaddressbook_redo" ); | 1800 | "kaddressbook_redo" ); |
1795 | } else { | 1801 | } else { |
1796 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1802 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1797 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1803 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1798 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1804 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1799 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1805 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1800 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1806 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1801 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1807 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1802 | } | 1808 | } |
1803 | 1809 | ||
1804 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1810 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1805 | Key_Delete, this, SLOT( deleteContacts() ), | 1811 | Key_Delete, this, SLOT( deleteContacts() ), |
1806 | actionCollection(), "edit_delete" ); | 1812 | actionCollection(), "edit_delete" ); |
1807 | 1813 | ||
1808 | mActionUndo->setEnabled( false ); | 1814 | mActionUndo->setEnabled( false ); |
1809 | mActionRedo->setEnabled( false ); | 1815 | mActionRedo->setEnabled( false ); |
1810 | 1816 | ||
1811 | // settings menu | 1817 | // settings menu |
1812 | #ifdef KAB_EMBEDDED | 1818 | #ifdef KAB_EMBEDDED |
1813 | //US special menuentry to configure the addressbook resources. On KDE | 1819 | //US special menuentry to configure the addressbook resources. On KDE |
1814 | // you do that through the control center !!! | 1820 | // you do that through the control center !!! |
1815 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1821 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1816 | SLOT( configureResources() ), actionCollection(), | 1822 | SLOT( configureResources() ), actionCollection(), |
1817 | "kaddressbook_configure_resources" ); | 1823 | "kaddressbook_configure_resources" ); |
1818 | #endif //KAB_EMBEDDED | 1824 | #endif //KAB_EMBEDDED |
1819 | 1825 | ||
1820 | if ( mIsPart ) { | 1826 | if ( mIsPart ) { |
1821 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1827 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1822 | SLOT( openConfigDialog() ), actionCollection(), | 1828 | SLOT( openConfigDialog() ), actionCollection(), |
1823 | "kaddressbook_configure" ); | 1829 | "kaddressbook_configure" ); |
1824 | 1830 | ||
1825 | //US not implemented yet | 1831 | //US not implemented yet |
1826 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1832 | //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1827 | // this, SLOT( configureKeyBindings() ), actionCollection(), | 1833 | // this, SLOT( configureKeyBindings() ), actionCollection(), |
1828 | // "kaddressbook_configure_shortcuts" ); | 1834 | // "kaddressbook_configure_shortcuts" ); |
1829 | #ifdef KAB_EMBEDDED | 1835 | #ifdef KAB_EMBEDDED |
1830 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1836 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1831 | mActionConfigureToolbars->setEnabled( false ); | 1837 | mActionConfigureToolbars->setEnabled( false ); |
1832 | #endif //KAB_EMBEDDED | 1838 | #endif //KAB_EMBEDDED |
1833 | 1839 | ||
1834 | } else { | 1840 | } else { |
1835 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1841 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1836 | 1842 | ||
1837 | //US not implemented yet | 1843 | //US not implemented yet |
1838 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1844 | //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1839 | } | 1845 | } |
1840 | 1846 | ||
1841 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1847 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1842 | actionCollection(), "options_show_jump_bar" ); | 1848 | actionCollection(), "options_show_jump_bar" ); |
1843 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1849 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1844 | 1850 | ||
1845 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1851 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1846 | actionCollection(), "options_show_details" ); | 1852 | actionCollection(), "options_show_details" ); |
1847 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1853 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1848 | 1854 | ||
1849 | 1855 | ||
1850 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, | 1856 | mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, |
1851 | SLOT( toggleBeamReceive() ), actionCollection(), | 1857 | SLOT( toggleBeamReceive() ), actionCollection(), |
1852 | "kaddressbook_beam_rec" ); | 1858 | "kaddressbook_beam_rec" ); |
1853 | 1859 | ||
1854 | 1860 | ||
1855 | // misc | 1861 | // misc |
1856 | // only enable LDAP lookup if we can handle the protocol | 1862 | // only enable LDAP lookup if we can handle the protocol |
1857 | #ifndef KAB_EMBEDDED | 1863 | #ifndef KAB_EMBEDDED |
1858 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1864 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1859 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1865 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1860 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1866 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1861 | "ldap_lookup" ); | 1867 | "ldap_lookup" ); |
1862 | } | 1868 | } |
1863 | #else //KAB_EMBEDDED | 1869 | #else //KAB_EMBEDDED |
1864 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1870 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1865 | #endif //KAB_EMBEDDED | 1871 | #endif //KAB_EMBEDDED |
1866 | 1872 | ||
1867 | 1873 | ||
1868 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1874 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1869 | SLOT( setWhoAmI() ), actionCollection(), | 1875 | SLOT( setWhoAmI() ), actionCollection(), |
1870 | "set_personal" ); | 1876 | "set_personal" ); |
1871 | 1877 | ||
1872 | 1878 | ||
1873 | 1879 | ||
1874 | 1880 | ||
1875 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1881 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1876 | SLOT( setCategories() ), actionCollection(), | 1882 | SLOT( setCategories() ), actionCollection(), |
1877 | "edit_set_categories" ); | 1883 | "edit_set_categories" ); |
1878 | 1884 | ||
1879 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1885 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1880 | SLOT( removeVoice() ), actionCollection(), | 1886 | SLOT( removeVoice() ), actionCollection(), |
1881 | "remove_voice" ); | 1887 | "remove_voice" ); |
1882 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1888 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1883 | SLOT( importFromOL() ), actionCollection(), | 1889 | SLOT( importFromOL() ), actionCollection(), |
1884 | "import_OL" ); | 1890 | "import_OL" ); |
1885 | #ifdef KAB_EMBEDDED | 1891 | #ifdef KAB_EMBEDDED |
1886 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1892 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1887 | this, SLOT( showLicence() ), actionCollection(), | 1893 | this, SLOT( showLicence() ), actionCollection(), |
1888 | "licence_about_data" ); | 1894 | "licence_about_data" ); |
1889 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1895 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1890 | this, SLOT( faq() ), actionCollection(), | 1896 | this, SLOT( faq() ), actionCollection(), |
1891 | "faq_about_data" ); | 1897 | "faq_about_data" ); |
1892 | mActionWN = new KAction( i18n( "What's New?" ), 0, | 1898 | mActionWN = new KAction( i18n( "What's New?" ), 0, |
1893 | this, SLOT( whatsnew() ), actionCollection(), | 1899 | this, SLOT( whatsnew() ), actionCollection(), |
1894 | "wn" ); | 1900 | "wn" ); |
1895 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, | 1901 | mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, |
1896 | this, SLOT( synchowto() ), actionCollection(), | 1902 | this, SLOT( synchowto() ), actionCollection(), |
1897 | "sync" ); | 1903 | "sync" ); |
1898 | 1904 | ||
1899 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1905 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1900 | this, SLOT( createAboutData() ), actionCollection(), | 1906 | this, SLOT( createAboutData() ), actionCollection(), |
1901 | "kaddressbook_about_data" ); | 1907 | "kaddressbook_about_data" ); |
1902 | #endif //KAB_EMBEDDED | 1908 | #endif //KAB_EMBEDDED |
1903 | 1909 | ||
1904 | clipboardDataChanged(); | 1910 | clipboardDataChanged(); |
1905 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1911 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1906 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1912 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1907 | } | 1913 | } |
1908 | 1914 | ||
1909 | //US we need this function, to plug all actions into the correct menues. | 1915 | //US we need this function, to plug all actions into the correct menues. |
1910 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1916 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1911 | void KABCore::addActionsManually() | 1917 | void KABCore::addActionsManually() |
1912 | { | 1918 | { |
1913 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1919 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1914 | 1920 | ||
1915 | #ifdef KAB_EMBEDDED | 1921 | #ifdef KAB_EMBEDDED |
1916 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1922 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1917 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1923 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1918 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1924 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1919 | 1925 | ||
1920 | KToolBar* tb = mMainWindow->toolBar(); | 1926 | KToolBar* tb = mMainWindow->toolBar(); |
1921 | 1927 | ||
1922 | 1928 | ||
1923 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { | 1929 | if ( KABPrefs::instance()->mFullMenuBarVisible ) { |
1924 | QMenuBar* mb = mMainWindow->menuBar(); | 1930 | QMenuBar* mb = mMainWindow->menuBar(); |
1925 | 1931 | ||
1926 | //US setup menubar. | 1932 | //US setup menubar. |
1927 | //Disable the following block if you do not want to have a menubar. | 1933 | //Disable the following block if you do not want to have a menubar. |
1928 | mb->insertItem( "&File", fileMenu ); | 1934 | mb->insertItem( "&File", fileMenu ); |
1929 | mb->insertItem( "&Edit", editMenu ); | 1935 | mb->insertItem( "&Edit", editMenu ); |
1930 | mb->insertItem( "&View", viewMenu ); | 1936 | mb->insertItem( "&View", viewMenu ); |
1931 | mb->insertItem( "&Settings", settingsMenu ); | 1937 | mb->insertItem( "&Settings", settingsMenu ); |
1932 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1938 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1933 | mb->insertItem( "&Change selected", changeMenu ); | 1939 | mb->insertItem( "&Change selected", changeMenu ); |
1934 | mb->insertItem( "&Help", helpMenu ); | 1940 | mb->insertItem( "&Help", helpMenu ); |
1935 | mIncSearchWidget = new IncSearchWidget( tb ); | 1941 | mIncSearchWidget = new IncSearchWidget( tb ); |
1936 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1942 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1937 | 1943 | ||
1938 | } else { | 1944 | } else { |
1939 | //US setup toolbar | 1945 | //US setup toolbar |
1940 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1946 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1941 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1947 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1942 | menuBarTB->insertItem( "ME", popupBarTB); | 1948 | menuBarTB->insertItem( "ME", popupBarTB); |
1943 | tb->insertWidget(-1, 0, menuBarTB); | 1949 | tb->insertWidget(-1, 0, menuBarTB); |
1944 | mIncSearchWidget = new IncSearchWidget( tb ); | 1950 | mIncSearchWidget = new IncSearchWidget( tb ); |
1945 | 1951 | ||
1946 | tb->enableMoving(false); | 1952 | tb->enableMoving(false); |
1947 | popupBarTB->insertItem( "&File", fileMenu ); | 1953 | popupBarTB->insertItem( "&File", fileMenu ); |
1948 | popupBarTB->insertItem( "&Edit", editMenu ); | 1954 | popupBarTB->insertItem( "&Edit", editMenu ); |
1949 | popupBarTB->insertItem( "&View", viewMenu ); | 1955 | popupBarTB->insertItem( "&View", viewMenu ); |
1950 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1956 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1951 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1957 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1952 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1958 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1953 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1959 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1954 | popupBarTB->insertItem( "&Help", helpMenu ); | 1960 | popupBarTB->insertItem( "&Help", helpMenu ); |
1955 | if (QApplication::desktop()->width() > 320 ) { | 1961 | if (QApplication::desktop()->width() > 320 ) { |
1956 | // mViewManager->getFilterAction()->plug ( tb); | 1962 | // mViewManager->getFilterAction()->plug ( tb); |
1957 | } | 1963 | } |
1958 | } | 1964 | } |
1959 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1965 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1960 | 1966 | ||
1961 | 1967 | ||
1962 | 1968 | ||
1963 | //US Now connect the actions with the menue entries. | 1969 | //US Now connect the actions with the menue entries. |
1964 | mActionPrint->plug( fileMenu ); | 1970 | mActionPrint->plug( fileMenu ); |
1965 | mActionMail->plug( fileMenu ); | 1971 | mActionMail->plug( fileMenu ); |
1966 | fileMenu->insertSeparator(); | 1972 | fileMenu->insertSeparator(); |
1967 | 1973 | ||
1968 | mActionNewContact->plug( fileMenu ); | 1974 | mActionNewContact->plug( fileMenu ); |
1969 | mActionNewContact->plug( tb ); | 1975 | mActionNewContact->plug( tb ); |
1970 | 1976 | ||
1971 | mActionEditAddressee->plug( fileMenu ); | 1977 | mActionEditAddressee->plug( fileMenu ); |
1972 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1978 | // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1973 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1979 | // (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1974 | mActionEditAddressee->plug( tb ); | 1980 | mActionEditAddressee->plug( tb ); |
1975 | 1981 | ||
1976 | fileMenu->insertSeparator(); | 1982 | fileMenu->insertSeparator(); |
1977 | mActionSave->plug( fileMenu ); | 1983 | mActionSave->plug( fileMenu ); |
1978 | fileMenu->insertItem( "&Import", ImportMenu ); | 1984 | fileMenu->insertItem( "&Import", ImportMenu ); |
1979 | fileMenu->insertItem( "&Export", ExportMenu ); | 1985 | fileMenu->insertItem( "&Export", ExportMenu ); |
1980 | fileMenu->insertSeparator(); | 1986 | fileMenu->insertSeparator(); |
1981 | mActionMailVCard->plug( fileMenu ); | 1987 | mActionMailVCard->plug( fileMenu ); |
1982 | #ifndef DESKTOP_VERSION | 1988 | #ifndef DESKTOP_VERSION |
1983 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1989 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1984 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1990 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1985 | #endif | 1991 | #endif |
1986 | fileMenu->insertSeparator(); | 1992 | fileMenu->insertSeparator(); |
1987 | mActionQuit->plug( fileMenu ); | 1993 | mActionQuit->plug( fileMenu ); |
1988 | #ifdef _WIN32_ | 1994 | #ifdef _WIN32_ |
1989 | mActionImportOL->plug( ImportMenu ); | 1995 | mActionImportOL->plug( ImportMenu ); |
1990 | #endif | 1996 | #endif |
1991 | // edit menu | 1997 | // edit menu |
1992 | mActionUndo->plug( editMenu ); | 1998 | mActionUndo->plug( editMenu ); |
1993 | mActionRedo->plug( editMenu ); | 1999 | mActionRedo->plug( editMenu ); |
1994 | editMenu->insertSeparator(); | 2000 | editMenu->insertSeparator(); |
1995 | mActionCut->plug( editMenu ); | 2001 | mActionCut->plug( editMenu ); |
1996 | mActionCopy->plug( editMenu ); | 2002 | mActionCopy->plug( editMenu ); |
1997 | mActionPaste->plug( editMenu ); | 2003 | mActionPaste->plug( editMenu ); |
1998 | mActionDelete->plug( editMenu ); | 2004 | mActionDelete->plug( editMenu ); |
1999 | editMenu->insertSeparator(); | 2005 | editMenu->insertSeparator(); |
2000 | mActionSelectAll->plug( editMenu ); | 2006 | mActionSelectAll->plug( editMenu ); |
2001 | 2007 | ||
2002 | mActionRemoveVoice->plug( changeMenu ); | 2008 | mActionRemoveVoice->plug( changeMenu ); |
2003 | // settings menu | 2009 | // settings menu |
2004 | //US special menuentry to configure the addressbook resources. On KDE | 2010 | //US special menuentry to configure the addressbook resources. On KDE |
2005 | // you do that through the control center !!! | 2011 | // you do that through the control center !!! |
2006 | mActionConfigResources->plug( settingsMenu ); | 2012 | mActionConfigResources->plug( settingsMenu ); |
2007 | settingsMenu->insertSeparator(); | 2013 | settingsMenu->insertSeparator(); |
2008 | 2014 | ||
2009 | mActionConfigKAddressbook->plug( settingsMenu ); | 2015 | mActionConfigKAddressbook->plug( settingsMenu ); |
2010 | 2016 | ||
2011 | if ( mIsPart ) { | 2017 | if ( mIsPart ) { |
2012 | //US not implemented yet | 2018 | //US not implemented yet |
2013 | //mActionConfigShortcuts->plug( settingsMenu ); | 2019 | //mActionConfigShortcuts->plug( settingsMenu ); |
2014 | //mActionConfigureToolbars->plug( settingsMenu ); | 2020 | //mActionConfigureToolbars->plug( settingsMenu ); |
2015 | 2021 | ||
2016 | } else { | 2022 | } else { |
2017 | //US not implemented yet | 2023 | //US not implemented yet |
2018 | //mActionKeyBindings->plug( settingsMenu ); | 2024 | //mActionKeyBindings->plug( settingsMenu ); |
2019 | } | 2025 | } |
2020 | 2026 | ||
2021 | settingsMenu->insertSeparator(); | 2027 | settingsMenu->insertSeparator(); |
2022 | 2028 | ||
2023 | mActionJumpBar->plug( settingsMenu ); | 2029 | mActionJumpBar->plug( settingsMenu ); |
2024 | mActionDetails->plug( settingsMenu ); | 2030 | mActionDetails->plug( settingsMenu ); |
2025 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2031 | //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2026 | mActionDetails->plug( tb ); | 2032 | mActionDetails->plug( tb ); |
2027 | settingsMenu->insertSeparator(); | 2033 | settingsMenu->insertSeparator(); |
2028 | mActionBR->plug(settingsMenu ); | 2034 | mActionBR->plug(settingsMenu ); |
2029 | settingsMenu->insertSeparator(); | 2035 | settingsMenu->insertSeparator(); |
2030 | 2036 | ||
2031 | mActionWhoAmI->plug( settingsMenu ); | 2037 | mActionWhoAmI->plug( settingsMenu ); |
2032 | mActionCategories->plug( settingsMenu ); | 2038 | mActionCategories->plug( settingsMenu ); |
2033 | 2039 | ||
2034 | 2040 | ||
2035 | mActionWN->plug( helpMenu ); | 2041 | mActionWN->plug( helpMenu ); |
2036 | mActionSyncHowto->plug( helpMenu ); | 2042 | mActionSyncHowto->plug( helpMenu ); |
2037 | mActionLicence->plug( helpMenu ); | 2043 | mActionLicence->plug( helpMenu ); |
2038 | mActionFaq->plug( helpMenu ); | 2044 | mActionFaq->plug( helpMenu ); |
2039 | mActionAboutKAddressbook->plug( helpMenu ); | 2045 | mActionAboutKAddressbook->plug( helpMenu ); |
2040 | 2046 | ||
2041 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2047 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2042 | 2048 | ||
2043 | mActionSave->plug( tb ); | 2049 | mActionSave->plug( tb ); |
2044 | mViewManager->getFilterAction()->plug ( tb); | 2050 | mViewManager->getFilterAction()->plug ( tb); |
2045 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2051 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2046 | mActionUndo->plug( tb ); | 2052 | mActionUndo->plug( tb ); |
2047 | mActionDelete->plug( tb ); | 2053 | mActionDelete->plug( tb ); |
2048 | mActionRedo->plug( tb ); | 2054 | mActionRedo->plug( tb ); |
2049 | } | 2055 | } |
2050 | } else { | 2056 | } else { |
2051 | mActionSave->plug( tb ); | 2057 | mActionSave->plug( tb ); |
2052 | tb->enableMoving(false); | 2058 | tb->enableMoving(false); |
2053 | } | 2059 | } |
2054 | //mActionQuit->plug ( tb ); | 2060 | //mActionQuit->plug ( tb ); |
2055 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2061 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2056 | 2062 | ||
2057 | //US link the searchwidget first to this. | 2063 | //US link the searchwidget first to this. |
2058 | // The real linkage to the toolbar happens later. | 2064 | // The real linkage to the toolbar happens later. |
2059 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2065 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2060 | //US tb->insertItem( mIncSearchWidget ); | 2066 | //US tb->insertItem( mIncSearchWidget ); |
2061 | /*US | 2067 | /*US |
2062 | mIncSearchWidget = new IncSearchWidget( tb ); | 2068 | mIncSearchWidget = new IncSearchWidget( tb ); |
2063 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2069 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2064 | SLOT( incrementalSearch( const QString& ) ) ); | 2070 | SLOT( incrementalSearch( const QString& ) ) ); |
2065 | 2071 | ||
2066 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2072 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2067 | 2073 | ||
2068 | //US topLayout->addWidget( mJumpButtonBar ); | 2074 | //US topLayout->addWidget( mJumpButtonBar ); |
2069 | this->layout()->add( mJumpButtonBar ); | 2075 | this->layout()->add( mJumpButtonBar ); |
2070 | */ | 2076 | */ |
2071 | 2077 | ||
2072 | #endif //KAB_EMBEDDED | 2078 | #endif //KAB_EMBEDDED |
2073 | 2079 | ||
2074 | mActionExport2phone->plug( ExportMenu ); | 2080 | mActionExport2phone->plug( ExportMenu ); |
2075 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2081 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2076 | syncManager->fillSyncMenu(); | 2082 | syncManager->fillSyncMenu(); |
2077 | 2083 | ||
2078 | } | 2084 | } |
2079 | void KABCore::showLicence() | 2085 | void KABCore::showLicence() |
2080 | { | 2086 | { |
2081 | KApplication::showLicence(); | 2087 | KApplication::showLicence(); |
2082 | } | 2088 | } |
2083 | void KABCore::removeVoice() | 2089 | void KABCore::removeVoice() |
2084 | { | 2090 | { |
2085 | 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 ) | 2091 | 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 ) |
2086 | return; | 2092 | return; |
2087 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2093 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2088 | KABC::Addressee::List::Iterator it; | 2094 | KABC::Addressee::List::Iterator it; |
2089 | for ( it = list.begin(); it != list.end(); ++it ) { | 2095 | for ( it = list.begin(); it != list.end(); ++it ) { |
2090 | 2096 | ||
2091 | if ( (*it).removeVoice() ) | 2097 | if ( (*it).removeVoice() ) |
2092 | contactModified((*it) ); | 2098 | contactModified((*it) ); |
2093 | } | 2099 | } |
2094 | } | 2100 | } |
2095 | 2101 | ||
2096 | 2102 | ||
2097 | 2103 | ||
2098 | void KABCore::clipboardDataChanged() | 2104 | void KABCore::clipboardDataChanged() |
2099 | { | 2105 | { |
2100 | 2106 | ||
2101 | if ( mReadWrite ) | 2107 | if ( mReadWrite ) |
2102 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2108 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2103 | 2109 | ||
2104 | } | 2110 | } |
2105 | 2111 | ||
2106 | void KABCore::updateActionMenu() | 2112 | void KABCore::updateActionMenu() |
2107 | { | 2113 | { |
2108 | UndoStack *undo = UndoStack::instance(); | 2114 | UndoStack *undo = UndoStack::instance(); |
2109 | RedoStack *redo = RedoStack::instance(); | 2115 | RedoStack *redo = RedoStack::instance(); |
2110 | 2116 | ||
2111 | if ( undo->isEmpty() ) | 2117 | if ( undo->isEmpty() ) |
2112 | mActionUndo->setText( i18n( "Undo" ) ); | 2118 | mActionUndo->setText( i18n( "Undo" ) ); |
2113 | else | 2119 | else |
2114 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2120 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2115 | 2121 | ||
2116 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2122 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2117 | 2123 | ||
2118 | if ( !redo->top() ) | 2124 | if ( !redo->top() ) |
2119 | mActionRedo->setText( i18n( "Redo" ) ); | 2125 | mActionRedo->setText( i18n( "Redo" ) ); |
2120 | else | 2126 | else |
2121 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2127 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2122 | 2128 | ||
2123 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2129 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2124 | } | 2130 | } |
2125 | 2131 | ||
2126 | void KABCore::configureKeyBindings() | 2132 | void KABCore::configureKeyBindings() |
2127 | { | 2133 | { |
2128 | #ifndef KAB_EMBEDDED | 2134 | #ifndef KAB_EMBEDDED |
2129 | KKeyDialog::configure( actionCollection(), true ); | 2135 | KKeyDialog::configure( actionCollection(), true ); |
2130 | #else //KAB_EMBEDDED | 2136 | #else //KAB_EMBEDDED |
2131 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2137 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2132 | #endif //KAB_EMBEDDED | 2138 | #endif //KAB_EMBEDDED |
2133 | } | 2139 | } |
2134 | 2140 | ||
2135 | #ifdef KAB_EMBEDDED | 2141 | #ifdef KAB_EMBEDDED |
2136 | void KABCore::configureResources() | 2142 | void KABCore::configureResources() |
2137 | { | 2143 | { |
2138 | KRES::KCMKResources dlg( this, "" , 0 ); | 2144 | KRES::KCMKResources dlg( this, "" , 0 ); |
2139 | 2145 | ||
2140 | if ( !dlg.exec() ) | 2146 | if ( !dlg.exec() ) |
2141 | return; | 2147 | return; |
2142 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2148 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2143 | } | 2149 | } |
2144 | #endif //KAB_EMBEDDED | 2150 | #endif //KAB_EMBEDDED |
2145 | 2151 | ||
2146 | 2152 | ||
2147 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2153 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2148 | * for the attendees list of an event. | 2154 | * for the attendees list of an event. |
2149 | */ | 2155 | */ |
2150 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2156 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2151 | { | 2157 | { |
2152 | QStringList nameList; | 2158 | QStringList nameList; |
2153 | QStringList emailList; | 2159 | QStringList emailList; |
2154 | QStringList uidList; | 2160 | QStringList uidList; |
2155 | 2161 | ||
2156 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2162 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2157 | uint i=0; | 2163 | uint i=0; |
2158 | for (i=0; i < list.count(); i++) | 2164 | for (i=0; i < list.count(); i++) |
2159 | { | 2165 | { |
2160 | nameList.append(list[i].realName()); | 2166 | nameList.append(list[i].realName()); |
2161 | emailList.append(list[i].preferredEmail()); | 2167 | emailList.append(list[i].preferredEmail()); |
2162 | uidList.append(list[i].uid()); | 2168 | uidList.append(list[i].uid()); |
2163 | } | 2169 | } |
2164 | 2170 | ||
2165 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2171 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2166 | 2172 | ||
2167 | } | 2173 | } |
2168 | 2174 | ||
2169 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2175 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2170 | * to put them into the calendar. | 2176 | * to put them into the calendar. |
2171 | */ | 2177 | */ |
2172 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2178 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2173 | { | 2179 | { |
2174 | // qDebug("KABCore::requestForBirthdayList"); | 2180 | // qDebug("KABCore::requestForBirthdayList"); |
2175 | QStringList birthdayList; | 2181 | QStringList birthdayList; |
2176 | QStringList anniversaryList; | 2182 | QStringList anniversaryList; |
2177 | QStringList realNameList; | 2183 | QStringList realNameList; |
2178 | QStringList preferredEmailList; | 2184 | QStringList preferredEmailList; |
2179 | QStringList assembledNameList; | 2185 | QStringList assembledNameList; |
2180 | QStringList uidList; | 2186 | QStringList uidList; |
2181 | 2187 | ||
2182 | KABC::AddressBook::Iterator it; | 2188 | KABC::AddressBook::Iterator it; |
2183 | 2189 | ||
2184 | int count = 0; | 2190 | int count = 0; |
2185 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2191 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2186 | ++count; | 2192 | ++count; |
2187 | } | 2193 | } |
2188 | QProgressBar bar(count,0 ); | 2194 | QProgressBar bar(count,0 ); |
2189 | int w = 300; | 2195 | int w = 300; |
2190 | if ( QApplication::desktop()->width() < 320 ) | 2196 | if ( QApplication::desktop()->width() < 320 ) |
2191 | w = 220; | 2197 | w = 220; |
2192 | int h = bar.sizeHint().height() ; | 2198 | int h = bar.sizeHint().height() ; |
2193 | int dw = QApplication::desktop()->width(); | 2199 | int dw = QApplication::desktop()->width(); |
2194 | int dh = QApplication::desktop()->height(); | 2200 | int dh = QApplication::desktop()->height(); |
2195 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2201 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2196 | bar.show(); | 2202 | bar.show(); |
2197 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); | 2203 | bar.setCaption (i18n("Collecting birthdays - close to abort!") ); |
2198 | qApp->processEvents(); | 2204 | qApp->processEvents(); |
2199 | 2205 | ||
2200 | QDate bday; | 2206 | QDate bday; |
2201 | QString anni; | 2207 | QString anni; |
2202 | QString formattedbday; | 2208 | QString formattedbday; |
2203 | 2209 | ||
2204 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2210 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2205 | { | 2211 | { |
2206 | if ( ! bar.isVisible() ) | 2212 | if ( ! bar.isVisible() ) |
2207 | return; | 2213 | return; |
2208 | bar.setProgress( count++ ); | 2214 | bar.setProgress( count++ ); |
2209 | qApp->processEvents(); | 2215 | qApp->processEvents(); |
2210 | bday = (*it).birthday().date(); | 2216 | bday = (*it).birthday().date(); |
2211 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2217 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2212 | 2218 | ||
2213 | if ( bday.isValid() || !anni.isEmpty()) | 2219 | if ( bday.isValid() || !anni.isEmpty()) |
2214 | { | 2220 | { |
2215 | if (bday.isValid()) | 2221 | if (bday.isValid()) |
2216 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2222 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2217 | else | 2223 | else |
2218 | formattedbday = "NOTVALID"; | 2224 | formattedbday = "NOTVALID"; |
2219 | if (anni.isEmpty()) | 2225 | if (anni.isEmpty()) |
2220 | anni = "INVALID"; | 2226 | anni = "INVALID"; |
2221 | 2227 | ||
2222 | birthdayList.append(formattedbday); | 2228 | birthdayList.append(formattedbday); |
2223 | anniversaryList.append(anni); //should be ISODate | 2229 | anniversaryList.append(anni); //should be ISODate |
2224 | realNameList.append((*it).realName()); | 2230 | realNameList.append((*it).realName()); |
2225 | preferredEmailList.append((*it).preferredEmail()); | 2231 | preferredEmailList.append((*it).preferredEmail()); |
2226 | assembledNameList.append((*it).assembledName()); | 2232 | assembledNameList.append((*it).assembledName()); |
2227 | uidList.append((*it).uid()); | 2233 | uidList.append((*it).uid()); |
2228 | 2234 | ||
2229 | 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() ); | 2235 | 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() ); |
2230 | } | 2236 | } |
2231 | } | 2237 | } |
2232 | 2238 | ||
2233 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2239 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2234 | 2240 | ||
2235 | } | 2241 | } |
2236 | 2242 | ||
2237 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2243 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2238 | */ | 2244 | */ |
2239 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2245 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2240 | { | 2246 | { |
2241 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2247 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2242 | 2248 | ||
2243 | QString foundUid = QString::null; | 2249 | QString foundUid = QString::null; |
2244 | if ( ! uid.isEmpty() ) { | 2250 | if ( ! uid.isEmpty() ) { |
2245 | Addressee adrr = mAddressBook->findByUid( uid ); | 2251 | Addressee adrr = mAddressBook->findByUid( uid ); |
2246 | if ( !adrr.isEmpty() ) { | 2252 | if ( !adrr.isEmpty() ) { |
2247 | foundUid = uid; | 2253 | foundUid = uid; |
2248 | } | 2254 | } |
2249 | if ( email == "sendbacklist" ) { | 2255 | if ( email == "sendbacklist" ) { |
2250 | //qDebug("ssssssssssssssssssssssend "); | 2256 | //qDebug("ssssssssssssssssssssssend "); |
2251 | QStringList nameList; | 2257 | QStringList nameList; |
2252 | QStringList emailList; | 2258 | QStringList emailList; |
2253 | QStringList uidList; | 2259 | QStringList uidList; |
2254 | nameList.append(adrr.realName()); | 2260 | nameList.append(adrr.realName()); |
2255 | emailList = adrr.emails(); | 2261 | emailList = adrr.emails(); |
2256 | uidList.append( adrr.preferredEmail()); | 2262 | uidList.append( adrr.preferredEmail()); |
2257 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2263 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2258 | return; | 2264 | return; |
2259 | } | 2265 | } |
2260 | 2266 | ||
2261 | } | 2267 | } |
2262 | 2268 | ||
2263 | if ( email == "sendbacklist" ) | 2269 | if ( email == "sendbacklist" ) |
2264 | return; | 2270 | return; |
2265 | if (foundUid.isEmpty()) | 2271 | if (foundUid.isEmpty()) |
2266 | { | 2272 | { |
2267 | //find the uid of the person first | 2273 | //find the uid of the person first |
2268 | Addressee::List namelist; | 2274 | Addressee::List namelist; |
2269 | Addressee::List emaillist; | 2275 | Addressee::List emaillist; |
2270 | 2276 | ||
2271 | if (!name.isEmpty()) | 2277 | if (!name.isEmpty()) |
2272 | namelist = mAddressBook->findByName( name ); | 2278 | namelist = mAddressBook->findByName( name ); |
2273 | 2279 | ||
2274 | if (!email.isEmpty()) | 2280 | if (!email.isEmpty()) |
2275 | emaillist = mAddressBook->findByEmail( email ); | 2281 | emaillist = mAddressBook->findByEmail( email ); |
2276 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2282 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2277 | //check if we have a match in Namelist and Emaillist | 2283 | //check if we have a match in Namelist and Emaillist |
2278 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2284 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2279 | foundUid = emaillist[0].uid(); | 2285 | foundUid = emaillist[0].uid(); |
2280 | } | 2286 | } |
2281 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2287 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2282 | foundUid = namelist[0].uid(); | 2288 | foundUid = namelist[0].uid(); |
2283 | else | 2289 | else |
2284 | { | 2290 | { |
2285 | for (int i = 0; i < namelist.count(); i++) | 2291 | for (int i = 0; i < namelist.count(); i++) |
2286 | { | 2292 | { |
2287 | for (int j = 0; j < emaillist.count(); j++) | 2293 | for (int j = 0; j < emaillist.count(); j++) |
2288 | { | 2294 | { |
2289 | if (namelist[i] == emaillist[j]) | 2295 | if (namelist[i] == emaillist[j]) |
2290 | { | 2296 | { |
2291 | foundUid = namelist[i].uid(); | 2297 | foundUid = namelist[i].uid(); |
2292 | } | 2298 | } |
2293 | } | 2299 | } |
2294 | } | 2300 | } |
2295 | } | 2301 | } |
2296 | } | 2302 | } |
2297 | else | 2303 | else |
2298 | { | 2304 | { |
2299 | foundUid = uid; | 2305 | foundUid = uid; |
2300 | } | 2306 | } |
2301 | 2307 | ||
2302 | if (!foundUid.isEmpty()) | 2308 | if (!foundUid.isEmpty()) |
2303 | { | 2309 | { |
2304 | 2310 | ||
2305 | // raise Ka/Pi if it is in the background | 2311 | // raise Ka/Pi if it is in the background |
2306 | #ifndef DESKTOP_VERSION | 2312 | #ifndef DESKTOP_VERSION |
2307 | #ifndef KORG_NODCOP | 2313 | #ifndef KORG_NODCOP |
2308 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2314 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2309 | #endif | 2315 | #endif |
2310 | #endif | 2316 | #endif |
2311 | 2317 | ||
2312 | mMainWindow->showMaximized(); | 2318 | mMainWindow->showMaximized(); |
2313 | mMainWindow-> raise(); | 2319 | mMainWindow-> raise(); |
2314 | 2320 | ||
2315 | mViewManager->setSelected( "", false); | 2321 | mViewManager->setSelected( "", false); |
2316 | mViewManager->refreshView( "" ); | 2322 | mViewManager->refreshView( "" ); |
2317 | mViewManager->setSelected( foundUid, true ); | 2323 | mViewManager->setSelected( foundUid, true ); |
2318 | mViewManager->refreshView( foundUid ); | 2324 | mViewManager->refreshView( foundUid ); |
2319 | 2325 | ||
2320 | if ( !mMultipleViewsAtOnce ) | 2326 | if ( !mMultipleViewsAtOnce ) |
2321 | { | 2327 | { |
2322 | setDetailsVisible( true ); | 2328 | setDetailsVisible( true ); |
2323 | mActionDetails->setChecked(true); | 2329 | mActionDetails->setChecked(true); |
2324 | } | 2330 | } |
2325 | } | 2331 | } |
2326 | } | 2332 | } |
2327 | 2333 | ||
2328 | void KABCore::whatsnew() | 2334 | void KABCore::whatsnew() |
2329 | { | 2335 | { |
2330 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 2336 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
2331 | } | 2337 | } |
2332 | void KABCore::synchowto() | 2338 | void KABCore::synchowto() |
2333 | { | 2339 | { |
2334 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 2340 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
2335 | } | 2341 | } |
2336 | 2342 | ||
2337 | void KABCore::faq() | 2343 | void KABCore::faq() |
2338 | { | 2344 | { |
2339 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2345 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2340 | } | 2346 | } |
2341 | 2347 | ||
2342 | #include <libkcal/syncdefines.h> | 2348 | #include <libkcal/syncdefines.h> |
2343 | 2349 | ||
2344 | KABC::Addressee KABCore::getLastSyncAddressee() | 2350 | KABC::Addressee KABCore::getLastSyncAddressee() |
2345 | { | 2351 | { |
2346 | Addressee lse; | 2352 | Addressee lse; |
2347 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2353 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2348 | 2354 | ||
2349 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2355 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2350 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2356 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2351 | if (lse.isEmpty()) { | 2357 | if (lse.isEmpty()) { |
2352 | qDebug("Creating new last-syncAddressee "); | 2358 | qDebug("Creating new last-syncAddressee "); |
2353 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2359 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2354 | QString sum = ""; | 2360 | QString sum = ""; |
2355 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2361 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2356 | sum = "E: "; | 2362 | sum = "E: "; |
2357 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2363 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2358 | lse.setRevision( mLastAddressbookSync ); | 2364 | lse.setRevision( mLastAddressbookSync ); |
2359 | lse.setCategories( i18n("SyncEvent") ); | 2365 | lse.setCategories( i18n("SyncEvent") ); |
2360 | mAddressBook->insertAddressee( lse ); | 2366 | mAddressBook->insertAddressee( lse ); |
2361 | } | 2367 | } |
2362 | return lse; | 2368 | return lse; |
2363 | } | 2369 | } |
2364 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2370 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2365 | { | 2371 | { |
2366 | 2372 | ||
2367 | //void setZaurusId(int id); | 2373 | //void setZaurusId(int id); |
2368 | // int zaurusId() const; | 2374 | // int zaurusId() const; |
2369 | // void setZaurusUid(int id); | 2375 | // void setZaurusUid(int id); |
2370 | // int zaurusUid() const; | 2376 | // int zaurusUid() const; |
2371 | // void setZaurusStat(int id); | 2377 | // void setZaurusStat(int id); |
2372 | // int zaurusStat() const; | 2378 | // int zaurusStat() const; |
2373 | // 0 equal | 2379 | // 0 equal |
2374 | // 1 take local | 2380 | // 1 take local |
2375 | // 2 take remote | 2381 | // 2 take remote |
2376 | // 3 cancel | 2382 | // 3 cancel |
2377 | QDateTime lastSync = mLastAddressbookSync; | 2383 | QDateTime lastSync = mLastAddressbookSync; |
2378 | QDateTime localMod = local->revision(); | 2384 | QDateTime localMod = local->revision(); |
2379 | QDateTime remoteMod = remote->revision(); | 2385 | QDateTime remoteMod = remote->revision(); |
2380 | 2386 | ||
2381 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2387 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2382 | 2388 | ||
2383 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2389 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2384 | bool remCh, locCh; | 2390 | bool remCh, locCh; |
2385 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2391 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2386 | 2392 | ||
2387 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2393 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2388 | locCh = ( localMod > mLastAddressbookSync ); | 2394 | locCh = ( localMod > mLastAddressbookSync ); |
2389 | if ( !remCh && ! locCh ) { | 2395 | if ( !remCh && ! locCh ) { |
2390 | //qDebug("both not changed "); | 2396 | //qDebug("both not changed "); |
2391 | lastSync = localMod.addDays(1); | 2397 | lastSync = localMod.addDays(1); |
2392 | if ( mode <= SYNC_PREF_ASK ) | 2398 | if ( mode <= SYNC_PREF_ASK ) |
2393 | return 0; | 2399 | return 0; |
2394 | } else { | 2400 | } else { |
2395 | if ( locCh ) { | 2401 | if ( locCh ) { |
2396 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2402 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2397 | lastSync = localMod.addDays( -1 ); | 2403 | lastSync = localMod.addDays( -1 ); |
2398 | if ( !remCh ) | 2404 | if ( !remCh ) |
2399 | remoteMod =( lastSync.addDays( -1 ) ); | 2405 | remoteMod =( lastSync.addDays( -1 ) ); |
2400 | } else { | 2406 | } else { |
2401 | //qDebug(" not loc changed "); | 2407 | //qDebug(" not loc changed "); |
2402 | lastSync = localMod.addDays( 1 ); | 2408 | lastSync = localMod.addDays( 1 ); |
2403 | if ( remCh ) | 2409 | if ( remCh ) |
2404 | remoteMod =( lastSync.addDays( 1 ) ); | 2410 | remoteMod =( lastSync.addDays( 1 ) ); |
2405 | 2411 | ||
2406 | } | 2412 | } |
2407 | } | 2413 | } |
2408 | full = true; | 2414 | full = true; |
2409 | if ( mode < SYNC_PREF_ASK ) | 2415 | if ( mode < SYNC_PREF_ASK ) |
2410 | mode = SYNC_PREF_ASK; | 2416 | mode = SYNC_PREF_ASK; |
2411 | } else { | 2417 | } else { |
2412 | if ( localMod == remoteMod ) | 2418 | if ( localMod == remoteMod ) |
2413 | return 0; | 2419 | return 0; |
2414 | 2420 | ||
2415 | } | 2421 | } |
2416 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2422 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2417 | 2423 | ||
2418 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2424 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2419 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2425 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2420 | //full = true; //debug only | 2426 | //full = true; //debug only |
2421 | if ( full ) { | 2427 | if ( full ) { |
2422 | bool equ = ( (*local) == (*remote) ); | 2428 | bool equ = ( (*local) == (*remote) ); |
2423 | if ( equ ) { | 2429 | if ( equ ) { |
2424 | //qDebug("equal "); | 2430 | //qDebug("equal "); |
2425 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2431 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2426 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2432 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2427 | } | 2433 | } |
2428 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2434 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2429 | return 0; | 2435 | return 0; |
2430 | 2436 | ||
2431 | }//else //debug only | 2437 | }//else //debug only |
2432 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2438 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2433 | } | 2439 | } |
2434 | int result; | 2440 | int result; |
2435 | bool localIsNew; | 2441 | bool localIsNew; |
2436 | //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() ); | 2442 | //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() ); |
2437 | 2443 | ||
2438 | if ( full && mode < SYNC_PREF_NEWEST ) | 2444 | if ( full && mode < SYNC_PREF_NEWEST ) |
2439 | mode = SYNC_PREF_ASK; | 2445 | mode = SYNC_PREF_ASK; |
2440 | 2446 | ||
2441 | switch( mode ) { | 2447 | switch( mode ) { |
2442 | case SYNC_PREF_LOCAL: | 2448 | case SYNC_PREF_LOCAL: |
2443 | if ( lastSync > remoteMod ) | 2449 | if ( lastSync > remoteMod ) |
2444 | return 1; | 2450 | return 1; |
2445 | if ( lastSync > localMod ) | 2451 | if ( lastSync > localMod ) |
2446 | return 2; | 2452 | return 2; |
2447 | return 1; | 2453 | return 1; |
2448 | break; | 2454 | break; |
2449 | case SYNC_PREF_REMOTE: | 2455 | case SYNC_PREF_REMOTE: |
2450 | if ( lastSync > remoteMod ) | 2456 | if ( lastSync > remoteMod ) |
2451 | return 1; | 2457 | return 1; |
2452 | if ( lastSync > localMod ) | 2458 | if ( lastSync > localMod ) |
2453 | return 2; | 2459 | return 2; |
2454 | return 2; | 2460 | return 2; |
2455 | break; | 2461 | break; |
2456 | case SYNC_PREF_NEWEST: | 2462 | case SYNC_PREF_NEWEST: |
2457 | if ( localMod > remoteMod ) | 2463 | if ( localMod > remoteMod ) |
2458 | return 1; | 2464 | return 1; |
2459 | else | 2465 | else |
2460 | return 2; | 2466 | return 2; |
2461 | break; | 2467 | break; |
2462 | case SYNC_PREF_ASK: | 2468 | case SYNC_PREF_ASK: |
2463 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2469 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2464 | if ( lastSync > remoteMod ) | 2470 | if ( lastSync > remoteMod ) |
2465 | return 1; | 2471 | return 1; |
2466 | if ( lastSync > localMod ) | 2472 | if ( lastSync > localMod ) |
2467 | return 2; | 2473 | return 2; |
2468 | localIsNew = localMod >= remoteMod; | 2474 | localIsNew = localMod >= remoteMod; |
2469 | //qDebug("conflict! ************************************** "); | 2475 | //qDebug("conflict! ************************************** "); |
2470 | { | 2476 | { |
2471 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2477 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2472 | result = acd.executeD(localIsNew); | 2478 | result = acd.executeD(localIsNew); |
2473 | return result; | 2479 | return result; |
2474 | } | 2480 | } |
2475 | break; | 2481 | break; |
2476 | case SYNC_PREF_FORCE_LOCAL: | 2482 | case SYNC_PREF_FORCE_LOCAL: |
2477 | return 1; | 2483 | return 1; |
2478 | break; | 2484 | break; |
2479 | case SYNC_PREF_FORCE_REMOTE: | 2485 | case SYNC_PREF_FORCE_REMOTE: |
2480 | return 2; | 2486 | return 2; |
2481 | break; | 2487 | break; |
2482 | 2488 | ||
2483 | default: | 2489 | default: |
2484 | // SYNC_PREF_TAKE_BOTH not implemented | 2490 | // SYNC_PREF_TAKE_BOTH not implemented |
2485 | break; | 2491 | break; |
2486 | } | 2492 | } |
2487 | return 0; | 2493 | return 0; |
2488 | } | 2494 | } |
2489 | 2495 | ||
2490 | 2496 | ||
2491 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2497 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2492 | { | 2498 | { |
2493 | bool syncOK = true; | 2499 | bool syncOK = true; |
2494 | int addedAddressee = 0; | 2500 | int addedAddressee = 0; |
2495 | int addedAddresseeR = 0; | 2501 | int addedAddresseeR = 0; |
2496 | int deletedAddresseeR = 0; | 2502 | int deletedAddresseeR = 0; |
2497 | int deletedAddresseeL = 0; | 2503 | int deletedAddresseeL = 0; |
2498 | int changedLocal = 0; | 2504 | int changedLocal = 0; |
2499 | int changedRemote = 0; | 2505 | int changedRemote = 0; |
2500 | 2506 | ||
2501 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2507 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2502 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2508 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2503 | 2509 | ||
2504 | //QPtrList<Addressee> el = local->rawAddressees(); | 2510 | //QPtrList<Addressee> el = local->rawAddressees(); |
2505 | Addressee addresseeR; | 2511 | Addressee addresseeR; |
2506 | QString uid; | 2512 | QString uid; |
2507 | int take; | 2513 | int take; |
2508 | Addressee addresseeL; | 2514 | Addressee addresseeL; |
2509 | Addressee addresseeRSync; | 2515 | Addressee addresseeRSync; |
2510 | Addressee addresseeLSync; | 2516 | Addressee addresseeLSync; |
2511 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2517 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2512 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2518 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2513 | bool fullDateRange = false; | 2519 | bool fullDateRange = false; |
2514 | local->resetTempSyncStat(); | 2520 | local->resetTempSyncStat(); |
2515 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2521 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2516 | if ( syncManager->syncWithDesktop() ) { | 2522 | if ( syncManager->syncWithDesktop() ) { |
2517 | // remote->removeSyncInfo( QString());//remove all info | 2523 | // remote->removeSyncInfo( QString());//remove all info |
2518 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 2524 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
2519 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; | 2525 | mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; |
2520 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); | 2526 | qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); |
2521 | } else { | 2527 | } else { |
2522 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 2528 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
2523 | } | 2529 | } |
2524 | } | 2530 | } |
2525 | QDateTime modifiedCalendar = mLastAddressbookSync; | 2531 | QDateTime modifiedCalendar = mLastAddressbookSync; |
2526 | addresseeLSync = getLastSyncAddressee(); | 2532 | addresseeLSync = getLastSyncAddressee(); |
2527 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2533 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2528 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2534 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2529 | if ( !addresseeR.isEmpty() ) { | 2535 | if ( !addresseeR.isEmpty() ) { |
2530 | addresseeRSync = addresseeR; | 2536 | addresseeRSync = addresseeR; |
2531 | remote->removeAddressee(addresseeR ); | 2537 | remote->removeAddressee(addresseeR ); |
2532 | 2538 | ||
2533 | } else { | 2539 | } else { |
2534 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2540 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2535 | addresseeRSync = addresseeLSync ; | 2541 | addresseeRSync = addresseeLSync ; |
2536 | } else { | 2542 | } else { |
2537 | qDebug("FULLDATE 1"); | 2543 | qDebug("FULLDATE 1"); |
2538 | fullDateRange = true; | 2544 | fullDateRange = true; |
2539 | Addressee newAdd; | 2545 | Addressee newAdd; |
2540 | addresseeRSync = newAdd; | 2546 | addresseeRSync = newAdd; |
2541 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2547 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2542 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2548 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2543 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2549 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2544 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2550 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2545 | } | 2551 | } |
2546 | } | 2552 | } |
2547 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2553 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2548 | qDebug("FULLDATE 2"); | 2554 | qDebug("FULLDATE 2"); |
2549 | fullDateRange = true; | 2555 | fullDateRange = true; |
2550 | } | 2556 | } |
2551 | if ( ! fullDateRange ) { | 2557 | if ( ! fullDateRange ) { |
2552 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2558 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2553 | 2559 | ||
2554 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2560 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2555 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2561 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2556 | fullDateRange = true; | 2562 | fullDateRange = true; |
2557 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2563 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2558 | } | 2564 | } |
2559 | } | 2565 | } |
2560 | // fullDateRange = true; // debug only! | 2566 | // fullDateRange = true; // debug only! |
2561 | if ( fullDateRange ) | 2567 | if ( fullDateRange ) |
2562 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2568 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2563 | else | 2569 | else |
2564 | mLastAddressbookSync = addresseeLSync.revision(); | 2570 | mLastAddressbookSync = addresseeLSync.revision(); |
2565 | // for resyncing if own file has changed | 2571 | // for resyncing if own file has changed |
2566 | // PENDING fixme later when implemented | 2572 | // PENDING fixme later when implemented |
2567 | #if 0 | 2573 | #if 0 |
2568 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2574 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2569 | mLastAddressbookSync = loadedFileVersion; | 2575 | mLastAddressbookSync = loadedFileVersion; |
2570 | qDebug("setting mLastAddressbookSync "); | 2576 | qDebug("setting mLastAddressbookSync "); |
2571 | } | 2577 | } |
2572 | #endif | 2578 | #endif |
2573 | 2579 | ||
2574 | //qDebug("*************************** "); | 2580 | //qDebug("*************************** "); |
2575 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2581 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2576 | QStringList er = remote->uidList(); | 2582 | QStringList er = remote->uidList(); |
2577 | Addressee inR ;//= er.first(); | 2583 | Addressee inR ;//= er.first(); |
2578 | Addressee inL; | 2584 | Addressee inL; |
2579 | 2585 | ||
2580 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2586 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2581 | 2587 | ||
2582 | int modulo = (er.count()/10)+1; | 2588 | int modulo = (er.count()/10)+1; |
2583 | int incCounter = 0; | 2589 | int incCounter = 0; |
2584 | while ( incCounter < er.count()) { | 2590 | while ( incCounter < er.count()) { |
2585 | if (syncManager->isProgressBarCanceled()) | 2591 | if (syncManager->isProgressBarCanceled()) |
2586 | return false; | 2592 | return false; |
2587 | if ( incCounter % modulo == 0 ) | 2593 | if ( incCounter % modulo == 0 ) |
2588 | syncManager->showProgressBar(incCounter); | 2594 | syncManager->showProgressBar(incCounter); |
2589 | 2595 | ||
2590 | uid = er[ incCounter ]; | 2596 | uid = er[ incCounter ]; |
2591 | bool skipIncidence = false; | 2597 | bool skipIncidence = false; |
2592 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2598 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2593 | skipIncidence = true; | 2599 | skipIncidence = true; |
2594 | QString idS,OidS; | 2600 | QString idS,OidS; |
2595 | qApp->processEvents(); | 2601 | qApp->processEvents(); |
2596 | if ( !skipIncidence ) { | 2602 | if ( !skipIncidence ) { |
2597 | inL = local->findByUid( uid ); | 2603 | inL = local->findByUid( uid ); |
2598 | inR = remote->findByUid( uid ); | 2604 | inR = remote->findByUid( uid ); |
2599 | //inL.setResource( 0 ); | 2605 | //inL.setResource( 0 ); |
2600 | //inR.setResource( 0 ); | 2606 | //inR.setResource( 0 ); |
2601 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2607 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2602 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2608 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2603 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2609 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2604 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2610 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2605 | if ( take == 3 ) | 2611 | if ( take == 3 ) |
2606 | return false; | 2612 | return false; |
2607 | if ( take == 1 ) {// take local | 2613 | if ( take == 1 ) {// take local |
2608 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2614 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2609 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2615 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2610 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2616 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2611 | local->insertAddressee( inL, false ); | 2617 | local->insertAddressee( inL, false ); |
2612 | idS = inR.externalUID(); | 2618 | idS = inR.externalUID(); |
2613 | OidS = inR.originalExternalUID(); | 2619 | OidS = inR.originalExternalUID(); |
2614 | } | 2620 | } |
2615 | else | 2621 | else |
2616 | idS = inR.IDStr(); | 2622 | idS = inR.IDStr(); |
2617 | remote->removeAddressee( inR ); | 2623 | remote->removeAddressee( inR ); |
2618 | inR = inL; | 2624 | inR = inL; |
2619 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2625 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2620 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2626 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2621 | inR.setOriginalExternalUID( OidS ); | 2627 | inR.setOriginalExternalUID( OidS ); |
2622 | inR.setExternalUID( idS ); | 2628 | inR.setExternalUID( idS ); |
2623 | if ( syncManager->syncWithDesktop() ) | 2629 | if ( syncManager->syncWithDesktop() ) |
2624 | inR.setIDStr("changed" ); | 2630 | inR.setIDStr("changed" ); |
2625 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); | 2631 | //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); |
2626 | } else { | 2632 | } else { |
2627 | inR.setIDStr( idS ); | 2633 | inR.setIDStr( idS ); |
2628 | } | 2634 | } |
2629 | inR.setResource( 0 ); | 2635 | inR.setResource( 0 ); |
2630 | remote->insertAddressee( inR , false); | 2636 | remote->insertAddressee( inR , false); |
2631 | ++changedRemote; | 2637 | ++changedRemote; |
2632 | } else { // take == 2 take remote | 2638 | } else { // take == 2 take remote |
2633 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2639 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2634 | if ( inR.revision().date().year() < 2004 ) | 2640 | if ( inR.revision().date().year() < 2004 ) |
2635 | inR.setRevision( modifiedCalendar ); | 2641 | inR.setRevision( modifiedCalendar ); |
2636 | } | 2642 | } |
2637 | idS = inL.IDStr(); | 2643 | idS = inL.IDStr(); |
2638 | local->removeAddressee( inL ); | 2644 | local->removeAddressee( inL ); |
2639 | inL = inR; | 2645 | inL = inR; |
2640 | inL.setIDStr( idS ); | 2646 | inL.setIDStr( idS ); |
2641 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2647 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2642 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2648 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2643 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2649 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2644 | } | 2650 | } |
2645 | inL.setResource( 0 ); | 2651 | inL.setResource( 0 ); |
2646 | local->insertAddressee( inL , false ); | 2652 | local->insertAddressee( inL , false ); |
2647 | ++changedLocal; | 2653 | ++changedLocal; |
2648 | } | 2654 | } |
2649 | } | 2655 | } |
2650 | } | 2656 | } |
2651 | } else { // no conflict | 2657 | } else { // no conflict |
2652 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2658 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2653 | QString des = addresseeLSync.note(); | 2659 | QString des = addresseeLSync.note(); |
2654 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2660 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2655 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2661 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2656 | remote->insertAddressee( inR, false ); | 2662 | remote->insertAddressee( inR, false ); |
2657 | ++deletedAddresseeR; | 2663 | ++deletedAddresseeR; |
2658 | } else { | 2664 | } else { |
2659 | inR.setRevision( modifiedCalendar ); | 2665 | inR.setRevision( modifiedCalendar ); |
2660 | remote->insertAddressee( inR, false ); | 2666 | remote->insertAddressee( inR, false ); |
2661 | inL = inR; | 2667 | inL = inR; |
2662 | inL.setResource( 0 ); | 2668 | inL.setResource( 0 ); |
2663 | local->insertAddressee( inL , false); | 2669 | local->insertAddressee( inL , false); |
2664 | ++addedAddressee; | 2670 | ++addedAddressee; |
2665 | } | 2671 | } |
2666 | } else { | 2672 | } else { |
2667 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2673 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2668 | inR.setRevision( modifiedCalendar ); | 2674 | inR.setRevision( modifiedCalendar ); |
2669 | remote->insertAddressee( inR, false ); | 2675 | remote->insertAddressee( inR, false ); |
2670 | inR.setResource( 0 ); | 2676 | inR.setResource( 0 ); |
2671 | local->insertAddressee( inR, false ); | 2677 | local->insertAddressee( inR, false ); |
2672 | ++addedAddressee; | 2678 | ++addedAddressee; |
2673 | } else { | 2679 | } else { |
2674 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2680 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2675 | remote->removeAddressee( inR ); | 2681 | remote->removeAddressee( inR ); |
2676 | ++deletedAddresseeR; | 2682 | ++deletedAddresseeR; |
2677 | } | 2683 | } |
2678 | } | 2684 | } |
2679 | } | 2685 | } |
2680 | } | 2686 | } |
2681 | ++incCounter; | 2687 | ++incCounter; |
2682 | } | 2688 | } |
2683 | er.clear(); | 2689 | er.clear(); |
2684 | QStringList el = local->uidList(); | 2690 | QStringList el = local->uidList(); |
2685 | modulo = (el.count()/10)+1; | 2691 | modulo = (el.count()/10)+1; |
2686 | 2692 | ||
2687 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2693 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2688 | incCounter = 0; | 2694 | incCounter = 0; |
2689 | while ( incCounter < el.count()) { | 2695 | while ( incCounter < el.count()) { |
2690 | qApp->processEvents(); | 2696 | qApp->processEvents(); |
2691 | if (syncManager->isProgressBarCanceled()) | 2697 | if (syncManager->isProgressBarCanceled()) |
2692 | return false; | 2698 | return false; |
2693 | if ( incCounter % modulo == 0 ) | 2699 | if ( incCounter % modulo == 0 ) |
2694 | syncManager->showProgressBar(incCounter); | 2700 | syncManager->showProgressBar(incCounter); |
2695 | uid = el[ incCounter ]; | 2701 | uid = el[ incCounter ]; |
2696 | bool skipIncidence = false; | 2702 | bool skipIncidence = false; |
2697 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2703 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2698 | skipIncidence = true; | 2704 | skipIncidence = true; |
2699 | if ( !skipIncidence ) { | 2705 | if ( !skipIncidence ) { |
2700 | inL = local->findByUid( uid ); | 2706 | inL = local->findByUid( uid ); |
2701 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2707 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2702 | inR = remote->findByUid( uid ); | 2708 | inR = remote->findByUid( uid ); |
2703 | if ( inR.isEmpty() ) { | 2709 | if ( inR.isEmpty() ) { |
2704 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2710 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2705 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2711 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2706 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2712 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2707 | local->removeAddressee( inL ); | 2713 | local->removeAddressee( inL ); |
2708 | ++deletedAddresseeL; | 2714 | ++deletedAddresseeL; |
2709 | } else { | 2715 | } else { |
2710 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2716 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2711 | inL.removeID(mCurrentSyncDevice ); | 2717 | inL.removeID(mCurrentSyncDevice ); |
2712 | ++addedAddresseeR; | 2718 | ++addedAddresseeR; |
2713 | inL.setRevision( modifiedCalendar ); | 2719 | inL.setRevision( modifiedCalendar ); |
2714 | local->insertAddressee( inL, false ); | 2720 | local->insertAddressee( inL, false ); |
2715 | inR = inL; | 2721 | inR = inL; |
2716 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2722 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2717 | inR.setResource( 0 ); | 2723 | inR.setResource( 0 ); |
2718 | remote->insertAddressee( inR, false ); | 2724 | remote->insertAddressee( inR, false ); |
2719 | } | 2725 | } |
2720 | } | 2726 | } |
2721 | } else { | 2727 | } else { |
2722 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2728 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2723 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2729 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2724 | local->removeAddressee( inL ); | 2730 | local->removeAddressee( inL ); |
2725 | ++deletedAddresseeL; | 2731 | ++deletedAddresseeL; |
2726 | } else { | 2732 | } else { |
2727 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2733 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2728 | ++addedAddresseeR; | 2734 | ++addedAddresseeR; |
2729 | inL.setRevision( modifiedCalendar ); | 2735 | inL.setRevision( modifiedCalendar ); |
2730 | local->insertAddressee( inL, false ); | 2736 | local->insertAddressee( inL, false ); |
2731 | inR = inL; | 2737 | inR = inL; |
2732 | inR.setResource( 0 ); | 2738 | inR.setResource( 0 ); |
2733 | remote->insertAddressee( inR, false ); | 2739 | remote->insertAddressee( inR, false ); |
2734 | } | 2740 | } |
2735 | } | 2741 | } |
2736 | } | 2742 | } |
2737 | } | 2743 | } |
2738 | } | 2744 | } |
2739 | } | 2745 | } |
2740 | ++incCounter; | 2746 | ++incCounter; |
2741 | } | 2747 | } |
2742 | el.clear(); | 2748 | el.clear(); |
2743 | syncManager->hideProgressBar(); | 2749 | syncManager->hideProgressBar(); |
2744 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2750 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2745 | // get rid of micro seconds | 2751 | // get rid of micro seconds |
2746 | QTime t = mLastAddressbookSync.time(); | 2752 | QTime t = mLastAddressbookSync.time(); |
2747 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2753 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2748 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2754 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2749 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2755 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2750 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2756 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2751 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2757 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2752 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2758 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2753 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2759 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2754 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2760 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2755 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2761 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2756 | addresseeRSync.setNote( "" ) ; | 2762 | addresseeRSync.setNote( "" ) ; |
2757 | addresseeLSync.setNote( "" ); | 2763 | addresseeLSync.setNote( "" ); |
2758 | 2764 | ||
2759 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2765 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2760 | remote->insertAddressee( addresseeRSync, false ); | 2766 | remote->insertAddressee( addresseeRSync, false ); |
2761 | local->insertAddressee( addresseeLSync, false ); | 2767 | local->insertAddressee( addresseeLSync, false ); |
2762 | QString mes; | 2768 | QString mes; |
2763 | 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 ); | 2769 | 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 ); |
2764 | if ( syncManager->mShowSyncSummary ) { | 2770 | if ( syncManager->mShowSyncSummary ) { |
2765 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2771 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2766 | } | 2772 | } |
2767 | qDebug( mes ); | 2773 | qDebug( mes ); |
2768 | return syncOK; | 2774 | return syncOK; |
2769 | } | 2775 | } |
2770 | 2776 | ||
2771 | 2777 | ||
2772 | //this is a overwritten callbackmethods from the syncinterface | 2778 | //this is a overwritten callbackmethods from the syncinterface |
2773 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2779 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2774 | { | 2780 | { |
2775 | 2781 | ||
2776 | //pending prepare addresseeview for output | 2782 | //pending prepare addresseeview for output |
2777 | //pending detect, if remote file has REV field. if not switch to external sync | 2783 | //pending detect, if remote file has REV field. if not switch to external sync |
2778 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2784 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2779 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2785 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2780 | 2786 | ||
2781 | AddressBook abLocal(filename,"syncContact"); | 2787 | AddressBook abLocal(filename,"syncContact"); |
2782 | bool syncOK = false; | 2788 | bool syncOK = false; |
2783 | if ( abLocal.load() ) { | 2789 | if ( abLocal.load() ) { |
2784 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2790 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2785 | bool external = false; | 2791 | bool external = false; |
2786 | bool isXML = false; | 2792 | bool isXML = false; |
2787 | if ( filename.right(4) == ".xml") { | 2793 | if ( filename.right(4) == ".xml") { |
2788 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2794 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2789 | isXML = true; | 2795 | isXML = true; |
2790 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2796 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2791 | } else { | 2797 | } else { |
2792 | external = !manager->mIsKapiFile; | 2798 | external = !manager->mIsKapiFile; |
2793 | if ( external ) { | 2799 | if ( external ) { |
2794 | qDebug("Setting vcf mode to external "); | 2800 | qDebug("Setting vcf mode to external "); |
2795 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2801 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2796 | AddressBook::Iterator it; | 2802 | AddressBook::Iterator it; |
2797 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2803 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2798 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2804 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2799 | (*it).computeCsum( mCurrentSyncDevice ); | 2805 | (*it).computeCsum( mCurrentSyncDevice ); |
2800 | } | 2806 | } |
2801 | } | 2807 | } |
2802 | } | 2808 | } |
2803 | //AddressBook::Iterator it; | 2809 | //AddressBook::Iterator it; |
2804 | //QStringList vcards; | 2810 | //QStringList vcards; |
2805 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2811 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2806 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2812 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2807 | //} | 2813 | //} |
2808 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2814 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2809 | if ( syncOK ) { | 2815 | if ( syncOK ) { |
2810 | if ( syncManager->mWriteBackFile ) | 2816 | if ( syncManager->mWriteBackFile ) |
2811 | { | 2817 | { |
2812 | if ( external ) | 2818 | if ( external ) |
2813 | abLocal.removeSyncAddressees( !isXML); | 2819 | abLocal.removeSyncAddressees( !isXML); |
2814 | qDebug("Saving remote AB "); | 2820 | qDebug("Saving remote AB "); |
2815 | if ( ! abLocal.saveAB()) | 2821 | if ( ! abLocal.saveAB()) |
2816 | qDebug("Error writing back AB to file "); | 2822 | qDebug("Error writing back AB to file "); |
2817 | if ( external ) { | 2823 | if ( external ) { |
2818 | // afterwrite processing | 2824 | // afterwrite processing |
2819 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); | 2825 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); |
2820 | } | 2826 | } |
2821 | } | 2827 | } |
2822 | } | 2828 | } |
2823 | setModified(); | 2829 | setModified(); |
2824 | 2830 | ||
2825 | } | 2831 | } |
2826 | if ( syncOK ) | 2832 | if ( syncOK ) |
2827 | mViewManager->refreshView(); | 2833 | mViewManager->refreshView(); |
2828 | return syncOK; | 2834 | return syncOK; |
2829 | 2835 | ||
2830 | } | 2836 | } |
2831 | void KABCore::removeSyncInfo( QString syncProfile) | 2837 | void KABCore::removeSyncInfo( QString syncProfile) |
2832 | { | 2838 | { |
2833 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); | 2839 | qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); |
2834 | mAddressBook->removeSyncInfo( syncProfile ); | 2840 | mAddressBook->removeSyncInfo( syncProfile ); |
2835 | setModified(); | 2841 | setModified(); |
2836 | } | 2842 | } |
2837 | 2843 | ||
2838 | 2844 | ||
2839 | //this is a overwritten callbackmethods from the syncinterface | 2845 | //this is a overwritten callbackmethods from the syncinterface |
2840 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2846 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2841 | { | 2847 | { |
2842 | if ( resource == "phone" ) | 2848 | if ( resource == "phone" ) |
2843 | return syncPhone(); | 2849 | return syncPhone(); |
2844 | disableBR( true ); | 2850 | disableBR( true ); |
2845 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2851 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2846 | 2852 | ||
2847 | AddressBook abLocal( resource,"syncContact"); | 2853 | AddressBook abLocal( resource,"syncContact"); |
2848 | bool syncOK = false; | 2854 | bool syncOK = false; |
2849 | if ( abLocal.load() ) { | 2855 | if ( abLocal.load() ) { |
2850 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2856 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2851 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2857 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2852 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2858 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2853 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2859 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2854 | if ( syncOK ) { | 2860 | if ( syncOK ) { |
2855 | if ( syncManager->mWriteBackFile ) { | 2861 | if ( syncManager->mWriteBackFile ) { |
2856 | abLocal.removeSyncAddressees( false ); | 2862 | abLocal.removeSyncAddressees( false ); |
2857 | abLocal.saveAB(); | 2863 | abLocal.saveAB(); |
2858 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2864 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2859 | } | 2865 | } |
2860 | } | 2866 | } |
2861 | setModified(); | 2867 | setModified(); |
2862 | } | 2868 | } |
2863 | if ( syncOK ) | 2869 | if ( syncOK ) |
2864 | mViewManager->refreshView(); | 2870 | mViewManager->refreshView(); |
2865 | disableBR( false ); | 2871 | disableBR( false ); |
2866 | return syncOK; | 2872 | return syncOK; |
2867 | 2873 | ||
2868 | } | 2874 | } |
2869 | void KABCore::message( QString m ) | 2875 | void KABCore::message( QString m ) |
2870 | { | 2876 | { |
2871 | topLevelWidget()->setCaption( m ); | 2877 | topLevelWidget()->setCaption( m ); |
2872 | mMessageTimer->start( 15000, true ); | 2878 | mMessageTimer->start( 15000, true ); |
2873 | } | 2879 | } |
2874 | bool KABCore::syncPhone() | 2880 | bool KABCore::syncPhone() |
2875 | { | 2881 | { |
2876 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2882 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2877 | QString fileName = getPhoneFile(); | 2883 | QString fileName = getPhoneFile(); |
2878 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2884 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2879 | message(i18n("Phone access failed!")); | 2885 | message(i18n("Phone access failed!")); |
2880 | return false; | 2886 | return false; |
2881 | } | 2887 | } |
2882 | AddressBook abLocal( fileName,"syncContact"); | 2888 | AddressBook abLocal( fileName,"syncContact"); |
2883 | bool syncOK = false; | 2889 | bool syncOK = false; |
2884 | { | 2890 | { |
2885 | abLocal.importFromFile( fileName ); | 2891 | abLocal.importFromFile( fileName ); |
2886 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2892 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2887 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2893 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2888 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2894 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2889 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2895 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2890 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2896 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2891 | if ( syncOK ) { | 2897 | if ( syncOK ) { |
2892 | if ( syncManager->mWriteBackFile ) { | 2898 | if ( syncManager->mWriteBackFile ) { |
2893 | abLocal.removeSyncAddressees( true ); | 2899 | abLocal.removeSyncAddressees( true ); |
2894 | abLocal.saveABphone( fileName ); | 2900 | abLocal.saveABphone( fileName ); |
2895 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2901 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2896 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2902 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2897 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); | 2903 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); |
2898 | } | 2904 | } |
2899 | } | 2905 | } |
2900 | setModified(); | 2906 | setModified(); |
2901 | } | 2907 | } |
2902 | if ( syncOK ) | 2908 | if ( syncOK ) |
2903 | mViewManager->refreshView(); | 2909 | mViewManager->refreshView(); |
2904 | return syncOK; | 2910 | return syncOK; |
2905 | } | 2911 | } |
2906 | void KABCore::getFile( bool success ) | 2912 | void KABCore::getFile( bool success ) |
2907 | { | 2913 | { |
2908 | if ( ! success ) { | 2914 | if ( ! success ) { |
2909 | message( i18n("Error receiving file. Nothing changed!") ); | 2915 | message( i18n("Error receiving file. Nothing changed!") ); |
2910 | return; | 2916 | return; |
2911 | } | 2917 | } |
2912 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2918 | int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2913 | if ( count ) | 2919 | if ( count ) |
2914 | setModified( true ); | 2920 | setModified( true ); |
2915 | message( i18n("Pi-Sync successful!") ); | 2921 | message( i18n("Pi-Sync successful!") ); |
2916 | mViewManager->refreshView(); | 2922 | mViewManager->refreshView(); |
2917 | } | 2923 | } |
2918 | void KABCore::syncFileRequest() | 2924 | void KABCore::syncFileRequest() |
2919 | { | 2925 | { |
2920 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { | 2926 | if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { |
2921 | syncManager->slotSyncMenu( 999 ); | 2927 | syncManager->slotSyncMenu( 999 ); |
2922 | } | 2928 | } |
2923 | mAddressBook->export2File( sentSyncFile() ); | 2929 | mAddressBook->export2File( sentSyncFile() ); |
2924 | } | 2930 | } |
2925 | QString KABCore::sentSyncFile() | 2931 | QString KABCore::sentSyncFile() |
2926 | { | 2932 | { |
2927 | #ifdef DESKTOP_VERSION | 2933 | #ifdef DESKTOP_VERSION |
2928 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2934 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2929 | #else | 2935 | #else |
2930 | return QString( "/tmp/copysyncab.vcf" ); | 2936 | return QString( "/tmp/copysyncab.vcf" ); |
2931 | #endif | 2937 | #endif |
2932 | } | 2938 | } |
2933 | 2939 | ||
2934 | void KABCore::setCaptionBack() | 2940 | void KABCore::setCaptionBack() |
2935 | { | 2941 | { |
2936 | mMessageTimer->stop(); | 2942 | mMessageTimer->stop(); |
2937 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2943 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2938 | } | 2944 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index a288505..6831ec9 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,503 +1,504 @@ | |||
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 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <qwidget.h> | 34 | #include <qwidget.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <ksyncmanager.h> | 36 | #include <ksyncmanager.h> |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | namespace KABC { | 41 | namespace KABC { |
42 | class AddressBook; | 42 | class AddressBook; |
43 | } | 43 | } |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | class KAboutData; | 46 | class KAboutData; |
47 | class KConfig; | 47 | class KConfig; |
48 | 48 | ||
49 | class KAddressBookService; | 49 | class KAddressBookService; |
50 | class LDAPSearchDialog; | 50 | class LDAPSearchDialog; |
51 | #else //KAB_EMBEDDED | 51 | #else //KAB_EMBEDDED |
52 | class KAddressBookMain; | 52 | class KAddressBookMain; |
53 | //US class QAction; | 53 | //US class QAction; |
54 | #endif //KAB_EMBEDDED | 54 | #endif //KAB_EMBEDDED |
55 | class KCMultiDialog; | 55 | class KCMultiDialog; |
56 | class KXMLGUIClient; | 56 | class KXMLGUIClient; |
57 | class ExtensionManager; | 57 | class ExtensionManager; |
58 | class XXPortManager; | 58 | class XXPortManager; |
59 | class JumpButtonBar; | 59 | class JumpButtonBar; |
60 | class IncSearchWidget; | 60 | class IncSearchWidget; |
61 | class KDGanttMinimizeSplitter; | 61 | class KDGanttMinimizeSplitter; |
62 | class KAction; | 62 | class KAction; |
63 | class KActionCollection; | 63 | class KActionCollection; |
64 | class KToggleAction; | 64 | class KToggleAction; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | 66 | ||
67 | class QAction; | 67 | class QAction; |
68 | class QMenuBar; | 68 | class QMenuBar; |
69 | class QSplitter; | 69 | class QSplitter; |
70 | class ViewContainer; | 70 | class ViewContainer; |
71 | class ViewManager; | 71 | class ViewManager; |
72 | class AddresseeEditorDialog; | 72 | class AddresseeEditorDialog; |
73 | class Ir; | 73 | class Ir; |
74 | 74 | ||
75 | class KABCore : public QWidget, public KSyncInterface | 75 | class KABCore : public QWidget, public KSyncInterface |
76 | { | 76 | { |
77 | Q_OBJECT | 77 | Q_OBJECT |
78 | 78 | ||
79 | public: | 79 | public: |
80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 80 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
81 | 81 | ||
82 | 82 | ||
83 | ~KABCore(); | 83 | ~KABCore(); |
84 | 84 | ||
85 | 85 | ||
86 | #ifdef KAB_EMBEDDED | 86 | #ifdef KAB_EMBEDDED |
87 | //US added functionality | 87 | //US added functionality |
88 | QPopupMenu* getViewMenu() {return viewMenu;} | 88 | QPopupMenu* getViewMenu() {return viewMenu;} |
89 | QPopupMenu* getFilterMenu() {return filterMenu;} | 89 | QPopupMenu* getFilterMenu() {return filterMenu;} |
90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 90 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
91 | void addActionsManually(); | 91 | void addActionsManually(); |
92 | #endif //KAB_EMBEDDED | 92 | #endif //KAB_EMBEDDED |
93 | /** | 93 | /** |
94 | Restores the global settings. | 94 | Restores the global settings. |
95 | */ | 95 | */ |
96 | void restoreSettings(); | 96 | void restoreSettings(); |
97 | 97 | ||
98 | /** | 98 | /** |
99 | Saves the global settings. | 99 | Saves the global settings. |
100 | */ | 100 | */ |
101 | void saveSettings(); | 101 | void saveSettings(); |
102 | 102 | ||
103 | /** | 103 | /** |
104 | Returns a pointer to the StdAddressBook of the application. | 104 | Returns a pointer to the StdAddressBook of the application. |
105 | */ | 105 | */ |
106 | KABC::AddressBook *addressBook() const; | 106 | KABC::AddressBook *addressBook() const; |
107 | 107 | ||
108 | /** | 108 | /** |
109 | Returns a pointer to the KConfig object of the application. | 109 | Returns a pointer to the KConfig object of the application. |
110 | */ | 110 | */ |
111 | static KConfig *config(); | 111 | static KConfig *config(); |
112 | 112 | ||
113 | /** | 113 | /** |
114 | Returns a pointer to the global KActionCollection object. So | 114 | Returns a pointer to the global KActionCollection object. So |
115 | other classes can register their actions easily. | 115 | other classes can register their actions easily. |
116 | */ | 116 | */ |
117 | KActionCollection *actionCollection() const; | 117 | KActionCollection *actionCollection() const; |
118 | 118 | ||
119 | /** | 119 | /** |
120 | Returns the current search field of the Incremental Search Widget. | 120 | Returns the current search field of the Incremental Search Widget. |
121 | */ | 121 | */ |
122 | KABC::Field *currentSearchField() const; | 122 | KABC::Field *currentSearchField() const; |
123 | 123 | ||
124 | /** | 124 | /** |
125 | Returns the uid list of the currently selected contacts. | 125 | Returns the uid list of the currently selected contacts. |
126 | */ | 126 | */ |
127 | QStringList selectedUIDs() const; | 127 | QStringList selectedUIDs() const; |
128 | 128 | ||
129 | /** | 129 | /** |
130 | Displays the ResourceSelectDialog and returns the selected | 130 | Displays the ResourceSelectDialog and returns the selected |
131 | resource or a null pointer if no resource was selected by | 131 | resource or a null pointer if no resource was selected by |
132 | the user. | 132 | the user. |
133 | */ | 133 | */ |
134 | KABC::Resource *requestResource( QWidget *parent ); | 134 | KABC::Resource *requestResource( QWidget *parent ); |
135 | 135 | ||
136 | #ifndef KAB_EMBEDDED | 136 | #ifndef KAB_EMBEDDED |
137 | static KAboutData *createAboutData(); | 137 | static KAboutData *createAboutData(); |
138 | #endif //KAB_EMBEDDED | 138 | #endif //KAB_EMBEDDED |
139 | 139 | ||
140 | #ifdef KAB_EMBEDDED | 140 | #ifdef KAB_EMBEDDED |
141 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 141 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
142 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 142 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
143 | #endif //KAB_EMBEDDED | 143 | #endif //KAB_EMBEDDED |
144 | 144 | ||
145 | public slots: | 145 | public slots: |
146 | #ifdef KAB_EMBEDDED | 146 | #ifdef KAB_EMBEDDED |
147 | void createAboutData(); | 147 | void createAboutData(); |
148 | #endif //KAB_EMBEDDED | 148 | #endif //KAB_EMBEDDED |
149 | void setDetailsToggle(); | ||
149 | 150 | ||
150 | void showLicence(); | 151 | void showLicence(); |
151 | void faq(); | 152 | void faq(); |
152 | void whatsnew() ; | 153 | void whatsnew() ; |
153 | void synchowto() ; | 154 | void synchowto() ; |
154 | void writeToPhone(); | 155 | void writeToPhone(); |
155 | 156 | ||
156 | /** | 157 | /** |
157 | Is called whenever a contact is selected in the view. | 158 | Is called whenever a contact is selected in the view. |
158 | */ | 159 | */ |
159 | void setContactSelected( const QString &uid ); | 160 | void setContactSelected( const QString &uid ); |
160 | 161 | ||
161 | /** | 162 | /** |
162 | Opens the preferred mail composer with all selected contacts as | 163 | Opens the preferred mail composer with all selected contacts as |
163 | arguments. | 164 | arguments. |
164 | */ | 165 | */ |
165 | void sendMail(); | 166 | void sendMail(); |
166 | 167 | ||
167 | /** | 168 | /** |
168 | Opens the preferred mail composer with the given contacts as | 169 | Opens the preferred mail composer with the given contacts as |
169 | arguments. | 170 | arguments. |
170 | */ | 171 | */ |
171 | void sendMail( const QString& email ); | 172 | void sendMail( const QString& email ); |
172 | 173 | ||
173 | 174 | ||
174 | void mailVCard(); | 175 | void mailVCard(); |
175 | void mailVCard(const QStringList& uids); | 176 | void mailVCard(const QStringList& uids); |
176 | 177 | ||
177 | /** | 178 | /** |
178 | Beams the "WhoAmI contact. | 179 | Beams the "WhoAmI contact. |
179 | */ | 180 | */ |
180 | void beamMySelf(); | 181 | void beamMySelf(); |
181 | 182 | ||
182 | void beamVCard(); | 183 | void beamVCard(); |
183 | void export2phone(); | 184 | void export2phone(); |
184 | void beamVCard(const QStringList& uids); | 185 | void beamVCard(const QStringList& uids); |
185 | void beamDone( Ir *ir ); | 186 | void beamDone( Ir *ir ); |
186 | 187 | ||
187 | 188 | ||
188 | /** | 189 | /** |
189 | Starts the preferred web browser with the given URL as argument. | 190 | Starts the preferred web browser with the given URL as argument. |
190 | */ | 191 | */ |
191 | void browse( const QString& url ); | 192 | void browse( const QString& url ); |
192 | 193 | ||
193 | /** | 194 | /** |
194 | Select all contacts in the view. | 195 | Select all contacts in the view. |
195 | */ | 196 | */ |
196 | void selectAllContacts(); | 197 | void selectAllContacts(); |
197 | 198 | ||
198 | /** | 199 | /** |
199 | Deletes all selected contacts from the address book. | 200 | Deletes all selected contacts from the address book. |
200 | */ | 201 | */ |
201 | void deleteContacts(); | 202 | void deleteContacts(); |
202 | 203 | ||
203 | /** | 204 | /** |
204 | Deletes given contacts from the address book. | 205 | Deletes given contacts from the address book. |
205 | 206 | ||
206 | @param uids The uids of the contacts, which shall be deleted. | 207 | @param uids The uids of the contacts, which shall be deleted. |
207 | */ | 208 | */ |
208 | void deleteContacts( const QStringList &uids ); | 209 | void deleteContacts( const QStringList &uids ); |
209 | 210 | ||
210 | /** | 211 | /** |
211 | Copys the selected contacts into clipboard for later pasting. | 212 | Copys the selected contacts into clipboard for later pasting. |
212 | */ | 213 | */ |
213 | void copyContacts(); | 214 | void copyContacts(); |
214 | 215 | ||
215 | /** | 216 | /** |
216 | Cuts the selected contacts and stores them for later pasting. | 217 | Cuts the selected contacts and stores them for later pasting. |
217 | */ | 218 | */ |
218 | void cutContacts(); | 219 | void cutContacts(); |
219 | 220 | ||
220 | /** | 221 | /** |
221 | Paste contacts from clipboard into the address book. | 222 | Paste contacts from clipboard into the address book. |
222 | */ | 223 | */ |
223 | void pasteContacts(); | 224 | void pasteContacts(); |
224 | 225 | ||
225 | /** | 226 | /** |
226 | Paste given contacts into the address book. | 227 | Paste given contacts into the address book. |
227 | 228 | ||
228 | @param list The list of addressee, which shall be pasted. | 229 | @param list The list of addressee, which shall be pasted. |
229 | */ | 230 | */ |
230 | void pasteContacts( KABC::Addressee::List &list ); | 231 | void pasteContacts( KABC::Addressee::List &list ); |
231 | 232 | ||
232 | /** | 233 | /** |
233 | Sets the whoAmI contact, that is used by many other programs to | 234 | Sets the whoAmI contact, that is used by many other programs to |
234 | get personal information about the current user. | 235 | get personal information about the current user. |
235 | */ | 236 | */ |
236 | void setWhoAmI(); | 237 | void setWhoAmI(); |
237 | 238 | ||
238 | /** | 239 | /** |
239 | Displays the category dialog and applies the result to all | 240 | Displays the category dialog and applies the result to all |
240 | selected contacts. | 241 | selected contacts. |
241 | */ | 242 | */ |
242 | void setCategories(); | 243 | void setCategories(); |
243 | 244 | ||
244 | /** | 245 | /** |
245 | Sets the field list of the Incremental Search Widget. | 246 | Sets the field list of the Incremental Search Widget. |
246 | */ | 247 | */ |
247 | void setSearchFields( const KABC::Field::List &fields ); | 248 | void setSearchFields( const KABC::Field::List &fields ); |
248 | 249 | ||
249 | /** | 250 | /** |
250 | Search with the current search field for a contact, that matches | 251 | Search with the current search field for a contact, that matches |
251 | the given text, and selects it in the view. | 252 | the given text, and selects it in the view. |
252 | */ | 253 | */ |
253 | void incrementalSearch( const QString& text ); | 254 | void incrementalSearch( const QString& text ); |
254 | 255 | ||
255 | /** | 256 | /** |
256 | Marks the address book as modified. | 257 | Marks the address book as modified. |
257 | */ | 258 | */ |
258 | void setModified(); | 259 | void setModified(); |
259 | /** | 260 | /** |
260 | Marks the address book as modified without refreshing the view. | 261 | Marks the address book as modified without refreshing the view. |
261 | */ | 262 | */ |
262 | void setModifiedWOrefresh(); | 263 | void setModifiedWOrefresh(); |
263 | 264 | ||
264 | /** | 265 | /** |
265 | Marks the address book as modified concerning the argument. | 266 | Marks the address book as modified concerning the argument. |
266 | */ | 267 | */ |
267 | void setModified( bool modified ); | 268 | void setModified( bool modified ); |
268 | 269 | ||
269 | /** | 270 | /** |
270 | Returns whether the address book is modified. | 271 | Returns whether the address book is modified. |
271 | */ | 272 | */ |
272 | bool modified() const; | 273 | bool modified() const; |
273 | 274 | ||
274 | /** | 275 | /** |
275 | Called whenever an contact is modified in the contact editor | 276 | Called whenever an contact is modified in the contact editor |
276 | dialog or the quick edit. | 277 | dialog or the quick edit. |
277 | */ | 278 | */ |
278 | void contactModified( const KABC::Addressee &addr ); | 279 | void contactModified( const KABC::Addressee &addr ); |
279 | 280 | ||
280 | /** | 281 | /** |
281 | DCOP METHODS. | 282 | DCOP METHODS. |
282 | */ | 283 | */ |
283 | void addEmail( QString addr ); | 284 | void addEmail( QString addr ); |
284 | void importVCard( const KURL& url, bool showPreview ); | 285 | void importVCard( const KURL& url, bool showPreview ); |
285 | void importVCard( const QString& vCard, bool showPreview ); | 286 | void importVCard( const QString& vCard, bool showPreview ); |
286 | void newContact(); | 287 | void newContact(); |
287 | QString getNameByPhone( const QString& phone ); | 288 | QString getNameByPhone( const QString& phone ); |
288 | /** | 289 | /** |
289 | END DCOP METHODS | 290 | END DCOP METHODS |
290 | */ | 291 | */ |
291 | 292 | ||
292 | /** | 293 | /** |
293 | Saves the contents of the AddressBook back to disk. | 294 | Saves the contents of the AddressBook back to disk. |
294 | */ | 295 | */ |
295 | void save(); | 296 | void save(); |
296 | 297 | ||
297 | /** | 298 | /** |
298 | Undos the last command using the undo stack. | 299 | Undos the last command using the undo stack. |
299 | */ | 300 | */ |
300 | void undo(); | 301 | void undo(); |
301 | 302 | ||
302 | /** | 303 | /** |
303 | Redos the last command that was undone, using the redo stack. | 304 | Redos the last command that was undone, using the redo stack. |
304 | */ | 305 | */ |
305 | void redo(); | 306 | void redo(); |
306 | 307 | ||
307 | /** | 308 | /** |
308 | Shows the edit dialog for the given uid. If the uid is QString::null, | 309 | Shows the edit dialog for the given uid. If the uid is QString::null, |
309 | the method will try to find a selected addressee in the view. | 310 | the method will try to find a selected addressee in the view. |
310 | */ | 311 | */ |
311 | void editContact( const QString &uid /*US = QString::null*/ ); | 312 | void editContact( const QString &uid /*US = QString::null*/ ); |
312 | //US added a second method without defaultparameter | 313 | //US added a second method without defaultparameter |
313 | void editContact2(); | 314 | void editContact2(); |
314 | 315 | ||
315 | /** | 316 | /** |
316 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 317 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
317 | the method will try to find a selected addressee in the view. | 318 | the method will try to find a selected addressee in the view. |
318 | */ | 319 | */ |
319 | void executeContact( const QString &uid /*US = QString::null*/ ); | 320 | void executeContact( const QString &uid /*US = QString::null*/ ); |
320 | 321 | ||
321 | /** | 322 | /** |
322 | Launches the configuration dialog. | 323 | Launches the configuration dialog. |
323 | */ | 324 | */ |
324 | void openConfigDialog(); | 325 | void openConfigDialog(); |
325 | 326 | ||
326 | /** | 327 | /** |
327 | Launches the ldap search dialog. | 328 | Launches the ldap search dialog. |
328 | */ | 329 | */ |
329 | void openLDAPDialog(); | 330 | void openLDAPDialog(); |
330 | 331 | ||
331 | /** | 332 | /** |
332 | Creates a KAddressBookPrinter, which will display the print | 333 | Creates a KAddressBookPrinter, which will display the print |
333 | dialog and do the printing. | 334 | dialog and do the printing. |
334 | */ | 335 | */ |
335 | void print(); | 336 | void print(); |
336 | 337 | ||
337 | /** | 338 | /** |
338 | Registers a new GUI client, so plugins can register its actions. | 339 | Registers a new GUI client, so plugins can register its actions. |
339 | */ | 340 | */ |
340 | void addGUIClient( KXMLGUIClient *client ); | 341 | void addGUIClient( KXMLGUIClient *client ); |
341 | 342 | ||
342 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 343 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
343 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 344 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
344 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 345 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
345 | 346 | ||
346 | 347 | ||
347 | signals: | 348 | signals: |
348 | void contactSelected( const QString &name ); | 349 | void contactSelected( const QString &name ); |
349 | void contactSelected( const QPixmap &pixmap ); | 350 | void contactSelected( const QPixmap &pixmap ); |
350 | public slots: | 351 | public slots: |
351 | void recieve(QString cmsg ); | 352 | void recieve(QString cmsg ); |
352 | void getFile( bool success ); | 353 | void getFile( bool success ); |
353 | void syncFileRequest(); | 354 | void syncFileRequest(); |
354 | void setDetailsVisible( bool visible ); | 355 | void setDetailsVisible( bool visible ); |
355 | void setDetailsToState(); | 356 | void setDetailsToState(); |
356 | // void slotSyncMenu( int ); | 357 | // void slotSyncMenu( int ); |
357 | private slots: | 358 | private slots: |
358 | void receive( const QCString& cmsg, const QByteArray& data ); | 359 | void receive( const QCString& cmsg, const QByteArray& data ); |
359 | void toggleBeamReceive( ); | 360 | void toggleBeamReceive( ); |
360 | void disableBR(bool); | 361 | void disableBR(bool); |
361 | void setJumpButtonBarVisible( bool visible ); | 362 | void setJumpButtonBarVisible( bool visible ); |
362 | void setCaptionBack(); | 363 | void setCaptionBack(); |
363 | void importFromOL(); | 364 | void importFromOL(); |
364 | void extensionModified( const KABC::Addressee::List &list ); | 365 | void extensionModified( const KABC::Addressee::List &list ); |
365 | void extensionChanged( int id ); | 366 | void extensionChanged( int id ); |
366 | void clipboardDataChanged(); | 367 | void clipboardDataChanged(); |
367 | void updateActionMenu(); | 368 | void updateActionMenu(); |
368 | void configureKeyBindings(); | 369 | void configureKeyBindings(); |
369 | void removeVoice(); | 370 | void removeVoice(); |
370 | #ifdef KAB_EMBEDDED | 371 | #ifdef KAB_EMBEDDED |
371 | void configureResources(); | 372 | void configureResources(); |
372 | #endif //KAB_EMBEDDED | 373 | #endif //KAB_EMBEDDED |
373 | 374 | ||
374 | void slotEditorDestroyed( const QString &uid ); | 375 | void slotEditorDestroyed( const QString &uid ); |
375 | void configurationChanged(); | 376 | void configurationChanged(); |
376 | void addressBookChanged(); | 377 | void addressBookChanged(); |
377 | 378 | ||
378 | private: | 379 | private: |
379 | bool mBRdisabled; | 380 | bool mBRdisabled; |
380 | #ifndef DESKTOP_VERSION | 381 | #ifndef DESKTOP_VERSION |
381 | QCopChannel* infrared; | 382 | QCopChannel* infrared; |
382 | #endif | 383 | #endif |
383 | QTimer *mMessageTimer; | 384 | QTimer *mMessageTimer; |
384 | void initGUI(); | 385 | void initGUI(); |
385 | void initActions(); | 386 | void initActions(); |
386 | QString getPhoneFile(); | 387 | QString getPhoneFile(); |
387 | 388 | ||
388 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 389 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
389 | const char *name = 0 ); | 390 | const char *name = 0 ); |
390 | 391 | ||
391 | KXMLGUIClient *mGUIClient; | 392 | KXMLGUIClient *mGUIClient; |
392 | 393 | ||
393 | KABC::AddressBook *mAddressBook; | 394 | KABC::AddressBook *mAddressBook; |
394 | 395 | ||
395 | ViewManager *mViewManager; | 396 | ViewManager *mViewManager; |
396 | // QSplitter *mDetailsSplitter; | 397 | // QSplitter *mDetailsSplitter; |
397 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 398 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
398 | ViewContainer *mDetails; | 399 | ViewContainer *mDetails; |
399 | KDGanttMinimizeSplitter* mMiniSplitter; | 400 | KDGanttMinimizeSplitter* mMiniSplitter; |
400 | XXPortManager *mXXPortManager; | 401 | XXPortManager *mXXPortManager; |
401 | JumpButtonBar *mJumpButtonBar; | 402 | JumpButtonBar *mJumpButtonBar; |
402 | IncSearchWidget *mIncSearchWidget; | 403 | IncSearchWidget *mIncSearchWidget; |
403 | ExtensionManager *mExtensionManager; | 404 | ExtensionManager *mExtensionManager; |
404 | 405 | ||
405 | KCMultiDialog *mConfigureDialog; | 406 | KCMultiDialog *mConfigureDialog; |
406 | 407 | ||
407 | #ifndef KAB_EMBEDDED | 408 | #ifndef KAB_EMBEDDED |
408 | LDAPSearchDialog *mLdapSearchDialog; | 409 | LDAPSearchDialog *mLdapSearchDialog; |
409 | #endif //KAB_EMBEDDED | 410 | #endif //KAB_EMBEDDED |
410 | // QDict<AddresseeEditorDialog> mEditorDict; | 411 | // QDict<AddresseeEditorDialog> mEditorDict; |
411 | AddresseeEditorDialog *mEditorDialog; | 412 | AddresseeEditorDialog *mEditorDialog; |
412 | bool mReadWrite; | 413 | bool mReadWrite; |
413 | bool mModified; | 414 | bool mModified; |
414 | bool mIsPart; | 415 | bool mIsPart; |
415 | bool mMultipleViewsAtOnce; | 416 | bool mMultipleViewsAtOnce; |
416 | 417 | ||
417 | 418 | ||
418 | //US file menu | 419 | //US file menu |
419 | KAction *mActionMail; | 420 | KAction *mActionMail; |
420 | KAction *mActionBeam; | 421 | KAction *mActionBeam; |
421 | KToggleAction *mActionBR; | 422 | KToggleAction *mActionBR; |
422 | KAction *mActionExport2phone; | 423 | KAction *mActionExport2phone; |
423 | KAction* mActionPrint; | 424 | KAction* mActionPrint; |
424 | KAction* mActionNewContact; | 425 | KAction* mActionNewContact; |
425 | KAction *mActionSave; | 426 | KAction *mActionSave; |
426 | KAction *mActionEditAddressee; | 427 | KAction *mActionEditAddressee; |
427 | KAction *mActionMailVCard; | 428 | KAction *mActionMailVCard; |
428 | KAction *mActionBeamVCard; | 429 | KAction *mActionBeamVCard; |
429 | 430 | ||
430 | KAction *mActionQuit; | 431 | KAction *mActionQuit; |
431 | 432 | ||
432 | //US edit menu | 433 | //US edit menu |
433 | KAction *mActionCopy; | 434 | KAction *mActionCopy; |
434 | KAction *mActionCut; | 435 | KAction *mActionCut; |
435 | KAction *mActionPaste; | 436 | KAction *mActionPaste; |
436 | KAction *mActionSelectAll; | 437 | KAction *mActionSelectAll; |
437 | KAction *mActionUndo; | 438 | KAction *mActionUndo; |
438 | KAction *mActionRedo; | 439 | KAction *mActionRedo; |
439 | KAction *mActionDelete; | 440 | KAction *mActionDelete; |
440 | 441 | ||
441 | //US settings menu | 442 | //US settings menu |
442 | KAction *mActionConfigResources; | 443 | KAction *mActionConfigResources; |
443 | KAction *mActionConfigKAddressbook; | 444 | KAction *mActionConfigKAddressbook; |
444 | KAction *mActionConfigShortcuts; | 445 | KAction *mActionConfigShortcuts; |
445 | KAction *mActionConfigureToolbars; | 446 | KAction *mActionConfigureToolbars; |
446 | KAction *mActionKeyBindings; | 447 | KAction *mActionKeyBindings; |
447 | KToggleAction *mActionJumpBar; | 448 | KToggleAction *mActionJumpBar; |
448 | KToggleAction *mActionDetails; | 449 | KToggleAction *mActionDetails; |
449 | KAction *mActionWhoAmI; | 450 | KAction *mActionWhoAmI; |
450 | KAction *mActionCategories; | 451 | KAction *mActionCategories; |
451 | KAction *mActionAboutKAddressbook; | 452 | KAction *mActionAboutKAddressbook; |
452 | KAction *mActionLicence; | 453 | KAction *mActionLicence; |
453 | KAction *mActionFaq; | 454 | KAction *mActionFaq; |
454 | KAction *mActionWN; | 455 | KAction *mActionWN; |
455 | KAction *mActionSyncHowto; | 456 | KAction *mActionSyncHowto; |
456 | 457 | ||
457 | KAction *mActionDeleteView; | 458 | KAction *mActionDeleteView; |
458 | 459 | ||
459 | QPopupMenu *viewMenu; | 460 | QPopupMenu *viewMenu; |
460 | QPopupMenu *filterMenu; | 461 | QPopupMenu *filterMenu; |
461 | QPopupMenu *settingsMenu; | 462 | QPopupMenu *settingsMenu; |
462 | QPopupMenu *changeMenu; | 463 | QPopupMenu *changeMenu; |
463 | //US QAction *mActionSave; | 464 | //US QAction *mActionSave; |
464 | QPopupMenu *ImportMenu; | 465 | QPopupMenu *ImportMenu; |
465 | QPopupMenu *ExportMenu; | 466 | QPopupMenu *ExportMenu; |
466 | //LR additional methods | 467 | //LR additional methods |
467 | KAction *mActionRemoveVoice; | 468 | KAction *mActionRemoveVoice; |
468 | KAction * mActionImportOL; | 469 | KAction * mActionImportOL; |
469 | 470 | ||
470 | #ifndef KAB_EMBEDDED | 471 | #ifndef KAB_EMBEDDED |
471 | KAddressBookService *mAddressBookService; | 472 | KAddressBookService *mAddressBookService; |
472 | #endif //KAB_EMBEDDED | 473 | #endif //KAB_EMBEDDED |
473 | 474 | ||
474 | class KABCorePrivate; | 475 | class KABCorePrivate; |
475 | KABCorePrivate *d; | 476 | KABCorePrivate *d; |
476 | //US bool mBlockSaveFlag; | 477 | //US bool mBlockSaveFlag; |
477 | 478 | ||
478 | #ifdef KAB_EMBEDDED | 479 | #ifdef KAB_EMBEDDED |
479 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 480 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
480 | #endif //KAB_EMBEDDED | 481 | #endif //KAB_EMBEDDED |
481 | 482 | ||
482 | //this are the overwritten callbackmethods from the syncinterface | 483 | //this are the overwritten callbackmethods from the syncinterface |
483 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 484 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
484 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 485 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
485 | virtual void removeSyncInfo( QString syncProfile); | 486 | virtual void removeSyncInfo( QString syncProfile); |
486 | bool syncPhone(); | 487 | bool syncPhone(); |
487 | void message( QString m ); | 488 | void message( QString m ); |
488 | 489 | ||
489 | // LR ******************************* | 490 | // LR ******************************* |
490 | // sync stuff! | 491 | // sync stuff! |
491 | QString sentSyncFile(); | 492 | QString sentSyncFile(); |
492 | QPopupMenu *syncMenu; | 493 | QPopupMenu *syncMenu; |
493 | KSyncManager* syncManager; | 494 | KSyncManager* syncManager; |
494 | int mGlobalSyncMode; | 495 | int mGlobalSyncMode; |
495 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 496 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
496 | KABC::Addressee getLastSyncAddressee(); | 497 | KABC::Addressee getLastSyncAddressee(); |
497 | QDateTime mLastAddressbookSync; | 498 | QDateTime mLastAddressbookSync; |
498 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 499 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
499 | // ********************* | 500 | // ********************* |
500 | 501 | ||
501 | }; | 502 | }; |
502 | 503 | ||
503 | #endif | 504 | #endif |
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 9085673..9f12152 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -1,1181 +1,1187 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | 31 | ||
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qtopia/qcopenvelope_qws.h> | 38 | #include <qtopia/qcopenvelope_qws.h> |
39 | #else | 39 | #else |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | 45 | ||
46 | 46 | ||
47 | #include "externalapphandler.h" | 47 | #include "externalapphandler.h" |
48 | 48 | ||
49 | #include "kpimglobalprefs.h" | 49 | #include "kpimglobalprefs.h" |
50 | 50 | ||
51 | //uncomment line to get debug output | 51 | //uncomment line to get debug output |
52 | //#define DEBUG_EXT_APP_HANDLER | 52 | //#define DEBUG_EXT_APP_HANDLER |
53 | 53 | ||
54 | /********************************************************************************* | 54 | /********************************************************************************* |
55 | * | 55 | * |
56 | ********************************************************************************/ | 56 | ********************************************************************************/ |
57 | 57 | ||
58 | 58 | ||
59 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 59 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
60 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) | 60 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) |
61 | { | 61 | { |
62 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 | 62 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 |
63 | if (_usedSourceParameters == 0) | 63 | if (_usedSourceParameters == 0) |
64 | _sourceMessageParameters = "QString,QString)"; | 64 | _sourceMessageParameters = "QString,QString)"; |
65 | else if (_usedSourceParameters == 1) | 65 | else if (_usedSourceParameters == 1) |
66 | _sourceMessageParameters = "(QString,QString,QString)"; | 66 | _sourceMessageParameters = "(QString,QString,QString)"; |
67 | else if (_usedSourceParameters == 2) | 67 | else if (_usedSourceParameters == 2) |
68 | _sourceMessageParameters = "(QString,QString,QString,QString)"; | 68 | _sourceMessageParameters = "(QString,QString,QString,QString)"; |
69 | else if (_usedSourceParameters == 3) | 69 | else if (_usedSourceParameters == 3) |
70 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; | 70 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; |
71 | } | 71 | } |
72 | 72 | ||
73 | /*********************************************************************************/ | 73 | /*********************************************************************************/ |
74 | 74 | ||
75 | QCopTransferItem::QCopTransferItem() | 75 | QCopTransferItem::QCopTransferItem() |
76 | { | 76 | { |
77 | } | 77 | } |
78 | 78 | ||
79 | /*********************************************************************************/ | 79 | /*********************************************************************************/ |
80 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) | 80 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) |
81 | { | 81 | { |
82 | 82 | ||
83 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
84 | //sourceMessage passes two parameters: sourceChannel, uid | 84 | //sourceMessage passes two parameters: sourceChannel, uid |
85 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; | 85 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; |
86 | #ifdef DEBUG_EXT_APP_HANDLER | 86 | #ifdef DEBUG_EXT_APP_HANDLER |
87 | qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); | 87 | qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); |
88 | qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); | 88 | qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); |
89 | #endif | 89 | #endif |
90 | 90 | ||
91 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); | 91 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); |
92 | 92 | ||
93 | e << _sourceChannel << uid; | 93 | e << _sourceChannel << uid; |
94 | 94 | ||
95 | if (_usedSourceParameters == 1) | 95 | if (_usedSourceParameters == 1) |
96 | e << param1; | 96 | e << param1; |
97 | else if (_usedSourceParameters == 2) | 97 | else if (_usedSourceParameters == 2) |
98 | e << param1 << param2; | 98 | e << param1 << param2; |
99 | else if (_usedSourceParameters == 3) | 99 | else if (_usedSourceParameters == 3) |
100 | e << param1 << param2 << param3; | 100 | e << param1 << param2 << param3; |
101 | 101 | ||
102 | qApp->processEvents(); | 102 | qApp->processEvents(); |
103 | 103 | ||
104 | return true; | 104 | return true; |
105 | 105 | ||
106 | #else | 106 | #else |
107 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 107 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
108 | return false; | 108 | return false; |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | /*********************************************************************************/ | 114 | /*********************************************************************************/ |
115 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) | 115 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) |
116 | { | 116 | { |
117 | 117 | ||
118 | if ( !sourceChannel.isEmpty()) | 118 | if ( !sourceChannel.isEmpty()) |
119 | _sourceChannel = sourceChannel; | 119 | _sourceChannel = sourceChannel; |
120 | } | 120 | } |
121 | 121 | ||
122 | 122 | ||
123 | /*********************************************************************************/ | 123 | /*********************************************************************************/ |
124 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 124 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
125 | { | 125 | { |
126 | 126 | ||
127 | // copied from old mail2 | 127 | // copied from old mail2 |
128 | /* | 128 | /* |
129 | static int ii = 0; | 129 | static int ii = 0; |
130 | 130 | ||
131 | // block second call | 131 | // block second call |
132 | if ( ii < 2 ) { | 132 | if ( ii < 2 ) { |
133 | ++ii; | 133 | ++ii; |
134 | if ( ii > 1 ) { | 134 | if ( ii > 1 ) { |
135 | qDebug("qcop call blocked "); | 135 | qDebug("qcop call blocked "); |
136 | return true; | 136 | return true; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | */ | 139 | */ |
140 | 140 | ||
141 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); | 141 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); |
142 | 142 | ||
143 | //we are in the target and get a request from the source | 143 | //we are in the target and get a request from the source |
144 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) | 144 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) |
145 | { | 145 | { |
146 | 146 | ||
147 | QDataStream stream( data, IO_ReadOnly ); | 147 | QDataStream stream( data, IO_ReadOnly ); |
148 | 148 | ||
149 | 149 | ||
150 | QString sourceChannel; | 150 | QString sourceChannel; |
151 | QString uid; | 151 | QString uid; |
152 | QString param1; | 152 | QString param1; |
153 | QString param2; | 153 | QString param2; |
154 | QString param3; | 154 | QString param3; |
155 | 155 | ||
156 | stream >> sourceChannel >> uid; | 156 | stream >> sourceChannel >> uid; |
157 | 157 | ||
158 | if (_usedSourceParameters == 0) | 158 | if (_usedSourceParameters == 0) |
159 | { | 159 | { |
160 | emit receivedMessageFromSource(sourceChannel, uid); | 160 | emit receivedMessageFromSource(sourceChannel, uid); |
161 | } | 161 | } |
162 | else if (_usedSourceParameters == 1) | 162 | else if (_usedSourceParameters == 1) |
163 | { | 163 | { |
164 | stream >> param1; | 164 | stream >> param1; |
165 | emit receivedMessageFromSource(sourceChannel, uid, param1); | 165 | emit receivedMessageFromSource(sourceChannel, uid, param1); |
166 | } | 166 | } |
167 | else if (_usedSourceParameters == 2) | 167 | else if (_usedSourceParameters == 2) |
168 | { | 168 | { |
169 | stream >> param1 >> param2; | 169 | stream >> param1 >> param2; |
170 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); | 170 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); |
171 | } | 171 | } |
172 | else if (_usedSourceParameters == 3) | 172 | else if (_usedSourceParameters == 3) |
173 | { | 173 | { |
174 | stream >> param1 >> param2 >> param3; | 174 | stream >> param1 >> param2 >> param3; |
175 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); | 175 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); |
176 | } | 176 | } |
177 | 177 | ||
178 | return true; | 178 | return true; |
179 | } | 179 | } |
180 | 180 | ||
181 | return false; | 181 | return false; |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | /********************************************************************************* | 185 | /********************************************************************************* |
186 | * | 186 | * |
187 | ********************************************************************************/ | 187 | ********************************************************************************/ |
188 | 188 | ||
189 | 189 | ||
190 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 190 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
191 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 191 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
192 | { | 192 | { |
193 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> | 193 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> |
194 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; | 194 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; |
195 | } | 195 | } |
196 | 196 | ||
197 | /*********************************************************************************/ | 197 | /*********************************************************************************/ |
198 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) | 198 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) |
199 | { | 199 | { |
200 | #ifndef DESKTOP_VERSION | 200 | #ifndef DESKTOP_VERSION |
201 | //targetMessage passes two parameters: uid, map | 201 | //targetMessage passes two parameters: uid, map |
202 | QString targetMessage = _targetMessage + _targetMessageParameters; | 202 | QString targetMessage = _targetMessage + _targetMessageParameters; |
203 | 203 | ||
204 | #ifdef DEBUG_EXT_APP_HANDLER | 204 | #ifdef DEBUG_EXT_APP_HANDLER |
205 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 205 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
206 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); | 206 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); |
207 | #endif | 207 | #endif |
208 | 208 | ||
209 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 209 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
210 | //US we need no names in the To field. The emailadresses are enough | 210 | //US we need no names in the To field. The emailadresses are enough |
211 | 211 | ||
212 | e << uid << nameEmailMap; | 212 | e << uid << nameEmailMap; |
213 | 213 | ||
214 | qApp->processEvents(); | 214 | qApp->processEvents(); |
215 | 215 | ||
216 | return true; | 216 | return true; |
217 | 217 | ||
218 | #else | 218 | #else |
219 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 219 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
220 | return false; | 220 | return false; |
221 | #endif | 221 | #endif |
222 | 222 | ||
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | /*********************************************************************************/ | 226 | /*********************************************************************************/ |
227 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 227 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
228 | { | 228 | { |
229 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 229 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
230 | 230 | ||
231 | if (res == false) | 231 | if (res == false) |
232 | { | 232 | { |
233 | QDataStream stream( data, IO_ReadOnly ); | 233 | QDataStream stream( data, IO_ReadOnly ); |
234 | 234 | ||
235 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); | 235 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); |
236 | 236 | ||
237 | //we are in the source and get an answer from the target | 237 | //we are in the source and get an answer from the target |
238 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 238 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
239 | { | 239 | { |
240 | QMap<QString,QString> adrMap; | 240 | QMap<QString,QString> adrMap; |
241 | QString uid; | 241 | QString uid; |
242 | 242 | ||
243 | stream >> uid >> adrMap; | 243 | stream >> uid >> adrMap; |
244 | 244 | ||
245 | emit receivedMessageFromTarget(uid, adrMap); | 245 | emit receivedMessageFromTarget(uid, adrMap); |
246 | 246 | ||
247 | 247 | ||
248 | return true; | 248 | return true; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | return false; | 252 | return false; |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | /********************************************************************************* | 256 | /********************************************************************************* |
257 | * | 257 | * |
258 | ********************************************************************************/ | 258 | ********************************************************************************/ |
259 | 259 | ||
260 | QCopListTransferItem::~QCopListTransferItem() | 260 | QCopListTransferItem::~QCopListTransferItem() |
261 | { | 261 | { |
262 | 262 | ||
263 | } | 263 | } |
264 | 264 | ||
265 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 265 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
266 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 266 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
267 | { | 267 | { |
268 | //targetMessage returns later two parameters: uid, and three lists | 268 | //targetMessage returns later two parameters: uid, and three lists |
269 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; | 269 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; |
270 | } | 270 | } |
271 | 271 | ||
272 | /*********************************************************************************/ | 272 | /*********************************************************************************/ |
273 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) | 273 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) |
274 | { | 274 | { |
275 | #ifndef DESKTOP_VERSION | 275 | #ifndef DESKTOP_VERSION |
276 | //targetMessage passes two parameters: uid, map | 276 | //targetMessage passes two parameters: uid, map |
277 | QString targetMessage = _targetMessage + _targetMessageParameters; | 277 | QString targetMessage = _targetMessage + _targetMessageParameters; |
278 | 278 | ||
279 | #ifdef DEBUG_EXT_APP_HANDLER | 279 | #ifdef DEBUG_EXT_APP_HANDLER |
280 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 280 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
281 | qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); | 281 | qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); |
282 | 282 | ||
283 | 283 | ||
284 | for ( int i = 0; i < list3.count(); i++) | 284 | for ( int i = 0; i < list3.count(); i++) |
285 | qDebug("listentry list3: %s",list3[i].latin1()); | 285 | qDebug("listentry list3: %s",list3[i].latin1()); |
286 | #endif | 286 | #endif |
287 | 287 | ||
288 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 288 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
289 | //US we need no names in the To field. The emailadresses are enough | 289 | //US we need no names in the To field. The emailadresses are enough |
290 | 290 | ||
291 | e << uid << list1 << list2 << list3 << list4 << list5 << list6; | 291 | e << uid << list1 << list2 << list3 << list4 << list5 << list6; |
292 | 292 | ||
293 | qApp->processEvents(); | 293 | qApp->processEvents(); |
294 | 294 | ||
295 | return true; | 295 | return true; |
296 | 296 | ||
297 | #else | 297 | #else |
298 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 298 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
299 | return false; | 299 | return false; |
300 | #endif | 300 | #endif |
301 | 301 | ||
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | /*********************************************************************************/ | 305 | /*********************************************************************************/ |
306 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 306 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
307 | { | 307 | { |
308 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 308 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
309 | #ifdef DEBUG_EXT_APP_HANDLER | 309 | #ifdef DEBUG_EXT_APP_HANDLER |
310 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 310 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
311 | #endif | 311 | #endif |
312 | 312 | ||
313 | if (res == false) | 313 | if (res == false) |
314 | { | 314 | { |
315 | QDataStream stream( data, IO_ReadOnly ); | 315 | QDataStream stream( data, IO_ReadOnly ); |
316 | 316 | ||
317 | #ifdef DEBUG_EXT_APP_HANDLER | 317 | #ifdef DEBUG_EXT_APP_HANDLER |
318 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 318 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
319 | #endif | 319 | #endif |
320 | 320 | ||
321 | //we are in the source and get an answer from the target | 321 | //we are in the source and get an answer from the target |
322 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 322 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
323 | { | 323 | { |
324 | QStringList list1; | 324 | QStringList list1; |
325 | QStringList list2; | 325 | QStringList list2; |
326 | QStringList list3; | 326 | QStringList list3; |
327 | QStringList list4; | 327 | QStringList list4; |
328 | QStringList list5; | 328 | QStringList list5; |
329 | QStringList list6; | 329 | QStringList list6; |
330 | QString uid; | 330 | QString uid; |
331 | 331 | ||
332 | #ifdef DEBUG_EXT_APP_HANDLER | 332 | #ifdef DEBUG_EXT_APP_HANDLER |
333 | qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 333 | qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
334 | #endif | 334 | #endif |
335 | 335 | ||
336 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; | 336 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; |
337 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); | 337 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); |
338 | 338 | ||
339 | 339 | ||
340 | return true; | 340 | return true; |
341 | } | 341 | } |
342 | } | 342 | } |
343 | 343 | ||
344 | return false; | 344 | return false; |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | 348 | ||
349 | /********************************************************************************* | 349 | /********************************************************************************* |
350 | * | 350 | * |
351 | ********************************************************************************/ | 351 | ********************************************************************************/ |
352 | 352 | ||
353 | 353 | ||
354 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 354 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
355 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 355 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
356 | 356 | ||
357 | ExternalAppHandler::ExternalAppHandler() | 357 | ExternalAppHandler::ExternalAppHandler() |
358 | { | 358 | { |
359 | mDefaultItems.setAutoDelete(true); | 359 | mDefaultItems.setAutoDelete(true); |
360 | 360 | ||
361 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); | 361 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); |
362 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); | 362 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); |
363 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 363 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
364 | 364 | ||
365 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); | 365 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); |
366 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); | 366 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); |
367 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 367 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
368 | 368 | ||
369 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); | 369 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); |
370 | connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 370 | connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
371 | 371 | ||
372 | 372 | ||
373 | 373 | ||
374 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); | 374 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); |
375 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); | 375 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); |
376 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 376 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
377 | 377 | ||
378 | 378 | ||
379 | } | 379 | } |
380 | 380 | ||
381 | ExternalAppHandler::~ExternalAppHandler() | 381 | ExternalAppHandler::~ExternalAppHandler() |
382 | { | 382 | { |
383 | delete mNameEmailUidListFromKAPITransfer; | 383 | delete mNameEmailUidListFromKAPITransfer; |
384 | //delete mFindByEmailFromKAPITransfer; | 384 | //delete mFindByEmailFromKAPITransfer; |
385 | delete mDisplayDetails; | 385 | delete mDisplayDetails; |
386 | delete mBirthdayListFromKAPITransfer; | 386 | delete mBirthdayListFromKAPITransfer; |
387 | } | 387 | } |
388 | 388 | ||
389 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, | 389 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, |
390 | const QStringList& nameList, | 390 | const QStringList& nameList, |
391 | const QStringList& emailList, | 391 | const QStringList& emailList, |
392 | const QStringList& uidList, | 392 | const QStringList& uidList, |
393 | const QStringList&, | 393 | const QStringList&, |
394 | const QStringList&, | 394 | const QStringList&, |
395 | const QStringList& ) | 395 | const QStringList& ) |
396 | { | 396 | { |
397 | // this method is a conevnient way to reduce the number of parameters I have to pass | 397 | // this method is a conevnient way to reduce the number of parameters I have to pass |
398 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); | 398 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void ExternalAppHandler::loadConfig() | 402 | void ExternalAppHandler::loadConfig() |
403 | { | 403 | { |
404 | 404 | ||
405 | mDefaultItems.clear(); | 405 | mDefaultItems.clear(); |
406 | mEmailAppAvailable = UNDEFINED; | 406 | mEmailAppAvailable = UNDEFINED; |
407 | mPhoneAppAvailable = UNDEFINED; | 407 | mPhoneAppAvailable = UNDEFINED; |
408 | mFaxAppAvailable = UNDEFINED; | 408 | mFaxAppAvailable = UNDEFINED; |
409 | mSMSAppAvailable = UNDEFINED; | 409 | mSMSAppAvailable = UNDEFINED; |
410 | mPagerAppAvailable = UNDEFINED; | 410 | mPagerAppAvailable = UNDEFINED; |
411 | mSIPAppAvailable = UNDEFINED; | 411 | mSIPAppAvailable = UNDEFINED; |
412 | 412 | ||
413 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 413 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
414 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 414 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
415 | 415 | ||
416 | if (opiepath.isEmpty()) | 416 | if (opiepath.isEmpty()) |
417 | opiepath = qtopiapath; | 417 | opiepath = qtopiapath; |
418 | 418 | ||
419 | //mailclients | 419 | //mailclients |
420 | QString mailmsg1 = "writeMail(QString,QString)"; | 420 | QString mailmsg1 = "writeMail(QString,QString)"; |
421 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 421 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
422 | 422 | ||
423 | QString undefined = ""; | 423 | QString undefined = ""; |
424 | 424 | ||
425 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 425 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
426 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 426 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
427 | 427 | ||
428 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 428 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
429 | ( QFile::exists( opiepath + "/bin/ompi" ))) | 429 | ( QFile::exists( opiepath + "/bin/ompi" ))) |
430 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 430 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
431 | 431 | ||
432 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) | 432 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) |
433 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 433 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
434 | 434 | ||
435 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 435 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
436 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 436 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
437 | 437 | ||
438 | 438 | ||
439 | 439 | ||
440 | //phoneclients | 440 | //phoneclients |
441 | 441 | ||
442 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 442 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); |
443 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | 443 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
444 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 444 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
445 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 445 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
446 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 446 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
447 | 447 | ||
448 | //faxclients | 448 | //faxclients |
449 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 449 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
450 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 450 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
451 | 451 | ||
452 | //smsclients | 452 | //smsclients |
453 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 453 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
454 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 454 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
455 | 455 | ||
456 | //pagerclients | 456 | //pagerclients |
457 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 457 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
458 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 458 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
459 | 459 | ||
460 | //sipclients | 460 | //sipclients |
461 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); | 461 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); |
462 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); | 462 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); |
463 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 463 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
464 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 464 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
465 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 465 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
466 | 466 | ||
467 | } | 467 | } |
468 | 468 | ||
469 | ExternalAppHandler *ExternalAppHandler::instance() | 469 | ExternalAppHandler *ExternalAppHandler::instance() |
470 | { | 470 | { |
471 | if ( !sInstance ) { | 471 | if ( !sInstance ) { |
472 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 472 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
473 | sInstance->loadConfig(); | 473 | sInstance->loadConfig(); |
474 | } | 474 | } |
475 | 475 | ||
476 | return sInstance; | 476 | return sInstance; |
477 | } | 477 | } |
478 | 478 | ||
479 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) | 479 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) |
480 | { | 480 | { |
481 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 481 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
482 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); | 482 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); |
483 | mDefaultItems.append(dai); | 483 | mDefaultItems.append(dai); |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 487 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
488 | { | 488 | { |
489 | QList<DefaultAppItem> list; | 489 | QList<DefaultAppItem> list; |
490 | 490 | ||
491 | DefaultAppItem* dai; | 491 | DefaultAppItem* dai; |
492 | 492 | ||
493 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 493 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
494 | { | 494 | { |
495 | if (dai->_type == type) | 495 | if (dai->_type == type) |
496 | list.append(dai); | 496 | list.append(dai); |
497 | } | 497 | } |
498 | 498 | ||
499 | return list; | 499 | return list; |
500 | } | 500 | } |
501 | 501 | ||
502 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 502 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
503 | { | 503 | { |
504 | DefaultAppItem* dai; | 504 | DefaultAppItem* dai; |
505 | 505 | ||
506 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 506 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
507 | { | 507 | { |
508 | if (dai->_type == type && dai->_id == clientid) | 508 | if (dai->_type == type && dai->_id == clientid) |
509 | return dai; | 509 | return dai; |
510 | } | 510 | } |
511 | 511 | ||
512 | return 0; | 512 | return 0; |
513 | } | 513 | } |
514 | 514 | ||
515 | bool ExternalAppHandler::isEmailAppAvailable() | 515 | bool ExternalAppHandler::isEmailAppAvailable() |
516 | { | 516 | { |
517 | #ifndef DESKTOP_VERSION | 517 | #ifndef DESKTOP_VERSION |
518 | if (mEmailAppAvailable == UNDEFINED) | 518 | if (mEmailAppAvailable == UNDEFINED) |
519 | { | 519 | { |
520 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 520 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
521 | if (client == KPimGlobalPrefs::NONE_EMC) | 521 | if (client == KPimGlobalPrefs::NONE_EMC) |
522 | mEmailAppAvailable = UNAVAILABLE; | 522 | mEmailAppAvailable = UNAVAILABLE; |
523 | else | 523 | else |
524 | mEmailAppAvailable = AVAILABLE; | 524 | mEmailAppAvailable = AVAILABLE; |
525 | } | 525 | } |
526 | return (mEmailAppAvailable == AVAILABLE); | 526 | return (mEmailAppAvailable == AVAILABLE); |
527 | 527 | ||
528 | #else //DESKTOP_VERSION | 528 | #else //DESKTOP_VERSION |
529 | return false; | 529 | return false; |
530 | #endif //DESKTOP_VERSION | 530 | #endif //DESKTOP_VERSION |
531 | } | 531 | } |
532 | 532 | ||
533 | bool ExternalAppHandler::isSMSAppAvailable() | 533 | bool ExternalAppHandler::isSMSAppAvailable() |
534 | { | 534 | { |
535 | #ifndef DESKTOP_VERSION | 535 | #ifndef DESKTOP_VERSION |
536 | if (mSMSAppAvailable == UNDEFINED) | 536 | if (mSMSAppAvailable == UNDEFINED) |
537 | { | 537 | { |
538 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 538 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
539 | if (client == KPimGlobalPrefs::NONE_SMC) | 539 | if (client == KPimGlobalPrefs::NONE_SMC) |
540 | mSMSAppAvailable = UNAVAILABLE; | 540 | mSMSAppAvailable = UNAVAILABLE; |
541 | else | 541 | else |
542 | mSMSAppAvailable = AVAILABLE; | 542 | mSMSAppAvailable = AVAILABLE; |
543 | } | 543 | } |
544 | 544 | ||
545 | return (mSMSAppAvailable == AVAILABLE); | 545 | return (mSMSAppAvailable == AVAILABLE); |
546 | #else //DESKTOP_VERSION | 546 | #else //DESKTOP_VERSION |
547 | return false; | 547 | return false; |
548 | #endif //DESKTOP_VERSION | 548 | #endif //DESKTOP_VERSION |
549 | } | 549 | } |
550 | 550 | ||
551 | bool ExternalAppHandler::isPhoneAppAvailable() | 551 | bool ExternalAppHandler::isPhoneAppAvailable() |
552 | { | 552 | { |
553 | #ifndef DESKTOP_VERSION | 553 | #ifndef DESKTOP_VERSION |
554 | if (mPhoneAppAvailable == UNDEFINED) | 554 | if (mPhoneAppAvailable == UNDEFINED) |
555 | { | 555 | { |
556 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 556 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
557 | if (client == KPimGlobalPrefs::NONE_PHC) | 557 | if (client == KPimGlobalPrefs::NONE_PHC) |
558 | mPhoneAppAvailable = UNAVAILABLE; | 558 | mPhoneAppAvailable = UNAVAILABLE; |
559 | else | 559 | else |
560 | mPhoneAppAvailable = AVAILABLE; | 560 | mPhoneAppAvailable = AVAILABLE; |
561 | } | 561 | } |
562 | 562 | ||
563 | return (mPhoneAppAvailable == AVAILABLE); | 563 | return (mPhoneAppAvailable == AVAILABLE); |
564 | #else //DESKTOP_VERSION | 564 | #else //DESKTOP_VERSION |
565 | return false; | 565 | return false; |
566 | #endif //DESKTOP_VERSION | 566 | #endif //DESKTOP_VERSION |
567 | } | 567 | } |
568 | 568 | ||
569 | bool ExternalAppHandler::isFaxAppAvailable() | 569 | bool ExternalAppHandler::isFaxAppAvailable() |
570 | { | 570 | { |
571 | #ifndef DESKTOP_VERSION | 571 | #ifndef DESKTOP_VERSION |
572 | if (mFaxAppAvailable == UNDEFINED) | 572 | if (mFaxAppAvailable == UNDEFINED) |
573 | { | 573 | { |
574 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 574 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
575 | if (client == KPimGlobalPrefs::NONE_FAC) | 575 | if (client == KPimGlobalPrefs::NONE_FAC) |
576 | mFaxAppAvailable = UNAVAILABLE; | 576 | mFaxAppAvailable = UNAVAILABLE; |
577 | else | 577 | else |
578 | mFaxAppAvailable = AVAILABLE; | 578 | mFaxAppAvailable = AVAILABLE; |
579 | } | 579 | } |
580 | 580 | ||
581 | return (mFaxAppAvailable == AVAILABLE); | 581 | return (mFaxAppAvailable == AVAILABLE); |
582 | #else //DESKTOP_VERSION | 582 | #else //DESKTOP_VERSION |
583 | return false; | 583 | return false; |
584 | #endif //DESKTOP_VERSION | 584 | #endif //DESKTOP_VERSION |
585 | } | 585 | } |
586 | 586 | ||
587 | bool ExternalAppHandler::isPagerAppAvailable() | 587 | bool ExternalAppHandler::isPagerAppAvailable() |
588 | { | 588 | { |
589 | #ifndef DESKTOP_VERSION | 589 | #ifndef DESKTOP_VERSION |
590 | if (mPagerAppAvailable == UNDEFINED) | 590 | if (mPagerAppAvailable == UNDEFINED) |
591 | { | 591 | { |
592 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 592 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
593 | if (client == KPimGlobalPrefs::NONE_PAC) | 593 | if (client == KPimGlobalPrefs::NONE_PAC) |
594 | mPagerAppAvailable = UNAVAILABLE; | 594 | mPagerAppAvailable = UNAVAILABLE; |
595 | else | 595 | else |
596 | mPagerAppAvailable = AVAILABLE; | 596 | mPagerAppAvailable = AVAILABLE; |
597 | } | 597 | } |
598 | 598 | ||
599 | return (mPagerAppAvailable == AVAILABLE); | 599 | return (mPagerAppAvailable == AVAILABLE); |
600 | #else //DESKTOP_VERSION | 600 | #else //DESKTOP_VERSION |
601 | return false; | 601 | return false; |
602 | #endif //DESKTOP_VERSION | 602 | #endif //DESKTOP_VERSION |
603 | } | 603 | } |
604 | 604 | ||
605 | 605 | ||
606 | bool ExternalAppHandler::isSIPAppAvailable() | 606 | bool ExternalAppHandler::isSIPAppAvailable() |
607 | { | 607 | { |
608 | #ifndef DESKTOP_VERSION | 608 | #ifndef DESKTOP_VERSION |
609 | if (mSIPAppAvailable == UNDEFINED) | 609 | if (mSIPAppAvailable == UNDEFINED) |
610 | { | 610 | { |
611 | int client = KPimGlobalPrefs::instance()->mSipClient; | 611 | int client = KPimGlobalPrefs::instance()->mSipClient; |
612 | if (client == KPimGlobalPrefs::NONE_SIC) | 612 | if (client == KPimGlobalPrefs::NONE_SIC) |
613 | mSIPAppAvailable = UNAVAILABLE; | 613 | mSIPAppAvailable = UNAVAILABLE; |
614 | else | 614 | else |
615 | mSIPAppAvailable = AVAILABLE; | 615 | mSIPAppAvailable = AVAILABLE; |
616 | } | 616 | } |
617 | 617 | ||
618 | return (mSIPAppAvailable == AVAILABLE); | 618 | return (mSIPAppAvailable == AVAILABLE); |
619 | #else //DESKTOP_VERSION | 619 | #else //DESKTOP_VERSION |
620 | return false; | 620 | return false; |
621 | #endif //DESKTOP_VERSION | 621 | #endif //DESKTOP_VERSION |
622 | } | 622 | } |
623 | 623 | ||
624 | /************************************************************************** | 624 | /************************************************************************** |
625 | * | 625 | * |
626 | **************************************************************************/ | 626 | **************************************************************************/ |
627 | 627 | ||
628 | 628 | ||
629 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 629 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
630 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 630 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
631 | { | 631 | { |
632 | 632 | ||
633 | #ifndef DESKTOP_VERSION | 633 | #ifndef DESKTOP_VERSION |
634 | QString channel; | 634 | QString channel; |
635 | QString message2; | 635 | QString message2; |
636 | QString parameters2; | 636 | QString parameters2; |
637 | 637 | ||
638 | 638 | ||
639 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 639 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
640 | if (client == KPimGlobalPrefs::OTHER_EMC) | 640 | if (client == KPimGlobalPrefs::OTHER_EMC) |
641 | { | 641 | { |
642 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 642 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
643 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 643 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
644 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 644 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
645 | } | 645 | } |
646 | else | 646 | else |
647 | { | 647 | { |
648 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 648 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
649 | if (!dai) | 649 | if (!dai) |
650 | { | 650 | { |
651 | qDebug("could not find configured email application."); | 651 | qDebug("could not find configured email application."); |
652 | return false; | 652 | return false; |
653 | } | 653 | } |
654 | channel = dai->_channel; | 654 | channel = dai->_channel; |
655 | message2 = dai->_message2; | 655 | message2 = dai->_message2; |
656 | parameters2 = dai->_parameters2; | 656 | parameters2 = dai->_parameters2; |
657 | } | 657 | } |
658 | 658 | ||
659 | //first check if one of the mailers need the emails right in the message. | 659 | //first check if one of the mailers need the emails right in the message. |
660 | message2 = translateMessage(message2, emails, urls); | 660 | message2 = translateMessage(message2, emails, urls); |
661 | 661 | ||
662 | 662 | ||
663 | #ifdef DEBUG_EXT_APP_HANDLER | 663 | #ifdef DEBUG_EXT_APP_HANDLER |
664 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 664 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
665 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 665 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
666 | #endif | 666 | #endif |
667 | 667 | ||
668 | 668 | ||
669 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 669 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
670 | //US we need no names in the To field. The emailadresses are enough | 670 | //US we need no names in the To field. The emailadresses are enough |
671 | 671 | ||
672 | passParameters(&e, parameters2, emails, urls); | 672 | passParameters(&e, parameters2, emails, urls); |
673 | 673 | ||
674 | 674 | ||
675 | 675 | ||
676 | #else | 676 | #else |
677 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 677 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
678 | #endif | 678 | #endif |
679 | 679 | ||
680 | return true; | 680 | return true; |
681 | } | 681 | } |
682 | 682 | ||
683 | /************************************************************************** | 683 | /************************************************************************** |
684 | * | 684 | * |
685 | **************************************************************************/ | 685 | **************************************************************************/ |
686 | 686 | ||
687 | 687 | ||
688 | //calls the emailapplication and creates a mail with parameter emails as recipients | 688 | //calls the emailapplication and creates a mail with parameter emails as recipients |
689 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 689 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
690 | { | 690 | { |
691 | #ifndef DESKTOP_VERSION | 691 | #ifndef DESKTOP_VERSION |
692 | QString channel; | 692 | QString channel; |
693 | QString message; | 693 | QString message; |
694 | QString parameters; | 694 | QString parameters; |
695 | 695 | ||
696 | 696 | ||
697 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 697 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
698 | if (client == KPimGlobalPrefs::OTHER_EMC) | 698 | if (client == KPimGlobalPrefs::OTHER_EMC) |
699 | { | 699 | { |
700 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 700 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
701 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 701 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
702 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 702 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
703 | } | 703 | } |
704 | else | 704 | else |
705 | { | 705 | { |
706 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 706 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
707 | if (!dai) | 707 | if (!dai) |
708 | { | 708 | { |
709 | qDebug("could not find configured email application."); | 709 | qDebug("could not find configured email application."); |
710 | return false; | 710 | return false; |
711 | } | 711 | } |
712 | channel = dai->_channel; | 712 | channel = dai->_channel; |
713 | message = dai->_message; | 713 | message = dai->_message; |
714 | parameters = dai->_parameters; | 714 | parameters = dai->_parameters; |
715 | } | 715 | } |
716 | 716 | ||
717 | 717 | ||
718 | //first check if one of the mailers need the emails right in the message. | 718 | //first check if one of the mailers need the emails right in the message. |
719 | message = translateMessage(message, name, emailadress); | 719 | message = translateMessage(message, name, emailadress); |
720 | 720 | ||
721 | 721 | ||
722 | #ifdef DEBUG_EXT_APP_HANDLER | 722 | #ifdef DEBUG_EXT_APP_HANDLER |
723 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 723 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
724 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 724 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
725 | #endif | 725 | #endif |
726 | 726 | ||
727 | QCopEnvelope e(channel.latin1(), message.latin1()); | 727 | QCopEnvelope e(channel.latin1(), message.latin1()); |
728 | //US we need no names in the To field. The emailadresses are enough | 728 | //US we need no names in the To field. The emailadresses are enough |
729 | 729 | ||
730 | passParameters(&e, parameters, name, emailadress); | 730 | passParameters(&e, parameters, name, emailadress); |
731 | 731 | ||
732 | 732 | ||
733 | #else | 733 | #else |
734 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 734 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
735 | #endif | 735 | #endif |
736 | 736 | ||
737 | 737 | ||
738 | return true; | 738 | return true; |
739 | } | 739 | } |
740 | 740 | ||
741 | /************************************************************************** | 741 | /************************************************************************** |
742 | * | 742 | * |
743 | **************************************************************************/ | 743 | **************************************************************************/ |
744 | 744 | ||
745 | //calls the emailapplication and creates a mail with parameter as recipients | 745 | //calls the emailapplication and creates a mail with parameter as recipients |
746 | // parameters format is | 746 | // parameters format is |
747 | // NAME <EMAIL>:SUBJECT | 747 | // NAME <EMAIL>:SUBJECT |
748 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 748 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
749 | { | 749 | { |
750 | QString line = adressline; | 750 | QString line = adressline; |
751 | 751 | ||
752 | int first = line.find( "<"); | 752 | int first = line.find( "<"); |
753 | int last = line.find( ">"); | 753 | int last = line.find( ">"); |
754 | QString name = line.left(first); | 754 | QString name = line.left(first); |
755 | QString emailadress = line.mid(first+1, last-first-1); | 755 | QString emailadress = line.mid(first+1, last-first-1); |
756 | 756 | ||
757 | //Subject can not be handled right now. | 757 | //Subject can not be handled right now. |
758 | return mailToOneContact( name, emailadress ); | 758 | return mailToOneContact( name, emailadress ); |
759 | 759 | ||
760 | } | 760 | } |
761 | 761 | ||
762 | 762 | ||
763 | /************************************************************************** | 763 | /************************************************************************** |
764 | * | 764 | * |
765 | **************************************************************************/ | 765 | **************************************************************************/ |
766 | 766 | ||
767 | //calls the phoneapplication with the number | 767 | //calls the phoneapplication with the number |
768 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 768 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
769 | { | 769 | { |
770 | #ifndef DESKTOP_VERSION | 770 | #ifndef DESKTOP_VERSION |
771 | QString channel; | 771 | QString channel; |
772 | QString message; | 772 | QString message; |
773 | QString parameters; | 773 | QString parameters; |
774 | 774 | ||
775 | 775 | ||
776 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 776 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
777 | if (client == KPimGlobalPrefs::OTHER_PHC) | 777 | if (client == KPimGlobalPrefs::OTHER_PHC) |
778 | { | 778 | { |
779 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 779 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
780 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 780 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
781 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 781 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
782 | } | 782 | } |
783 | else | 783 | else |
784 | { | 784 | { |
785 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 785 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
786 | if (!dai) | 786 | if (!dai) |
787 | { | 787 | { |
788 | qDebug("could not find configured phone application."); | 788 | qDebug("could not find configured phone application."); |
789 | return false; | 789 | return false; |
790 | } | 790 | } |
791 | channel = dai->_channel; | 791 | channel = dai->_channel; |
792 | message = dai->_message; | 792 | message = dai->_message; |
793 | parameters = dai->_parameters; | 793 | parameters = dai->_parameters; |
794 | } | 794 | } |
795 | 795 | ||
796 | 796 | ||
797 | //first check if one of the mailers need the emails right in the message. | 797 | //first check if one of the mailers need the emails right in the message. |
798 | message = translateMessage(message, phonenumber, ""); | 798 | message = translateMessage(message, phonenumber, ""); |
799 | 799 | ||
800 | 800 | ||
801 | #ifdef DEBUG_EXT_APP_HANDLER | 801 | #ifdef DEBUG_EXT_APP_HANDLER |
802 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 802 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
803 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 803 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
804 | #endif | 804 | #endif |
805 | 805 | ||
806 | QCopEnvelope e(channel.latin1(), message.latin1()); | 806 | QCopEnvelope e(channel.latin1(), message.latin1()); |
807 | //US we need no names in the To field. The emailadresses are enough | 807 | //US we need no names in the To field. The emailadresses are enough |
808 | 808 | ||
809 | passParameters(&e, parameters, phonenumber, ""); | 809 | passParameters(&e, parameters, phonenumber, ""); |
810 | 810 | ||
811 | 811 | ||
812 | #else | 812 | #else |
813 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 813 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
814 | #endif | 814 | #endif |
815 | 815 | ||
816 | 816 | ||
817 | return true; | 817 | return true; |
818 | } | 818 | } |
819 | 819 | ||
820 | /************************************************************************** | 820 | /************************************************************************** |
821 | * | 821 | * |
822 | **************************************************************************/ | 822 | **************************************************************************/ |
823 | 823 | ||
824 | //calls the smsapplication with the number | 824 | //calls the smsapplication with the number |
825 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 825 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
826 | { | 826 | { |
827 | #ifndef DESKTOP_VERSION | 827 | #ifndef DESKTOP_VERSION |
828 | QString channel; | 828 | QString channel; |
829 | QString message; | 829 | QString message; |
830 | QString parameters; | 830 | QString parameters; |
831 | 831 | ||
832 | 832 | ||
833 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 833 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
834 | if (client == KPimGlobalPrefs::OTHER_SMC) | 834 | if (client == KPimGlobalPrefs::OTHER_SMC) |
835 | { | 835 | { |
836 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 836 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
837 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 837 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
838 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 838 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
839 | } | 839 | } |
840 | else | 840 | else |
841 | { | 841 | { |
842 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 842 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
843 | if (!dai) | 843 | if (!dai) |
844 | { | 844 | { |
845 | qDebug("could not find configured sms application."); | 845 | qDebug("could not find configured sms application."); |
846 | return false; | 846 | return false; |
847 | } | 847 | } |
848 | channel = dai->_channel; | 848 | channel = dai->_channel; |
849 | message = dai->_message; | 849 | message = dai->_message; |
850 | parameters = dai->_parameters; | 850 | parameters = dai->_parameters; |
851 | } | 851 | } |
852 | 852 | ||
853 | 853 | ||
854 | //first check if one of the mailers need the emails right in the message. | 854 | //first check if one of the mailers need the emails right in the message. |
855 | message = translateMessage(message, phonenumber, ""); | 855 | message = translateMessage(message, phonenumber, ""); |
856 | 856 | ||
857 | 857 | ||
858 | #ifdef DEBUG_EXT_APP_HANDLER | 858 | #ifdef DEBUG_EXT_APP_HANDLER |
859 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 859 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
860 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 860 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
861 | #endif | 861 | #endif |
862 | 862 | ||
863 | QCopEnvelope e(channel.latin1(), message.latin1()); | 863 | QCopEnvelope e(channel.latin1(), message.latin1()); |
864 | //US we need no names in the To field. The emailadresses are enough | 864 | //US we need no names in the To field. The emailadresses are enough |
865 | 865 | ||
866 | passParameters(&e, parameters, phonenumber, ""); | 866 | passParameters(&e, parameters, phonenumber, ""); |
867 | 867 | ||
868 | 868 | ||
869 | #else | 869 | #else |
870 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); | 870 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
871 | #endif | 871 | #endif |
872 | 872 | ||
873 | 873 | ||
874 | return true; | 874 | return true; |
875 | } | 875 | } |
876 | 876 | ||
877 | /************************************************************************** | 877 | /************************************************************************** |
878 | * | 878 | * |
879 | **************************************************************************/ | 879 | **************************************************************************/ |
880 | 880 | ||
881 | //calls the pagerapplication with the number | 881 | //calls the pagerapplication with the number |
882 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 882 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
883 | { | 883 | { |
884 | #ifndef DESKTOP_VERSION | 884 | #ifndef DESKTOP_VERSION |
885 | QString channel; | 885 | QString channel; |
886 | QString message; | 886 | QString message; |
887 | QString parameters; | 887 | QString parameters; |
888 | 888 | ||
889 | 889 | ||
890 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 890 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
891 | if (client == KPimGlobalPrefs::OTHER_PAC) | 891 | if (client == KPimGlobalPrefs::OTHER_PAC) |
892 | { | 892 | { |
893 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | 893 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; |
894 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | 894 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; |
895 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | 895 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; |
896 | } | 896 | } |
897 | else | 897 | else |
898 | { | 898 | { |
899 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | 899 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); |
900 | if (!dai) | 900 | if (!dai) |
901 | { | 901 | { |
902 | qDebug("could not find configured pager application."); | 902 | qDebug("could not find configured pager application."); |
903 | return false; | 903 | return false; |
904 | } | 904 | } |
905 | channel = dai->_channel; | 905 | channel = dai->_channel; |
906 | message = dai->_message; | 906 | message = dai->_message; |
907 | parameters = dai->_parameters; | 907 | parameters = dai->_parameters; |
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||
911 | //first check if one of the mailers need the emails right in the message. | 911 | //first check if one of the mailers need the emails right in the message. |
912 | message = translateMessage(message, pagernumber, ""); | 912 | message = translateMessage(message, pagernumber, ""); |
913 | 913 | ||
914 | 914 | ||
915 | #ifdef DEBUG_EXT_APP_HANDLER | 915 | #ifdef DEBUG_EXT_APP_HANDLER |
916 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 916 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
917 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | 917 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); |
918 | #endif | 918 | #endif |
919 | 919 | ||
920 | QCopEnvelope e(channel.latin1(), message.latin1()); | 920 | QCopEnvelope e(channel.latin1(), message.latin1()); |
921 | //US we need no names in the To field. The emailadresses are enough | 921 | //US we need no names in the To field. The emailadresses are enough |
922 | 922 | ||
923 | passParameters(&e, parameters, pagernumber, ""); | 923 | passParameters(&e, parameters, pagernumber, ""); |
924 | 924 | ||
925 | 925 | ||
926 | #else | 926 | #else |
927 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); | 927 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
928 | #endif | 928 | #endif |
929 | 929 | ||
930 | 930 | ||
931 | return true; | 931 | return true; |
932 | } | 932 | } |
933 | 933 | ||
934 | /************************************************************************** | 934 | /************************************************************************** |
935 | * | 935 | * |
936 | **************************************************************************/ | 936 | **************************************************************************/ |
937 | 937 | ||
938 | //calls the faxapplication with the number | 938 | //calls the faxapplication with the number |
939 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 939 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
940 | { | 940 | { |
941 | #ifndef DESKTOP_VERSION | 941 | #ifndef DESKTOP_VERSION |
942 | QString channel; | 942 | QString channel; |
943 | QString message; | 943 | QString message; |
944 | QString parameters; | 944 | QString parameters; |
945 | 945 | ||
946 | 946 | ||
947 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 947 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
948 | if (client == KPimGlobalPrefs::OTHER_FAC) | 948 | if (client == KPimGlobalPrefs::OTHER_FAC) |
949 | { | 949 | { |
950 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 950 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
951 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 951 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
952 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 952 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
953 | } | 953 | } |
954 | else | 954 | else |
955 | { | 955 | { |
956 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 956 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
957 | if (!dai) | 957 | if (!dai) |
958 | { | 958 | { |
959 | qDebug("could not find configured fax application."); | 959 | qDebug("could not find configured fax application."); |
960 | return false; | 960 | return false; |
961 | } | 961 | } |
962 | channel = dai->_channel; | 962 | channel = dai->_channel; |
963 | message = dai->_message; | 963 | message = dai->_message; |
964 | parameters = dai->_parameters; | 964 | parameters = dai->_parameters; |
965 | } | 965 | } |
966 | 966 | ||
967 | 967 | ||
968 | //first check if one of the mailers need the emails right in the message. | 968 | //first check if one of the mailers need the emails right in the message. |
969 | message = translateMessage(message, faxnumber, ""); | 969 | message = translateMessage(message, faxnumber, ""); |
970 | 970 | ||
971 | 971 | ||
972 | #ifdef DEBUG_EXT_APP_HANDLER | 972 | #ifdef DEBUG_EXT_APP_HANDLER |
973 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 973 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
974 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 974 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
975 | #endif | 975 | #endif |
976 | 976 | ||
977 | QCopEnvelope e(channel.latin1(), message.latin1()); | 977 | QCopEnvelope e(channel.latin1(), message.latin1()); |
978 | //US we need no names in the To field. The emailadresses are enough | 978 | //US we need no names in the To field. The emailadresses are enough |
979 | 979 | ||
980 | passParameters(&e, parameters, faxnumber, ""); | 980 | passParameters(&e, parameters, faxnumber, ""); |
981 | 981 | ||
982 | 982 | ||
983 | #else | 983 | #else |
984 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); | 984 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
985 | #endif | 985 | #endif |
986 | 986 | ||
987 | 987 | ||
988 | return true; | 988 | return true; |
989 | } | 989 | } |
990 | 990 | ||
991 | /************************************************************************** | 991 | /************************************************************************** |
992 | * | 992 | * |
993 | **************************************************************************/ | 993 | **************************************************************************/ |
994 | 994 | ||
995 | //calls the sipapplication with the number | 995 | //calls the sipapplication with the number |
996 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) | 996 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) |
997 | { | 997 | { |
998 | #ifndef DESKTOP_VERSION | 998 | #ifndef DESKTOP_VERSION |
999 | QString channel; | 999 | QString channel; |
1000 | QString message; | 1000 | QString message; |
1001 | QString parameters; | 1001 | QString parameters; |
1002 | 1002 | ||
1003 | 1003 | ||
1004 | int client = KPimGlobalPrefs::instance()->mSipClient; | 1004 | int client = KPimGlobalPrefs::instance()->mSipClient; |
1005 | if (client == KPimGlobalPrefs::OTHER_SIC) | 1005 | if (client == KPimGlobalPrefs::OTHER_SIC) |
1006 | { | 1006 | { |
1007 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; | 1007 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; |
1008 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; | 1008 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; |
1009 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; | 1009 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; |
1010 | } | 1010 | } |
1011 | else | 1011 | else |
1012 | { | 1012 | { |
1013 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); | 1013 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); |
1014 | if (!dai) | 1014 | if (!dai) |
1015 | { | 1015 | { |
1016 | qDebug("could not find configured sip application."); | 1016 | qDebug("could not find configured sip application."); |
1017 | return false; | 1017 | return false; |
1018 | } | 1018 | } |
1019 | channel = dai->_channel; | 1019 | channel = dai->_channel; |
1020 | message = dai->_message; | 1020 | message = dai->_message; |
1021 | parameters = dai->_parameters; | 1021 | parameters = dai->_parameters; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | 1024 | ||
1025 | //first check if one of the sip apps need the emails right in the message. | 1025 | //first check if one of the sip apps need the emails right in the message. |
1026 | message = translateMessage(message, sipnumber, ""); | 1026 | message = translateMessage(message, sipnumber, ""); |
1027 | 1027 | ||
1028 | 1028 | ||
1029 | #ifdef DEBUG_EXT_APP_HANDLER | 1029 | #ifdef DEBUG_EXT_APP_HANDLER |
1030 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 1030 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
1031 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); | 1031 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); |
1032 | #endif | 1032 | #endif |
1033 | 1033 | ||
1034 | QCopEnvelope e(channel.latin1(), message.latin1()); | 1034 | QCopEnvelope e(channel.latin1(), message.latin1()); |
1035 | //US we need no names in the To field. The emailadresses are enough | 1035 | //US we need no names in the To field. The emailadresses are enough |
1036 | 1036 | ||
1037 | passParameters(&e, parameters, sipnumber, ""); | 1037 | passParameters(&e, parameters, sipnumber, ""); |
1038 | 1038 | ||
1039 | 1039 | ||
1040 | #else | 1040 | #else |
1041 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); | 1041 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); |
1042 | #endif | 1042 | #endif |
1043 | 1043 | ||
1044 | 1044 | ||
1045 | return true; | 1045 | return true; |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | 1048 | ||
1049 | /************************************************************************** | 1049 | /************************************************************************** |
1050 | * | 1050 | * |
1051 | **************************************************************************/ | 1051 | **************************************************************************/ |
1052 | 1052 | ||
1053 | 1053 | ||
1054 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 1054 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
1055 | { | 1055 | { |
1056 | message = message.replace( QRegExp("%1"), param1 ); | 1056 | message = message.replace( QRegExp("%1"), param1 ); |
1057 | return message.replace( QRegExp("%2"), param2 ); | 1057 | return message.replace( QRegExp("%2"), param2 ); |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | /************************************************************************** | 1060 | /************************************************************************** |
1061 | * | 1061 | * |
1062 | **************************************************************************/ | 1062 | **************************************************************************/ |
1063 | 1063 | ||
1064 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 1064 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
1065 | { | 1065 | { |
1066 | #ifndef DESKTOP_VERSION | 1066 | #ifndef DESKTOP_VERSION |
1067 | QMap<QString, QString> valmap; | 1067 | QMap<QString, QString> valmap; |
1068 | bool useValMap = false; | 1068 | bool useValMap = false; |
1069 | 1069 | ||
1070 | // first extract all parts of the parameters. | 1070 | // first extract all parts of the parameters. |
1071 | QStringList paramlist = QStringList::split(";", parameters); | 1071 | QStringList paramlist = QStringList::split(";", parameters); |
1072 | 1072 | ||
1073 | //Now check how many parts we have. | 1073 | //Now check how many parts we have. |
1074 | //=0 :no params to pass | 1074 | //=0 :no params to pass |
1075 | //>0 :parameters to pass | 1075 | //>0 :parameters to pass |
1076 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 1076 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
1077 | { | 1077 | { |
1078 | QString param = (*it); | 1078 | QString param = (*it); |
1079 | QStringList keyvallist = QStringList::split("=", param); | 1079 | QStringList keyvallist = QStringList::split("=", param); |
1080 | 1080 | ||
1081 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 1081 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
1082 | QStringList::Iterator it2 = keyvallist.begin(); | 1082 | QStringList::Iterator it2 = keyvallist.begin(); |
1083 | QString key = (*it2); | 1083 | QString key = (*it2); |
1084 | key = key.replace( QRegExp("%1"), param1 ); | 1084 | key = key.replace( QRegExp("%1"), param1 ); |
1085 | key = key.replace( QRegExp("%2"), param2 ); | 1085 | key = key.replace( QRegExp("%2"), param2 ); |
1086 | ++it2; | 1086 | ++it2; |
1087 | 1087 | ||
1088 | if(it2 != keyvallist.end()) | 1088 | if(it2 != keyvallist.end()) |
1089 | { | 1089 | { |
1090 | QString value = (*it2); | 1090 | QString value = (*it2); |
1091 | value = value.replace( QRegExp("%1"), param1 ); | 1091 | value = value.replace( QRegExp("%1"), param1 ); |
1092 | value = value.replace( QRegExp("%2"), param2 ); | 1092 | value = value.replace( QRegExp("%2"), param2 ); |
1093 | 1093 | ||
1094 | valmap.insert(key, value); | 1094 | valmap.insert(key, value); |
1095 | useValMap = true; | 1095 | useValMap = true; |
1096 | } | 1096 | } |
1097 | else | 1097 | else |
1098 | { | 1098 | { |
1099 | // qDebug("pass parameter << %s", key.latin1()); | 1099 | // qDebug("pass parameter << %s", key.latin1()); |
1100 | (*e) << key; | 1100 | (*e) << key; |
1101 | } | 1101 | } |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | if (useValMap == true) | 1104 | if (useValMap == true) |
1105 | (*e) << valmap; | 1105 | (*e) << valmap; |
1106 | 1106 | ||
1107 | #endif | 1107 | #endif |
1108 | 1108 | ||
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | 1111 | ||
1112 | 1112 | ||
1113 | /************************************************************************** | 1113 | /************************************************************************** |
1114 | * | 1114 | * |
1115 | **************************************************************************/ | 1115 | **************************************************************************/ |
1116 | 1116 | ||
1117 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | 1117 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) |
1118 | { | 1118 | { |
1119 | |||
1120 | if ( cmsg == "nextView()" ) { | ||
1121 | emit nextView(); | ||
1122 | return; | ||
1123 | } | ||
1124 | |||
1119 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1125 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1120 | if (!res) | 1126 | if (!res) |
1121 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); | 1127 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); |
1122 | 1128 | ||
1123 | if (!res) | 1129 | if (!res) |
1124 | res = mDisplayDetails->appMessage( cmsg, data ); | 1130 | res = mDisplayDetails->appMessage( cmsg, data ); |
1125 | 1131 | ||
1126 | // if (!res) | 1132 | // if (!res) |
1127 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1133 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1128 | } | 1134 | } |
1129 | 1135 | ||
1130 | 1136 | ||
1131 | 1137 | ||
1132 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1138 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
1133 | { | 1139 | { |
1134 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1140 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1135 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1141 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); |
1136 | } | 1142 | } |
1137 | 1143 | ||
1138 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1144 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1139 | { | 1145 | { |
1140 | QStringList list4, list5, list6; | 1146 | QStringList list4, list5, list6; |
1141 | 1147 | ||
1142 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1148 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1143 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1149 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1144 | } | 1150 | } |
1145 | 1151 | ||
1146 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) | 1152 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) |
1147 | { | 1153 | { |
1148 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1154 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1149 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); | 1155 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); |
1150 | } | 1156 | } |
1151 | 1157 | ||
1152 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1158 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1153 | { | 1159 | { |
1154 | QStringList list4, list5, list6; | 1160 | QStringList list4, list5, list6; |
1155 | 1161 | ||
1156 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1162 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1157 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1163 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1158 | } | 1164 | } |
1159 | 1165 | ||
1160 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) | 1166 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) |
1161 | { | 1167 | { |
1162 | mDisplayDetails->setSourceChannel(""); | 1168 | mDisplayDetails->setSourceChannel(""); |
1163 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); | 1169 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); |
1164 | } | 1170 | } |
1165 | 1171 | ||
1166 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1172 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
1167 | { | 1173 | { |
1168 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); | 1174 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); |
1169 | return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1175 | return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); |
1170 | } | 1176 | } |
1171 | 1177 | ||
1172 | bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) | 1178 | bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) |
1173 | { | 1179 | { |
1174 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); | 1180 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); |
1175 | return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1181 | return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1176 | } | 1182 | } |
1177 | 1183 | ||
1178 | 1184 | ||
1179 | 1185 | ||
1180 | 1186 | ||
1181 | 1187 | ||
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h index 6f5d345..52a64e1 100644 --- a/libkdepim/externalapphandler.h +++ b/libkdepim/externalapphandler.h | |||
@@ -1,291 +1,292 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #ifndef EXTERNALAPPHANDLER_H | 31 | #ifndef EXTERNALAPPHANDLER_H |
32 | #define EXTERNALAPPHANDLER_H | 32 | #define EXTERNALAPPHANDLER_H |
33 | 33 | ||
34 | #include <qobject.h> | 34 | #include <qobject.h> |
35 | #include <qlist.h> | 35 | #include <qlist.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | class QCopEnvelope; | 38 | class QCopEnvelope; |
39 | 39 | ||
40 | 40 | ||
41 | class ExternalAppHandler; | 41 | class ExternalAppHandler; |
42 | class QCopTransferItem : public QObject | 42 | class QCopTransferItem : public QObject |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | 46 | QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); |
47 | QCopTransferItem(); | 47 | QCopTransferItem(); |
48 | 48 | ||
49 | bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null); | 49 | bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null); |
50 | 50 | ||
51 | void setSourceChannel(const QString& sourceChannel); | 51 | void setSourceChannel(const QString& sourceChannel); |
52 | 52 | ||
53 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | 53 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); |
54 | 54 | ||
55 | 55 | ||
56 | signals: | 56 | signals: |
57 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid); | 57 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid); |
58 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); | 58 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); |
59 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2); | 59 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2); |
60 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3); | 60 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3); |
61 | 61 | ||
62 | public: | 62 | public: |
63 | int _usedSourceParameters; | 63 | int _usedSourceParameters; |
64 | QString _sourceChannel; | 64 | QString _sourceChannel; |
65 | QString _sourceMessage; | 65 | QString _sourceMessage; |
66 | QString _sourceMessageParameters; | 66 | QString _sourceMessageParameters; |
67 | QString _targetChannel; | 67 | QString _targetChannel; |
68 | QString _targetMessage; | 68 | QString _targetMessage; |
69 | QString _targetMessageParameters; | 69 | QString _targetMessageParameters; |
70 | 70 | ||
71 | }; | 71 | }; |
72 | 72 | ||
73 | /********************************************************************************* | 73 | /********************************************************************************* |
74 | * | 74 | * |
75 | ********************************************************************************/ | 75 | ********************************************************************************/ |
76 | 76 | ||
77 | class QCopMapTransferItem : public QCopTransferItem | 77 | class QCopMapTransferItem : public QCopTransferItem |
78 | { | 78 | { |
79 | Q_OBJECT | 79 | Q_OBJECT |
80 | public: | 80 | public: |
81 | QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | 81 | QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); |
82 | 82 | ||
83 | bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); | 83 | bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); |
84 | 84 | ||
85 | 85 | ||
86 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | 86 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); |
87 | 87 | ||
88 | 88 | ||
89 | signals: | 89 | signals: |
90 | void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); | 90 | void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); |
91 | 91 | ||
92 | }; | 92 | }; |
93 | 93 | ||
94 | /********************************************************************************* | 94 | /********************************************************************************* |
95 | * | 95 | * |
96 | ********************************************************************************/ | 96 | ********************************************************************************/ |
97 | 97 | ||
98 | class QCopListTransferItem : public QCopTransferItem | 98 | class QCopListTransferItem : public QCopTransferItem |
99 | { | 99 | { |
100 | Q_OBJECT | 100 | Q_OBJECT |
101 | public: | 101 | public: |
102 | QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | 102 | QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); |
103 | ~QCopListTransferItem(); | 103 | ~QCopListTransferItem(); |
104 | bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6); | 104 | bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6); |
105 | 105 | ||
106 | 106 | ||
107 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | 107 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); |
108 | 108 | ||
109 | 109 | ||
110 | signals: | 110 | signals: |
111 | void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6); | 111 | void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6); |
112 | 112 | ||
113 | }; | 113 | }; |
114 | 114 | ||
115 | /********************************************************************************* | 115 | /********************************************************************************* |
116 | * | 116 | * |
117 | ********************************************************************************/ | 117 | ********************************************************************************/ |
118 | 118 | ||
119 | 119 | ||
120 | class DefaultAppItem | 120 | class DefaultAppItem |
121 | { | 121 | { |
122 | public: | 122 | public: |
123 | DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) | 123 | DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) |
124 | : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) | 124 | : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) |
125 | {} | 125 | {} |
126 | 126 | ||
127 | DefaultAppItem() | 127 | DefaultAppItem() |
128 | { } | 128 | { } |
129 | 129 | ||
130 | public: | 130 | public: |
131 | int _type; | 131 | int _type; |
132 | int _id; | 132 | int _id; |
133 | QString _label; | 133 | QString _label; |
134 | QString _channel; | 134 | QString _channel; |
135 | QString _message; | 135 | QString _message; |
136 | QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; | 136 | QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; |
137 | QString _message2; | 137 | QString _message2; |
138 | QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; | 138 | QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; |
139 | 139 | ||
140 | }; | 140 | }; |
141 | 141 | ||
142 | /********************************************************************************* | 142 | /********************************************************************************* |
143 | * | 143 | * |
144 | ********************************************************************************/ | 144 | ********************************************************************************/ |
145 | 145 | ||
146 | class ExternalAppHandler : public QObject | 146 | class ExternalAppHandler : public QObject |
147 | { | 147 | { |
148 | Q_OBJECT | 148 | Q_OBJECT |
149 | public: | 149 | public: |
150 | virtual ~ExternalAppHandler(); | 150 | virtual ~ExternalAppHandler(); |
151 | 151 | ||
152 | static ExternalAppHandler *instance(); | 152 | static ExternalAppHandler *instance(); |
153 | 153 | ||
154 | enum Types { | 154 | enum Types { |
155 | EMAIL = 0, | 155 | EMAIL = 0, |
156 | PHONE = 1, | 156 | PHONE = 1, |
157 | SMS = 2, | 157 | SMS = 2, |
158 | FAX = 3, | 158 | FAX = 3, |
159 | PAGER = 4, | 159 | PAGER = 4, |
160 | SIP = 5 | 160 | SIP = 5 |
161 | }; | 161 | }; |
162 | 162 | ||
163 | enum Availability { | 163 | enum Availability { |
164 | UNDEFINED = -1, | 164 | UNDEFINED = -1, |
165 | UNAVAILABLE = 0, | 165 | UNAVAILABLE = 0, |
166 | AVAILABLE = 1 | 166 | AVAILABLE = 1 |
167 | }; | 167 | }; |
168 | 168 | ||
169 | //calls the emailapplication with a number of attachments that need to be send. | 169 | //calls the emailapplication with a number of attachments that need to be send. |
170 | //either parameter can be left empty. | 170 | //either parameter can be left empty. |
171 | bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); | 171 | bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); |
172 | 172 | ||
173 | //calls the emailapplication and creates a mail with parameter emailadress as recipients | 173 | //calls the emailapplication and creates a mail with parameter emailadress as recipients |
174 | bool mailToOneContact( const QString& name, const QString& emailadress ); | 174 | bool mailToOneContact( const QString& name, const QString& emailadress ); |
175 | 175 | ||
176 | //calls the emailapplication and creates a mail with parameter as recipients | 176 | //calls the emailapplication and creates a mail with parameter as recipients |
177 | // parameters format is | 177 | // parameters format is |
178 | // NAME <EMAIL>:SUBJECT | 178 | // NAME <EMAIL>:SUBJECT |
179 | bool mailToOneContact( const QString& adressline ); | 179 | bool mailToOneContact( const QString& adressline ); |
180 | 180 | ||
181 | //calls the phoneapplication with the number | 181 | //calls the phoneapplication with the number |
182 | bool callByPhone( const QString& phonenumber ); | 182 | bool callByPhone( const QString& phonenumber ); |
183 | 183 | ||
184 | //calls the smsapplication with the number | 184 | //calls the smsapplication with the number |
185 | bool callBySMS( const QString& phonenumber ); | 185 | bool callBySMS( const QString& phonenumber ); |
186 | 186 | ||
187 | //calls the pagerapplication with the number | 187 | //calls the pagerapplication with the number |
188 | bool callByPager( const QString& pagernumber ); | 188 | bool callByPager( const QString& pagernumber ); |
189 | 189 | ||
190 | //calls the faxapplication with the number | 190 | //calls the faxapplication with the number |
191 | bool callByFax( const QString& faxnumber ); | 191 | bool callByFax( const QString& faxnumber ); |
192 | 192 | ||
193 | //calls the sipapplication with the number | 193 | //calls the sipapplication with the number |
194 | bool callBySIP( const QString& sipnumber ); | 194 | bool callBySIP( const QString& sipnumber ); |
195 | 195 | ||
196 | bool isEmailAppAvailable(); | 196 | bool isEmailAppAvailable(); |
197 | bool isSMSAppAvailable(); | 197 | bool isSMSAppAvailable(); |
198 | bool isPhoneAppAvailable(); | 198 | bool isPhoneAppAvailable(); |
199 | bool isFaxAppAvailable(); | 199 | bool isFaxAppAvailable(); |
200 | bool isPagerAppAvailable(); | 200 | bool isPagerAppAvailable(); |
201 | bool isSIPAppAvailable(); | 201 | bool isSIPAppAvailable(); |
202 | 202 | ||
203 | 203 | ||
204 | //Call this method on the source when you want to select names from the addressbook by using QCop | 204 | //Call this method on the source when you want to select names from the addressbook by using QCop |
205 | bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); | 205 | bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); |
206 | //Call this method on the target when you want to return the name/email map to the source (client). | 206 | //Call this method on the target when you want to return the name/email map to the source (client). |
207 | bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); | 207 | bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); | 211 | bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); |
212 | bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); | 212 | bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); |
213 | 213 | ||
214 | bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); | 214 | bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); |
215 | 215 | ||
216 | 216 | ||
217 | 217 | ||
218 | bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid); | 218 | bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid); |
219 | bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, | 219 | bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, |
220 | const QStringList& birthdayList, const QStringList& anniversaryList, | 220 | const QStringList& birthdayList, const QStringList& anniversaryList, |
221 | const QStringList& realNameList, const QStringList& emailList, | 221 | const QStringList& realNameList, const QStringList& emailList, |
222 | const QStringList& assembledNameList, const QStringList& uidList); | 222 | const QStringList& assembledNameList, const QStringList& uidList); |
223 | 223 | ||
224 | 224 | ||
225 | //loadConfig clears the cache and checks again if the applications are available or not | 225 | //loadConfig clears the cache and checks again if the applications are available or not |
226 | void loadConfig(); | 226 | void loadConfig(); |
227 | 227 | ||
228 | QList<DefaultAppItem> getAvailableDefaultItems(Types); | 228 | QList<DefaultAppItem> getAvailableDefaultItems(Types); |
229 | DefaultAppItem* getDefaultItem(Types, int); | 229 | DefaultAppItem* getDefaultItem(Types, int); |
230 | 230 | ||
231 | public slots: | 231 | public slots: |
232 | void appMessage( const QCString& msg, const QByteArray& data ); | 232 | void appMessage( const QCString& msg, const QByteArray& data ); |
233 | 233 | ||
234 | 234 | ||
235 | signals: | 235 | signals: |
236 | void nextView(); | ||
236 | // Emmitted when the target app receives a request from the source app | 237 | // Emmitted when the target app receives a request from the source app |
237 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); | 238 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); |
238 | 239 | ||
239 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi | 240 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi |
240 | // The first parameter is a uniqueid. It can be used to identify the event | 241 | // The first parameter is a uniqueid. It can be used to identify the event |
241 | void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); | 242 | void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); |
242 | 243 | ||
243 | void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); | 244 | void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); |
244 | void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); | 245 | void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); |
245 | 246 | ||
246 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 247 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
247 | 248 | ||
248 | 249 | ||
249 | // Emmitted when the target app receives a request from the source app | 250 | // Emmitted when the target app receives a request from the source app |
250 | void requestForBirthdayList(const QString& sourceChannel, const QString& uid); | 251 | void requestForBirthdayList(const QString& sourceChannel, const QString& uid); |
251 | 252 | ||
252 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi | 253 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi |
253 | // The first parameter is a uniqueid. It can be used to identify the event | 254 | // The first parameter is a uniqueid. It can be used to identify the event |
254 | void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList, | 255 | void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList, |
255 | const QStringList& anniversaryList, const QStringList& realNameList, | 256 | const QStringList& anniversaryList, const QStringList& realNameList, |
256 | const QStringList& emailList, const QStringList& assembledNameList, | 257 | const QStringList& emailList, const QStringList& assembledNameList, |
257 | const QStringList& uidList); | 258 | const QStringList& uidList); |
258 | 259 | ||
259 | 260 | ||
260 | private: | 261 | private: |
261 | ExternalAppHandler(); | 262 | ExternalAppHandler(); |
262 | QList<DefaultAppItem> mDefaultItems; | 263 | QList<DefaultAppItem> mDefaultItems; |
263 | 264 | ||
264 | Availability mEmailAppAvailable; | 265 | Availability mEmailAppAvailable; |
265 | Availability mPhoneAppAvailable; | 266 | Availability mPhoneAppAvailable; |
266 | Availability mFaxAppAvailable; | 267 | Availability mFaxAppAvailable; |
267 | Availability mSMSAppAvailable; | 268 | Availability mSMSAppAvailable; |
268 | Availability mPagerAppAvailable; | 269 | Availability mPagerAppAvailable; |
269 | Availability mSIPAppAvailable; | 270 | Availability mSIPAppAvailable; |
270 | 271 | ||
271 | QCopListTransferItem* mNameEmailUidListFromKAPITransfer; | 272 | QCopListTransferItem* mNameEmailUidListFromKAPITransfer; |
272 | QCopListTransferItem* mFindByEmailFromKAPITransfer; | 273 | QCopListTransferItem* mFindByEmailFromKAPITransfer; |
273 | QCopTransferItem* mDisplayDetails; | 274 | QCopTransferItem* mDisplayDetails; |
274 | QCopListTransferItem* mBirthdayListFromKAPITransfer; | 275 | QCopListTransferItem* mBirthdayListFromKAPITransfer; |
275 | 276 | ||
276 | 277 | ||
277 | void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); | 278 | void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); |
278 | 279 | ||
279 | QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; | 280 | QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; |
280 | void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; | 281 | void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; |
281 | 282 | ||
282 | 283 | ||
283 | static ExternalAppHandler *sInstance; | 284 | static ExternalAppHandler *sInstance; |
284 | 285 | ||
285 | private slots: | 286 | private slots: |
286 | void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ); | 287 | void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ); |
287 | 288 | ||
288 | }; | 289 | }; |
289 | 290 | ||
290 | 291 | ||
291 | #endif | 292 | #endif |
diff --git a/pwmanager/pwmanager/pwminit.cpp b/pwmanager/pwmanager/pwminit.cpp index fbd17a7..68f3637 100644 --- a/pwmanager/pwmanager/pwminit.cpp +++ b/pwmanager/pwmanager/pwminit.cpp | |||
@@ -1,650 +1,660 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2004 by Michael Buesch * | 3 | * copyright (C) 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | /*************************************************************************** | 12 | /*************************************************************************** |
13 | * copyright (C) 2004 by Ulf Schenk | 13 | * copyright (C) 2004 by Ulf Schenk |
14 | * This file is originaly based on version 1.0.1 of pwmanager | 14 | * This file is originaly based on version 1.0.1 of pwmanager |
15 | * and was modified to run on embedded devices that run microkde | 15 | * and was modified to run on embedded devices that run microkde |
16 | * | 16 | * |
17 | * $Id$ | 17 | * $Id$ |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | 19 | ||
20 | #include "pwminit.h" | 20 | #include "pwminit.h" |
21 | #include "randomizer.h" | 21 | #include "randomizer.h" |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | 23 | ||
24 | #ifndef PWM_EMBEDDED | 24 | #ifndef PWM_EMBEDDED |
25 | #include "selftest.h" | 25 | #include "selftest.h" |
26 | #include "configuration.h" | 26 | #include "configuration.h" |
27 | #else | 27 | #else |
28 | #include "pwmprefs.h" | 28 | #include "pwmprefs.h" |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #include "pwm.h" | 31 | #include "pwm.h" |
32 | #include "pwmexception.h" | 32 | #include "pwmexception.h" |
33 | #include "pwmtray.h" | 33 | #include "pwmtray.h" |
34 | #include "pwmdoc.h" | 34 | #include "pwmdoc.h" |
35 | 35 | ||
36 | #ifdef CONFIG_KWALLETIF | 36 | #ifdef CONFIG_KWALLETIF |
37 | # include "kwalletemu.h" | 37 | # include "kwalletemu.h" |
38 | #endif // CONFIG_KWALLETIF | 38 | #endif // CONFIG_KWALLETIF |
39 | #ifdef CONFIG_KEYCARD | 39 | #ifdef CONFIG_KEYCARD |
40 | # include "pwmkeycard.h" | 40 | # include "pwmkeycard.h" |
41 | #endif // CONFIG_KEYCARD | 41 | #endif // CONFIG_KEYCARD |
42 | 42 | ||
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | 44 | ||
45 | #include <kmessagebox.h> | 45 | #include <kmessagebox.h> |
46 | #ifndef PWM_EMBEDDED | 46 | #ifndef PWM_EMBEDDED |
47 | #include <kcmdlineargs.h> | 47 | #include <kcmdlineargs.h> |
48 | #include <kwin.h> | 48 | #include <kwin.h> |
49 | #include <dcopclient.h> | 49 | #include <dcopclient.h> |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #include <kapplication.h> | 52 | #include <kapplication.h> |
53 | #include <kiconloader.h> | 53 | #include <kiconloader.h> |
54 | 54 | ||
55 | #include <signal.h> | 55 | #include <signal.h> |
56 | 56 | ||
57 | static PwMInit *sig_init_pointer; | 57 | static PwMInit *sig_init_pointer; |
58 | #ifdef _WIN32_ | 58 | #ifdef _WIN32_ |
59 | static void sig_handler(int signum) | 59 | static void sig_handler(int signum) |
60 | #else | 60 | #else |
61 | static NOREGPARM void sig_handler(int signum) | 61 | static NOREGPARM void sig_handler(int signum) |
62 | #endif | 62 | #endif |
63 | { | 63 | { |
64 | switch (signum) { | 64 | switch (signum) { |
65 | case SIGINT: | 65 | case SIGINT: |
66 | case SIGTERM: | 66 | case SIGTERM: |
67 | sig_init_pointer->shutdownApp(20 + signum); | 67 | sig_init_pointer->shutdownApp(20 + signum); |
68 | break; | 68 | break; |
69 | default: | 69 | default: |
70 | printDebug(string("unhandled signal ") | 70 | printDebug(string("unhandled signal ") |
71 | + tostr(signum)); | 71 | + tostr(signum)); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | PwMInit::PwMInit(PwMApplication *_app) | 77 | PwMInit::PwMInit(PwMApplication *_app) |
78 | : runStatus (unknown) | 78 | : runStatus (unknown) |
79 | , _curWidget (0) | 79 | , _curWidget (0) |
80 | , _dcopClient (0) | 80 | , _dcopClient (0) |
81 | , _kwalletEmu (0) | 81 | , _kwalletEmu (0) |
82 | , _keycard (0) | 82 | , _keycard (0) |
83 | , _tray (0) | 83 | , _tray (0) |
84 | { | 84 | { |
85 | sig_init_pointer = this; | 85 | sig_init_pointer = this; |
86 | app = _app; | 86 | app = _app; |
87 | } | 87 | } |
88 | 88 | ||
89 | PwMInit::~PwMInit() | 89 | PwMInit::~PwMInit() |
90 | { | 90 | { |
91 | qDebug("PwMInit::~PwMInit() "); | 91 | qDebug("PwMInit::~PwMInit() "); |
92 | #ifndef PWM_EMBEDDED | 92 | #ifndef PWM_EMBEDDED |
93 | SelfTest::cancel(); | 93 | SelfTest::cancel(); |
94 | // close all open mainwnds | 94 | // close all open mainwnds |
95 | QValueList<PwM *>::iterator i = _mainWndList.begin(), | 95 | QValueList<PwM *>::iterator i = _mainWndList.begin(), |
96 | end = _mainWndList.end(); | 96 | end = _mainWndList.end(); |
97 | 97 | ||
98 | #else | 98 | #else |
99 | // close all open mainwnds | 99 | // close all open mainwnds |
100 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), | 100 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), |
101 | end = _mainWndList.end(); | 101 | end = _mainWndList.end(); |
102 | #endif | 102 | #endif |
103 | while (i != end) { | 103 | while (i != end) { |
104 | disconnect(*i, SIGNAL(closed(PwM *)), | 104 | disconnect(*i, SIGNAL(closed(PwM *)), |
105 | this, SLOT(mainWndClosed(PwM *))); | 105 | this, SLOT(mainWndClosed(PwM *))); |
106 | delete *i; | 106 | delete *i; |
107 | ++i; | 107 | ++i; |
108 | } | 108 | } |
109 | _mainWndList.clear(); | 109 | _mainWndList.clear(); |
110 | // close all remaining open documents | 110 | // close all remaining open documents |
111 | PwMDocList *_dl = PwMDoc::getOpenDocList(); | 111 | PwMDocList *_dl = PwMDoc::getOpenDocList(); |
112 | vector<PwMDocList::listItem> dl = *(_dl->getList()); | 112 | vector<PwMDocList::listItem> dl = *(_dl->getList()); |
113 | vector<PwMDocList::listItem>::iterator i2 = dl.begin(), | 113 | vector<PwMDocList::listItem>::iterator i2 = dl.begin(), |
114 | end2 = dl.end(); | 114 | end2 = dl.end(); |
115 | while (i2 != end2) { | 115 | while (i2 != end2) { |
116 | delete (*i2).doc; | 116 | delete (*i2).doc; |
117 | ++i2; | 117 | ++i2; |
118 | } | 118 | } |
119 | 119 | ||
120 | #ifdef CONFIG_KWALLETIF | 120 | #ifdef CONFIG_KWALLETIF |
121 | delete_ifnot_null(_kwalletEmu); | 121 | delete_ifnot_null(_kwalletEmu); |
122 | #endif // CONFIG_KWALLETIF | 122 | #endif // CONFIG_KWALLETIF |
123 | #ifdef CONFIG_KEYCARD | 123 | #ifdef CONFIG_KEYCARD |
124 | delete_ifnot_null(_keycard); | 124 | delete_ifnot_null(_keycard); |
125 | #endif // CONFIG_KEYCARD | 125 | #endif // CONFIG_KEYCARD |
126 | delete_ifnot_null(_tray); | 126 | delete_ifnot_null(_tray); |
127 | 127 | ||
128 | Randomizer::cleanup(); | 128 | Randomizer::cleanup(); |
129 | #ifndef PWM_EMBEDDED | 129 | #ifndef PWM_EMBEDDED |
130 | Configuration::cleanup(); | 130 | Configuration::cleanup(); |
131 | #endif | 131 | #endif |
132 | } | 132 | } |
133 | 133 | ||
134 | void PwMInit::initializeApp() | 134 | void PwMInit::initializeApp() |
135 | { | 135 | { |
136 | //qDebug("PwMInit::initializeApp() "); | 136 | //qDebug("PwMInit::initializeApp() "); |
137 | PWM_ASSERT(runStatus == unknown); | 137 | PWM_ASSERT(runStatus == unknown); |
138 | runStatus = init; | 138 | runStatus = init; |
139 | initPosixSignalHandler(); | 139 | initPosixSignalHandler(); |
140 | Randomizer::init(); | 140 | Randomizer::init(); |
141 | #ifndef PWM_EMBEDDED | 141 | #ifndef PWM_EMBEDDED |
142 | Configuration::init(); | 142 | Configuration::init(); |
143 | #endif | 143 | #endif |
144 | initDCOP(); | 144 | initDCOP(); |
145 | initKWalletEmu(); | 145 | initKWalletEmu(); |
146 | initKeycard(); | 146 | initKeycard(); |
147 | initTray(); | 147 | initTray(); |
148 | handleCmdLineArgs(); | 148 | handleCmdLineArgs(); |
149 | bool openDeeplocked = false; | 149 | bool openDeeplocked = false; |
150 | if (conf()->confGlobAutostartDeepLocked() || | 150 | if (conf()->confGlobAutostartDeepLocked() || |
151 | savedCmd.open_deeplocked) | 151 | savedCmd.open_deeplocked) |
152 | openDeeplocked = true; | 152 | openDeeplocked = true; |
153 | if ( false ){ | 153 | if ( false ){ |
154 | // LR is not working | 154 | // LR is not working |
155 | //if (conf()->confWndAutoMinimizeOnStart() || | 155 | //if (conf()->confWndAutoMinimizeOnStart() || |
156 | // savedCmd.minToTray) { | 156 | // savedCmd.minToTray) { |
157 | PwMDoc *newDoc = createDoc(); | 157 | PwMDoc *newDoc = createDoc(); |
158 | qDebug(" createDoc()"); | 158 | qDebug(" createDoc()"); |
159 | if (!newDoc->openDocUi(newDoc, | 159 | if (!newDoc->openDocUi(newDoc, |
160 | conf()->confGlobAutoStart(), | 160 | conf()->confGlobAutoStart(), |
161 | openDeeplocked)) { | 161 | openDeeplocked)) { |
162 | delete newDoc; | 162 | delete newDoc; |
163 | } | 163 | } |
164 | 164 | ||
165 | //US ENH for embedded devices: in the case of failure, open a document the default way | 165 | //US ENH for embedded devices: in the case of failure, open a document the default way |
166 | createMainWnd(conf()->confGlobAutoStart(), | 166 | createMainWnd(conf()->confGlobAutoStart(), |
167 | openDeeplocked, | 167 | openDeeplocked, |
168 | true, | 168 | true, |
169 | 0, | 169 | 0, |
170 | savedCmd.minimized); | 170 | savedCmd.minimized); |
171 | 171 | ||
172 | 172 | ||
173 | 173 | ||
174 | 174 | ||
175 | //} | 175 | //} |
176 | } else { | 176 | } else { |
177 | createMainWnd(conf()->confGlobAutoStart(), | 177 | createMainWnd(conf()->confGlobAutoStart(), |
178 | openDeeplocked, | 178 | openDeeplocked, |
179 | true, | 179 | true, |
180 | 0, | 180 | 0, |
181 | savedCmd.minimized); | 181 | savedCmd.minimized); |
182 | } | 182 | } |
183 | runStatus = running; | 183 | runStatus = running; |
184 | } | 184 | } |
185 | 185 | ||
186 | void PwMInit::shutdownApp(int exitStatus) | 186 | void PwMInit::shutdownApp(int exitStatus) |
187 | { | 187 | { |
188 | |||
189 | |||
190 | PwM * iii; | ||
191 | while ( iii = _mainWndList.first() ) { | ||
192 | disconnect(iii, SIGNAL(closed(PwM *)), | ||
193 | this, SLOT(mainWndClosed(PwM *))); | ||
194 | mainWndClosed((iii)); | ||
195 | } | ||
196 | |||
188 | printDebug(string("PwMInit::shutdownApp(") | 197 | printDebug(string("PwMInit::shutdownApp(") |
189 | + tostr(exitStatus) + ") called."); | 198 | + tostr(exitStatus) + ") called."); |
190 | PWM_ASSERT((runStatus == running) || (runStatus == init)); | 199 | PWM_ASSERT((runStatus == running) || (runStatus == init)); |
191 | runStatus = shutdown; | 200 | runStatus = shutdown; |
192 | QApplication::exit(exitStatus); | 201 | QApplication::exit(exitStatus); |
193 | /* The destructor of PwMInit is called when control | 202 | /* The destructor of PwMInit is called when control |
194 | * leaves main() | 203 | * leaves main() |
195 | */ | 204 | */ |
196 | } | 205 | } |
197 | 206 | ||
198 | void PwMInit::initPosixSignalHandler() | 207 | void PwMInit::initPosixSignalHandler() |
199 | { | 208 | { |
200 | signal(SIGINT, sig_handler); | 209 | signal(SIGINT, sig_handler); |
201 | signal(SIGTERM, sig_handler); | 210 | signal(SIGTERM, sig_handler); |
202 | } | 211 | } |
203 | 212 | ||
204 | void PwMInit::initDCOP() | 213 | void PwMInit::initDCOP() |
205 | { | 214 | { |
206 | #ifndef PWM_EMBEDDED | 215 | #ifndef PWM_EMBEDDED |
207 | _dcopClient = app->dcopClient(); | 216 | _dcopClient = app->dcopClient(); |
208 | _dcopClient->setNotifications(true); | 217 | _dcopClient->setNotifications(true); |
209 | #endif | 218 | #endif |
210 | 219 | ||
211 | } | 220 | } |
212 | 221 | ||
213 | void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) | 222 | void PwMInit::initKWalletEmu(bool forceDisable, bool forceReload) |
214 | { | 223 | { |
215 | #ifdef CONFIG_KWALLETIF | 224 | #ifdef CONFIG_KWALLETIF |
216 | if (!conf()->confGlobKwalletEmu() || | 225 | if (!conf()->confGlobKwalletEmu() || |
217 | forceDisable) { | 226 | forceDisable) { |
218 | delete_ifnot_null(_kwalletEmu); | 227 | delete_ifnot_null(_kwalletEmu); |
219 | return; | 228 | return; |
220 | } | 229 | } |
221 | try { | 230 | try { |
222 | if (_kwalletEmu && forceReload) | 231 | if (_kwalletEmu && forceReload) |
223 | delete_and_null(_kwalletEmu); | 232 | delete_and_null(_kwalletEmu); |
224 | if (!_kwalletEmu) | 233 | if (!_kwalletEmu) |
225 | _kwalletEmu = new KWalletEmu(this); | 234 | _kwalletEmu = new KWalletEmu(this); |
226 | } catch (PwMException e) { | 235 | } catch (PwMException e) { |
227 | string errMsg("initializing KWallet emulation failed. ID: "); | 236 | string errMsg("initializing KWallet emulation failed. ID: "); |
228 | errMsg += tostr(static_cast<int>(e.getId())); | 237 | errMsg += tostr(static_cast<int>(e.getId())); |
229 | errMsg += " err-message: "; | 238 | errMsg += " err-message: "; |
230 | errMsg += e.getMessage(); | 239 | errMsg += e.getMessage(); |
231 | printWarn(errMsg); | 240 | printWarn(errMsg); |
232 | return; | 241 | return; |
233 | } | 242 | } |
234 | #else // CONFIG_KWALLETIF | 243 | #else // CONFIG_KWALLETIF |
235 | PARAM_UNUSED(forceDisable); | 244 | PARAM_UNUSED(forceDisable); |
236 | PARAM_UNUSED(forceReload); | 245 | PARAM_UNUSED(forceReload); |
237 | #endif // CONFIG_KWALLETIF | 246 | #endif // CONFIG_KWALLETIF |
238 | } | 247 | } |
239 | 248 | ||
240 | void PwMInit::initKeycard() | 249 | void PwMInit::initKeycard() |
241 | { | 250 | { |
242 | #ifdef CONFIG_KEYCARD | 251 | #ifdef CONFIG_KEYCARD |
243 | PWM_ASSERT(!_keycard); | 252 | PWM_ASSERT(!_keycard); |
244 | _keycard = new PwMKeyCard(this); | 253 | _keycard = new PwMKeyCard(this); |
245 | #endif // CONFIG_KEYCARD | 254 | #endif // CONFIG_KEYCARD |
246 | } | 255 | } |
247 | 256 | ||
248 | void PwMInit::initTray() | 257 | void PwMInit::initTray() |
249 | { | 258 | { |
250 | #ifdef PWM_EMBEDDED | 259 | #ifdef PWM_EMBEDDED |
251 | //US ENH : embedded version does not support a tray | 260 | //US ENH : embedded version does not support a tray |
252 | return; | 261 | return; |
253 | #endif | 262 | #endif |
254 | 263 | ||
255 | if (!conf()->confGlobTray()) { | 264 | if (!conf()->confGlobTray()) { |
256 | if (!_tray) | 265 | if (!_tray) |
257 | return; | 266 | return; |
258 | _tray->hide(); | 267 | _tray->hide(); |
259 | delete_and_null(_tray); | 268 | delete_and_null(_tray); |
260 | return; | 269 | return; |
261 | } | 270 | } |
262 | if (_tray) | 271 | if (_tray) |
263 | return; | 272 | return; |
264 | _tray = new PwMTray(this); | 273 | _tray = new PwMTray(this); |
265 | connect(_tray, SIGNAL(quitSelected()), | 274 | connect(_tray, SIGNAL(quitSelected()), |
266 | this, SLOT(removeTrayAndQuit())); | 275 | this, SLOT(removeTrayAndQuit())); |
267 | connect(_tray, SIGNAL(closed(PwMTray *)), | 276 | connect(_tray, SIGNAL(closed(PwMTray *)), |
268 | this, SLOT(trayIconClosed(PwMTray *))); | 277 | this, SLOT(trayIconClosed(PwMTray *))); |
269 | KIconLoader icons; | 278 | KIconLoader icons; |
270 | #ifndef PWM_EMBEDDED | 279 | #ifndef PWM_EMBEDDED |
271 | _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); | 280 | _tray->setPixmap(icons.loadIcon(PACKAGE_NAME, KIcon::Small)); |
272 | #endif | 281 | #endif |
273 | _tray->show(); | 282 | _tray->show(); |
274 | // connect the signals of all open documents. | 283 | // connect the signals of all open documents. |
275 | const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); | 284 | const vector<PwMDocList::listItem> *dl = PwMDoc::getOpenDocList()->getList(); |
276 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), | 285 | vector<PwMDocList::listItem>::const_iterator i = dl->begin(), |
277 | end = dl->end(); | 286 | end = dl->end(); |
278 | while (i != end) { | 287 | while (i != end) { |
279 | _tray->connectDocToTray((*i).doc); | 288 | _tray->connectDocToTray((*i).doc); |
280 | ++i; | 289 | ++i; |
281 | } | 290 | } |
282 | } | 291 | } |
283 | 292 | ||
284 | void PwMInit::removeTrayAndQuit() | 293 | void PwMInit::removeTrayAndQuit() |
285 | { | 294 | { |
286 | PWM_ASSERT(_tray); | 295 | PWM_ASSERT(_tray); |
287 | // _tray is deleted in ~PwMInit | 296 | // _tray is deleted in ~PwMInit |
288 | shutdownApp(0); | 297 | shutdownApp(0); |
289 | } | 298 | } |
290 | 299 | ||
291 | PwM * PwMInit::createMainWnd(const QString &loadFile, | 300 | PwM * PwMInit::createMainWnd(const QString &loadFile, |
292 | bool loadFileDeepLocked, | 301 | bool loadFileDeepLocked, |
293 | bool virginity, | 302 | bool virginity, |
294 | PwMDoc *doc, | 303 | PwMDoc *doc, |
295 | bool minimized) | 304 | bool minimized) |
296 | { | 305 | { |
297 | PwM *newWnd; | 306 | PwM *newWnd; |
298 | if (!doc) | 307 | if (!doc) |
299 | doc = createDoc(); | 308 | doc = createDoc(); |
300 | newWnd = new PwM(this, doc, virginity); | 309 | newWnd = new PwM(this, doc, virginity); |
301 | #ifndef PWM_EMBEDDED | 310 | #ifndef PWM_EMBEDDED |
302 | _mainWndList.push_back(newWnd); | 311 | _mainWndList.push_back(newWnd); |
303 | #else | 312 | #else |
304 | _mainWndList.append(newWnd); | 313 | _mainWndList.append(newWnd); |
305 | #endif | 314 | #endif |
306 | connect(newWnd, SIGNAL(closed(PwM *)), | 315 | connect(newWnd, SIGNAL(closed(PwM *)), |
307 | this, SLOT(mainWndClosed(PwM *))); | 316 | this, SLOT(mainWndClosed(PwM *))); |
308 | connect(newWnd, SIGNAL(gotFocus(PwM *)), | 317 | connect(newWnd, SIGNAL(gotFocus(PwM *)), |
309 | this, SLOT(setCurWidget(PwM *))); | 318 | this, SLOT(setCurWidget(PwM *))); |
310 | connect(newWnd, SIGNAL(lostFocus(PwM *)), | 319 | connect(newWnd, SIGNAL(lostFocus(PwM *)), |
311 | this, SLOT(resetCurWidget())); | 320 | this, SLOT(resetCurWidget())); |
312 | 321 | ||
313 | //US ENH | 322 | //US ENH |
314 | #ifndef PWM_EMBEDDED | 323 | #ifndef PWM_EMBEDDED |
315 | if (minimized) | 324 | if (minimized) |
316 | newWnd->showMinimized(); | 325 | newWnd->showMinimized(); |
317 | else | 326 | else |
318 | newWnd->show(); | 327 | newWnd->show(); |
319 | 328 | ||
320 | #else //PWM_EMBEDDED | 329 | #else //PWM_EMBEDDED |
321 | 330 | ||
322 | #ifndef DESKTOP_VERSION | 331 | #ifndef DESKTOP_VERSION |
323 | app->showMainWidget( newWnd ); | 332 | app->showMainWidget( newWnd ); |
324 | #else //DESKTOP_VERSION | 333 | #else //DESKTOP_VERSION |
325 | newWnd->resize (640, 480 ); | 334 | newWnd->resize (640, 480 ); |
326 | newWnd->show(); | 335 | newWnd->show(); |
327 | #endif //DESKTOP_VERSION | 336 | #endif //DESKTOP_VERSION |
328 | 337 | ||
329 | #endif //PWM_EMBEDDED | 338 | #endif //PWM_EMBEDDED |
330 | 339 | ||
331 | if (loadFile != QString::null && | 340 | if (loadFile != QString::null && |
332 | loadFile != "") { | 341 | loadFile != "") { |
333 | newWnd->openDoc(loadFile, loadFileDeepLocked); | 342 | newWnd->openDoc(loadFile, loadFileDeepLocked); |
334 | } | 343 | } |
335 | return newWnd; | 344 | return newWnd; |
336 | } | 345 | } |
337 | 346 | ||
338 | PwMDoc * PwMInit::createDoc() | 347 | PwMDoc * PwMInit::createDoc() |
339 | { | 348 | { |
340 | PwMDoc *doc = new PwMDoc(this); | 349 | PwMDoc *doc = new PwMDoc(this); |
341 | #ifdef CONFIG_KEYCARD | 350 | #ifdef CONFIG_KEYCARD |
342 | doc->setPwMKeyCard(keycard()); | 351 | doc->setPwMKeyCard(keycard()); |
343 | #endif | 352 | #endif |
344 | #ifdef CONFIG_KWALLETIF | 353 | #ifdef CONFIG_KWALLETIF |
345 | if (kwalletEmu()) | 354 | if (kwalletEmu()) |
346 | kwalletEmu()->connectDocSignals(doc); | 355 | kwalletEmu()->connectDocSignals(doc); |
347 | #endif | 356 | #endif |
348 | 357 | ||
349 | if (_tray) | 358 | if (_tray) |
350 | _tray->connectDocToTray(doc); | 359 | _tray->connectDocToTray(doc); |
351 | 360 | ||
352 | return doc; | 361 | return doc; |
353 | 362 | ||
354 | } | 363 | } |
355 | 364 | ||
356 | void PwMInit::mainWndClosed(PwM *wnd) | 365 | void PwMInit::mainWndClosed(PwM *wnd) |
357 | { | 366 | { |
358 | bool doMinimizeToTray = false; | 367 | bool doMinimizeToTray = false; |
359 | bool doDeleteDoc = false; | 368 | bool doDeleteDoc = false; |
360 | #ifndef PWM_EMBEDDED | 369 | #ifndef PWM_EMBEDDED |
361 | dcopClient()->suspend(); | 370 | dcopClient()->suspend(); |
362 | dcopClient()->setAcceptCalls(false); | 371 | dcopClient()->setAcceptCalls(false); |
363 | #endif | 372 | #endif |
364 | again: | 373 | again: |
365 | 374 | ||
366 | if (wnd->isForceMinimizeToTray()) { | 375 | if (wnd->isForceMinimizeToTray()) { |
367 | if (unlikely(!_tray)) { | 376 | if (unlikely(!_tray)) { |
368 | /* This should not happen! If we set forceMinimizeToTray , | 377 | /* This should not happen! If we set forceMinimizeToTray , |
369 | * we must be sure that _tray exists. | 378 | * we must be sure that _tray exists. |
370 | */ | 379 | */ |
371 | BUG(); | 380 | BUG(); |
372 | wnd->setForceMinimizeToTray(false); | 381 | wnd->setForceMinimizeToTray(false); |
373 | goto again; | 382 | goto again; |
374 | } | 383 | } |
375 | doMinimizeToTray = true; | 384 | doMinimizeToTray = true; |
376 | } else { | 385 | } else { |
377 | // Ask to minimize to tray. If not, delete doc. | 386 | // Ask to minimize to tray. If not, delete doc. |
378 | if (_tray && | 387 | if (_tray && |
379 | runStatus != shutdown && | 388 | runStatus != shutdown && |
380 | !wnd->isForceQuit() && | 389 | !wnd->isForceQuit() && |
381 | !wnd->curDoc()->isDeleted()) { | 390 | !wnd->curDoc()->isDeleted()) { |
382 | if (conf()->confWndClose()) | 391 | if (conf()->confWndClose()) |
383 | doDeleteDoc = true; | 392 | doDeleteDoc = true; |
384 | else | 393 | else |
385 | doMinimizeToTray = true; | 394 | doMinimizeToTray = true; |
386 | } else { | 395 | } else { |
387 | doDeleteDoc = true; | 396 | doDeleteDoc = true; |
388 | } | 397 | } |
389 | } | 398 | } |
390 | 399 | ||
391 | if (doMinimizeToTray) { | 400 | if (doMinimizeToTray) { |
392 | qDebug("doMinimizeToTray "); | 401 | qDebug("doMinimizeToTray "); |
393 | PWM_ASSERT(_tray); | 402 | PWM_ASSERT(_tray); |
394 | int mmlock = conf()->confGlobMinimizeLock(); | 403 | int mmlock = conf()->confGlobMinimizeLock(); |
395 | switch (mmlock) { | 404 | switch (mmlock) { |
396 | case 0: // don't lock anything | 405 | case 0: // don't lock anything |
397 | break; | 406 | break; |
398 | case 1: // normal lock | 407 | case 1: // normal lock |
399 | wnd->curDoc()->lockAll(true); | 408 | wnd->curDoc()->lockAll(true); |
400 | break; | 409 | break; |
401 | case 2: // deep-lock | 410 | case 2: // deep-lock |
402 | wnd->curDoc()->deepLock(); | 411 | wnd->curDoc()->deepLock(); |
403 | break; | 412 | break; |
404 | default: | 413 | default: |
405 | WARN(); | 414 | WARN(); |
406 | } | 415 | } |
407 | } else if (doDeleteDoc) { | 416 | } else if (doDeleteDoc) { |
408 | qDebug("doDeleteDoc "); | 417 | qDebug("doDeleteDoc "); |
409 | if (!wnd->curDoc()->tryDelete()) { | 418 | if (!wnd->curDoc()->tryDelete()) { |
410 | /* We failed deleting the doc, | 419 | /* We failed deleting the doc, |
411 | * so open a new window with it, again. | 420 | * so open a new window with it, again. |
412 | */ | 421 | */ |
413 | createMainWnd(QString::null, false, | 422 | createMainWnd(QString::null, false, |
414 | false, wnd->curDoc()); | 423 | false, wnd->curDoc()); |
415 | } | 424 | } |
416 | } | 425 | } |
417 | #ifndef PWM_EMBEDDED | 426 | #ifndef PWM_EMBEDDED |
418 | // find the closed window in the "mainWndList" and delete it. | 427 | // find the closed window in the "mainWndList" and delete it. |
419 | QValueList<PwM *>::iterator i = _mainWndList.begin(), | 428 | QValueList<PwM *>::iterator i = _mainWndList.begin(), |
420 | end = _mainWndList.end(); | 429 | end = _mainWndList.end(); |
421 | #else | 430 | #else |
422 | // find the closed window in the "mainWndList" and delete it. | 431 | // find the closed window in the "mainWndList" and delete it. |
423 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), | 432 | QValueList<PwM *>::Iterator i = _mainWndList.begin(), |
424 | end = _mainWndList.end(); | 433 | end = _mainWndList.end(); |
425 | #endif | 434 | #endif |
426 | while (i != end) { | 435 | while (i != end) { |
436 | //qDebug("iii %x end %x wnd %x", (*i), (*end), wnd); | ||
427 | if (*i == wnd) { | 437 | if (*i == wnd) { |
428 | #ifndef PWM_EMBEDDED | 438 | #ifndef PWM_EMBEDDED |
429 | _mainWndList.erase(i); | 439 | _mainWndList.erase(i); |
430 | #else | 440 | #else |
431 | _mainWndList.remove(i); | 441 | _mainWndList.remove(i); |
432 | #endif | 442 | #endif |
433 | 443 | ||
434 | if ( app->mainWidget() == wnd ) { | 444 | if ( app->mainWidget() == wnd ) { |
435 | if ( _mainWndList.count() ) { | 445 | if ( _mainWndList.count() ) { |
436 | #ifndef DESKTOP_VERSION | 446 | #ifndef DESKTOP_VERSION |
437 | app->showMainWidget(_mainWndList.first() ); | 447 | app->showMainWidget(_mainWndList.first() ); |
438 | #endif //DESKTOP_VERSION | 448 | #endif //DESKTOP_VERSION |
439 | 449 | ||
440 | } | 450 | } |
441 | } | 451 | } |
442 | delete wnd; | 452 | delete wnd; |
443 | goto out_success; | 453 | goto out_success; |
444 | } | 454 | } |
445 | ++i; | 455 | ++i; |
446 | } | 456 | } |
447 | BUG(); | 457 | BUG(); |
448 | out_success: | 458 | out_success: |
449 | #ifndef PWM_EMBEDDED | 459 | #ifndef PWM_EMBEDDED |
450 | if (!_mainWndList.size()) | 460 | if (!_mainWndList.size()) |
451 | #else | 461 | #else |
452 | if (!_mainWndList.count()) | 462 | if (!_mainWndList.count()) |
453 | #endif | 463 | #endif |
454 | 464 | ||
455 | { | 465 | { |
456 | /* If there's no main window and no tray icon | 466 | /* If there's no main window and no tray icon |
457 | * left, we have no user interface, so we can | 467 | * left, we have no user interface, so we can |
458 | * shut down the application. | 468 | * shut down the application. |
459 | */ | 469 | */ |
460 | if (!_tray) { | 470 | if (!_tray) { |
461 | #ifndef PWM_EMBEDDED | 471 | #ifndef PWM_EMBEDDED |
462 | dcopClient()->setAcceptCalls(true); | 472 | dcopClient()->setAcceptCalls(true); |
463 | dcopClient()->resume(); | 473 | dcopClient()->resume(); |
464 | #endif | 474 | #endif |
465 | shutdownApp(0); | 475 | shutdownApp(0); |
466 | return; | 476 | return; |
467 | } | 477 | } |
468 | /* There is no widget left, so set | 478 | /* There is no widget left, so set |
469 | * _curWidget to 0 | 479 | * _curWidget to 0 |
470 | */ | 480 | */ |
471 | resetCurWidget(); | 481 | resetCurWidget(); |
472 | } | 482 | } |
473 | #ifndef PWM_EMBEDDED | 483 | #ifndef PWM_EMBEDDED |
474 | dcopClient()->setAcceptCalls(true); | 484 | dcopClient()->setAcceptCalls(true); |
475 | dcopClient()->resume(); | 485 | dcopClient()->resume(); |
476 | #endif | 486 | #endif |
477 | } | 487 | } |
478 | 488 | ||
479 | void PwMInit::trayIconClosed(PwMTray *tray) | 489 | void PwMInit::trayIconClosed(PwMTray *tray) |
480 | { | 490 | { |
481 | if (runStatus != running) | 491 | if (runStatus != running) |
482 | return; | 492 | return; |
483 | PARAM_UNUSED(tray); | 493 | PARAM_UNUSED(tray); |
484 | PWM_ASSERT(tray == _tray); | 494 | PWM_ASSERT(tray == _tray); |
485 | /* If there's no main wnd left we have to | 495 | /* If there's no main wnd left we have to |
486 | * shutdown the app (same as in mainWndClosed()) | 496 | * shutdown the app (same as in mainWndClosed()) |
487 | */ | 497 | */ |
488 | #ifndef PWM_EMBEDDED | 498 | #ifndef PWM_EMBEDDED |
489 | if (!_mainWndList.size()) | 499 | if (!_mainWndList.size()) |
490 | shutdownApp(0); | 500 | shutdownApp(0); |
491 | #else | 501 | #else |
492 | if (!_mainWndList.count()) | 502 | if (!_mainWndList.count()) |
493 | shutdownApp(0); | 503 | shutdownApp(0); |
494 | #endif | 504 | #endif |
495 | } | 505 | } |
496 | 506 | ||
497 | void PwMInit::handleCmdLineArgs(bool initial) | 507 | void PwMInit::handleCmdLineArgs(bool initial) |
498 | { | 508 | { |
499 | #ifndef PWM_EMBEDDED | 509 | #ifndef PWM_EMBEDDED |
500 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 510 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
501 | PWM_ASSERT(args); | 511 | PWM_ASSERT(args); |
502 | int i, numArgs = args->count(); | 512 | int i, numArgs = args->count(); |
503 | const char *curArg; | 513 | const char *curArg; |
504 | 514 | ||
505 | // read all cmdline options | 515 | // read all cmdline options |
506 | savedCmd.open_deeplocked = args->isSet("open-deeplocked"); | 516 | savedCmd.open_deeplocked = args->isSet("open-deeplocked"); |
507 | savedCmd.minimized = args->isSet("minimized"); | 517 | savedCmd.minimized = args->isSet("minimized"); |
508 | savedCmd.minToTray = args->isSet("mintray"); | 518 | savedCmd.minToTray = args->isSet("mintray"); |
509 | savedCmd.skipSelfTest = args->isSet("skip-self-test"); | 519 | savedCmd.skipSelfTest = args->isSet("skip-self-test"); |
510 | if (savedCmd.minimized && | 520 | if (savedCmd.minimized && |
511 | savedCmd.minToTray) { | 521 | savedCmd.minToTray) { |
512 | printInfo(i18n("Commandline option \"--minimized\" and " | 522 | printInfo(i18n("Commandline option \"--minimized\" and " |
513 | "\"--mintray\" selected. These are incompatible. " | 523 | "\"--mintray\" selected. These are incompatible. " |
514 | "\"--mintray\" will be selected.").latin1()); | 524 | "\"--mintray\" will be selected.").latin1()); |
515 | } | 525 | } |
516 | /* Iterate through all non-option arguments. | 526 | /* Iterate through all non-option arguments. |
517 | * Every non-option arg is a filename to open. | 527 | * Every non-option arg is a filename to open. |
518 | */ | 528 | */ |
519 | for (i = 0; i < numArgs; ++i) { | 529 | for (i = 0; i < numArgs; ++i) { |
520 | curArg = args->arg(i); | 530 | curArg = args->arg(i); |
521 | PWM_ASSERT(curArg); | 531 | PWM_ASSERT(curArg); |
522 | if (savedCmd.minToTray) { | 532 | if (savedCmd.minToTray) { |
523 | PwMDoc *newDoc = createDoc(); | 533 | PwMDoc *newDoc = createDoc(); |
524 | if (!newDoc->openDocUi(newDoc, | 534 | if (!newDoc->openDocUi(newDoc, |
525 | curArg, | 535 | curArg, |
526 | savedCmd.open_deeplocked)) { | 536 | savedCmd.open_deeplocked)) { |
527 | delete newDoc; | 537 | delete newDoc; |
528 | } | 538 | } |
529 | } else { | 539 | } else { |
530 | PwM *newInstance = createMainWnd(QString::null, | 540 | PwM *newInstance = createMainWnd(QString::null, |
531 | false, | 541 | false, |
532 | true, | 542 | true, |
533 | 0, | 543 | 0, |
534 | savedCmd.minimized); | 544 | savedCmd.minimized); |
535 | PwMDoc *newDoc = newInstance->openDoc(curArg, | 545 | PwMDoc *newDoc = newInstance->openDoc(curArg, |
536 | savedCmd.open_deeplocked); | 546 | savedCmd.open_deeplocked); |
537 | if (!newDoc) { | 547 | if (!newDoc) { |
538 | newInstance->setForceQuit(true); | 548 | newInstance->setForceQuit(true); |
539 | delete_and_null(newInstance); | 549 | delete_and_null(newInstance); |
540 | } | 550 | } |
541 | } | 551 | } |
542 | } | 552 | } |
543 | 553 | ||
544 | if (savedCmd.minToTray) { | 554 | if (savedCmd.minToTray) { |
545 | minimizeAllMainWnd(true); | 555 | minimizeAllMainWnd(true); |
546 | } else if (savedCmd.minimized) { | 556 | } else if (savedCmd.minimized) { |
547 | minimizeAllMainWnd(false); | 557 | minimizeAllMainWnd(false); |
548 | } | 558 | } |
549 | if (!savedCmd.skipSelfTest && initial) { | 559 | if (!savedCmd.skipSelfTest && initial) { |
550 | SelfTest::schedule(); | 560 | SelfTest::schedule(); |
551 | } | 561 | } |
552 | args->clear(); | 562 | args->clear(); |
553 | #endif | 563 | #endif |
554 | } | 564 | } |
555 | 565 | ||
556 | void PwMInit::minimizeAllMainWnd(bool toTray) | 566 | void PwMInit::minimizeAllMainWnd(bool toTray) |
557 | { | 567 | { |
558 | #ifndef PWM_EMBEDDED | 568 | #ifndef PWM_EMBEDDED |
559 | if (!_mainWndList.size()) | 569 | if (!_mainWndList.size()) |
560 | return; | 570 | return; |
561 | #else | 571 | #else |
562 | if (!_mainWndList.count()) | 572 | if (!_mainWndList.count()) |
563 | return; | 573 | return; |
564 | #endif | 574 | #endif |
565 | const QValueList<PwM *> *ml = mainWndList(); | 575 | const QValueList<PwM *> *ml = mainWndList(); |
566 | #ifndef PWM_EMBEDDED | 576 | #ifndef PWM_EMBEDDED |
567 | QValueList<PwM *>::const_iterator it = ml->begin(), | 577 | QValueList<PwM *>::const_iterator it = ml->begin(), |
568 | end = ml->end(); | 578 | end = ml->end(); |
569 | #else | 579 | #else |
570 | QValueList<PwM *>::ConstIterator it = ml->begin(), | 580 | QValueList<PwM *>::ConstIterator it = ml->begin(), |
571 | end = ml->end(); | 581 | end = ml->end(); |
572 | #endif | 582 | #endif |
573 | PwM *wnd; | 583 | PwM *wnd; |
574 | if (toTray && _tray) { | 584 | if (toTray && _tray) { |
575 | /* minimize to tray. | 585 | /* minimize to tray. |
576 | * close all mainWnd. | 586 | * close all mainWnd. |
577 | */ | 587 | */ |
578 | while (it != end) { | 588 | while (it != end) { |
579 | wnd = *it; | 589 | wnd = *it; |
580 | wnd->setForceMinimizeToTray(true); | 590 | wnd->setForceMinimizeToTray(true); |
581 | wnd->close_slot(); | 591 | wnd->close_slot(); |
582 | ++it; | 592 | ++it; |
583 | } | 593 | } |
584 | } else { | 594 | } else { |
585 | // normal minimize | 595 | // normal minimize |
586 | while (it != end) { | 596 | while (it != end) { |
587 | wnd = *it; | 597 | wnd = *it; |
588 | wnd->hide(); | 598 | wnd->hide(); |
589 | wnd->showMinimized(); | 599 | wnd->showMinimized(); |
590 | ++it; | 600 | ++it; |
591 | } | 601 | } |
592 | } | 602 | } |
593 | } | 603 | } |
594 | 604 | ||
595 | #ifdef PWM_EMBEDDED | 605 | #ifdef PWM_EMBEDDED |
596 | 606 | ||
597 | #ifndef DESKTOP_VERSION | 607 | #ifndef DESKTOP_VERSION |
598 | 608 | ||
599 | PwMApplication::PwMApplication(int & argc, char ** argv) | 609 | PwMApplication::PwMApplication(int & argc, char ** argv) |
600 | : QPEApplication( argc, argv ) | 610 | : QPEApplication( argc, argv ) |
601 | , init (0) | 611 | , init (0) |
602 | { | 612 | { |
603 | this->setKeepRunning (); | 613 | this->setKeepRunning (); |
604 | } | 614 | } |
605 | 615 | ||
606 | PwMApplication::~PwMApplication() | 616 | PwMApplication::~PwMApplication() |
607 | { | 617 | { |
608 | delete_ifnot_null(init); | 618 | delete_ifnot_null(init); |
609 | } | 619 | } |
610 | #else //DESKTOP_VERSION | 620 | #else //DESKTOP_VERSION |
611 | 621 | ||
612 | PwMApplication::PwMApplication(int & argc, char ** argv) | 622 | PwMApplication::PwMApplication(int & argc, char ** argv) |
613 | : QApplication( argc, argv ) | 623 | : QApplication( argc, argv ) |
614 | , init (0) | 624 | , init (0) |
615 | { | 625 | { |
616 | setStyle( new QPlatinumStyle ()); | 626 | setStyle( new QPlatinumStyle ()); |
617 | QString hdir = QDir::homeDirPath(); | 627 | QString hdir = QDir::homeDirPath(); |
618 | // there is a bug when creating dirs for WIN 98 | 628 | // there is a bug when creating dirs for WIN 98 |
619 | // it is difficult to fix, because we have no WIN 98 runnung | 629 | // it is difficult to fix, because we have no WIN 98 runnung |
620 | // such that we try it to create the dirs at startup here | 630 | // such that we try it to create the dirs at startup here |
621 | if ( hdir == "C:\\" ) | 631 | if ( hdir == "C:\\" ) |
622 | { | 632 | { |
623 | // win 98 or ME | 633 | // win 98 or ME |
624 | QDir app_dir; | 634 | QDir app_dir; |
625 | if ( !app_dir.exists("C:\\kdepim") ) | 635 | if ( !app_dir.exists("C:\\kdepim") ) |
626 | app_dir.mkdir ("C:\\kdepim"); | 636 | app_dir.mkdir ("C:\\kdepim"); |
627 | if ( !app_dir.exists("C:\\kdepim\\apps") ) | 637 | if ( !app_dir.exists("C:\\kdepim\\apps") ) |
628 | app_dir.mkdir ("C:\\kdepim\\apps"); | 638 | app_dir.mkdir ("C:\\kdepim\\apps"); |
629 | if ( !app_dir.exists("C:\\kdepim\\config") ) | 639 | if ( !app_dir.exists("C:\\kdepim\\config") ) |
630 | app_dir.mkdir ("C:\\kdepim\\config"); | 640 | app_dir.mkdir ("C:\\kdepim\\config"); |
631 | if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") ) | 641 | if ( !app_dir.exists("C:\\kdepim\\apps\\pwmanager") ) |
632 | app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager"); | 642 | app_dir.mkdir ("C:\\kdepim\\apps\\pwmanager"); |
633 | } | 643 | } |
634 | } | 644 | } |
635 | 645 | ||
636 | PwMApplication::~PwMApplication() | 646 | PwMApplication::~PwMApplication() |
637 | { | 647 | { |
638 | delete_ifnot_null(init); | 648 | delete_ifnot_null(init); |
639 | } | 649 | } |
640 | 650 | ||
641 | #endif //DESKTOP_VERSION | 651 | #endif //DESKTOP_VERSION |
642 | 652 | ||
643 | #endif //PWM_EMBEDDED | 653 | #endif //PWM_EMBEDDED |
644 | 654 | ||
645 | 655 | ||
646 | 656 | ||
647 | 657 | ||
648 | #ifndef PWM_EMBEDDED | 658 | #ifndef PWM_EMBEDDED |
649 | #include "pwminit.moc" | 659 | #include "pwminit.moc" |
650 | #endif | 660 | #endif |