summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt3
-rw-r--r--kaddressbook/kabcore.cpp1
-rw-r--r--libkdepim/externalapphandler.cpp5
3 files changed, 8 insertions, 1 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index b5285bf..03aec7b 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,217 +1,220 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.0.22 ************ 3********** VERSION 2.0.22 ************
4 4
5KO/Pi: 5KO/Pi:
6Fix for creating events/todos via the abgenda context menu. 6Fix for creating events/todos via the abgenda context menu.
7Added option to split toolbar to 3 toolbars. 7Added option to split toolbar to 3 toolbars.
8Added option to show one small filter-view-toolbar. 8Added option to show one small filter-view-toolbar.
9Added a print option to the desktop version: 9Added a print option to the desktop version:
10Now you can print out the view of the "Event Viewer". 10Now you can print out the view of the "Event Viewer".
11That means you can print all data of one particular event/todo. 11That means you can print all data of one particular event/todo.
12Added scaling options to printout of Event Viewer and What'sNext View. 12Added scaling options to printout of Event Viewer and What'sNext View.
13Fixed some problems in the month view in "week start sunday" mode. 13Fixed some problems in the month view in "week start sunday" mode.
14KA/Pi:
15Added two more config options.
16Fixed resizing problem of address request dialog when orientation was switched.
14 17
15********** VERSION 2.0.21 ************ 18********** VERSION 2.0.21 ************
16 19
17Fixed another SMTP problem in OM/Pi. 20Fixed another SMTP problem in OM/Pi.
18Some small changed in the new datenavigator in KO/Pi. 21Some small changed in the new datenavigator in KO/Pi.
19Changed default setting for new filter in KA/Pi to "exclude categories". 22Changed default setting for new filter in KA/Pi to "exclude categories".
20Changed the default font size for 640x480 display . 23Changed the default font size for 640x480 display .
21Changed popup menu behaviour in agenda and list view. 24Changed popup menu behaviour in agenda and list view.
22Fixed some layout problems of the date label size in the month view. 25Fixed some layout problems of the date label size in the month view.
23Made month view update faster. 26Made month view update faster.
24Made first datenavigator repainting faster. 27Made first datenavigator repainting faster.
25Changed the title of the event/todo edit dialogs. 28Changed the title of the event/todo edit dialogs.
26Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course). 29Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course).
27Many small usebility fixes in KO/Pi. 30Many small usebility fixes in KO/Pi.
28Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi. 31Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi.
29The set of possible "next views" are the views you have toolbar buttons for. 32The set of possible "next views" are the views you have toolbar buttons for.
30 33
31Made alarm sound working on Linux. 34Made alarm sound working on Linux.
32 35
33KO/Pi alarm applet changed: 36KO/Pi alarm applet changed:
34Made buttons in alarm dialog much bigger. 37Made buttons in alarm dialog much bigger.
35Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger. 38Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger.
36The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings. 39The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings.
37 40
38And because this version is realeased at Easter, I added an Easter-egg: 41And because this version is realeased at Easter, I added an Easter-egg:
39With a new undocumented command you can get a message box about the next alarm. 42With a new undocumented command you can get a message box about the next alarm.
40Good luck to find it! 43Good luck to find it!
41 44
42 45
43 46
44********** VERSION 2.0.20 ************ 47********** VERSION 2.0.20 ************
45 48
46Two small fixes in OM/Pi. 49Two small fixes in OM/Pi.
47 50
48Better resizing of the new datenavigator in KO/Pi. 51Better resizing of the new datenavigator in KO/Pi.
49 52
50********** VERSION 2.0.19 ************ 53********** VERSION 2.0.19 ************
51KO/Pi: 54KO/Pi:
52Enhancements and bugfixes in the new datenavigator. 55Enhancements and bugfixes in the new datenavigator.
53Bugfix in this changelog: 56Bugfix in this changelog:
54The datenavigator was changed in version 2.0.18, not the datepicker. 57The datenavigator was changed in version 2.0.18, not the datepicker.
55 58
56********** VERSION 2.0.18 ************ 59********** VERSION 2.0.18 ************
57KO/Pi: 60KO/Pi:
58Fixed some minor problems. 61Fixed some minor problems.
59Cleaned up the KO/Pi config dialog. 62Cleaned up the KO/Pi config dialog.
60Fixed problem moving events in aganda view. 63Fixed problem moving events in aganda view.
61Made datepicker scaleable, i.e. if the datenavigator shows now a 64Made datepicker scaleable, i.e. if the datenavigator shows now a
62datenavigator matrix depending on its size. 65datenavigator matrix depending on its size.
63Birthdays are now displayed green in the datenavigator. 66Birthdays are now displayed green in the datenavigator.
64What'sThis Help in datenavigator shows all events of the day. 67What'sThis Help in datenavigator shows all events of the day.
65 68
66OM/Pi: 69OM/Pi:
67Updated the backend mail library to the latest version. 70Updated the backend mail library to the latest version.
68Please backup your mail before using this version. 71Please backup your mail before using this version.
69 72
70********** VERSION 2.0.17 ************ 73********** VERSION 2.0.17 ************
71 74
72KO/Pi: 75KO/Pi:
73Tooltips in month view were not sorted. Fixed. 76Tooltips in month view were not sorted. Fixed.
74Daylabel in agenda view ( for display of one day ) was too short. Fixed. 77Daylabel in agenda view ( for display of one day ) was too short. Fixed.
75Conflict display dialog for syncing was not on top of other windows. Fixed. 78Conflict display dialog for syncing was not on top of other windows. Fixed.
76Fixed some minor problems. 79Fixed some minor problems.
77 80
78Fixed an endless loop when importing vcs file with RESOURCES entry. 81Fixed an endless loop when importing vcs file with RESOURCES entry.
79 82
80********** VERSION 2.0.16 ************ 83********** VERSION 2.0.16 ************
81OM/Pi: 84OM/Pi:
82Fixed the SMTP account setting the option. 85Fixed the SMTP account setting the option.
83Fixed something in mail sending. 86Fixed something in mail sending.
84 87
85KO/Pi: 88KO/Pi:
86Added possibility to export selected events/todos as vcal file. 89Added possibility to export selected events/todos as vcal file.
87 90
88********** VERSION 2.0.15 ************ 91********** VERSION 2.0.15 ************
89 92
90PwM/Pi: 93PwM/Pi:
91Added keyboard shorcuts for 94Added keyboard shorcuts for
92- toggling summary view (space bar) 95- toggling summary view (space bar)
93- delete item (delete + backspace key) 96- delete item (delete + backspace key)
94- add new item ( i + n key) 97- add new item ( i + n key)
95Fixed length of info in the title. 98Fixed length of info in the title.
96 99
97KO/Pi-KA/Pi: 100KO/Pi-KA/Pi:
98Changed "ME" menu bar entry to an icon. 101Changed "ME" menu bar entry to an icon.
99 102
100KO/Pi: 103KO/Pi:
101Fixed two minor bugs in displaying todos. 104Fixed two minor bugs in displaying todos.
102If in month view a cell is selected, the key shortcut "d" shows now that date. 105If in month view a cell is selected, the key shortcut "d" shows now that date.
103Added complete info for a todo in month view as an icon left of the text. 106Added complete info for a todo in month view as an icon left of the text.
104Fixed problems of displaying data when "<" or ">" are used in summary/location/description. 107Fixed problems of displaying data when "<" or ">" are used in summary/location/description.
105Fixed problem of search dialog size when switching displays. 108Fixed problem of search dialog size when switching displays.
106Cancel key now closes date picker. 109Cancel key now closes date picker.
107Rearranged KO/Pi file menu structure. 110Rearranged KO/Pi file menu structure.
108 111
109OM/Pi: 112OM/Pi:
110Added to the SMTP account setting the option 113Added to the SMTP account setting the option
111"No secure connection". 114"No secure connection".
112You have to configure your SMTP accounts again, sorry. 115You have to configure your SMTP accounts again, sorry.
113 116
114KA/Pi: 117KA/Pi:
115Added support for importing quoted-printable. 118Added support for importing quoted-printable.
116Support was added by Peter P.. Thanks, Peter! 119Support was added by Peter P.. Thanks, Peter!
117 120
118 121
119********** VERSION 2.0.14 ************ 122********** VERSION 2.0.14 ************
120 123
121Made Passwordmanager PwM/Pi more userfriendly: 124Made Passwordmanager PwM/Pi more userfriendly:
122Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. 125Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more.
123Fixed bug in KO/Pi todo printing. 126Fixed bug in KO/Pi todo printing.
124Made Qtopia calendar import possible on desktop . 127Made Qtopia calendar import possible on desktop .
125 128
126********** VERSION 2.0.13 ************ 129********** VERSION 2.0.13 ************
127 130
128Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. 131Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter.
129 132
130In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". 133In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down".
131 134
132OM/Pi: 135OM/Pi:
133Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. 136Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails.
134Added missing German translation. 137Added missing German translation.
135Added warning if path is specified in local folder settings of account config. 138Added warning if path is specified in local folder settings of account config.
136 139
137********** VERSION 2.0.12 ************ 140********** VERSION 2.0.12 ************
138 141
139KO/Pi: 142KO/Pi:
140Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. 143Fixed a bug in todo start/due date handling for non recurring todos with a start and due date.
141Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. 144Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes.
142Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. 145Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer.
143 146
144Fixed problem in pi-sync mode when wrong password was sent. 147Fixed problem in pi-sync mode when wrong password was sent.
145 148
146OM/Pi: 149OM/Pi:
147Fixed a crash when displaying mails with "Show mail as html" was checked in the config. 150Fixed a crash when displaying mails with "Show mail as html" was checked in the config.
148Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. 151Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled.
149 152
150********** VERSION 2.0.11 ************ 153********** VERSION 2.0.11 ************
151 154
152Fixed some problems in pi-sync mode 155Fixed some problems in pi-sync mode
153(e.g. details of events were not synced properly) 156(e.g. details of events were not synced properly)
154 157
155********** VERSION 2.0.10 ************ 158********** VERSION 2.0.10 ************
156 159
157KO/Pi: 160KO/Pi:
158In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. 161In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view.
159This is fixed. 162This is fixed.
160Changed the search dialog a bit to make it more user friendly. 163Changed the search dialog a bit to make it more user friendly.
161(E.g.: Removed message box about "no items found" and set key focus to search line edit after search). 164(E.g.: Removed message box about "no items found" and set key focus to search line edit after search).
162 165
163Added config option to hide the week number in KO/Pi toolbar. 166Added config option to hide the week number in KO/Pi toolbar.
164 167
165********** VERSION 2.0.9 ************ 168********** VERSION 2.0.9 ************
166 169
167Made month view icons for multiday events a bit nicer. 170Made month view icons for multiday events a bit nicer.
168Some minor fixes in KO/Pi 171Some minor fixes in KO/Pi
169(e.g. go to today did not work for new week view properly). 172(e.g. go to today did not work for new week view properly).
170 173
171 174
172********** VERSION 2.0.8 ************ 175********** VERSION 2.0.8 ************
173 176
174Fixed a problem in dependency info in the ipk files for the Zaurus. 177Fixed a problem in dependency info in the ipk files for the Zaurus.
175 178
176Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar. 179Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar.
177 180
178Added a "go today" button to the datepicker. 181Added a "go today" button to the datepicker.
179 182
180Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) 183Added "created" and "last modified" to event/todo viewer (and What'sThis viewer)
181and made it configureable to show these values. 184and made it configureable to show these values.
182 185
183Fixed a problem for events (from external iCal files) that do have a duration but no end date. 186Fixed a problem for events (from external iCal files) that do have a duration but no end date.
184 187
185 188
186********** VERSION 2.0.7 ************ 189********** VERSION 2.0.7 ************
187 190
188Added global application font settings 191Added global application font settings
189(for all KDE-Pim/Pi apps) to the general settings. 192(for all KDE-Pim/Pi apps) to the general settings.
190 193
191Fixed a problem in OM/Pi when trying to login to some IMAP servers 194Fixed a problem in OM/Pi when trying to login to some IMAP servers
192(like the IMAP server of Apple: mail.mac.com ) 195(like the IMAP server of Apple: mail.mac.com )
193 196
194Added recurring todos to KO/Pi. 197Added recurring todos to KO/Pi.
195 198
196 199
197********** VERSION 2.0.6 ************ 200********** VERSION 2.0.6 ************
198 201
199Stable release 2.0.6! 202Stable release 2.0.6!
200 203
201Some bugfixes in the pi-sync mode. 204Some bugfixes in the pi-sync mode.
202Added German translation for pi-sync mode. 205Added German translation for pi-sync mode.
203 206
204KO/Pi: 207KO/Pi:
205Made the todolist using alternate background. 208Made the todolist using alternate background.
206 209
207Other minor fixes in KO/Pi. 210Other minor fixes in KO/Pi.
208 211
209 212
210You can find the complete changelog 213You can find the complete changelog
211from version 1.7.7 to 2.0.5 214from version 1.7.7 to 2.0.5
212in the source package or on 215in the source package or on
213 216
214http://www.pi-sync.net/html/changelog.html 217http://www.pi-sync.net/html/changelog.html
215 218
216 219
217 220
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index db19dd5..27aca2d 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3365 +1,3366 @@
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 Async a special exception, permission is given to link this program 19 Async 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
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118#include "xxportselectdialog.h" 118#include "xxportselectdialog.h"
119 119
120 120
121#include <kresources/selectdialog.h> 121#include <kresources/selectdialog.h>
122#include <kmessagebox.h> 122#include <kmessagebox.h>
123 123
124#include <picture.h> 124#include <picture.h>
125#include <resource.h> 125#include <resource.h>
126 126
127//US#include <qsplitter.h> 127//US#include <qsplitter.h>
128#include <qmap.h> 128#include <qmap.h>
129#include <qdir.h> 129#include <qdir.h>
130#include <qfile.h> 130#include <qfile.h>
131#include <qvbox.h> 131#include <qvbox.h>
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include "nameeditdialog.h" 154#include "nameeditdialog.h"
155#include <kcmultidialog.h> 155#include <kcmultidialog.h>
156 156
157#ifdef _WIN32_ 157#ifdef _WIN32_
158#ifdef _OL_IMPORT_ 158#ifdef _OL_IMPORT_
159#include "kaimportoldialog.h" 159#include "kaimportoldialog.h"
160#endif 160#endif
161#else 161#else
162#include <unistd.h> 162#include <unistd.h>
163#endif 163#endif
164// sync includes 164// sync includes
165#include <libkdepim/ksyncprofile.h> 165#include <libkdepim/ksyncprofile.h>
166#include <libkdepim/ksyncprefsdialog.h> 166#include <libkdepim/ksyncprefsdialog.h>
167 167
168 168
169class KABCatPrefs : public QDialog 169class KABCatPrefs : public QDialog
170{ 170{
171 public: 171 public:
172 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 172 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
173 QDialog( parent, name, true ) 173 QDialog( parent, name, true )
174 { 174 {
175 setCaption( i18n("Manage new Categories") ); 175 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 176 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 177 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 178 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 180 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 182 lay->addWidget( format );
183 format->setExclusive ( true ) ; 183 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 184 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from addressees"), format ); 185 new QRadioButton(i18n("Remove from addressees"), format );
186 addCatBut->setChecked( true ); 186 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 187 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 188 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 190 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 193 resize( 200, 200 );
194 } 194 }
195 195
196 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
197private: 197private:
198 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
199}; 199};
200 200
201class KABFormatPrefs : public QDialog 201class KABFormatPrefs : public QDialog
202{ 202{
203 public: 203 public:
204 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 204 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
205 QDialog( parent, name, true ) 205 QDialog( parent, name, true )
206 { 206 {
207 setCaption( i18n("Set formatted name") ); 207 setCaption( i18n("Set formatted name") );
208 QVBoxLayout* lay = new QVBoxLayout( this ); 208 QVBoxLayout* lay = new QVBoxLayout( this );
209 lay->setSpacing( 3 ); 209 lay->setSpacing( 3 );
210 lay->setMargin( 3 ); 210 lay->setMargin( 3 );
211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
212 lay->addWidget( lab ); 212 lay->addWidget( lab );
213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
214 lay->addWidget( format ); 214 lay->addWidget( format );
215 format->setExclusive ( true ) ; 215 format->setExclusive ( true ) ;
216 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 216 simple = new QRadioButton(i18n("Simple: James Bond"), format );
217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
219 company = new QRadioButton(i18n("Organization: MI6"), format ); 219 company = new QRadioButton(i18n("Organization: MI6"), format );
220 simple->setChecked( true ); 220 simple->setChecked( true );
221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
222 lay->addWidget( setCompany ); 222 lay->addWidget( setCompany );
223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
224 lay->addWidget( ok ); 224 lay->addWidget( ok );
225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
226 lay->addWidget( cancel ); 226 lay->addWidget( cancel );
227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
229 //resize( 200, 200 ); 229 //resize( 200, 200 );
230 230
231 } 231 }
232public: 232public:
233 QRadioButton* simple, *full, *reverse, *company; 233 QRadioButton* simple, *full, *reverse, *company;
234 QCheckBox* setCompany; 234 QCheckBox* setCompany;
235}; 235};
236 236
237 237
238 238
239class KAex2phonePrefs : public QDialog 239class KAex2phonePrefs : public QDialog
240{ 240{
241 public: 241 public:
242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
243 QDialog( parent, name, true ) 243 QDialog( parent, name, true )
244 { 244 {
245 setCaption( i18n("Export to phone options") ); 245 setCaption( i18n("Export to phone options") );
246 QVBoxLayout* lay = new QVBoxLayout( this ); 246 QVBoxLayout* lay = new QVBoxLayout( this );
247 lay->setSpacing( 3 ); 247 lay->setSpacing( 3 );
248 lay->setMargin( 3 ); 248 lay->setMargin( 3 );
249 QLabel *lab; 249 QLabel *lab;
250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
251 lab->setAlignment (AlignHCenter ); 251 lab->setAlignment (AlignHCenter );
252 QHBox* temphb; 252 QHBox* temphb;
253 temphb = new QHBox( this ); 253 temphb = new QHBox( this );
254 new QLabel( i18n("I/O device: "), temphb ); 254 new QLabel( i18n("I/O device: "), temphb );
255 mPhoneDevice = new QLineEdit( temphb); 255 mPhoneDevice = new QLineEdit( temphb);
256 lay->addWidget( temphb ); 256 lay->addWidget( temphb );
257 temphb = new QHBox( this ); 257 temphb = new QHBox( this );
258 new QLabel( i18n("Connection: "), temphb ); 258 new QLabel( i18n("Connection: "), temphb );
259 mPhoneConnection = new QLineEdit( temphb); 259 mPhoneConnection = new QLineEdit( temphb);
260 lay->addWidget( temphb ); 260 lay->addWidget( temphb );
261 temphb = new QHBox( this ); 261 temphb = new QHBox( this );
262 new QLabel( i18n("Model(opt.): "), temphb ); 262 new QLabel( i18n("Model(opt.): "), temphb );
263 mPhoneModel = new QLineEdit( temphb); 263 mPhoneModel = new QLineEdit( temphb);
264 lay->addWidget( temphb ); 264 lay->addWidget( temphb );
265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
266 // lay->addWidget( mWriteToSim ); 266 // lay->addWidget( mWriteToSim );
267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
268 lab->setAlignment (AlignHCenter); 268 lab->setAlignment (AlignHCenter);
269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
270 lay->addWidget( ok ); 270 lay->addWidget( ok );
271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
272 lay->addWidget( cancel ); 272 lay->addWidget( cancel );
273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
275 resize( 220, 240 ); 275 resize( 220, 240 );
276 276
277 } 277 }
278 278
279public: 279public:
280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
281 QCheckBox* mWriteToSim; 281 QCheckBox* mWriteToSim;
282}; 282};
283 283
284 284
285bool pasteWithNewUid = true; 285bool pasteWithNewUid = true;
286 286
287#ifdef KAB_EMBEDDED 287#ifdef KAB_EMBEDDED
288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
292#else //KAB_EMBEDDED 292#else //KAB_EMBEDDED
293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
296 mReadWrite( readWrite ), mModified( false ) 296 mReadWrite( readWrite ), mModified( false )
297#endif //KAB_EMBEDDED 297#endif //KAB_EMBEDDED
298{ 298{
299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
300 // syncManager->setBlockSave(false); 300 // syncManager->setBlockSave(false);
301 mIncSearchWidget = 0; 301 mIncSearchWidget = 0;
302 mMiniSplitter = 0; 302 mMiniSplitter = 0;
303 mExtensionBarSplitter = 0; 303 mExtensionBarSplitter = 0;
304 mIsPart = !parent->inherits( "KAddressBookMain" ); 304 mIsPart = !parent->inherits( "KAddressBookMain" );
305 mAddressBook = KABC::StdAddressBook::self(); 305 mAddressBook = KABC::StdAddressBook::self();
306 KABC::StdAddressBook::setAutomaticSave( false ); 306 KABC::StdAddressBook::setAutomaticSave( false );
307 307
308#ifndef KAB_EMBEDDED 308#ifndef KAB_EMBEDDED
309 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 309 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
310#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
311 311
312 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 312 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
313 SLOT( addressBookChanged() ) ); 313 SLOT( addressBookChanged() ) );
314 314
315#if 0 315#if 0
316 // LP moved to addressbook init method 316 // LP moved to addressbook init method
317 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 317 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
318 "X-Department", "KADDRESSBOOK" ); 318 "X-Department", "KADDRESSBOOK" );
319 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 319 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
320 "X-Profession", "KADDRESSBOOK" ); 320 "X-Profession", "KADDRESSBOOK" );
321 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 321 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
322 "X-AssistantsName", "KADDRESSBOOK" ); 322 "X-AssistantsName", "KADDRESSBOOK" );
323 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 323 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
324 "X-ManagersName", "KADDRESSBOOK" ); 324 "X-ManagersName", "KADDRESSBOOK" );
325 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 325 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
326 "X-SpousesName", "KADDRESSBOOK" ); 326 "X-SpousesName", "KADDRESSBOOK" );
327 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 327 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
328 "X-Office", "KADDRESSBOOK" ); 328 "X-Office", "KADDRESSBOOK" );
329 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 329 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
330 "X-IMAddress", "KADDRESSBOOK" ); 330 "X-IMAddress", "KADDRESSBOOK" );
331 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 331 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
332 "X-Anniversary", "KADDRESSBOOK" ); 332 "X-Anniversary", "KADDRESSBOOK" );
333 333
334 //US added this field to become compatible with Opie/qtopia addressbook 334 //US added this field to become compatible with Opie/qtopia addressbook
335 // values can be "female" or "male" or "". An empty field represents undefined. 335 // values can be "female" or "male" or "". An empty field represents undefined.
336 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 336 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
337 "X-Gender", "KADDRESSBOOK" ); 337 "X-Gender", "KADDRESSBOOK" );
338 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 338 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
339 "X-Children", "KADDRESSBOOK" ); 339 "X-Children", "KADDRESSBOOK" );
340 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 340 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
341 "X-FreeBusyUrl", "KADDRESSBOOK" ); 341 "X-FreeBusyUrl", "KADDRESSBOOK" );
342#endif 342#endif
343 initGUI(); 343 initGUI();
344 344
345 mIncSearchWidget->setFocus(); 345 mIncSearchWidget->setFocus();
346 346
347 347
348 connect( mViewManager, SIGNAL( selected( const QString& ) ), 348 connect( mViewManager, SIGNAL( selected( const QString& ) ),
349 SLOT( setContactSelected( const QString& ) ) ); 349 SLOT( setContactSelected( const QString& ) ) );
350 connect( mViewManager, SIGNAL( executed( const QString& ) ), 350 connect( mViewManager, SIGNAL( executed( const QString& ) ),
351 SLOT( executeContact( const QString& ) ) ); 351 SLOT( executeContact( const QString& ) ) );
352 352
353 connect( mViewManager, SIGNAL( deleteRequest( ) ), 353 connect( mViewManager, SIGNAL( deleteRequest( ) ),
354 SLOT( deleteContacts( ) ) ); 354 SLOT( deleteContacts( ) ) );
355 connect( mViewManager, SIGNAL( modified() ), 355 connect( mViewManager, SIGNAL( modified() ),
356 SLOT( setModified() ) ); 356 SLOT( setModified() ) );
357 357
358 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 358 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
359 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 359 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
360 360
361 connect( mXXPortManager, SIGNAL( modified() ), 361 connect( mXXPortManager, SIGNAL( modified() ),
362 SLOT( setModified() ) ); 362 SLOT( setModified() ) );
363 363
364 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 364 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
365 SLOT( incrementalSearch( const QString& ) ) ); 365 SLOT( incrementalSearch( const QString& ) ) );
366 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 366 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
367 mJumpButtonBar, SLOT( recreateButtons() ) ); 367 mJumpButtonBar, SLOT( recreateButtons() ) );
368 368
369 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 369 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
370 SLOT( sendMail( const QString& ) ) ); 370 SLOT( sendMail( const QString& ) ) );
371 371
372 372
373 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 373 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
374 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&))); 374 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&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 375 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 376 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
377 377
378 378
379#ifndef KAB_EMBEDDED 379#ifndef KAB_EMBEDDED
380 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 380 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
381 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 381 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
382 382
383 connect( mDetails, SIGNAL( browse( const QString& ) ), 383 connect( mDetails, SIGNAL( browse( const QString& ) ),
384 SLOT( browse( const QString& ) ) ); 384 SLOT( browse( const QString& ) ) );
385 385
386 386
387 mAddressBookService = new KAddressBookService( this ); 387 mAddressBookService = new KAddressBookService( this );
388 388
389#endif //KAB_EMBEDDED 389#endif //KAB_EMBEDDED
390 390
391 mMessageTimer = new QTimer( this ); 391 mMessageTimer = new QTimer( this );
392 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 392 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
393 mEditorDialog = 0; 393 mEditorDialog = 0;
394 createAddresseeEditorDialog( this ); 394 createAddresseeEditorDialog( this );
395 setModified( false ); 395 setModified( false );
396 mBRdisabled = false; 396 mBRdisabled = false;
397#ifndef DESKTOP_VERSION 397#ifndef DESKTOP_VERSION
398 infrared = 0; 398 infrared = 0;
399#endif 399#endif
400 //toggleBeamReceive( ); 400 //toggleBeamReceive( );
401 //mMainWindow->toolBar()->show(); 401 //mMainWindow->toolBar()->show();
402 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 402 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
403 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 403 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
404} 404}
405 405
406void KABCore::updateToolBar() 406void KABCore::updateToolBar()
407{ 407{
408 static int iii = 0; 408 static int iii = 0;
409 ++iii; 409 ++iii;
410 mMainWindow->toolBar()->repaintMe(); 410 mMainWindow->toolBar()->repaintMe();
411 if ( iii < 4 ) 411 if ( iii < 4 )
412 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 412 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
413} 413}
414KABCore::~KABCore() 414KABCore::~KABCore()
415{ 415{
416 // save(); 416 // save();
417 //saveSettings(); 417 //saveSettings();
418 //KABPrefs::instance()->writeConfig(); 418 //KABPrefs::instance()->writeConfig();
419 delete AddresseeConfig::instance(); 419 delete AddresseeConfig::instance();
420 mAddressBook = 0; 420 mAddressBook = 0;
421 KABC::StdAddressBook::close(); 421 KABC::StdAddressBook::close();
422 422
423 delete syncManager; 423 delete syncManager;
424#ifndef DESKTOP_VERSION 424#ifndef DESKTOP_VERSION
425 if ( infrared ) 425 if ( infrared )
426 delete infrared; 426 delete infrared;
427#endif 427#endif
428} 428}
429void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 429void KABCore::receive( const QCString& cmsg, const QByteArray& data )
430{ 430{
431 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 431 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
432 if ( cmsg == "setDocument(QString)" ) { 432 if ( cmsg == "setDocument(QString)" ) {
433 QDataStream stream( data, IO_ReadOnly ); 433 QDataStream stream( data, IO_ReadOnly );
434 QString fileName; 434 QString fileName;
435 stream >> fileName; 435 stream >> fileName;
436 recieve( fileName ); 436 recieve( fileName );
437 return; 437 return;
438 } 438 }
439} 439}
440void KABCore::toggleBeamReceive( ) 440void KABCore::toggleBeamReceive( )
441{ 441{
442 if ( mBRdisabled ) 442 if ( mBRdisabled )
443 return; 443 return;
444#ifndef DESKTOP_VERSION 444#ifndef DESKTOP_VERSION
445 if ( infrared ) { 445 if ( infrared ) {
446 qDebug("KA: AB disable BeamReceive "); 446 qDebug("KA: AB disable BeamReceive ");
447 delete infrared; 447 delete infrared;
448 infrared = 0; 448 infrared = 0;
449 mActionBR->setChecked(false); 449 mActionBR->setChecked(false);
450 return; 450 return;
451 } 451 }
452 qDebug("KA: AB enable BeamReceive "); 452 qDebug("KA: AB enable BeamReceive ");
453 mActionBR->setChecked(true); 453 mActionBR->setChecked(true);
454 454
455 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 455 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
456 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 456 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
457#endif 457#endif
458} 458}
459 459
460 460
461void KABCore::disableBR(bool b) 461void KABCore::disableBR(bool b)
462{ 462{
463#ifndef DESKTOP_VERSION 463#ifndef DESKTOP_VERSION
464 if ( b ) { 464 if ( b ) {
465 if ( infrared ) { 465 if ( infrared ) {
466 toggleBeamReceive( ); 466 toggleBeamReceive( );
467 } 467 }
468 mBRdisabled = true; 468 mBRdisabled = true;
469 } else { 469 } else {
470 if ( mBRdisabled ) { 470 if ( mBRdisabled ) {
471 mBRdisabled = false; 471 mBRdisabled = false;
472 //toggleBeamReceive( ); 472 //toggleBeamReceive( );
473 } 473 }
474 } 474 }
475#endif 475#endif
476 476
477} 477}
478void KABCore::recieve( QString fn ) 478void KABCore::recieve( QString fn )
479{ 479{
480 //qDebug("KABCore::recieve "); 480 //qDebug("KABCore::recieve ");
481 int count = mAddressBook->importFromFile( fn, true ); 481 int count = mAddressBook->importFromFile( fn, true );
482 if ( count ) 482 if ( count )
483 setModified( true ); 483 setModified( true );
484 mViewManager->refreshView(); 484 mViewManager->refreshView();
485 message(i18n("%1 contact(s) received!").arg( count )); 485 message(i18n("%1 contact(s) received!").arg( count ));
486 topLevelWidget()->showMaximized(); 486 topLevelWidget()->showMaximized();
487 topLevelWidget()->raise(); 487 topLevelWidget()->raise();
488} 488}
489void KABCore::restoreSettings() 489void KABCore::restoreSettings()
490{ 490{
491 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 491 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
492 492
493 bool state; 493 bool state;
494 494
495 if (mMultipleViewsAtOnce) 495 if (mMultipleViewsAtOnce)
496 state = KABPrefs::instance()->mDetailsPageVisible; 496 state = KABPrefs::instance()->mDetailsPageVisible;
497 else 497 else
498 state = false; 498 state = false;
499 499
500 mActionDetails->setChecked( state ); 500 mActionDetails->setChecked( state );
501 setDetailsVisible( state ); 501 setDetailsVisible( state );
502 502
503 state = KABPrefs::instance()->mJumpButtonBarVisible; 503 state = KABPrefs::instance()->mJumpButtonBarVisible;
504 504
505 mActionJumpBar->setChecked( state ); 505 mActionJumpBar->setChecked( state );
506 setJumpButtonBarVisible( state ); 506 setJumpButtonBarVisible( state );
507/*US 507/*US
508 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 508 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
509 if ( splitterSize.count() == 0 ) { 509 if ( splitterSize.count() == 0 ) {
510 splitterSize.append( width() / 2 ); 510 splitterSize.append( width() / 2 );
511 splitterSize.append( width() / 2 ); 511 splitterSize.append( width() / 2 );
512 } 512 }
513 mMiniSplitter->setSizes( splitterSize ); 513 mMiniSplitter->setSizes( splitterSize );
514 if ( mExtensionBarSplitter ) { 514 if ( mExtensionBarSplitter ) {
515 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 515 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
516 if ( splitterSize.count() == 0 ) { 516 if ( splitterSize.count() == 0 ) {
517 splitterSize.append( width() / 2 ); 517 splitterSize.append( width() / 2 );
518 splitterSize.append( width() / 2 ); 518 splitterSize.append( width() / 2 );
519 } 519 }
520 mExtensionBarSplitter->setSizes( splitterSize ); 520 mExtensionBarSplitter->setSizes( splitterSize );
521 521
522 } 522 }
523*/ 523*/
524 mViewManager->restoreSettings(); 524 mViewManager->restoreSettings();
525 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 525 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
526 mExtensionManager->restoreSettings(); 526 mExtensionManager->restoreSettings();
527#ifdef DESKTOP_VERSION 527#ifdef DESKTOP_VERSION
528 int wid = width(); 528 int wid = width();
529 if ( wid < 10 ) 529 if ( wid < 10 )
530 wid = 400; 530 wid = 400;
531#else 531#else
532 int wid = QApplication::desktop()->width(); 532 int wid = QApplication::desktop()->width();
533 if ( wid < 640 ) 533 if ( wid < 640 )
534 wid = QApplication::desktop()->height(); 534 wid = QApplication::desktop()->height();
535#endif 535#endif
536 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 536 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
537 if ( true /*splitterSize.count() == 0*/ ) { 537 if ( true /*splitterSize.count() == 0*/ ) {
538 splitterSize.append( wid / 2 ); 538 splitterSize.append( wid / 2 );
539 splitterSize.append( wid / 2 ); 539 splitterSize.append( wid / 2 );
540 } 540 }
541 mMiniSplitter->setSizes( splitterSize ); 541 mMiniSplitter->setSizes( splitterSize );
542 if ( mExtensionBarSplitter ) { 542 if ( mExtensionBarSplitter ) {
543 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 543 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
544 if ( true /*splitterSize.count() == 0*/ ) { 544 if ( true /*splitterSize.count() == 0*/ ) {
545 splitterSize.append( wid / 2 ); 545 splitterSize.append( wid / 2 );
546 splitterSize.append( wid / 2 ); 546 splitterSize.append( wid / 2 );
547 } 547 }
548 mExtensionBarSplitter->setSizes( splitterSize ); 548 mExtensionBarSplitter->setSizes( splitterSize );
549 549
550 } 550 }
551 551
552 552
553} 553}
554 554
555void KABCore::saveSettings() 555void KABCore::saveSettings()
556{ 556{
557 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 557 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
558 if ( mExtensionBarSplitter ) 558 if ( mExtensionBarSplitter )
559 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 559 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
560 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 560 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
561 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 561 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
562#ifndef KAB_EMBEDDED 562#ifndef KAB_EMBEDDED
563 563
564 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 564 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
565 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 565 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
566#endif //KAB_EMBEDDED 566#endif //KAB_EMBEDDED
567 mExtensionManager->saveSettings(); 567 mExtensionManager->saveSettings();
568 mViewManager->saveSettings(); 568 mViewManager->saveSettings();
569 569
570 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 570 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
571 KABPrefs::instance()->writeConfig(); 571 KABPrefs::instance()->writeConfig();
572 qDebug("KA: KABCore::saveSettings() "); 572 qDebug("KA: KABCore::saveSettings() ");
573} 573}
574 574
575KABC::AddressBook *KABCore::addressBook() const 575KABC::AddressBook *KABCore::addressBook() const
576{ 576{
577 return mAddressBook; 577 return mAddressBook;
578} 578}
579 579
580KConfig *KABCore::config() 580KConfig *KABCore::config()
581{ 581{
582#ifndef KAB_EMBEDDED 582#ifndef KAB_EMBEDDED
583 return KABPrefs::instance()->config(); 583 return KABPrefs::instance()->config();
584#else //KAB_EMBEDDED 584#else //KAB_EMBEDDED
585 return KABPrefs::instance()->getConfig(); 585 return KABPrefs::instance()->getConfig();
586#endif //KAB_EMBEDDED 586#endif //KAB_EMBEDDED
587} 587}
588 588
589KActionCollection *KABCore::actionCollection() const 589KActionCollection *KABCore::actionCollection() const
590{ 590{
591 return mGUIClient->actionCollection(); 591 return mGUIClient->actionCollection();
592} 592}
593 593
594KABC::Field *KABCore::currentSearchField() const 594KABC::Field *KABCore::currentSearchField() const
595{ 595{
596 if (mIncSearchWidget) 596 if (mIncSearchWidget)
597 return mIncSearchWidget->currentField(); 597 return mIncSearchWidget->currentField();
598 else 598 else
599 return 0; 599 return 0;
600} 600}
601 601
602QStringList KABCore::selectedUIDs() const 602QStringList KABCore::selectedUIDs() const
603{ 603{
604 return mViewManager->selectedUids(); 604 return mViewManager->selectedUids();
605} 605}
606 606
607KABC::Resource *KABCore::requestResource( QWidget *parent ) 607KABC::Resource *KABCore::requestResource( QWidget *parent )
608{ 608{
609 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 609 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
610 610
611 QPtrList<KRES::Resource> kresResources; 611 QPtrList<KRES::Resource> kresResources;
612 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 612 QPtrListIterator<KABC::Resource> resIt( kabcResources );
613 KABC::Resource *resource; 613 KABC::Resource *resource;
614 while ( ( resource = resIt.current() ) != 0 ) { 614 while ( ( resource = resIt.current() ) != 0 ) {
615 ++resIt; 615 ++resIt;
616 if ( !resource->readOnly() ) { 616 if ( !resource->readOnly() ) {
617 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 617 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
618 if ( res ) 618 if ( res )
619 kresResources.append( res ); 619 kresResources.append( res );
620 } 620 }
621 } 621 }
622 622
623 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 623 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
624 return static_cast<KABC::Resource*>( res ); 624 return static_cast<KABC::Resource*>( res );
625} 625}
626 626
627#ifndef KAB_EMBEDDED 627#ifndef KAB_EMBEDDED
628KAboutData *KABCore::createAboutData() 628KAboutData *KABCore::createAboutData()
629#else //KAB_EMBEDDED 629#else //KAB_EMBEDDED
630void KABCore::createAboutData() 630void KABCore::createAboutData()
631#endif //KAB_EMBEDDED 631#endif //KAB_EMBEDDED
632{ 632{
633#ifndef KAB_EMBEDDED 633#ifndef KAB_EMBEDDED
634 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 634 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
635 "3.1", I18N_NOOP( "The KDE Address Book" ), 635 "3.1", I18N_NOOP( "The KDE Address Book" ),
636 KAboutData::License_GPL_V2, 636 KAboutData::License_GPL_V2,
637 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 637 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
638 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 638 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
639 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 639 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
640 about->addAuthor( "Cornelius Schumacher", 640 about->addAuthor( "Cornelius Schumacher",
641 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 641 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
642 "schumacher@kde.org" ); 642 "schumacher@kde.org" );
643 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 643 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
644 "mpilone@slac.com" ); 644 "mpilone@slac.com" );
645 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 645 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
646 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 646 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
647 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 647 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
648 "michel@klaralvdalens-datakonsult.se" ); 648 "michel@klaralvdalens-datakonsult.se" );
649 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 649 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
650 "hansen@kde.org" ); 650 "hansen@kde.org" );
651 651
652 return about; 652 return about;
653#endif //KAB_EMBEDDED 653#endif //KAB_EMBEDDED
654 654
655 QString version; 655 QString version;
656#include <../version> 656#include <../version>
657 QMessageBox::about( this, "About KAddressbook/Pi", 657 QMessageBox::about( this, "About KAddressbook/Pi",
658 "KAddressbook/Platform-independent\n" 658 "KAddressbook/Platform-independent\n"
659 "(KA/Pi) " +version + " - " + 659 "(KA/Pi) " +version + " - " +
660#ifdef DESKTOP_VERSION 660#ifdef DESKTOP_VERSION
661 "Desktop Edition\n" 661 "Desktop Edition\n"
662#else 662#else
663 "PDA-Edition\n" 663 "PDA-Edition\n"
664 "for: Zaurus 5500 / 7x0 / 8x0\n" 664 "for: Zaurus 5500 / 7x0 / 8x0\n"
665#endif 665#endif
666 666
667 "(c) 2004 Ulf Schenk\n" 667 "(c) 2004 Ulf Schenk\n"
668 "(c) 2004 Lutz Rogowski\n" 668 "(c) 2004 Lutz Rogowski\n"
669 "(c) 1997-2003, The KDE PIM Team\n" 669 "(c) 1997-2003, The KDE PIM Team\n"
670 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 670 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
671 "Don Sanders Original author\n" 671 "Don Sanders Original author\n"
672 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 672 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
673 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 673 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
674 "Greg Stern DCOP interface\n" 674 "Greg Stern DCOP interface\n"
675 "Mark Westcot Contact pinning\n" 675 "Mark Westcot Contact pinning\n"
676 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 676 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
677 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 677 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
678#ifdef _WIN32_ 678#ifdef _WIN32_
679 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 679 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
680#endif 680#endif
681 ); 681 );
682} 682}
683 683
684void KABCore::setContactSelected( const QString &uid ) 684void KABCore::setContactSelected( const QString &uid )
685{ 685{
686 KABC::Addressee addr = mAddressBook->findByUid( uid ); 686 KABC::Addressee addr = mAddressBook->findByUid( uid );
687 if ( !mDetails->isHidden() ) 687 if ( !mDetails->isHidden() )
688 mDetails->setAddressee( addr ); 688 mDetails->setAddressee( addr );
689 689
690 if ( !addr.isEmpty() ) { 690 if ( !addr.isEmpty() ) {
691 emit contactSelected( addr.formattedName() ); 691 emit contactSelected( addr.formattedName() );
692 KABC::Picture pic = addr.photo(); 692 KABC::Picture pic = addr.photo();
693 if ( pic.isIntern() ) { 693 if ( pic.isIntern() ) {
694//US emit contactSelected( pic.data() ); 694//US emit contactSelected( pic.data() );
695//US instead use: 695//US instead use:
696 QPixmap px; 696 QPixmap px;
697 if (pic.data().isNull() != true) 697 if (pic.data().isNull() != true)
698 { 698 {
699 px.convertFromImage(pic.data()); 699 px.convertFromImage(pic.data());
700 } 700 }
701 701
702 emit contactSelected( px ); 702 emit contactSelected( px );
703 } 703 }
704 } 704 }
705 705
706 706
707 mExtensionManager->setSelectionChanged(); 707 mExtensionManager->setSelectionChanged();
708 708
709 // update the actions 709 // update the actions
710 bool selected = !uid.isEmpty(); 710 bool selected = !uid.isEmpty();
711 711
712 if ( mReadWrite ) { 712 if ( mReadWrite ) {
713 mActionCut->setEnabled( selected ); 713 mActionCut->setEnabled( selected );
714 mActionPaste->setEnabled( selected ); 714 mActionPaste->setEnabled( selected );
715 } 715 }
716 716
717 mActionCopy->setEnabled( selected ); 717 mActionCopy->setEnabled( selected );
718 mActionDelete->setEnabled( selected ); 718 mActionDelete->setEnabled( selected );
719 mActionEditAddressee->setEnabled( selected ); 719 mActionEditAddressee->setEnabled( selected );
720 mActionMail->setEnabled( selected ); 720 mActionMail->setEnabled( selected );
721 mActionMailVCard->setEnabled( selected ); 721 mActionMailVCard->setEnabled( selected );
722 //if (mActionBeam) 722 //if (mActionBeam)
723 //mActionBeam->setEnabled( selected ); 723 //mActionBeam->setEnabled( selected );
724 mActionWhoAmI->setEnabled( selected ); 724 mActionWhoAmI->setEnabled( selected );
725} 725}
726 726
727void KABCore::sendMail() 727void KABCore::sendMail()
728{ 728{
729 sendMail( mViewManager->selectedEmails().join( ", " ) ); 729 sendMail( mViewManager->selectedEmails().join( ", " ) );
730} 730}
731 731
732void KABCore::sendMail( const QString& emaillist ) 732void KABCore::sendMail( const QString& emaillist )
733{ 733{
734 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 734 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
735 if (emaillist.contains(",") > 0) 735 if (emaillist.contains(",") > 0)
736 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 736 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
737 else 737 else
738 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 738 ExternalAppHandler::instance()->mailToOneContact( emaillist );
739} 739}
740 740
741 741
742 742
743void KABCore::mailVCard() 743void KABCore::mailVCard()
744{ 744{
745 QStringList uids = mViewManager->selectedUids(); 745 QStringList uids = mViewManager->selectedUids();
746 if ( !uids.isEmpty() ) 746 if ( !uids.isEmpty() )
747 mailVCard( uids ); 747 mailVCard( uids );
748} 748}
749 749
750void KABCore::mailVCard( const QStringList& uids ) 750void KABCore::mailVCard( const QStringList& uids )
751{ 751{
752 QStringList urls; 752 QStringList urls;
753 753
754// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 754// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
755 755
756 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 756 QString dirName = "/tmp/" + KApplication::randomString( 8 );
757 757
758 758
759 759
760 QDir().mkdir( dirName, true ); 760 QDir().mkdir( dirName, true );
761 761
762 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 762 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
763 KABC::Addressee a = mAddressBook->findByUid( *it ); 763 KABC::Addressee a = mAddressBook->findByUid( *it );
764 764
765 if ( a.isEmpty() ) 765 if ( a.isEmpty() )
766 continue; 766 continue;
767 767
768 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 768 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
769 769
770 QString fileName = dirName + "/" + name; 770 QString fileName = dirName + "/" + name;
771 771
772 QFile outFile(fileName); 772 QFile outFile(fileName);
773 773
774 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 774 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
775 KABC::VCardConverter converter; 775 KABC::VCardConverter converter;
776 QString vcard; 776 QString vcard;
777 777
778 converter.addresseeToVCard( a, vcard ); 778 converter.addresseeToVCard( a, vcard );
779 779
780 QTextStream t( &outFile ); // use a text stream 780 QTextStream t( &outFile ); // use a text stream
781 t.setEncoding( QTextStream::UnicodeUTF8 ); 781 t.setEncoding( QTextStream::UnicodeUTF8 );
782 t << vcard; 782 t << vcard;
783 783
784 outFile.close(); 784 outFile.close();
785 785
786 urls.append( fileName ); 786 urls.append( fileName );
787 } 787 }
788 } 788 }
789 789
790 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 790 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
791 791
792 792
793/*US 793/*US
794 kapp->invokeMailer( QString::null, QString::null, QString::null, 794 kapp->invokeMailer( QString::null, QString::null, QString::null,
795 QString::null, // subject 795 QString::null, // subject
796 QString::null, // body 796 QString::null, // body
797 QString::null, 797 QString::null,
798 urls ); // attachments 798 urls ); // attachments
799*/ 799*/
800 800
801} 801}
802 802
803/** 803/**
804 Beams the "WhoAmI contact. 804 Beams the "WhoAmI contact.
805*/ 805*/
806void KABCore::beamMySelf() 806void KABCore::beamMySelf()
807{ 807{
808 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 808 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
809 if (!a.isEmpty()) 809 if (!a.isEmpty())
810 { 810 {
811 QStringList uids; 811 QStringList uids;
812 uids << a.uid(); 812 uids << a.uid();
813 813
814 beamVCard(uids); 814 beamVCard(uids);
815 } else { 815 } else {
816 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 816 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
817 817
818 818
819 } 819 }
820} 820}
821void KABCore::updateMainWindow() 821void KABCore::updateMainWindow()
822{ 822{
823 mMainWindow->showMaximized(); 823 mMainWindow->showMaximized();
824 mMainWindow->update(); 824 mMainWindow->update();
825} 825}
826void KABCore::resizeEvent(QResizeEvent* e ) 826void KABCore::resizeEvent(QResizeEvent* e )
827{ 827{
828 if ( !mMiniSplitter ) 828 if ( !mMiniSplitter )
829 return; 829 return;
830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
831 if ( QApplication::desktop()->width() >= 480 ) { 831 if ( QApplication::desktop()->width() >= 480 ) {
832 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 832 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
833 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 833 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
834 mMiniSplitter->setOrientation( Qt::Horizontal); 834 mMiniSplitter->setOrientation( Qt::Horizontal);
835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
836 } 836 }
837 if ( QApplication::desktop()->width() <= 640 ) { 837 if ( QApplication::desktop()->width() <= 640 ) {
838 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 838 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
839 mViewManager->getFilterAction()->setComboWidth( 150 ); 839 mViewManager->getFilterAction()->setComboWidth( 150 );
840 if ( mIncSearchWidget ) 840 if ( mIncSearchWidget )
841 mIncSearchWidget->setSize(); 841 mIncSearchWidget->setSize();
842 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 842 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
843 } 843 }
844 844
845 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 845 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
846 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 846 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
847 mMiniSplitter->setOrientation( Qt::Vertical ); 847 mMiniSplitter->setOrientation( Qt::Vertical );
848 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 848 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
849 } 849 }
850 if ( QApplication::desktop()->width() <= 640 ) { 850 if ( QApplication::desktop()->width() <= 640 ) {
851 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 851 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
852 mMainWindow->showMinimized(); 852 mMainWindow->showMinimized();
853 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 853 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
854 if ( mIncSearchWidget ) { 854 if ( mIncSearchWidget ) {
855 mIncSearchWidget->setSize(); 855 mIncSearchWidget->setSize();
856 } 856 }
857 } else { 857 } else {
858 mViewManager->getFilterAction()->setComboWidth( 0 ); 858 mViewManager->getFilterAction()->setComboWidth( 0 );
859 } 859 }
860 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 860 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
861 } 861 }
862 } 862 }
863 } 863 }
864 864
865} 865}
866void KABCore::export2phone() 866void KABCore::export2phone()
867{ 867{
868 868
869 QStringList uids; 869 QStringList uids;
870 XXPortSelectDialog dlg( this, false, this ); 870 XXPortSelectDialog dlg( this, false, this );
871 if ( dlg.exec() ) 871 if ( dlg.exec() )
872 uids = dlg.uids(); 872 uids = dlg.uids();
873 else 873 else
874 return; 874 return;
875 if ( uids.isEmpty() ) 875 if ( uids.isEmpty() )
876 return; 876 return;
877 // qDebug("count %d ", uids.count()); 877 // qDebug("count %d ", uids.count());
878 878
879 KAex2phonePrefs ex2phone; 879 KAex2phonePrefs ex2phone;
880 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 880 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
881 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 881 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
882 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 882 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
883 883
884 if ( !ex2phone.exec() ) { 884 if ( !ex2phone.exec() ) {
885 return; 885 return;
886 } 886 }
887 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 887 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
888 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 888 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
889 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 889 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
890 890
891 891
892 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 892 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
893 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 893 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
894 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 894 KPimGlobalPrefs::instance()->mEx2PhoneModel );
895 895
896 QString fileName = getPhoneFile(); 896 QString fileName = getPhoneFile();
897 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 897 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
898 return; 898 return;
899 899
900 message(i18n("Exporting to phone...")); 900 message(i18n("Exporting to phone..."));
901 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 901 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
902 902
903} 903}
904QString KABCore::getPhoneFile() 904QString KABCore::getPhoneFile()
905{ 905{
906#ifdef DESKTOP_VERSION 906#ifdef DESKTOP_VERSION
907 return locateLocal("tmp", "phonefile.vcf"); 907 return locateLocal("tmp", "phonefile.vcf");
908#else 908#else
909 return "/tmp/phonefile.vcf"; 909 return "/tmp/phonefile.vcf";
910#endif 910#endif
911 911
912} 912}
913void KABCore::writeToPhone( ) 913void KABCore::writeToPhone( )
914{ 914{
915 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 915 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
916 message(i18n("Export to phone finished!")); 916 message(i18n("Export to phone finished!"));
917 else 917 else
918 qDebug(i18n("KA: Error exporting to phone")); 918 qDebug(i18n("KA: Error exporting to phone"));
919} 919}
920void KABCore::beamVCard() 920void KABCore::beamVCard()
921{ 921{
922 QStringList uids; 922 QStringList uids;
923 XXPortSelectDialog dlg( this, false, this ); 923 XXPortSelectDialog dlg( this, false, this );
924 if ( dlg.exec() ) 924 if ( dlg.exec() )
925 uids = dlg.uids(); 925 uids = dlg.uids();
926 else 926 else
927 return; 927 return;
928 if ( uids.isEmpty() ) 928 if ( uids.isEmpty() )
929 return; 929 return;
930 beamVCard( uids ); 930 beamVCard( uids );
931} 931}
932 932
933 933
934void KABCore::beamVCard(const QStringList& uids) 934void KABCore::beamVCard(const QStringList& uids)
935{ 935{
936 936
937 // LR: we should use the /tmp dir on the Zaurus, 937 // LR: we should use the /tmp dir on the Zaurus,
938 // because: /tmp = RAM, (HOME)/kdepim = flash memory 938 // because: /tmp = RAM, (HOME)/kdepim = flash memory
939 939
940#ifdef DESKTOP_VERSION 940#ifdef DESKTOP_VERSION
941 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 941 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
942#else 942#else
943 QString fileName = "/tmp/kapibeamfile.vcf"; 943 QString fileName = "/tmp/kapibeamfile.vcf";
944#endif 944#endif
945 945
946 KABC::VCardConverter converter; 946 KABC::VCardConverter converter;
947 QString description; 947 QString description;
948 QString datastream; 948 QString datastream;
949 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 949 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
950 KABC::Addressee a = mAddressBook->findByUid( *it ); 950 KABC::Addressee a = mAddressBook->findByUid( *it );
951 951
952 if ( a.isEmpty() ) 952 if ( a.isEmpty() )
953 continue; 953 continue;
954 954
955 if (description.isEmpty()) 955 if (description.isEmpty())
956 description = a.formattedName(); 956 description = a.formattedName();
957 957
958 QString vcard; 958 QString vcard;
959 converter.addresseeToVCard( a, vcard ); 959 converter.addresseeToVCard( a, vcard );
960 int start = 0; 960 int start = 0;
961 int next; 961 int next;
962 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 962 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
963 int semi = vcard.find(";", next); 963 int semi = vcard.find(";", next);
964 int dopp = vcard.find(":", next); 964 int dopp = vcard.find(":", next);
965 int sep; 965 int sep;
966 if ( semi < dopp && semi >= 0 ) 966 if ( semi < dopp && semi >= 0 )
967 sep = semi ; 967 sep = semi ;
968 else 968 else
969 sep = dopp; 969 sep = dopp;
970 datastream +=vcard.mid( start, next - start); 970 datastream +=vcard.mid( start, next - start);
971 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 971 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
972 start = sep; 972 start = sep;
973 } 973 }
974 datastream += vcard.mid( start,vcard.length() ); 974 datastream += vcard.mid( start,vcard.length() );
975 } 975 }
976#ifndef DESKTOP_VERSION 976#ifndef DESKTOP_VERSION
977 QFile outFile(fileName); 977 QFile outFile(fileName);
978 if ( outFile.open(IO_WriteOnly) ) { 978 if ( outFile.open(IO_WriteOnly) ) {
979 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 979 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
980 QTextStream t( &outFile ); // use a text stream 980 QTextStream t( &outFile ); // use a text stream
981 //t.setEncoding( QTextStream::UnicodeUTF8 ); 981 //t.setEncoding( QTextStream::UnicodeUTF8 );
982 t.setEncoding( QTextStream::Latin1 ); 982 t.setEncoding( QTextStream::Latin1 );
983 t <<datastream.latin1(); 983 t <<datastream.latin1();
984 outFile.close(); 984 outFile.close();
985 Ir *ir = new Ir( this ); 985 Ir *ir = new Ir( this );
986 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 986 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
987 ir->send( fileName, description, "text/x-vCard" ); 987 ir->send( fileName, description, "text/x-vCard" );
988 } else { 988 } else {
989 qDebug("KA: Error open temp beam file "); 989 qDebug("KA: Error open temp beam file ");
990 return; 990 return;
991 } 991 }
992#endif 992#endif
993 993
994} 994}
995 995
996void KABCore::beamDone( Ir *ir ) 996void KABCore::beamDone( Ir *ir )
997{ 997{
998#ifndef DESKTOP_VERSION 998#ifndef DESKTOP_VERSION
999 delete ir; 999 delete ir;
1000#endif 1000#endif
1001 topLevelWidget()->raise(); 1001 topLevelWidget()->raise();
1002 message( i18n("Beaming finished!") ); 1002 message( i18n("Beaming finished!") );
1003} 1003}
1004 1004
1005 1005
1006void KABCore::browse( const QString& url ) 1006void KABCore::browse( const QString& url )
1007{ 1007{
1008#ifndef KAB_EMBEDDED 1008#ifndef KAB_EMBEDDED
1009 kapp->invokeBrowser( url ); 1009 kapp->invokeBrowser( url );
1010#else //KAB_EMBEDDED 1010#else //KAB_EMBEDDED
1011 qDebug("KABCore::browse must be fixed"); 1011 qDebug("KABCore::browse must be fixed");
1012#endif //KAB_EMBEDDED 1012#endif //KAB_EMBEDDED
1013} 1013}
1014 1014
1015void KABCore::selectAllContacts() 1015void KABCore::selectAllContacts()
1016{ 1016{
1017 mViewManager->setSelected( QString::null, true ); 1017 mViewManager->setSelected( QString::null, true );
1018} 1018}
1019 1019
1020void KABCore::deleteContacts() 1020void KABCore::deleteContacts()
1021{ 1021{
1022 QStringList uidList = mViewManager->selectedUids(); 1022 QStringList uidList = mViewManager->selectedUids();
1023 deleteContacts( uidList ); 1023 deleteContacts( uidList );
1024} 1024}
1025 1025
1026void KABCore::deleteContacts( const QStringList &uids ) 1026void KABCore::deleteContacts( const QStringList &uids )
1027{ 1027{
1028 if ( uids.count() > 0 ) { 1028 if ( uids.count() > 0 ) {
1029 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1029 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1030 UndoStack::instance()->push( command ); 1030 UndoStack::instance()->push( command );
1031 RedoStack::instance()->clear(); 1031 RedoStack::instance()->clear();
1032 1032
1033 // now if we deleted anything, refresh 1033 // now if we deleted anything, refresh
1034 setContactSelected( QString::null ); 1034 setContactSelected( QString::null );
1035 setModified( true ); 1035 setModified( true );
1036 } 1036 }
1037} 1037}
1038 1038
1039void KABCore::copyContacts() 1039void KABCore::copyContacts()
1040{ 1040{
1041 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1041 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1042 1042
1043 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1043 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1044 1044
1045 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1045 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1046 1046
1047 QClipboard *cb = QApplication::clipboard(); 1047 QClipboard *cb = QApplication::clipboard();
1048 cb->setText( clipText ); 1048 cb->setText( clipText );
1049} 1049}
1050 1050
1051void KABCore::cutContacts() 1051void KABCore::cutContacts()
1052{ 1052{
1053 QStringList uidList = mViewManager->selectedUids(); 1053 QStringList uidList = mViewManager->selectedUids();
1054 1054
1055//US if ( uidList.size() > 0 ) { 1055//US if ( uidList.size() > 0 ) {
1056 if ( uidList.count() > 0 ) { 1056 if ( uidList.count() > 0 ) {
1057 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1057 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1058 UndoStack::instance()->push( command ); 1058 UndoStack::instance()->push( command );
1059 RedoStack::instance()->clear(); 1059 RedoStack::instance()->clear();
1060 1060
1061 setModified( true ); 1061 setModified( true );
1062 } 1062 }
1063} 1063}
1064 1064
1065void KABCore::pasteContacts() 1065void KABCore::pasteContacts()
1066{ 1066{
1067 QClipboard *cb = QApplication::clipboard(); 1067 QClipboard *cb = QApplication::clipboard();
1068 1068
1069 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1069 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1070 1070
1071 pasteContacts( list ); 1071 pasteContacts( list );
1072} 1072}
1073 1073
1074void KABCore::pasteContacts( KABC::Addressee::List &list ) 1074void KABCore::pasteContacts( KABC::Addressee::List &list )
1075{ 1075{
1076 KABC::Resource *resource = requestResource( this ); 1076 KABC::Resource *resource = requestResource( this );
1077 KABC::Addressee::List::Iterator it; 1077 KABC::Addressee::List::Iterator it;
1078 for ( it = list.begin(); it != list.end(); ++it ) 1078 for ( it = list.begin(); it != list.end(); ++it )
1079 (*it).setResource( resource ); 1079 (*it).setResource( resource );
1080 1080
1081 PwPasteCommand *command = new PwPasteCommand( this, list ); 1081 PwPasteCommand *command = new PwPasteCommand( this, list );
1082 UndoStack::instance()->push( command ); 1082 UndoStack::instance()->push( command );
1083 RedoStack::instance()->clear(); 1083 RedoStack::instance()->clear();
1084 1084
1085 setModified( true ); 1085 setModified( true );
1086} 1086}
1087 1087
1088void KABCore::setWhoAmI() 1088void KABCore::setWhoAmI()
1089{ 1089{
1090 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1090 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1091 1091
1092 if ( addrList.count() > 1 ) { 1092 if ( addrList.count() > 1 ) {
1093 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1093 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1094 return; 1094 return;
1095 } 1095 }
1096 1096
1097 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1097 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1098 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1098 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1099 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1099 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1100} 1100}
1101void KABCore::editCategories() 1101void KABCore::editCategories()
1102{ 1102{
1103 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1103 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1104 dlg.exec(); 1104 dlg.exec();
1105} 1105}
1106void KABCore::setCategories() 1106void KABCore::setCategories()
1107{ 1107{
1108 1108
1109 QStringList uids; 1109 QStringList uids;
1110 XXPortSelectDialog dlgx( this, false, this ); 1110 XXPortSelectDialog dlgx( this, false, this );
1111 if ( dlgx.exec() ) 1111 if ( dlgx.exec() )
1112 uids = dlgx.uids(); 1112 uids = dlgx.uids();
1113 else 1113 else
1114 return; 1114 return;
1115 if ( uids.isEmpty() ) 1115 if ( uids.isEmpty() )
1116 return; 1116 return;
1117 // qDebug("count %d ", uids.count()); 1117 // qDebug("count %d ", uids.count());
1118 1118
1119 1119
1120 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1120 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1121 if ( !dlg.exec() ) { 1121 if ( !dlg.exec() ) {
1122 message( i18n("Setting categories cancelled") ); 1122 message( i18n("Setting categories cancelled") );
1123 return; 1123 return;
1124 } 1124 }
1125 bool merge = false; 1125 bool merge = false;
1126 QString msg = i18n( "Merge with existing categories?" ); 1126 QString msg = i18n( "Merge with existing categories?" );
1127 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1127 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1128 merge = true; 1128 merge = true;
1129 1129
1130 message( i18n("Setting categories ... please wait!") ); 1130 message( i18n("Setting categories ... please wait!") );
1131 QStringList categories = dlg.selectedCategories(); 1131 QStringList categories = dlg.selectedCategories();
1132 1132
1133 //QStringList uids = mViewManager->selectedUids(); 1133 //QStringList uids = mViewManager->selectedUids();
1134 QStringList::Iterator it; 1134 QStringList::Iterator it;
1135 for ( it = uids.begin(); it != uids.end(); ++it ) { 1135 for ( it = uids.begin(); it != uids.end(); ++it ) {
1136 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1136 KABC::Addressee addr = mAddressBook->findByUid( *it );
1137 if ( !addr.isEmpty() ) { 1137 if ( !addr.isEmpty() ) {
1138 if ( !merge ) 1138 if ( !merge )
1139 addr.setCategories( categories ); 1139 addr.setCategories( categories );
1140 else { 1140 else {
1141 QStringList addrCategories = addr.categories(); 1141 QStringList addrCategories = addr.categories();
1142 QStringList::Iterator catIt; 1142 QStringList::Iterator catIt;
1143 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1143 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1144 if ( !addrCategories.contains( *catIt ) ) 1144 if ( !addrCategories.contains( *catIt ) )
1145 addrCategories.append( *catIt ); 1145 addrCategories.append( *catIt );
1146 } 1146 }
1147 addr.setCategories( addrCategories ); 1147 addr.setCategories( addrCategories );
1148 } 1148 }
1149 mAddressBook->insertAddressee( addr ); 1149 mAddressBook->insertAddressee( addr );
1150 } 1150 }
1151 } 1151 }
1152 1152
1153 if ( uids.count() > 0 ) 1153 if ( uids.count() > 0 )
1154 setModified( true ); 1154 setModified( true );
1155 message( i18n("Setting categories completed!") ); 1155 message( i18n("Setting categories completed!") );
1156} 1156}
1157 1157
1158void KABCore::setSearchFields( const KABC::Field::List &fields ) 1158void KABCore::setSearchFields( const KABC::Field::List &fields )
1159{ 1159{
1160 mIncSearchWidget->setFields( fields ); 1160 mIncSearchWidget->setFields( fields );
1161} 1161}
1162 1162
1163void KABCore::incrementalSearch( const QString& text ) 1163void KABCore::incrementalSearch( const QString& text )
1164{ 1164{
1165 QString stext; 1165 QString stext;
1166 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1166 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1167 stext = "*" + text; 1167 stext = "*" + text;
1168 } else { 1168 } else {
1169 stext = text; 1169 stext = text;
1170 } 1170 }
1171 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1171 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1172} 1172}
1173 1173
1174void KABCore::setModified() 1174void KABCore::setModified()
1175{ 1175{
1176 setModified( true ); 1176 setModified( true );
1177} 1177}
1178 1178
1179void KABCore::setModifiedWOrefresh() 1179void KABCore::setModifiedWOrefresh()
1180{ 1180{
1181 // qDebug("KABCore::setModifiedWOrefresh() "); 1181 // qDebug("KABCore::setModifiedWOrefresh() ");
1182 mModified = true; 1182 mModified = true;
1183 mActionSave->setEnabled( mModified ); 1183 mActionSave->setEnabled( mModified );
1184 1184
1185 1185
1186} 1186}
1187void KABCore::setModified( bool modified ) 1187void KABCore::setModified( bool modified )
1188{ 1188{
1189 mModified = modified; 1189 mModified = modified;
1190 mActionSave->setEnabled( mModified ); 1190 mActionSave->setEnabled( mModified );
1191 1191
1192 if ( modified ) 1192 if ( modified )
1193 mJumpButtonBar->recreateButtons(); 1193 mJumpButtonBar->recreateButtons();
1194 1194
1195 mViewManager->refreshView(); 1195 mViewManager->refreshView();
1196 1196
1197} 1197}
1198 1198
1199bool KABCore::modified() const 1199bool KABCore::modified() const
1200{ 1200{
1201 return mModified; 1201 return mModified;
1202} 1202}
1203 1203
1204void KABCore::contactModified( const KABC::Addressee &addr ) 1204void KABCore::contactModified( const KABC::Addressee &addr )
1205{ 1205{
1206 addrModified( addr ); 1206 addrModified( addr );
1207#if 0 // debug only 1207#if 0 // debug only
1208 KABC::Addressee ad = addr; 1208 KABC::Addressee ad = addr;
1209 ad.computeCsum( "123"); 1209 ad.computeCsum( "123");
1210#endif 1210#endif
1211} 1211}
1212 1212
1213void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1213void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1214{ 1214{
1215 1215
1216 Command *command = 0; 1216 Command *command = 0;
1217 QString uid; 1217 QString uid;
1218 1218
1219 // check if it exists already 1219 // check if it exists already
1220 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1220 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1221 if ( origAddr.isEmpty() ) 1221 if ( origAddr.isEmpty() )
1222 command = new PwNewCommand( mAddressBook, addr ); 1222 command = new PwNewCommand( mAddressBook, addr );
1223 else { 1223 else {
1224 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1224 command = new PwEditCommand( mAddressBook, origAddr, addr );
1225 uid = addr.uid(); 1225 uid = addr.uid();
1226 } 1226 }
1227 1227
1228 UndoStack::instance()->push( command ); 1228 UndoStack::instance()->push( command );
1229 RedoStack::instance()->clear(); 1229 RedoStack::instance()->clear();
1230 if ( updateDetails ) 1230 if ( updateDetails )
1231 mDetails->setAddressee( addr ); 1231 mDetails->setAddressee( addr );
1232 setModified( true ); 1232 setModified( true );
1233} 1233}
1234 1234
1235void KABCore::newContact() 1235void KABCore::newContact()
1236{ 1236{
1237 1237
1238 1238
1239 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1239 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1240 1240
1241 QPtrList<KRES::Resource> kresResources; 1241 QPtrList<KRES::Resource> kresResources;
1242 QPtrListIterator<KABC::Resource> it( kabcResources ); 1242 QPtrListIterator<KABC::Resource> it( kabcResources );
1243 KABC::Resource *resource; 1243 KABC::Resource *resource;
1244 while ( ( resource = it.current() ) != 0 ) { 1244 while ( ( resource = it.current() ) != 0 ) {
1245 ++it; 1245 ++it;
1246 if ( !resource->readOnly() ) { 1246 if ( !resource->readOnly() ) {
1247 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1247 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1248 if ( res ) 1248 if ( res )
1249 kresResources.append( res ); 1249 kresResources.append( res );
1250 } 1250 }
1251 } 1251 }
1252 1252
1253 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1253 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1254 resource = static_cast<KABC::Resource*>( res ); 1254 resource = static_cast<KABC::Resource*>( res );
1255 1255
1256 if ( resource ) { 1256 if ( resource ) {
1257 KABC::Addressee addr; 1257 KABC::Addressee addr;
1258 addr.setResource( resource ); 1258 addr.setResource( resource );
1259 mEditorDialog->setAddressee( addr ); 1259 mEditorDialog->setAddressee( addr );
1260 KApplication::execDialog ( mEditorDialog ); 1260 KApplication::execDialog ( mEditorDialog );
1261 1261
1262 } else 1262 } else
1263 return; 1263 return;
1264 1264
1265 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1265 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1266 1266
1267 1267
1268} 1268}
1269 1269
1270void KABCore::addEmail( QString aStr ) 1270void KABCore::addEmail( QString aStr )
1271{ 1271{
1272#ifndef KAB_EMBEDDED 1272#ifndef KAB_EMBEDDED
1273 QString fullName, email; 1273 QString fullName, email;
1274 1274
1275 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1275 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1276 1276
1277 // Try to lookup the addressee matching the email address 1277 // Try to lookup the addressee matching the email address
1278 bool found = false; 1278 bool found = false;
1279 QStringList emailList; 1279 QStringList emailList;
1280 KABC::AddressBook::Iterator it; 1280 KABC::AddressBook::Iterator it;
1281 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1281 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1282 emailList = (*it).emails(); 1282 emailList = (*it).emails();
1283 if ( emailList.contains( email ) > 0 ) { 1283 if ( emailList.contains( email ) > 0 ) {
1284 found = true; 1284 found = true;
1285 (*it).setNameFromString( fullName ); 1285 (*it).setNameFromString( fullName );
1286 editContact( (*it).uid() ); 1286 editContact( (*it).uid() );
1287 } 1287 }
1288 } 1288 }
1289 1289
1290 if ( !found ) { 1290 if ( !found ) {
1291 KABC::Addressee addr; 1291 KABC::Addressee addr;
1292 addr.setNameFromString( fullName ); 1292 addr.setNameFromString( fullName );
1293 addr.insertEmail( email, true ); 1293 addr.insertEmail( email, true );
1294 1294
1295 mAddressBook->insertAddressee( addr ); 1295 mAddressBook->insertAddressee( addr );
1296 mViewManager->refreshView( addr.uid() ); 1296 mViewManager->refreshView( addr.uid() );
1297 editContact( addr.uid() ); 1297 editContact( addr.uid() );
1298 } 1298 }
1299#else //KAB_EMBEDDED 1299#else //KAB_EMBEDDED
1300 qDebug("KABCore::addEmail finsih method"); 1300 qDebug("KABCore::addEmail finsih method");
1301#endif //KAB_EMBEDDED 1301#endif //KAB_EMBEDDED
1302} 1302}
1303 1303
1304void KABCore::importVCard( const KURL &url, bool showPreview ) 1304void KABCore::importVCard( const KURL &url, bool showPreview )
1305{ 1305{
1306 mXXPortManager->importVCard( url, showPreview ); 1306 mXXPortManager->importVCard( url, showPreview );
1307} 1307}
1308void KABCore::importFromOL() 1308void KABCore::importFromOL()
1309{ 1309{
1310#ifdef _OL_IMPORT_ 1310#ifdef _OL_IMPORT_
1311 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1311 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1312 idgl->exec(); 1312 idgl->exec();
1313 KABC::Addressee::List list = idgl->getAddressList(); 1313 KABC::Addressee::List list = idgl->getAddressList();
1314 if ( list.count() > 0 ) { 1314 if ( list.count() > 0 ) {
1315 KABC::Addressee::List listNew; 1315 KABC::Addressee::List listNew;
1316 KABC::Addressee::List listExisting; 1316 KABC::Addressee::List listExisting;
1317 KABC::Addressee::List::Iterator it; 1317 KABC::Addressee::List::Iterator it;
1318 KABC::AddressBook::Iterator iter; 1318 KABC::AddressBook::Iterator iter;
1319 for ( it = list.begin(); it != list.end(); ++it ) { 1319 for ( it = list.begin(); it != list.end(); ++it ) {
1320 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1320 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1321 listNew.append( (*it) ); 1321 listNew.append( (*it) );
1322 else 1322 else
1323 listExisting.append( (*it) ); 1323 listExisting.append( (*it) );
1324 } 1324 }
1325 if ( listExisting.count() > 0 ) 1325 if ( listExisting.count() > 0 )
1326 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1326 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1327 if ( listNew.count() > 0 ) { 1327 if ( listNew.count() > 0 ) {
1328 pasteWithNewUid = false; 1328 pasteWithNewUid = false;
1329 pasteContacts( listNew ); 1329 pasteContacts( listNew );
1330 pasteWithNewUid = true; 1330 pasteWithNewUid = true;
1331 } 1331 }
1332 } 1332 }
1333 delete idgl; 1333 delete idgl;
1334#endif 1334#endif
1335} 1335}
1336 1336
1337void KABCore::importVCard( const QString &vCard, bool showPreview ) 1337void KABCore::importVCard( const QString &vCard, bool showPreview )
1338{ 1338{
1339 mXXPortManager->importVCard( vCard, showPreview ); 1339 mXXPortManager->importVCard( vCard, showPreview );
1340} 1340}
1341 1341
1342//US added a second method without defaultparameter 1342//US added a second method without defaultparameter
1343void KABCore::editContact2() { 1343void KABCore::editContact2() {
1344 editContact( QString::null ); 1344 editContact( QString::null );
1345} 1345}
1346 1346
1347void KABCore::editContact( const QString &uid ) 1347void KABCore::editContact( const QString &uid )
1348{ 1348{
1349 1349
1350 if ( mExtensionManager->isQuickEditVisible() ) 1350 if ( mExtensionManager->isQuickEditVisible() )
1351 return; 1351 return;
1352 1352
1353 // First, locate the contact entry 1353 // First, locate the contact entry
1354 QString localUID = uid; 1354 QString localUID = uid;
1355 if ( localUID.isNull() ) { 1355 if ( localUID.isNull() ) {
1356 QStringList uidList = mViewManager->selectedUids(); 1356 QStringList uidList = mViewManager->selectedUids();
1357 if ( uidList.count() > 0 ) 1357 if ( uidList.count() > 0 )
1358 localUID = *( uidList.at( 0 ) ); 1358 localUID = *( uidList.at( 0 ) );
1359 } 1359 }
1360 1360
1361 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1361 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1362 if ( !addr.isEmpty() ) { 1362 if ( !addr.isEmpty() ) {
1363 mEditorDialog->setAddressee( addr ); 1363 mEditorDialog->setAddressee( addr );
1364 KApplication::execDialog ( mEditorDialog ); 1364 KApplication::execDialog ( mEditorDialog );
1365 } 1365 }
1366} 1366}
1367 1367
1368/** 1368/**
1369 Shows or edits the detail view for the given uid. If the uid is QString::null, 1369 Shows or edits the detail view for the given uid. If the uid is QString::null,
1370 the method will try to find a selected addressee in the view. 1370 the method will try to find a selected addressee in the view.
1371 */ 1371 */
1372void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1372void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1373{ 1373{
1374 if ( mMultipleViewsAtOnce ) 1374 if ( mMultipleViewsAtOnce )
1375 { 1375 {
1376 editContact( uid ); 1376 editContact( uid );
1377 } 1377 }
1378 else 1378 else
1379 { 1379 {
1380 setDetailsVisible( true ); 1380 setDetailsVisible( true );
1381 mActionDetails->setChecked(true); 1381 mActionDetails->setChecked(true);
1382 } 1382 }
1383 1383
1384} 1384}
1385 1385
1386void KABCore::save() 1386void KABCore::save()
1387{ 1387{
1388 if (syncManager->blockSave()) 1388 if (syncManager->blockSave())
1389 return; 1389 return;
1390 if ( !mModified ) 1390 if ( !mModified )
1391 return; 1391 return;
1392 1392
1393 syncManager->setBlockSave(true); 1393 syncManager->setBlockSave(true);
1394 QString text = i18n( "There was an error while attempting to save\n the " 1394 QString text = i18n( "There was an error while attempting to save\n the "
1395 "address book. Please check that some \nother application is " 1395 "address book. Please check that some \nother application is "
1396 "not using it. " ); 1396 "not using it. " );
1397 message(i18n("Saving ... please wait! "), false); 1397 message(i18n("Saving ... please wait! "), false);
1398 //qApp->processEvents(); 1398 //qApp->processEvents();
1399#ifndef KAB_EMBEDDED 1399#ifndef KAB_EMBEDDED
1400 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1400 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1401 if ( !b || !b->save() ) { 1401 if ( !b || !b->save() ) {
1402 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1402 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1403 } 1403 }
1404#else //KAB_EMBEDDED 1404#else //KAB_EMBEDDED
1405 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1405 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1406 if ( !b || !b->save() ) { 1406 if ( !b || !b->save() ) {
1407 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1407 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1408 } 1408 }
1409#endif //KAB_EMBEDDED 1409#endif //KAB_EMBEDDED
1410 1410
1411 message(i18n("Addressbook saved!")); 1411 message(i18n("Addressbook saved!"));
1412 setModified( false ); 1412 setModified( false );
1413 syncManager->setBlockSave(false); 1413 syncManager->setBlockSave(false);
1414} 1414}
1415 1415
1416 1416
1417void KABCore::undo() 1417void KABCore::undo()
1418{ 1418{
1419 UndoStack::instance()->undo(); 1419 UndoStack::instance()->undo();
1420 1420
1421 // Refresh the view 1421 // Refresh the view
1422 mViewManager->refreshView(); 1422 mViewManager->refreshView();
1423} 1423}
1424 1424
1425void KABCore::redo() 1425void KABCore::redo()
1426{ 1426{
1427 RedoStack::instance()->redo(); 1427 RedoStack::instance()->redo();
1428 1428
1429 // Refresh the view 1429 // Refresh the view
1430 mViewManager->refreshView(); 1430 mViewManager->refreshView();
1431} 1431}
1432void KABCore::setJumpButtonBar( bool visible ) 1432void KABCore::setJumpButtonBar( bool visible )
1433{ 1433{
1434 setJumpButtonBarVisible(visible ); 1434 setJumpButtonBarVisible(visible );
1435 saveSettings(); 1435 saveSettings();
1436} 1436}
1437void KABCore::setJumpButtonBarVisible( bool visible ) 1437void KABCore::setJumpButtonBarVisible( bool visible )
1438{ 1438{
1439 if (mMultipleViewsAtOnce) 1439 if (mMultipleViewsAtOnce)
1440 { 1440 {
1441 if ( visible ) 1441 if ( visible )
1442 mJumpButtonBar->show(); 1442 mJumpButtonBar->show();
1443 else 1443 else
1444 mJumpButtonBar->hide(); 1444 mJumpButtonBar->hide();
1445 } 1445 }
1446 else 1446 else
1447 { 1447 {
1448 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1448 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1449 if (mViewManager->isVisible()) 1449 if (mViewManager->isVisible())
1450 { 1450 {
1451 if ( visible ) 1451 if ( visible )
1452 mJumpButtonBar->show(); 1452 mJumpButtonBar->show();
1453 else 1453 else
1454 mJumpButtonBar->hide(); 1454 mJumpButtonBar->hide();
1455 } 1455 }
1456 else 1456 else
1457 { 1457 {
1458 mJumpButtonBar->hide(); 1458 mJumpButtonBar->hide();
1459 } 1459 }
1460 } 1460 }
1461 if ( visible ) { 1461 if ( visible ) {
1462 if ( mIncSearchWidget->currentItem() == 0 ) { 1462 if ( mIncSearchWidget->currentItem() == 0 ) {
1463 message( i18n("Change search field enable jump bar") ); 1463 message( i18n("Change search field enable jump bar") );
1464 } 1464 }
1465 } 1465 }
1466} 1466}
1467 1467
1468 1468
1469void KABCore::setDetailsToState() 1469void KABCore::setDetailsToState()
1470{ 1470{
1471 setDetailsVisible( mActionDetails->isChecked() ); 1471 setDetailsVisible( mActionDetails->isChecked() );
1472} 1472}
1473void KABCore::setDetailsToggle() 1473void KABCore::setDetailsToggle()
1474{ 1474{
1475 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1475 mActionDetails->setChecked( !mActionDetails->isChecked() );
1476 setDetailsToState(); 1476 setDetailsToState();
1477} 1477}
1478 1478
1479 1479
1480 1480
1481void KABCore::setDetailsVisible( bool visible ) 1481void KABCore::setDetailsVisible( bool visible )
1482{ 1482{
1483 if (visible && mDetails->isHidden()) 1483 if (visible && mDetails->isHidden())
1484 { 1484 {
1485 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1485 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1486 if ( addrList.count() > 0 ) 1486 if ( addrList.count() > 0 )
1487 mDetails->setAddressee( addrList[ 0 ] ); 1487 mDetails->setAddressee( addrList[ 0 ] );
1488 } 1488 }
1489 1489
1490 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1490 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1491 // the listview and the detailview. We do that by changing the splitbar size. 1491 // the listview and the detailview. We do that by changing the splitbar size.
1492 if (mMultipleViewsAtOnce) 1492 if (mMultipleViewsAtOnce)
1493 { 1493 {
1494 if ( visible ) 1494 if ( visible )
1495 mDetails->show(); 1495 mDetails->show();
1496 else 1496 else
1497 mDetails->hide(); 1497 mDetails->hide();
1498 } 1498 }
1499 else 1499 else
1500 { 1500 {
1501 if ( visible ) { 1501 if ( visible ) {
1502 mViewManager->hide(); 1502 mViewManager->hide();
1503 mDetails->show(); 1503 mDetails->show();
1504 mIncSearchWidget->setFocus(); 1504 mIncSearchWidget->setFocus();
1505 } 1505 }
1506 else { 1506 else {
1507 mViewManager->show(); 1507 mViewManager->show();
1508 mDetails->hide(); 1508 mDetails->hide();
1509 mViewManager->setFocusAV(); 1509 mViewManager->setFocusAV();
1510 } 1510 }
1511 setJumpButtonBarVisible( !visible ); 1511 setJumpButtonBarVisible( !visible );
1512 } 1512 }
1513 1513
1514} 1514}
1515 1515
1516void KABCore::extensionChanged( int id ) 1516void KABCore::extensionChanged( int id )
1517{ 1517{
1518 //change the details view only for non desktop systems 1518 //change the details view only for non desktop systems
1519#ifndef DESKTOP_VERSION 1519#ifndef DESKTOP_VERSION
1520 1520
1521 if (id == 0) 1521 if (id == 0)
1522 { 1522 {
1523 //the user disabled the extension. 1523 //the user disabled the extension.
1524 1524
1525 if (mMultipleViewsAtOnce) 1525 if (mMultipleViewsAtOnce)
1526 { // enable detailsview again 1526 { // enable detailsview again
1527 setDetailsVisible( true ); 1527 setDetailsVisible( true );
1528 mActionDetails->setChecked( true ); 1528 mActionDetails->setChecked( true );
1529 } 1529 }
1530 else 1530 else
1531 { //go back to the listview 1531 { //go back to the listview
1532 setDetailsVisible( false ); 1532 setDetailsVisible( false );
1533 mActionDetails->setChecked( false ); 1533 mActionDetails->setChecked( false );
1534 mActionDetails->setEnabled(true); 1534 mActionDetails->setEnabled(true);
1535 } 1535 }
1536 1536
1537 } 1537 }
1538 else 1538 else
1539 { 1539 {
1540 //the user enabled the extension. 1540 //the user enabled the extension.
1541 setDetailsVisible( false ); 1541 setDetailsVisible( false );
1542 mActionDetails->setChecked( false ); 1542 mActionDetails->setChecked( false );
1543 1543
1544 if (!mMultipleViewsAtOnce) 1544 if (!mMultipleViewsAtOnce)
1545 { 1545 {
1546 mActionDetails->setEnabled(false); 1546 mActionDetails->setEnabled(false);
1547 } 1547 }
1548 1548
1549 mExtensionManager->setSelectionChanged(); 1549 mExtensionManager->setSelectionChanged();
1550 1550
1551 } 1551 }
1552 1552
1553#endif// DESKTOP_VERSION 1553#endif// DESKTOP_VERSION
1554 1554
1555} 1555}
1556 1556
1557 1557
1558void KABCore::extensionModified( const KABC::Addressee::List &list ) 1558void KABCore::extensionModified( const KABC::Addressee::List &list )
1559{ 1559{
1560 1560
1561 if ( list.count() != 0 ) { 1561 if ( list.count() != 0 ) {
1562 KABC::Addressee::List::ConstIterator it; 1562 KABC::Addressee::List::ConstIterator it;
1563 for ( it = list.begin(); it != list.end(); ++it ) 1563 for ( it = list.begin(); it != list.end(); ++it )
1564 mAddressBook->insertAddressee( *it ); 1564 mAddressBook->insertAddressee( *it );
1565 if ( list.count() > 1 ) 1565 if ( list.count() > 1 )
1566 setModified(); 1566 setModified();
1567 else 1567 else
1568 setModifiedWOrefresh(); 1568 setModifiedWOrefresh();
1569 } 1569 }
1570 if ( list.count() == 0 ) 1570 if ( list.count() == 0 )
1571 mViewManager->refreshView(); 1571 mViewManager->refreshView();
1572 else 1572 else
1573 mViewManager->refreshView( list[ 0 ].uid() ); 1573 mViewManager->refreshView( list[ 0 ].uid() );
1574 1574
1575 1575
1576 1576
1577} 1577}
1578 1578
1579QString KABCore::getNameByPhone( const QString &phone ) 1579QString KABCore::getNameByPhone( const QString &phone )
1580{ 1580{
1581#ifndef KAB_EMBEDDED 1581#ifndef KAB_EMBEDDED
1582 QRegExp r( "[/*/-/ ]" ); 1582 QRegExp r( "[/*/-/ ]" );
1583 QString localPhone( phone ); 1583 QString localPhone( phone );
1584 1584
1585 bool found = false; 1585 bool found = false;
1586 QString ownerName = ""; 1586 QString ownerName = "";
1587 KABC::AddressBook::Iterator iter; 1587 KABC::AddressBook::Iterator iter;
1588 KABC::PhoneNumber::List::Iterator phoneIter; 1588 KABC::PhoneNumber::List::Iterator phoneIter;
1589 KABC::PhoneNumber::List phoneList; 1589 KABC::PhoneNumber::List phoneList;
1590 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1590 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1591 phoneList = (*iter).phoneNumbers(); 1591 phoneList = (*iter).phoneNumbers();
1592 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1592 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1593 ++phoneIter) { 1593 ++phoneIter) {
1594 // Get rid of separator chars so just the numbers are compared. 1594 // Get rid of separator chars so just the numbers are compared.
1595 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1595 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1596 ownerName = (*iter).formattedName(); 1596 ownerName = (*iter).formattedName();
1597 found = true; 1597 found = true;
1598 } 1598 }
1599 } 1599 }
1600 } 1600 }
1601 1601
1602 return ownerName; 1602 return ownerName;
1603#else //KAB_EMBEDDED 1603#else //KAB_EMBEDDED
1604 qDebug("KABCore::getNameByPhone finsih method"); 1604 qDebug("KABCore::getNameByPhone finsih method");
1605 return ""; 1605 return "";
1606#endif //KAB_EMBEDDED 1606#endif //KAB_EMBEDDED
1607 1607
1608} 1608}
1609 1609
1610void KABCore::openConfigDialog() 1610void KABCore::openConfigDialog()
1611{ 1611{
1612 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1612 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1613 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1613 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1614 ConfigureDialog->addModule(kabcfg ); 1614 ConfigureDialog->addModule(kabcfg );
1615 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1615 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1616 ConfigureDialog->addModule(kdelibcfg ); 1616 ConfigureDialog->addModule(kdelibcfg );
1617 1617
1618 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1618 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1619 this, SLOT( configurationChanged() ) ); 1619 this, SLOT( configurationChanged() ) );
1620 connect( ConfigureDialog, SIGNAL( okClicked() ), 1620 connect( ConfigureDialog, SIGNAL( okClicked() ),
1621 this, SLOT( configurationChanged() ) ); 1621 this, SLOT( configurationChanged() ) );
1622 saveSettings(); 1622 saveSettings();
1623#ifndef DESKTOP_VERSION 1623#ifndef DESKTOP_VERSION
1624 ConfigureDialog->showMaximized(); 1624 ConfigureDialog->showMaximized();
1625#endif 1625#endif
1626 if ( ConfigureDialog->exec() ) 1626 if ( ConfigureDialog->exec() )
1627 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1627 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1628 delete ConfigureDialog; 1628 delete ConfigureDialog;
1629} 1629}
1630 1630
1631void KABCore::openLDAPDialog() 1631void KABCore::openLDAPDialog()
1632{ 1632{
1633#ifndef KAB_EMBEDDED 1633#ifndef KAB_EMBEDDED
1634 if ( !mLdapSearchDialog ) { 1634 if ( !mLdapSearchDialog ) {
1635 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1635 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1636 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1636 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1637 SLOT( refreshView() ) ); 1637 SLOT( refreshView() ) );
1638 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1638 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1639 SLOT( setModified() ) ); 1639 SLOT( setModified() ) );
1640 } else 1640 } else
1641 mLdapSearchDialog->restoreSettings(); 1641 mLdapSearchDialog->restoreSettings();
1642 1642
1643 if ( mLdapSearchDialog->isOK() ) 1643 if ( mLdapSearchDialog->isOK() )
1644 mLdapSearchDialog->exec(); 1644 mLdapSearchDialog->exec();
1645#else //KAB_EMBEDDED 1645#else //KAB_EMBEDDED
1646 qDebug("KABCore::openLDAPDialog() finsih method"); 1646 qDebug("KABCore::openLDAPDialog() finsih method");
1647#endif //KAB_EMBEDDED 1647#endif //KAB_EMBEDDED
1648} 1648}
1649 1649
1650void KABCore::print() 1650void KABCore::print()
1651{ 1651{
1652#ifndef KAB_EMBEDDED 1652#ifndef KAB_EMBEDDED
1653 KPrinter printer; 1653 KPrinter printer;
1654 if ( !printer.setup( this ) ) 1654 if ( !printer.setup( this ) )
1655 return; 1655 return;
1656 1656
1657 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1657 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1658 mViewManager->selectedUids(), this ); 1658 mViewManager->selectedUids(), this );
1659 1659
1660 wizard.exec(); 1660 wizard.exec();
1661#else //KAB_EMBEDDED 1661#else //KAB_EMBEDDED
1662 qDebug("KABCore::print() finsih method"); 1662 qDebug("KABCore::print() finsih method");
1663#endif //KAB_EMBEDDED 1663#endif //KAB_EMBEDDED
1664 1664
1665} 1665}
1666 1666
1667 1667
1668void KABCore::addGUIClient( KXMLGUIClient *client ) 1668void KABCore::addGUIClient( KXMLGUIClient *client )
1669{ 1669{
1670 if ( mGUIClient ) 1670 if ( mGUIClient )
1671 mGUIClient->insertChildClient( client ); 1671 mGUIClient->insertChildClient( client );
1672 else 1672 else
1673 KMessageBox::error( this, "no KXMLGUICLient"); 1673 KMessageBox::error( this, "no KXMLGUICLient");
1674} 1674}
1675 1675
1676 1676
1677void KABCore::configurationChanged() 1677void KABCore::configurationChanged()
1678{ 1678{
1679 mExtensionManager->reconfigure(); 1679 mExtensionManager->reconfigure();
1680} 1680}
1681 1681
1682void KABCore::addressBookChanged() 1682void KABCore::addressBookChanged()
1683{ 1683{
1684/*US 1684/*US
1685 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1685 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1686 while ( it.current() ) { 1686 while ( it.current() ) {
1687 if ( it.current()->dirty() ) { 1687 if ( it.current()->dirty() ) {
1688 QString text = i18n( "Data has been changed externally. Unsaved " 1688 QString text = i18n( "Data has been changed externally. Unsaved "
1689 "changes will be lost." ); 1689 "changes will be lost." );
1690 KMessageBox::information( this, text ); 1690 KMessageBox::information( this, text );
1691 } 1691 }
1692 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1692 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1693 ++it; 1693 ++it;
1694 } 1694 }
1695*/ 1695*/
1696 if (mEditorDialog) 1696 if (mEditorDialog)
1697 { 1697 {
1698 if (mEditorDialog->dirty()) 1698 if (mEditorDialog->dirty())
1699 { 1699 {
1700 QString text = i18n( "Data has been changed externally. Unsaved " 1700 QString text = i18n( "Data has been changed externally. Unsaved "
1701 "changes will be lost." ); 1701 "changes will be lost." );
1702 KMessageBox::information( this, text ); 1702 KMessageBox::information( this, text );
1703 } 1703 }
1704 QString currentuid = mEditorDialog->addressee().uid(); 1704 QString currentuid = mEditorDialog->addressee().uid();
1705 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1705 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1706 } 1706 }
1707 mViewManager->refreshView(); 1707 mViewManager->refreshView();
1708 1708
1709 1709
1710} 1710}
1711 1711
1712AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1712AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1713 const char *name ) 1713 const char *name )
1714{ 1714{
1715 1715
1716 if ( mEditorDialog == 0 ) { 1716 if ( mEditorDialog == 0 ) {
1717 mEditorDialog = new AddresseeEditorDialog( this, parent, 1717 mEditorDialog = new AddresseeEditorDialog( this, parent,
1718 name ? name : "editorDialog" ); 1718 name ? name : "editorDialog" );
1719 1719
1720 1720
1721 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1721 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1722 SLOT( contactModified( const KABC::Addressee& ) ) ); 1722 SLOT( contactModified( const KABC::Addressee& ) ) );
1723 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1723 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1724 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1724 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1725 } 1725 }
1726 1726
1727 return mEditorDialog; 1727 return mEditorDialog;
1728} 1728}
1729 1729
1730void KABCore::slotEditorDestroyed( const QString &uid ) 1730void KABCore::slotEditorDestroyed( const QString &uid )
1731{ 1731{
1732 //mEditorDict.remove( uid ); 1732 //mEditorDict.remove( uid );
1733} 1733}
1734 1734
1735void KABCore::initGUI() 1735void KABCore::initGUI()
1736{ 1736{
1737#ifndef KAB_EMBEDDED 1737#ifndef KAB_EMBEDDED
1738 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1738 QHBoxLayout *topLayout = new QHBoxLayout( this );
1739 topLayout->setSpacing( KDialogBase::spacingHint() ); 1739 topLayout->setSpacing( KDialogBase::spacingHint() );
1740 1740
1741 mExtensionBarSplitter = new QSplitter( this ); 1741 mExtensionBarSplitter = new QSplitter( this );
1742 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1742 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1743 1743
1744 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1744 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1745 1745
1746 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1746 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1747 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1747 mIncSearchWidget = new IncSearchWidget( viewSpace );
1748 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1748 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1749 SLOT( incrementalSearch( const QString& ) ) ); 1749 SLOT( incrementalSearch( const QString& ) ) );
1750 1750
1751 mViewManager = new ViewManager( this, viewSpace ); 1751 mViewManager = new ViewManager( this, viewSpace );
1752 viewSpace->setStretchFactor( mViewManager, 1 ); 1752 viewSpace->setStretchFactor( mViewManager, 1 );
1753 1753
1754 mDetails = new ViewContainer( mDetailsSplitter ); 1754 mDetails = new ViewContainer( mDetailsSplitter );
1755 1755
1756 mJumpButtonBar = new JumpButtonBar( this, this ); 1756 mJumpButtonBar = new JumpButtonBar( this, this );
1757 1757
1758 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1758 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1759 1759
1760 topLayout->addWidget( mExtensionBarSplitter ); 1760 topLayout->addWidget( mExtensionBarSplitter );
1761 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1761 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1762 topLayout->addWidget( mJumpButtonBar ); 1762 topLayout->addWidget( mJumpButtonBar );
1763 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1763 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1764 1764
1765 mXXPortManager = new XXPortManager( this, this ); 1765 mXXPortManager = new XXPortManager( this, this );
1766 1766
1767#else //KAB_EMBEDDED 1767#else //KAB_EMBEDDED
1768 //US initialize viewMenu before settingup viewmanager. 1768 //US initialize viewMenu before settingup viewmanager.
1769 // Viewmanager needs this menu to plugin submenues. 1769 // Viewmanager needs this menu to plugin submenues.
1770 viewMenu = new QPopupMenu( this ); 1770 viewMenu = new QPopupMenu( this );
1771 settingsMenu = new QPopupMenu( this ); 1771 settingsMenu = new QPopupMenu( this );
1772 //filterMenu = new QPopupMenu( this ); 1772 //filterMenu = new QPopupMenu( this );
1773 ImportMenu = new QPopupMenu( this ); 1773 ImportMenu = new QPopupMenu( this );
1774 ExportMenu = new QPopupMenu( this ); 1774 ExportMenu = new QPopupMenu( this );
1775 syncMenu = new QPopupMenu( this ); 1775 syncMenu = new QPopupMenu( this );
1776 changeMenu= new QPopupMenu( this ); 1776 changeMenu= new QPopupMenu( this );
1777 beamMenu= new QPopupMenu( this ); 1777 beamMenu= new QPopupMenu( this );
1778 1778
1779//US since we have no splitter for the embedded system, setup 1779//US since we have no splitter for the embedded system, setup
1780// a layout with two frames. One left and one right. 1780// a layout with two frames. One left and one right.
1781 1781
1782 QBoxLayout *topLayout; 1782 QBoxLayout *topLayout;
1783 1783
1784 // = new QHBoxLayout( this ); 1784 // = new QHBoxLayout( this );
1785// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1785// QBoxLayout *topLayout = (QBoxLayout*)layout();
1786 1786
1787// QWidget *mainBox = new QWidget( this ); 1787// QWidget *mainBox = new QWidget( this );
1788// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1788// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1789 1789
1790#ifdef DESKTOP_VERSION 1790#ifdef DESKTOP_VERSION
1791 topLayout = new QHBoxLayout( this ); 1791 topLayout = new QHBoxLayout( this );
1792 1792
1793 1793
1794 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1794 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1795 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1795 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1796 1796
1797 topLayout->addWidget(mMiniSplitter ); 1797 topLayout->addWidget(mMiniSplitter );
1798 1798
1799 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1799 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1800 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1800 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1801 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1801 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1802 mDetails = new ViewContainer( mMiniSplitter ); 1802 mDetails = new ViewContainer( mMiniSplitter );
1803 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1803 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1804#else 1804#else
1805 if ( QApplication::desktop()->width() > 480 ) { 1805 if ( QApplication::desktop()->width() > 480 ) {
1806 topLayout = new QHBoxLayout( this ); 1806 topLayout = new QHBoxLayout( this );
1807 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1807 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1808 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1808 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1809 } else { 1809 } else {
1810 1810
1811 topLayout = new QHBoxLayout( this ); 1811 topLayout = new QHBoxLayout( this );
1812 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1812 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1813 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1813 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1814 } 1814 }
1815 1815
1816 topLayout->addWidget(mMiniSplitter ); 1816 topLayout->addWidget(mMiniSplitter );
1817 mViewManager = new ViewManager( this, mMiniSplitter ); 1817 mViewManager = new ViewManager( this, mMiniSplitter );
1818 mDetails = new ViewContainer( mMiniSplitter ); 1818 mDetails = new ViewContainer( mMiniSplitter );
1819 1819
1820 1820
1821 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1821 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1822#endif 1822#endif
1823 //eh->hide(); 1823 //eh->hide();
1824 // topLayout->addWidget(mExtensionManager ); 1824 // topLayout->addWidget(mExtensionManager );
1825 1825
1826 1826
1827/*US 1827/*US
1828#ifndef KAB_NOSPLITTER 1828#ifndef KAB_NOSPLITTER
1829 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1829 QHBoxLayout *topLayout = new QHBoxLayout( this );
1830//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1830//US topLayout->setSpacing( KDialogBase::spacingHint() );
1831 topLayout->setSpacing( 10 ); 1831 topLayout->setSpacing( 10 );
1832 1832
1833 mDetailsSplitter = new QSplitter( this ); 1833 mDetailsSplitter = new QSplitter( this );
1834 1834
1835 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1835 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1836 1836
1837 mViewManager = new ViewManager( this, viewSpace ); 1837 mViewManager = new ViewManager( this, viewSpace );
1838 viewSpace->setStretchFactor( mViewManager, 1 ); 1838 viewSpace->setStretchFactor( mViewManager, 1 );
1839 1839
1840 mDetails = new ViewContainer( mDetailsSplitter ); 1840 mDetails = new ViewContainer( mDetailsSplitter );
1841 1841
1842 topLayout->addWidget( mDetailsSplitter ); 1842 topLayout->addWidget( mDetailsSplitter );
1843 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1843 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1844#else //KAB_NOSPLITTER 1844#else //KAB_NOSPLITTER
1845 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1845 QHBoxLayout *topLayout = new QHBoxLayout( this );
1846//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1846//US topLayout->setSpacing( KDialogBase::spacingHint() );
1847 topLayout->setSpacing( 10 ); 1847 topLayout->setSpacing( 10 );
1848 1848
1849// mDetailsSplitter = new QSplitter( this ); 1849// mDetailsSplitter = new QSplitter( this );
1850 1850
1851 QVBox *viewSpace = new QVBox( this ); 1851 QVBox *viewSpace = new QVBox( this );
1852 1852
1853 mViewManager = new ViewManager( this, viewSpace ); 1853 mViewManager = new ViewManager( this, viewSpace );
1854 viewSpace->setStretchFactor( mViewManager, 1 ); 1854 viewSpace->setStretchFactor( mViewManager, 1 );
1855 1855
1856 mDetails = new ViewContainer( this ); 1856 mDetails = new ViewContainer( this );
1857 1857
1858 topLayout->addWidget( viewSpace ); 1858 topLayout->addWidget( viewSpace );
1859// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1859// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1860 topLayout->addWidget( mDetails ); 1860 topLayout->addWidget( mDetails );
1861#endif //KAB_NOSPLITTER 1861#endif //KAB_NOSPLITTER
1862*/ 1862*/
1863 1863
1864 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1864 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1865 syncManager->setBlockSave(false); 1865 syncManager->setBlockSave(false);
1866 1866
1867 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1867 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1868 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1868 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1869 QString sync_file = sentSyncFile(); 1869 QString sync_file = sentSyncFile();
1870 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1870 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1871 syncManager->setDefaultFileName( sync_file ); 1871 syncManager->setDefaultFileName( sync_file );
1872 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1872 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1873 1873
1874#endif //KAB_EMBEDDED 1874#endif //KAB_EMBEDDED
1875 initActions(); 1875 initActions();
1876 1876
1877#ifdef KAB_EMBEDDED 1877#ifdef KAB_EMBEDDED
1878 addActionsManually(); 1878 addActionsManually();
1879 //US make sure the export and import menues are initialized before creating the xxPortManager. 1879 //US make sure the export and import menues are initialized before creating the xxPortManager.
1880 mXXPortManager = new XXPortManager( this, this ); 1880 mXXPortManager = new XXPortManager( this, this );
1881 1881
1882 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1882 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1883 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1883 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1884 // mActionQuit->plug ( mMainWindow->toolBar()); 1884 // mActionQuit->plug ( mMainWindow->toolBar());
1885 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1885 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1886 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1886 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1887 // mIncSearchWidget->hide(); 1887 // mIncSearchWidget->hide();
1888 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1888 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1889 SLOT( incrementalSearch( const QString& ) ) ); 1889 SLOT( incrementalSearch( const QString& ) ) );
1890 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1890 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1891 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1891 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1892 1892
1893 mJumpButtonBar = new JumpButtonBar( this, this ); 1893 mJumpButtonBar = new JumpButtonBar( this, this );
1894 1894
1895 topLayout->addWidget( mJumpButtonBar ); 1895 topLayout->addWidget( mJumpButtonBar );
1896//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1896//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1897 1897
1898// mMainWindow->getIconToolBar()->raise(); 1898// mMainWindow->getIconToolBar()->raise();
1899 1899
1900#endif //KAB_EMBEDDED 1900#endif //KAB_EMBEDDED
1901 1901
1902} 1902}
1903void KABCore::initActions() 1903void KABCore::initActions()
1904{ 1904{
1905//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1905//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1906 1906
1907#ifndef KAB_EMBEDDED 1907#ifndef KAB_EMBEDDED
1908 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1908 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1909 SLOT( clipboardDataChanged() ) ); 1909 SLOT( clipboardDataChanged() ) );
1910#endif //KAB_EMBEDDED 1910#endif //KAB_EMBEDDED
1911 1911
1912 // file menu 1912 // file menu
1913 1913
1914 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1914 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1915 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1915 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1916 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1916 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1917 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1917 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1918 1918
1919 1919
1920 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1920 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1921 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1921 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1922 1922
1923 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1923 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1924 SLOT( save() ), actionCollection(), "file_sync" ); 1924 SLOT( save() ), actionCollection(), "file_sync" );
1925 1925
1926 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1926 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1927 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1927 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1928 1928
1929 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1929 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1930 this, SLOT( mailVCard() ), 1930 this, SLOT( mailVCard() ),
1931 actionCollection(), "file_mail_vcard"); 1931 actionCollection(), "file_mail_vcard");
1932 1932
1933 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1933 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1934 SLOT( export2phone() ), actionCollection(), 1934 SLOT( export2phone() ), actionCollection(),
1935 "kaddressbook_ex2phone" ); 1935 "kaddressbook_ex2phone" );
1936 1936
1937 mActionBeamVCard = 0; 1937 mActionBeamVCard = 0;
1938 mActionBeam = 0; 1938 mActionBeam = 0;
1939 1939
1940#ifndef DESKTOP_VERSION 1940#ifndef DESKTOP_VERSION
1941 if ( Ir::supported() ) { 1941 if ( Ir::supported() ) {
1942 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1942 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1943 SLOT( beamVCard() ), actionCollection(), 1943 SLOT( beamVCard() ), actionCollection(),
1944 "kaddressbook_beam_vcard" ); 1944 "kaddressbook_beam_vcard" );
1945 1945
1946 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1946 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1947 SLOT( beamMySelf() ), actionCollection(), 1947 SLOT( beamMySelf() ), actionCollection(),
1948 "kaddressbook_beam_myself" ); 1948 "kaddressbook_beam_myself" );
1949 } 1949 }
1950#endif 1950#endif
1951 1951
1952 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1952 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1953 this, SLOT( editContact2() ), 1953 this, SLOT( editContact2() ),
1954 actionCollection(), "file_properties" ); 1954 actionCollection(), "file_properties" );
1955 1955
1956#ifdef KAB_EMBEDDED 1956#ifdef KAB_EMBEDDED
1957 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1957 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1958 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1958 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1959 mMainWindow, SLOT( exit() ), 1959 mMainWindow, SLOT( exit() ),
1960 actionCollection(), "quit" ); 1960 actionCollection(), "quit" );
1961#endif //KAB_EMBEDDED 1961#endif //KAB_EMBEDDED
1962 1962
1963 // edit menu 1963 // edit menu
1964 if ( mIsPart ) { 1964 if ( mIsPart ) {
1965 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1965 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1966 SLOT( copyContacts() ), actionCollection(), 1966 SLOT( copyContacts() ), actionCollection(),
1967 "kaddressbook_copy" ); 1967 "kaddressbook_copy" );
1968 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1968 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1969 SLOT( cutContacts() ), actionCollection(), 1969 SLOT( cutContacts() ), actionCollection(),
1970 "kaddressbook_cut" ); 1970 "kaddressbook_cut" );
1971 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1971 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1972 SLOT( pasteContacts() ), actionCollection(), 1972 SLOT( pasteContacts() ), actionCollection(),
1973 "kaddressbook_paste" ); 1973 "kaddressbook_paste" );
1974 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1974 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1975 SLOT( selectAllContacts() ), actionCollection(), 1975 SLOT( selectAllContacts() ), actionCollection(),
1976 "kaddressbook_select_all" ); 1976 "kaddressbook_select_all" );
1977 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1977 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1978 SLOT( undo() ), actionCollection(), 1978 SLOT( undo() ), actionCollection(),
1979 "kaddressbook_undo" ); 1979 "kaddressbook_undo" );
1980 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1980 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1981 this, SLOT( redo() ), actionCollection(), 1981 this, SLOT( redo() ), actionCollection(),
1982 "kaddressbook_redo" ); 1982 "kaddressbook_redo" );
1983 } else { 1983 } else {
1984 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1984 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1985 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1985 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1986 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1986 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1987 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1987 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1988 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1988 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1989 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1989 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1990 } 1990 }
1991 1991
1992 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1992 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1993 Key_Delete, this, SLOT( deleteContacts() ), 1993 Key_Delete, this, SLOT( deleteContacts() ),
1994 actionCollection(), "edit_delete" ); 1994 actionCollection(), "edit_delete" );
1995 1995
1996 mActionUndo->setEnabled( false ); 1996 mActionUndo->setEnabled( false );
1997 mActionRedo->setEnabled( false ); 1997 mActionRedo->setEnabled( false );
1998 1998
1999 // settings menu 1999 // settings menu
2000#ifdef KAB_EMBEDDED 2000#ifdef KAB_EMBEDDED
2001//US special menuentry to configure the addressbook resources. On KDE 2001//US special menuentry to configure the addressbook resources. On KDE
2002// you do that through the control center !!! 2002// you do that through the control center !!!
2003 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2003 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2004 SLOT( configureResources() ), actionCollection(), 2004 SLOT( configureResources() ), actionCollection(),
2005 "kaddressbook_configure_resources" ); 2005 "kaddressbook_configure_resources" );
2006#endif //KAB_EMBEDDED 2006#endif //KAB_EMBEDDED
2007 2007
2008 if ( mIsPart ) { 2008 if ( mIsPart ) {
2009 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2009 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2010 SLOT( openConfigDialog() ), actionCollection(), 2010 SLOT( openConfigDialog() ), actionCollection(),
2011 "kaddressbook_configure" ); 2011 "kaddressbook_configure" );
2012 2012
2013 //US not implemented yet 2013 //US not implemented yet
2014 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2014 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2015 // this, SLOT( configureKeyBindings() ), actionCollection(), 2015 // this, SLOT( configureKeyBindings() ), actionCollection(),
2016 // "kaddressbook_configure_shortcuts" ); 2016 // "kaddressbook_configure_shortcuts" );
2017#ifdef KAB_EMBEDDED 2017#ifdef KAB_EMBEDDED
2018 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2018 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2019 mActionConfigureToolbars->setEnabled( false ); 2019 mActionConfigureToolbars->setEnabled( false );
2020#endif //KAB_EMBEDDED 2020#endif //KAB_EMBEDDED
2021 2021
2022 } else { 2022 } else {
2023 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 2023 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
2024 2024
2025 //US not implemented yet 2025 //US not implemented yet
2026 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 2026 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
2027 } 2027 }
2028 2028
2029 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2029 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2030 actionCollection(), "options_show_jump_bar" ); 2030 actionCollection(), "options_show_jump_bar" );
2031 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2031 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2032 2032
2033 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2033 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2034 actionCollection(), "options_show_details" ); 2034 actionCollection(), "options_show_details" );
2035 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2035 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2036 2036
2037 2037
2038 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2038 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2039 SLOT( toggleBeamReceive() ), actionCollection(), 2039 SLOT( toggleBeamReceive() ), actionCollection(),
2040 "kaddressbook_beam_rec" ); 2040 "kaddressbook_beam_rec" );
2041 2041
2042 2042
2043 // misc 2043 // misc
2044 // only enable LDAP lookup if we can handle the protocol 2044 // only enable LDAP lookup if we can handle the protocol
2045#ifndef KAB_EMBEDDED 2045#ifndef KAB_EMBEDDED
2046 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2046 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2047 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2047 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2048 this, SLOT( openLDAPDialog() ), actionCollection(), 2048 this, SLOT( openLDAPDialog() ), actionCollection(),
2049 "ldap_lookup" ); 2049 "ldap_lookup" );
2050 } 2050 }
2051#else //KAB_EMBEDDED 2051#else //KAB_EMBEDDED
2052 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2052 //qDebug("KABCore::initActions() LDAP has to be implemented");
2053#endif //KAB_EMBEDDED 2053#endif //KAB_EMBEDDED
2054 2054
2055 2055
2056 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2056 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2057 SLOT( setWhoAmI() ), actionCollection(), 2057 SLOT( setWhoAmI() ), actionCollection(),
2058 "set_personal" ); 2058 "set_personal" );
2059 2059
2060 2060
2061 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2061 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2062 SLOT( setCategories() ), actionCollection(), 2062 SLOT( setCategories() ), actionCollection(),
2063 "edit_set_categories" ); 2063 "edit_set_categories" );
2064 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2064 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2065 SLOT( editCategories() ), actionCollection(), 2065 SLOT( editCategories() ), actionCollection(),
2066 "edit__categories" ); 2066 "edit__categories" );
2067 2067
2068 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2068 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2069 SLOT( removeVoice() ), actionCollection(), 2069 SLOT( removeVoice() ), actionCollection(),
2070 "remove_voice" ); 2070 "remove_voice" );
2071 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2071 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2072 SLOT( setFormattedName() ), actionCollection(), 2072 SLOT( setFormattedName() ), actionCollection(),
2073 "set_formatted" ); 2073 "set_formatted" );
2074 2074
2075 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2075 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2076 SLOT( manageCategories() ), actionCollection(), 2076 SLOT( manageCategories() ), actionCollection(),
2077 "remove_voice" ); 2077 "remove_voice" );
2078 2078
2079 2079
2080 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2080 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2081 SLOT( importFromOL() ), actionCollection(), 2081 SLOT( importFromOL() ), actionCollection(),
2082 "import_OL" ); 2082 "import_OL" );
2083#ifdef KAB_EMBEDDED 2083#ifdef KAB_EMBEDDED
2084 mActionLicence = new KAction( i18n( "Licence" ), 0, 2084 mActionLicence = new KAction( i18n( "Licence" ), 0,
2085 this, SLOT( showLicence() ), actionCollection(), 2085 this, SLOT( showLicence() ), actionCollection(),
2086 "licence_about_data" ); 2086 "licence_about_data" );
2087 mActionFaq = new KAction( i18n( "Faq" ), 0, 2087 mActionFaq = new KAction( i18n( "Faq" ), 0,
2088 this, SLOT( faq() ), actionCollection(), 2088 this, SLOT( faq() ), actionCollection(),
2089 "faq_about_data" ); 2089 "faq_about_data" );
2090 mActionWN = new KAction( i18n( "What's New?" ), 0, 2090 mActionWN = new KAction( i18n( "What's New?" ), 0,
2091 this, SLOT( whatsnew() ), actionCollection(), 2091 this, SLOT( whatsnew() ), actionCollection(),
2092 "wn" ); 2092 "wn" );
2093 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2093 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2094 this, SLOT( synchowto() ), actionCollection(), 2094 this, SLOT( synchowto() ), actionCollection(),
2095 "sync" ); 2095 "sync" );
2096 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2096 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2097 this, SLOT( kdesynchowto() ), actionCollection(), 2097 this, SLOT( kdesynchowto() ), actionCollection(),
2098 "kdesync" ); 2098 "kdesync" );
2099 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2099 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2100 this, SLOT( multisynchowto() ), actionCollection(), 2100 this, SLOT( multisynchowto() ), actionCollection(),
2101 "multisync" ); 2101 "multisync" );
2102 2102
2103 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2103 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2104 this, SLOT( createAboutData() ), actionCollection(), 2104 this, SLOT( createAboutData() ), actionCollection(),
2105 "kaddressbook_about_data" ); 2105 "kaddressbook_about_data" );
2106#endif //KAB_EMBEDDED 2106#endif //KAB_EMBEDDED
2107 2107
2108 clipboardDataChanged(); 2108 clipboardDataChanged();
2109 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2109 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2110 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2110 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2111} 2111}
2112 2112
2113//US we need this function, to plug all actions into the correct menues. 2113//US we need this function, to plug all actions into the correct menues.
2114// KDE uses a XML format to plug the actions, but we work her without this overhead. 2114// KDE uses a XML format to plug the actions, but we work her without this overhead.
2115void KABCore::addActionsManually() 2115void KABCore::addActionsManually()
2116{ 2116{
2117//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2117//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2118 2118
2119#ifdef KAB_EMBEDDED 2119#ifdef KAB_EMBEDDED
2120 QPopupMenu *fileMenu = new QPopupMenu( this ); 2120 QPopupMenu *fileMenu = new QPopupMenu( this );
2121 QPopupMenu *editMenu = new QPopupMenu( this ); 2121 QPopupMenu *editMenu = new QPopupMenu( this );
2122 QPopupMenu *helpMenu = new QPopupMenu( this ); 2122 QPopupMenu *helpMenu = new QPopupMenu( this );
2123 2123
2124 KToolBar* tb = mMainWindow->toolBar(); 2124 KToolBar* tb = mMainWindow->toolBar();
2125 2125
2126#ifndef DESKTOP_VERSION 2126#ifndef DESKTOP_VERSION
2127 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2127 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2128#endif 2128#endif
2129 QMenuBar* mb = mMainWindow->menuBar(); 2129 QMenuBar* mb = mMainWindow->menuBar();
2130 2130
2131 //US setup menubar. 2131 //US setup menubar.
2132 //Disable the following block if you do not want to have a menubar. 2132 //Disable the following block if you do not want to have a menubar.
2133 mb->insertItem( i18n("&File"), fileMenu ); 2133 mb->insertItem( i18n("&File"), fileMenu );
2134 mb->insertItem( i18n("&Edit"), editMenu ); 2134 mb->insertItem( i18n("&Edit"), editMenu );
2135 mb->insertItem( i18n("&View"), viewMenu ); 2135 mb->insertItem( i18n("&View"), viewMenu );
2136 mb->insertItem( i18n("&Settings"), settingsMenu ); 2136 mb->insertItem( i18n("&Settings"), settingsMenu );
2137#ifdef DESKTOP_VERSION 2137#ifdef DESKTOP_VERSION
2138 mb->insertItem( i18n("Synchronize"), syncMenu ); 2138 mb->insertItem( i18n("Synchronize"), syncMenu );
2139#else 2139#else
2140 mb->insertItem( i18n("Sync"), syncMenu ); 2140 mb->insertItem( i18n("Sync"), syncMenu );
2141#endif 2141#endif
2142 //mb->insertItem( i18n("&Change"), changeMenu ); 2142 //mb->insertItem( i18n("&Change"), changeMenu );
2143 mb->insertItem( i18n("&Help"), helpMenu ); 2143 mb->insertItem( i18n("&Help"), helpMenu );
2144 mIncSearchWidget = new IncSearchWidget( tb ); 2144 mIncSearchWidget = new IncSearchWidget( tb );
2145 // tb->insertWidget(-1, 0, mIncSearchWidget); 2145 // tb->insertWidget(-1, 0, mIncSearchWidget);
2146#ifndef DESKTOP_VERSION 2146#ifndef DESKTOP_VERSION
2147 } else { 2147 } else {
2148 //US setup toolbar 2148 //US setup toolbar
2149 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2149 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2150 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2150 QPopupMenu *popupBarTB = new QPopupMenu( this );
2151 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2151 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2152 tb->insertWidget(-1, 0, menuBarTB); 2152 tb->insertWidget(-1, 0, menuBarTB);
2153 mIncSearchWidget = new IncSearchWidget( tb ); 2153 mIncSearchWidget = new IncSearchWidget( tb );
2154 tb->enableMoving(false); 2154 tb->enableMoving(false);
2155 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2155 popupBarTB->insertItem( i18n("&File"), fileMenu );
2156 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2156 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2157 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2157 popupBarTB->insertItem( i18n("&View"), viewMenu );
2158 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2158 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2159 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2159 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2160 mViewManager->getFilterAction()->plug ( popupBarTB); 2160 mViewManager->getFilterAction()->plug ( popupBarTB);
2161 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2161 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2162 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2162 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2163 if (QApplication::desktop()->width() > 320 ) { 2163 if (QApplication::desktop()->width() > 320 ) {
2164 // mViewManager->getFilterAction()->plug ( tb); 2164 // mViewManager->getFilterAction()->plug ( tb);
2165 } 2165 }
2166 } 2166 }
2167#endif 2167#endif
2168 // mActionQuit->plug ( mMainWindow->toolBar()); 2168 // mActionQuit->plug ( mMainWindow->toolBar());
2169 2169
2170 2170
2171 2171
2172 //US Now connect the actions with the menue entries. 2172 //US Now connect the actions with the menue entries.
2173#ifdef DESKTOP_VERSION 2173#ifdef DESKTOP_VERSION
2174 mActionPrint->plug( fileMenu ); 2174 mActionPrint->plug( fileMenu );
2175 mActionPrintDetails->plug( fileMenu ); 2175 mActionPrintDetails->plug( fileMenu );
2176 fileMenu->insertSeparator(); 2176 fileMenu->insertSeparator();
2177#endif 2177#endif
2178 mActionMail->plug( fileMenu ); 2178 mActionMail->plug( fileMenu );
2179 fileMenu->insertSeparator(); 2179 fileMenu->insertSeparator();
2180 2180
2181 mActionNewContact->plug( fileMenu ); 2181 mActionNewContact->plug( fileMenu );
2182 mActionNewContact->plug( tb ); 2182 mActionNewContact->plug( tb );
2183 2183
2184 mActionEditAddressee->plug( fileMenu ); 2184 mActionEditAddressee->plug( fileMenu );
2185 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2185 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2186 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2186 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2187 mActionEditAddressee->plug( tb ); 2187 mActionEditAddressee->plug( tb );
2188 2188
2189 fileMenu->insertSeparator(); 2189 fileMenu->insertSeparator();
2190 mActionSave->plug( fileMenu ); 2190 mActionSave->plug( fileMenu );
2191 fileMenu->insertItem( "&Import", ImportMenu ); 2191 fileMenu->insertItem( "&Import", ImportMenu );
2192 fileMenu->insertItem( "&Export", ExportMenu ); 2192 fileMenu->insertItem( "&Export", ExportMenu );
2193 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2193 fileMenu->insertItem( i18n("&Change"), changeMenu );
2194#ifndef DESKTOP_VERSION 2194#ifndef DESKTOP_VERSION
2195 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2195 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2196#endif 2196#endif
2197#if 0 2197#if 0
2198 // PENDING fix MailVCard 2198 // PENDING fix MailVCard
2199 fileMenu->insertSeparator(); 2199 fileMenu->insertSeparator();
2200 mActionMailVCard->plug( fileMenu ); 2200 mActionMailVCard->plug( fileMenu );
2201#endif 2201#endif
2202#ifndef DESKTOP_VERSION 2202#ifndef DESKTOP_VERSION
2203 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2203 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2204 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2204 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2205 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2205 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2206#endif 2206#endif
2207 fileMenu->insertSeparator(); 2207 fileMenu->insertSeparator();
2208 mActionQuit->plug( fileMenu ); 2208 mActionQuit->plug( fileMenu );
2209#ifdef _OL_IMPORT_ 2209#ifdef _OL_IMPORT_
2210 mActionImportOL->plug( ImportMenu ); 2210 mActionImportOL->plug( ImportMenu );
2211#endif 2211#endif
2212 // edit menu 2212 // edit menu
2213 mActionUndo->plug( editMenu ); 2213 mActionUndo->plug( editMenu );
2214 mActionRedo->plug( editMenu ); 2214 mActionRedo->plug( editMenu );
2215 editMenu->insertSeparator(); 2215 editMenu->insertSeparator();
2216 mActionCut->plug( editMenu ); 2216 mActionCut->plug( editMenu );
2217 mActionCopy->plug( editMenu ); 2217 mActionCopy->plug( editMenu );
2218 mActionPaste->plug( editMenu ); 2218 mActionPaste->plug( editMenu );
2219 mActionDelete->plug( editMenu ); 2219 mActionDelete->plug( editMenu );
2220 editMenu->insertSeparator(); 2220 editMenu->insertSeparator();
2221 mActionSelectAll->plug( editMenu ); 2221 mActionSelectAll->plug( editMenu );
2222 2222
2223 mActionSetFormattedName->plug( changeMenu ); 2223 mActionSetFormattedName->plug( changeMenu );
2224 mActionRemoveVoice->plug( changeMenu ); 2224 mActionRemoveVoice->plug( changeMenu );
2225 // settingsmings menu 2225 // settingsmings menu
2226//US special menuentry to configure the addressbook resources. On KDE 2226//US special menuentry to configure the addressbook resources. On KDE
2227// you do that through the control center !!! 2227// you do that through the control center !!!
2228 // settingsMenu->insertSeparator(); 2228 // settingsMenu->insertSeparator();
2229 2229
2230 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2230 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2231 mActionConfigResources->plug( settingsMenu,1 ); 2231 mActionConfigResources->plug( settingsMenu,1 );
2232 settingsMenu->insertSeparator(2); 2232 settingsMenu->insertSeparator(2);
2233 2233
2234 if ( mIsPart ) { 2234 if ( mIsPart ) {
2235 //US not implemented yet 2235 //US not implemented yet
2236 //mActionConfigShortcuts->plug( settingsMenu ); 2236 //mActionConfigShortcuts->plug( settingsMenu );
2237 //mActionConfigureToolbars->plug( settingsMenu ); 2237 //mActionConfigureToolbars->plug( settingsMenu );
2238 2238
2239 } else { 2239 } else {
2240 //US not implemented yet 2240 //US not implemented yet
2241 //mActionKeyBindings->plug( settingsMenu ); 2241 //mActionKeyBindings->plug( settingsMenu );
2242 } 2242 }
2243 2243
2244 settingsMenu->insertSeparator(); 2244 settingsMenu->insertSeparator();
2245 2245
2246 mActionJumpBar->plug( settingsMenu ); 2246 mActionJumpBar->plug( settingsMenu );
2247 mActionDetails->plug( settingsMenu ); 2247 mActionDetails->plug( settingsMenu );
2248 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2248 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2249 mActionDetails->plug( tb ); 2249 mActionDetails->plug( tb );
2250 settingsMenu->insertSeparator(); 2250 settingsMenu->insertSeparator();
2251#ifndef DESKTOP_VERSION 2251#ifndef DESKTOP_VERSION
2252 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2252 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2253 settingsMenu->insertSeparator(); 2253 settingsMenu->insertSeparator();
2254#endif 2254#endif
2255 2255
2256 mActionWhoAmI->plug( settingsMenu ); 2256 mActionWhoAmI->plug( settingsMenu );
2257 mActionEditCategories->plug( settingsMenu ); 2257 mActionEditCategories->plug( settingsMenu );
2258 mActionEditCategories->plug( changeMenu ); 2258 mActionEditCategories->plug( changeMenu );
2259 mActionCategories->plug( changeMenu ); 2259 mActionCategories->plug( changeMenu );
2260 mActionManageCategories->plug( changeMenu ); 2260 mActionManageCategories->plug( changeMenu );
2261 2261
2262 mActionCategories->plug( settingsMenu ); 2262 mActionCategories->plug( settingsMenu );
2263 mActionManageCategories->plug( settingsMenu ); 2263 mActionManageCategories->plug( settingsMenu );
2264 2264
2265 2265
2266 mActionWN->plug( helpMenu ); 2266 mActionWN->plug( helpMenu );
2267 mActionSyncHowto->plug( helpMenu ); 2267 mActionSyncHowto->plug( helpMenu );
2268 mActionKdeSyncHowto->plug( helpMenu ); 2268 mActionKdeSyncHowto->plug( helpMenu );
2269 mActionMultiSyncHowto->plug( helpMenu ); 2269 mActionMultiSyncHowto->plug( helpMenu );
2270 mActionFaq->plug( helpMenu ); 2270 mActionFaq->plug( helpMenu );
2271 mActionLicence->plug( helpMenu ); 2271 mActionLicence->plug( helpMenu );
2272 mActionAboutKAddressbook->plug( helpMenu ); 2272 mActionAboutKAddressbook->plug( helpMenu );
2273 2273
2274 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2274 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2275 2275
2276 mActionSave->plug( tb ); 2276 mActionSave->plug( tb );
2277 mViewManager->getFilterAction()->plug ( tb); 2277 mViewManager->getFilterAction()->plug ( tb);
2278 //LR hide filteraction on started in 480x640 2278 //LR hide filteraction on started in 480x640
2279 if (QApplication::desktop()->width() == 480 ) { 2279 if (QApplication::desktop()->width() == 480 ) {
2280 mViewManager->getFilterAction()->setComboWidth( 0 ); 2280 mViewManager->getFilterAction()->setComboWidth( 0 );
2281 } 2281 }
2282 mActionUndo->plug( tb ); 2282 mActionUndo->plug( tb );
2283 mActionDelete->plug( tb ); 2283 mActionDelete->plug( tb );
2284 mActionRedo->plug( tb ); 2284 mActionRedo->plug( tb );
2285 } else { 2285 } else {
2286 mActionSave->plug( tb ); 2286 mActionSave->plug( tb );
2287 tb->enableMoving(false); 2287 tb->enableMoving(false);
2288 } 2288 }
2289 //mActionQuit->plug ( tb ); 2289 //mActionQuit->plug ( tb );
2290 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2290 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2291 2291
2292 //US link the searchwidget first to this. 2292 //US link the searchwidget first to this.
2293 // The real linkage to the toolbar happens later. 2293 // The real linkage to the toolbar happens later.
2294//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2294//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2295//US tb->insertItem( mIncSearchWidget ); 2295//US tb->insertItem( mIncSearchWidget );
2296/*US 2296/*US
2297 mIncSearchWidget = new IncSearchWidget( tb ); 2297 mIncSearchWidget = new IncSearchWidget( tb );
2298 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2298 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2299 SLOT( incrementalSearch( const QString& ) ) ); 2299 SLOT( incrementalSearch( const QString& ) ) );
2300 2300
2301 mJumpButtonBar = new JumpButtonBar( this, this ); 2301 mJumpButtonBar = new JumpButtonBar( this, this );
2302 2302
2303//US topLayout->addWidget( mJumpButtonBar ); 2303//US topLayout->addWidget( mJumpButtonBar );
2304 this->layout()->add( mJumpButtonBar ); 2304 this->layout()->add( mJumpButtonBar );
2305*/ 2305*/
2306 2306
2307#endif //KAB_EMBEDDED 2307#endif //KAB_EMBEDDED
2308 2308
2309 mActionExport2phone->plug( ExportMenu ); 2309 mActionExport2phone->plug( ExportMenu );
2310 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2310 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2311 syncManager->fillSyncMenu(); 2311 syncManager->fillSyncMenu();
2312 2312
2313} 2313}
2314void KABCore::showLicence() 2314void KABCore::showLicence()
2315{ 2315{
2316 KApplication::showLicence(); 2316 KApplication::showLicence();
2317} 2317}
2318 2318
2319void KABCore::manageCategories( ) 2319void KABCore::manageCategories( )
2320{ 2320{
2321 KABCatPrefs* cp = new KABCatPrefs(); 2321 KABCatPrefs* cp = new KABCatPrefs();
2322 cp->show(); 2322 cp->show();
2323 int w =cp->sizeHint().width() ; 2323 int w =cp->sizeHint().width() ;
2324 int h = cp->sizeHint().height() ; 2324 int h = cp->sizeHint().height() ;
2325 int dw = QApplication::desktop()->width(); 2325 int dw = QApplication::desktop()->width();
2326 int dh = QApplication::desktop()->height(); 2326 int dh = QApplication::desktop()->height();
2327 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2327 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2328 if ( !cp->exec() ) { 2328 if ( !cp->exec() ) {
2329 delete cp; 2329 delete cp;
2330 return; 2330 return;
2331 } 2331 }
2332 int count = 0; 2332 int count = 0;
2333 int cc = 0; 2333 int cc = 0;
2334 message( i18n("Please wait, processing categories...")); 2334 message( i18n("Please wait, processing categories..."));
2335 if ( cp->addCat() ) { 2335 if ( cp->addCat() ) {
2336 KABC::AddressBook::Iterator it; 2336 KABC::AddressBook::Iterator it;
2337 QStringList catList = KABPrefs::instance()->mCustomCategories; 2337 QStringList catList = KABPrefs::instance()->mCustomCategories;
2338 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2338 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2339 ++cc; 2339 ++cc;
2340 if ( cc %10 == 0) 2340 if ( cc %10 == 0)
2341 message(i18n("Processing contact #%1").arg(cc)); 2341 message(i18n("Processing contact #%1").arg(cc));
2342 QStringList catIncList = (*it).categories(); 2342 QStringList catIncList = (*it).categories();
2343 int i; 2343 int i;
2344 for( i = 0; i< catIncList.count(); ++i ) { 2344 for( i = 0; i< catIncList.count(); ++i ) {
2345 if ( !catList.contains (catIncList[i])) { 2345 if ( !catList.contains (catIncList[i])) {
2346 catList.append( catIncList[i] ); 2346 catList.append( catIncList[i] );
2347 //qDebug("add cat %s ", catIncList[i].latin1()); 2347 //qDebug("add cat %s ", catIncList[i].latin1());
2348 ++count; 2348 ++count;
2349 } 2349 }
2350 } 2350 }
2351 } 2351 }
2352 catList.sort(); 2352 catList.sort();
2353 KABPrefs::instance()->mCustomCategories = catList; 2353 KABPrefs::instance()->mCustomCategories = catList;
2354 KABPrefs::instance()->writeConfig(); 2354 KABPrefs::instance()->writeConfig();
2355 message(QString::number( count )+ i18n(" categories added to list! ")); 2355 message(QString::number( count )+ i18n(" categories added to list! "));
2356 } else { 2356 } else {
2357 QStringList catList = KABPrefs::instance()->mCustomCategories; 2357 QStringList catList = KABPrefs::instance()->mCustomCategories;
2358 QStringList catIncList; 2358 QStringList catIncList;
2359 QStringList newCatList; 2359 QStringList newCatList;
2360 KABC::AddressBook::Iterator it; 2360 KABC::AddressBook::Iterator it;
2361 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2361 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2362 ++cc; 2362 ++cc;
2363 if ( cc %10 == 0) 2363 if ( cc %10 == 0)
2364 message(i18n("Processing contact #%1").arg(cc)); 2364 message(i18n("Processing contact #%1").arg(cc));
2365 QStringList catIncList = (*it).categories(); 2365 QStringList catIncList = (*it).categories();
2366 int i; 2366 int i;
2367 if ( catIncList.count() ) { 2367 if ( catIncList.count() ) {
2368 newCatList.clear(); 2368 newCatList.clear();
2369 for( i = 0; i< catIncList.count(); ++i ) { 2369 for( i = 0; i< catIncList.count(); ++i ) {
2370 if ( catList.contains (catIncList[i])) { 2370 if ( catList.contains (catIncList[i])) {
2371 newCatList.append( catIncList[i] ); 2371 newCatList.append( catIncList[i] );
2372 } 2372 }
2373 } 2373 }
2374 newCatList.sort(); 2374 newCatList.sort();
2375 (*it).setCategories( newCatList ); 2375 (*it).setCategories( newCatList );
2376 mAddressBook->insertAddressee( (*it) ); 2376 mAddressBook->insertAddressee( (*it) );
2377 } 2377 }
2378 } 2378 }
2379 setModified( true ); 2379 setModified( true );
2380 mViewManager->refreshView(); 2380 mViewManager->refreshView();
2381 message( i18n("Removing categories done!")); 2381 message( i18n("Removing categories done!"));
2382 } 2382 }
2383 delete cp; 2383 delete cp;
2384} 2384}
2385void KABCore::removeVoice() 2385void KABCore::removeVoice()
2386{ 2386{
2387 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 ) 2387 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 )
2388 return; 2388 return;
2389 XXPortSelectDialog dlg( this, false, this ); 2389 XXPortSelectDialog dlg( this, false, this );
2390 if ( !dlg.exec() ) 2390 if ( !dlg.exec() )
2391 return; 2391 return;
2392 mAddressBook->setUntagged(); 2392 mAddressBook->setUntagged();
2393 dlg.tagSelected(); 2393 dlg.tagSelected();
2394 message(i18n("Removing voice..."), false ); 2394 message(i18n("Removing voice..."), false );
2395 KABC::AddressBook::Iterator it; 2395 KABC::AddressBook::Iterator it;
2396 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2396 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2397 if ( (*it).tagged() ) { 2397 if ( (*it).tagged() ) {
2398 (*it).removeVoice(); 2398 (*it).removeVoice();
2399 } 2399 }
2400 } 2400 }
2401 message(i18n("Refreshing view...") ); 2401 message(i18n("Refreshing view...") );
2402 qApp->processEvents(); 2402 qApp->processEvents();
2403 mViewManager->refreshView( "" ); 2403 mViewManager->refreshView( "" );
2404 Addressee add; 2404 Addressee add;
2405 mDetails->setAddressee( add ); 2405 mDetails->setAddressee( add );
2406 message(i18n("Remove voice completed!") ); 2406 message(i18n("Remove voice completed!") );
2407 2407
2408 2408
2409 2409
2410} 2410}
2411 2411
2412void KABCore::setFormattedName() 2412void KABCore::setFormattedName()
2413{ 2413{
2414 KABFormatPrefs setpref; 2414 KABFormatPrefs setpref;
2415 if ( !setpref.exec() ) { 2415 if ( !setpref.exec() ) {
2416 return; 2416 return;
2417 } 2417 }
2418 XXPortSelectDialog dlg( this, false, this ); 2418 XXPortSelectDialog dlg( this, false, this );
2419 if ( !dlg.exec() ) 2419 if ( !dlg.exec() )
2420 return; 2420 return;
2421 mAddressBook->setUntagged(); 2421 mAddressBook->setUntagged();
2422 dlg.tagSelected(); 2422 dlg.tagSelected();
2423 int count = 0; 2423 int count = 0;
2424 KABC::AddressBook::Iterator it; 2424 KABC::AddressBook::Iterator it;
2425 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2425 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2426 if ( (*it).tagged() ) { 2426 if ( (*it).tagged() ) {
2427 ++count; 2427 ++count;
2428 if ( count %10 == 0 ) 2428 if ( count %10 == 0 )
2429 message(i18n("Changing contact #%1").arg( count ) ); 2429 message(i18n("Changing contact #%1").arg( count ) );
2430 qApp->processEvents(); 2430 qApp->processEvents();
2431 QString fName; 2431 QString fName;
2432 if ( setpref.simple->isChecked() ) 2432 if ( setpref.simple->isChecked() )
2433 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2433 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2434 else if ( setpref.full->isChecked() ) 2434 else if ( setpref.full->isChecked() )
2435 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2435 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2436 else if ( setpref.reverse->isChecked() ) 2436 else if ( setpref.reverse->isChecked() )
2437 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2437 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2438 else 2438 else
2439 fName = (*it).organization(); 2439 fName = (*it).organization();
2440 if ( setpref.setCompany->isChecked() ) 2440 if ( setpref.setCompany->isChecked() )
2441 if ( fName.isEmpty() || fName =="," ) 2441 if ( fName.isEmpty() || fName =="," )
2442 fName = (*it).organization(); 2442 fName = (*it).organization();
2443 (*it).setFormattedName( fName ); 2443 (*it).setFormattedName( fName );
2444 } 2444 }
2445 } 2445 }
2446 message(i18n("Refreshing view...") ); 2446 message(i18n("Refreshing view...") );
2447 qApp->processEvents(); 2447 qApp->processEvents();
2448 mViewManager->refreshView( "" ); 2448 mViewManager->refreshView( "" );
2449 Addressee add; 2449 Addressee add;
2450 mDetails->setAddressee( add ); 2450 mDetails->setAddressee( add );
2451 message(i18n("Setting formatted name completed!") ); 2451 message(i18n("Setting formatted name completed!") );
2452} 2452}
2453 2453
2454void KABCore::clipboardDataChanged() 2454void KABCore::clipboardDataChanged()
2455{ 2455{
2456 2456
2457 if ( mReadWrite ) 2457 if ( mReadWrite )
2458 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2458 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2459 2459
2460} 2460}
2461 2461
2462void KABCore::updateActionMenu() 2462void KABCore::updateActionMenu()
2463{ 2463{
2464 UndoStack *undo = UndoStack::instance(); 2464 UndoStack *undo = UndoStack::instance();
2465 RedoStack *redo = RedoStack::instance(); 2465 RedoStack *redo = RedoStack::instance();
2466 2466
2467 if ( undo->isEmpty() ) 2467 if ( undo->isEmpty() )
2468 mActionUndo->setText( i18n( "Undo" ) ); 2468 mActionUndo->setText( i18n( "Undo" ) );
2469 else 2469 else
2470 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2470 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2471 2471
2472 mActionUndo->setEnabled( !undo->isEmpty() ); 2472 mActionUndo->setEnabled( !undo->isEmpty() );
2473 2473
2474 if ( !redo->top() ) 2474 if ( !redo->top() )
2475 mActionRedo->setText( i18n( "Redo" ) ); 2475 mActionRedo->setText( i18n( "Redo" ) );
2476 else 2476 else
2477 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2477 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2478 2478
2479 mActionRedo->setEnabled( !redo->isEmpty() ); 2479 mActionRedo->setEnabled( !redo->isEmpty() );
2480} 2480}
2481 2481
2482void KABCore::configureKeyBindings() 2482void KABCore::configureKeyBindings()
2483{ 2483{
2484#ifndef KAB_EMBEDDED 2484#ifndef KAB_EMBEDDED
2485 KKeyDialog::configure( actionCollection(), true ); 2485 KKeyDialog::configure( actionCollection(), true );
2486#else //KAB_EMBEDDED 2486#else //KAB_EMBEDDED
2487 qDebug("KABCore::configureKeyBindings() not implemented"); 2487 qDebug("KABCore::configureKeyBindings() not implemented");
2488#endif //KAB_EMBEDDED 2488#endif //KAB_EMBEDDED
2489} 2489}
2490 2490
2491#ifdef KAB_EMBEDDED 2491#ifdef KAB_EMBEDDED
2492void KABCore::configureResources() 2492void KABCore::configureResources()
2493{ 2493{
2494 KRES::KCMKResources dlg( this, "" , 0 ); 2494 KRES::KCMKResources dlg( this, "" , 0 );
2495 2495
2496 if ( !dlg.exec() ) 2496 if ( !dlg.exec() )
2497 return; 2497 return;
2498 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2498 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2499} 2499}
2500#endif //KAB_EMBEDDED 2500#endif //KAB_EMBEDDED
2501 2501
2502 2502
2503/* this method will be called through the QCop interface from Ko/Pi to select addresses 2503/* this method will be called through the QCop interface from Ko/Pi to select addresses
2504 * for the attendees list of an event. 2504 * for the attendees list of an event.
2505 */ 2505 */
2506void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2506void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2507{ 2507{
2508 QStringList nameList; 2508 QStringList nameList;
2509 QStringList emailList; 2509 QStringList emailList;
2510 QStringList uidList; 2510 QStringList uidList;
2511 bool ok = false; 2511 bool ok = false;
2512 int wid = uid.toInt( &ok ); 2512 int wid = uid.toInt( &ok );
2513 if ( ok ) { 2513 if ( ok ) {
2514 if ( wid != QApplication::desktop()->width() ) { 2514 if ( wid != QApplication::desktop()->width() ) {
2515 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2515 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2516 message( i18n("Resizing, please wait...") );
2516 raise(); 2517 raise();
2517 qApp->processEvents(); 2518 qApp->processEvents();
2518 } 2519 }
2519 2520
2520 } else { 2521 } else {
2521 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2522 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2522 } 2523 }
2523 2524
2524 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2525 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2525 uint i=0; 2526 uint i=0;
2526 for (i=0; i < list.count(); i++) 2527 for (i=0; i < list.count(); i++)
2527 { 2528 {
2528 nameList.append(list[i].realName()); 2529 nameList.append(list[i].realName());
2529 emailList.append(list[i].preferredEmail()); 2530 emailList.append(list[i].preferredEmail());
2530 uidList.append(list[i].uid()); 2531 uidList.append(list[i].uid());
2531 } 2532 }
2532 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2533 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2533 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2534 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2534 2535
2535} 2536}
2536 2537
2537/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2538/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2538 * to put them into the calendar. 2539 * to put them into the calendar.
2539 */ 2540 */
2540void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2541void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2541{ 2542{
2542 // qDebug("KABCore::requestForBirthdayList"); 2543 // qDebug("KABCore::requestForBirthdayList");
2543 QStringList birthdayList; 2544 QStringList birthdayList;
2544 QStringList anniversaryList; 2545 QStringList anniversaryList;
2545 QStringList realNameList; 2546 QStringList realNameList;
2546 QStringList preferredEmailList; 2547 QStringList preferredEmailList;
2547 QStringList assembledNameList; 2548 QStringList assembledNameList;
2548 QStringList uidList; 2549 QStringList uidList;
2549 2550
2550 KABC::AddressBook::Iterator it; 2551 KABC::AddressBook::Iterator it;
2551 2552
2552 int count = 0; 2553 int count = 0;
2553 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2554 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2554 ++count; 2555 ++count;
2555 } 2556 }
2556 QProgressBar bar(count,0 ); 2557 QProgressBar bar(count,0 );
2557 int w = 300; 2558 int w = 300;
2558 if ( QApplication::desktop()->width() < 320 ) 2559 if ( QApplication::desktop()->width() < 320 )
2559 w = 220; 2560 w = 220;
2560 int h = bar.sizeHint().height() ; 2561 int h = bar.sizeHint().height() ;
2561 int dw = QApplication::desktop()->width(); 2562 int dw = QApplication::desktop()->width();
2562 int dh = QApplication::desktop()->height(); 2563 int dh = QApplication::desktop()->height();
2563 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2564 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2564 bar.show(); 2565 bar.show();
2565 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2566 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2566 qApp->processEvents(); 2567 qApp->processEvents();
2567 2568
2568 QDate bday; 2569 QDate bday;
2569 QString anni; 2570 QString anni;
2570 QString formattedbday; 2571 QString formattedbday;
2571 2572
2572 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2573 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2573 { 2574 {
2574 if ( ! bar.isVisible() ) 2575 if ( ! bar.isVisible() )
2575 return; 2576 return;
2576 bar.setProgress( count++ ); 2577 bar.setProgress( count++ );
2577 qApp->processEvents(); 2578 qApp->processEvents();
2578 bday = (*it).birthday().date(); 2579 bday = (*it).birthday().date();
2579 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2580 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2580 2581
2581 if ( bday.isValid() || !anni.isEmpty()) 2582 if ( bday.isValid() || !anni.isEmpty())
2582 { 2583 {
2583 if (bday.isValid()) 2584 if (bday.isValid())
2584 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2585 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2585 else 2586 else
2586 formattedbday = "NOTVALID"; 2587 formattedbday = "NOTVALID";
2587 if (anni.isEmpty()) 2588 if (anni.isEmpty())
2588 anni = "INVALID"; 2589 anni = "INVALID";
2589 2590
2590 birthdayList.append(formattedbday); 2591 birthdayList.append(formattedbday);
2591 anniversaryList.append(anni); //should be ISODate 2592 anniversaryList.append(anni); //should be ISODate
2592 realNameList.append((*it).realName()); 2593 realNameList.append((*it).realName());
2593 preferredEmailList.append((*it).preferredEmail()); 2594 preferredEmailList.append((*it).preferredEmail());
2594 assembledNameList.append((*it).assembledName()); 2595 assembledNameList.append((*it).assembledName());
2595 uidList.append((*it).uid()); 2596 uidList.append((*it).uid());
2596 2597
2597 //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() ); 2598 //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() );
2598 } 2599 }
2599 } 2600 }
2600 2601
2601 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2602 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2602 2603
2603} 2604}
2604 2605
2605/* this method will be called through the QCop interface from other apps to show details of a contact. 2606/* this method will be called through the QCop interface from other apps to show details of a contact.
2606 */ 2607 */
2607void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2608void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2608{ 2609{
2609 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2610 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2610 2611
2611 QString foundUid = QString::null; 2612 QString foundUid = QString::null;
2612 if ( ! uid.isEmpty() ) { 2613 if ( ! uid.isEmpty() ) {
2613 Addressee adrr = mAddressBook->findByUid( uid ); 2614 Addressee adrr = mAddressBook->findByUid( uid );
2614 if ( !adrr.isEmpty() ) { 2615 if ( !adrr.isEmpty() ) {
2615 foundUid = uid; 2616 foundUid = uid;
2616 } 2617 }
2617 if ( email == "sendbacklist" ) { 2618 if ( email == "sendbacklist" ) {
2618 //qDebug("ssssssssssssssssssssssend "); 2619 //qDebug("ssssssssssssssssssssssend ");
2619 QStringList nameList; 2620 QStringList nameList;
2620 QStringList emailList; 2621 QStringList emailList;
2621 QStringList uidList; 2622 QStringList uidList;
2622 nameList.append(adrr.realName()); 2623 nameList.append(adrr.realName());
2623 emailList = adrr.emails(); 2624 emailList = adrr.emails();
2624 uidList.append( adrr.preferredEmail()); 2625 uidList.append( adrr.preferredEmail());
2625 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2626 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2626 return; 2627 return;
2627 } 2628 }
2628 2629
2629 } 2630 }
2630 2631
2631 if ( email == "sendbacklist" ) 2632 if ( email == "sendbacklist" )
2632 return; 2633 return;
2633 if (foundUid.isEmpty()) 2634 if (foundUid.isEmpty())
2634 { 2635 {
2635 //find the uid of the person first 2636 //find the uid of the person first
2636 Addressee::List namelist; 2637 Addressee::List namelist;
2637 Addressee::List emaillist; 2638 Addressee::List emaillist;
2638 2639
2639 if (!name.isEmpty()) 2640 if (!name.isEmpty())
2640 namelist = mAddressBook->findByName( name ); 2641 namelist = mAddressBook->findByName( name );
2641 2642
2642 if (!email.isEmpty()) 2643 if (!email.isEmpty())
2643 emaillist = mAddressBook->findByEmail( email ); 2644 emaillist = mAddressBook->findByEmail( email );
2644 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2645 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2645 //check if we have a match in Namelist and Emaillist 2646 //check if we have a match in Namelist and Emaillist
2646 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2647 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2647 foundUid = emaillist[0].uid(); 2648 foundUid = emaillist[0].uid();
2648 } 2649 }
2649 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2650 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2650 foundUid = namelist[0].uid(); 2651 foundUid = namelist[0].uid();
2651 else 2652 else
2652 { 2653 {
2653 for (int i = 0; i < namelist.count(); i++) 2654 for (int i = 0; i < namelist.count(); i++)
2654 { 2655 {
2655 for (int j = 0; j < emaillist.count(); j++) 2656 for (int j = 0; j < emaillist.count(); j++)
2656 { 2657 {
2657 if (namelist[i] == emaillist[j]) 2658 if (namelist[i] == emaillist[j])
2658 { 2659 {
2659 foundUid = namelist[i].uid(); 2660 foundUid = namelist[i].uid();
2660 } 2661 }
2661 } 2662 }
2662 } 2663 }
2663 } 2664 }
2664 } 2665 }
2665 else 2666 else
2666 { 2667 {
2667 foundUid = uid; 2668 foundUid = uid;
2668 } 2669 }
2669 2670
2670 if (!foundUid.isEmpty()) 2671 if (!foundUid.isEmpty())
2671 { 2672 {
2672 2673
2673 // raise Ka/Pi if it is in the background 2674 // raise Ka/Pi if it is in the background
2674#ifndef DESKTOP_VERSION 2675#ifndef DESKTOP_VERSION
2675#ifndef KORG_NODCOP 2676#ifndef KORG_NODCOP
2676 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2677 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2677#endif 2678#endif
2678#endif 2679#endif
2679 2680
2680 mMainWindow->showMaximized(); 2681 mMainWindow->showMaximized();
2681 mMainWindow-> raise(); 2682 mMainWindow-> raise();
2682 2683
2683 mViewManager->setSelected( "", false); 2684 mViewManager->setSelected( "", false);
2684 mViewManager->refreshView( "" ); 2685 mViewManager->refreshView( "" );
2685 mViewManager->setSelected( foundUid, true ); 2686 mViewManager->setSelected( foundUid, true );
2686 mViewManager->refreshView( foundUid ); 2687 mViewManager->refreshView( foundUid );
2687 2688
2688 if ( !mMultipleViewsAtOnce ) 2689 if ( !mMultipleViewsAtOnce )
2689 { 2690 {
2690 setDetailsVisible( true ); 2691 setDetailsVisible( true );
2691 mActionDetails->setChecked(true); 2692 mActionDetails->setChecked(true);
2692 } 2693 }
2693 } 2694 }
2694} 2695}
2695 2696
2696void KABCore::whatsnew() 2697void KABCore::whatsnew()
2697{ 2698{
2698 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2699 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2699} 2700}
2700void KABCore::synchowto() 2701void KABCore::synchowto()
2701{ 2702{
2702 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2703 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2703} 2704}
2704void KABCore::kdesynchowto() 2705void KABCore::kdesynchowto()
2705{ 2706{
2706 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2707 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2707} 2708}
2708void KABCore::multisynchowto() 2709void KABCore::multisynchowto()
2709{ 2710{
2710 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2711 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2711} 2712}
2712void KABCore::faq() 2713void KABCore::faq()
2713{ 2714{
2714 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2715 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2715} 2716}
2716 2717
2717#include <libkcal/syncdefines.h> 2718#include <libkcal/syncdefines.h>
2718 2719
2719KABC::Addressee KABCore::getLastSyncAddressee() 2720KABC::Addressee KABCore::getLastSyncAddressee()
2720{ 2721{
2721 Addressee lse; 2722 Addressee lse;
2722 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2723 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2723 2724
2724 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2725 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2725 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2726 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2726 if (lse.isEmpty()) { 2727 if (lse.isEmpty()) {
2727 qDebug("KA: Creating new last-syncAddressee "); 2728 qDebug("KA: Creating new last-syncAddressee ");
2728 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2729 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2729 QString sum = ""; 2730 QString sum = "";
2730 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2731 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2731 sum = "E: "; 2732 sum = "E: ";
2732 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2733 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2733 lse.setRevision( mLastAddressbookSync ); 2734 lse.setRevision( mLastAddressbookSync );
2734 lse.setCategories( i18n("SyncEvent") ); 2735 lse.setCategories( i18n("SyncEvent") );
2735 mAddressBook->insertAddressee( lse ); 2736 mAddressBook->insertAddressee( lse );
2736 } 2737 }
2737 return lse; 2738 return lse;
2738} 2739}
2739int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2740int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2740{ 2741{
2741 2742
2742 //void setZaurusId(int id); 2743 //void setZaurusId(int id);
2743 // int zaurusId() const; 2744 // int zaurusId() const;
2744 // void setZaurusUid(int id); 2745 // void setZaurusUid(int id);
2745 // int zaurusUid() const; 2746 // int zaurusUid() const;
2746 // void setZaurusStat(int id); 2747 // void setZaurusStat(int id);
2747 // int zaurusStat() const; 2748 // int zaurusStat() const;
2748 // 0 equal 2749 // 0 equal
2749 // 1 take local 2750 // 1 take local
2750 // 2 take remote 2751 // 2 take remote
2751 // 3 cancel 2752 // 3 cancel
2752 QDateTime lastSync = mLastAddressbookSync; 2753 QDateTime lastSync = mLastAddressbookSync;
2753 QDateTime localMod = local->revision(); 2754 QDateTime localMod = local->revision();
2754 QDateTime remoteMod = remote->revision(); 2755 QDateTime remoteMod = remote->revision();
2755 2756
2756 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2757 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2757 2758
2758 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2759 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2759 bool remCh, locCh; 2760 bool remCh, locCh;
2760 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2761 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2761 //if ( remCh ) 2762 //if ( remCh )
2762 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2763 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2763 locCh = ( localMod > mLastAddressbookSync ); 2764 locCh = ( localMod > mLastAddressbookSync );
2764 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2765 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2765 if ( !remCh && ! locCh ) { 2766 if ( !remCh && ! locCh ) {
2766 //qDebug("both not changed "); 2767 //qDebug("both not changed ");
2767 lastSync = localMod.addDays(1); 2768 lastSync = localMod.addDays(1);
2768 if ( mode <= SYNC_PREF_ASK ) 2769 if ( mode <= SYNC_PREF_ASK )
2769 return 0; 2770 return 0;
2770 } else { 2771 } else {
2771 if ( locCh ) { 2772 if ( locCh ) {
2772 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2773 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2773 lastSync = localMod.addDays( -1 ); 2774 lastSync = localMod.addDays( -1 );
2774 if ( !remCh ) 2775 if ( !remCh )
2775 remoteMod =( lastSync.addDays( -1 ) ); 2776 remoteMod =( lastSync.addDays( -1 ) );
2776 } else { 2777 } else {
2777 //qDebug(" not loc changed "); 2778 //qDebug(" not loc changed ");
2778 lastSync = localMod.addDays( 1 ); 2779 lastSync = localMod.addDays( 1 );
2779 if ( remCh ) { 2780 if ( remCh ) {
2780 //qDebug("rem changed "); 2781 //qDebug("rem changed ");
2781 remoteMod =( lastSync.addDays( 1 ) ); 2782 remoteMod =( lastSync.addDays( 1 ) );
2782 } 2783 }
2783 2784
2784 } 2785 }
2785 } 2786 }
2786 full = true; 2787 full = true;
2787 if ( mode < SYNC_PREF_ASK ) 2788 if ( mode < SYNC_PREF_ASK )
2788 mode = SYNC_PREF_ASK; 2789 mode = SYNC_PREF_ASK;
2789 } else { 2790 } else {
2790 if ( localMod == remoteMod ) 2791 if ( localMod == remoteMod )
2791 return 0; 2792 return 0;
2792 2793
2793 } 2794 }
2794 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2795 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2795 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2796 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2796 //full = true; //debug only 2797 //full = true; //debug only
2797 if ( full ) { 2798 if ( full ) {
2798 bool equ = ( (*local) == (*remote) ); 2799 bool equ = ( (*local) == (*remote) );
2799 if ( equ ) { 2800 if ( equ ) {
2800 //qDebug("equal "); 2801 //qDebug("equal ");
2801 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2802 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2802 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2803 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2803 } 2804 }
2804 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2805 if ( mode < SYNC_PREF_FORCE_LOCAL )
2805 return 0; 2806 return 0;
2806 2807
2807 }//else //debug only 2808 }//else //debug only
2808 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2809 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2809 } 2810 }
2810 int result; 2811 int result;
2811 bool localIsNew; 2812 bool localIsNew;
2812 //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() ); 2813 //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() );
2813 2814
2814 if ( full && mode < SYNC_PREF_NEWEST ) 2815 if ( full && mode < SYNC_PREF_NEWEST )
2815 mode = SYNC_PREF_ASK; 2816 mode = SYNC_PREF_ASK;
2816 2817
2817 switch( mode ) { 2818 switch( mode ) {
2818 case SYNC_PREF_LOCAL: 2819 case SYNC_PREF_LOCAL:
2819 if ( lastSync > remoteMod ) 2820 if ( lastSync > remoteMod )
2820 return 1; 2821 return 1;
2821 if ( lastSync > localMod ) 2822 if ( lastSync > localMod )
2822 return 2; 2823 return 2;
2823 return 1; 2824 return 1;
2824 break; 2825 break;
2825 case SYNC_PREF_REMOTE: 2826 case SYNC_PREF_REMOTE:
2826 if ( lastSync > remoteMod ) 2827 if ( lastSync > remoteMod )
2827 return 1; 2828 return 1;
2828 if ( lastSync > localMod ) 2829 if ( lastSync > localMod )
2829 return 2; 2830 return 2;
2830 return 2; 2831 return 2;
2831 break; 2832 break;
2832 case SYNC_PREF_NEWEST: 2833 case SYNC_PREF_NEWEST:
2833 if ( localMod > remoteMod ) 2834 if ( localMod > remoteMod )
2834 return 1; 2835 return 1;
2835 else 2836 else
2836 return 2; 2837 return 2;
2837 break; 2838 break;
2838 case SYNC_PREF_ASK: 2839 case SYNC_PREF_ASK:
2839 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2840 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2840 if ( lastSync > remoteMod ) 2841 if ( lastSync > remoteMod )
2841 return 1; 2842 return 1;
2842 if ( lastSync > localMod ) { 2843 if ( lastSync > localMod ) {
2843 return 2; 2844 return 2;
2844 } 2845 }
2845 localIsNew = localMod >= remoteMod; 2846 localIsNew = localMod >= remoteMod;
2846 //qDebug("conflict! ************************************** "); 2847 //qDebug("conflict! ************************************** ");
2847 { 2848 {
2848 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2849 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2849 result = acd.executeD(localIsNew); 2850 result = acd.executeD(localIsNew);
2850 return result; 2851 return result;
2851 } 2852 }
2852 break; 2853 break;
2853 case SYNC_PREF_FORCE_LOCAL: 2854 case SYNC_PREF_FORCE_LOCAL:
2854 return 1; 2855 return 1;
2855 break; 2856 break;
2856 case SYNC_PREF_FORCE_REMOTE: 2857 case SYNC_PREF_FORCE_REMOTE:
2857 return 2; 2858 return 2;
2858 break; 2859 break;
2859 2860
2860 default: 2861 default:
2861 // SYNC_PREF_TAKE_BOTH not implemented 2862 // SYNC_PREF_TAKE_BOTH not implemented
2862 break; 2863 break;
2863 } 2864 }
2864 return 0; 2865 return 0;
2865} 2866}
2866 2867
2867 2868
2868bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2869bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2869{ 2870{
2870 bool syncOK = true; 2871 bool syncOK = true;
2871 int addedAddressee = 0; 2872 int addedAddressee = 0;
2872 int addedAddresseeR = 0; 2873 int addedAddresseeR = 0;
2873 int deletedAddresseeR = 0; 2874 int deletedAddresseeR = 0;
2874 int deletedAddresseeL = 0; 2875 int deletedAddresseeL = 0;
2875 int changedLocal = 0; 2876 int changedLocal = 0;
2876 int changedRemote = 0; 2877 int changedRemote = 0;
2877 int filteredIN = 0; 2878 int filteredIN = 0;
2878 int filteredOUT = 0; 2879 int filteredOUT = 0;
2879 2880
2880 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2881 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2881 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2882 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2882 2883
2883 //QPtrList<Addressee> el = local->rawAddressees(); 2884 //QPtrList<Addressee> el = local->rawAddressees();
2884 Addressee addresseeR; 2885 Addressee addresseeR;
2885 QString uid; 2886 QString uid;
2886 int take; 2887 int take;
2887 Addressee addresseeL; 2888 Addressee addresseeL;
2888 Addressee addresseeRSync; 2889 Addressee addresseeRSync;
2889 Addressee addresseeLSync; 2890 Addressee addresseeLSync;
2890 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2891 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2891 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2892 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2892 bool fullDateRange = false; 2893 bool fullDateRange = false;
2893 local->resetTempSyncStat(); 2894 local->resetTempSyncStat();
2894 mLastAddressbookSync = QDateTime::currentDateTime(); 2895 mLastAddressbookSync = QDateTime::currentDateTime();
2895 if ( syncManager->syncWithDesktop() ) { 2896 if ( syncManager->syncWithDesktop() ) {
2896 // remote->removeSyncInfo( QString());//remove all info 2897 // remote->removeSyncInfo( QString());//remove all info
2897 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2898 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2898 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2899 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2899 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2900 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2900 } else { 2901 } else {
2901 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 2902 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
2902 } 2903 }
2903 } 2904 }
2904 QDateTime modifiedCalendar = mLastAddressbookSync; 2905 QDateTime modifiedCalendar = mLastAddressbookSync;
2905 addresseeLSync = getLastSyncAddressee(); 2906 addresseeLSync = getLastSyncAddressee();
2906 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2907 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
2907 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2908 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2908 if ( !addresseeR.isEmpty() ) { 2909 if ( !addresseeR.isEmpty() ) {
2909 addresseeRSync = addresseeR; 2910 addresseeRSync = addresseeR;
2910 remote->removeAddressee(addresseeR ); 2911 remote->removeAddressee(addresseeR );
2911 2912
2912 } else { 2913 } else {
2913 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2914 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2914 addresseeRSync = addresseeLSync ; 2915 addresseeRSync = addresseeLSync ;
2915 } else { 2916 } else {
2916 //qDebug("FULLDATE 1"); 2917 //qDebug("FULLDATE 1");
2917 fullDateRange = true; 2918 fullDateRange = true;
2918 Addressee newAdd; 2919 Addressee newAdd;
2919 addresseeRSync = newAdd; 2920 addresseeRSync = newAdd;
2920 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2921 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2921 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2922 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2922 addresseeRSync.setRevision( mLastAddressbookSync ); 2923 addresseeRSync.setRevision( mLastAddressbookSync );
2923 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2924 addresseeRSync.setCategories( i18n("SyncAddressee") );
2924 } 2925 }
2925 } 2926 }
2926 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2927 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2927 // qDebug("FULLDATE 2"); 2928 // qDebug("FULLDATE 2");
2928 fullDateRange = true; 2929 fullDateRange = true;
2929 } 2930 }
2930 if ( ! fullDateRange ) { 2931 if ( ! fullDateRange ) {
2931 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2932 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2932 2933
2933 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2934 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2934 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2935 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2935 fullDateRange = true; 2936 fullDateRange = true;
2936 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2937 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2937 } 2938 }
2938 } 2939 }
2939 // fullDateRange = true; // debug only! 2940 // fullDateRange = true; // debug only!
2940 if ( fullDateRange ) 2941 if ( fullDateRange )
2941 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2942 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2942 else 2943 else
2943 mLastAddressbookSync = addresseeLSync.revision(); 2944 mLastAddressbookSync = addresseeLSync.revision();
2944 // for resyncing if own file has changed 2945 // for resyncing if own file has changed
2945 // PENDING fixme later when implemented 2946 // PENDING fixme later when implemented
2946#if 0 2947#if 0
2947 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2948 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2948 mLastAddressbookSync = loadedFileVersion; 2949 mLastAddressbookSync = loadedFileVersion;
2949 qDebug("setting mLastAddressbookSync "); 2950 qDebug("setting mLastAddressbookSync ");
2950 } 2951 }
2951#endif 2952#endif
2952 2953
2953 2954
2954 // ********** setting filters **************** 2955 // ********** setting filters ****************
2955 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 2956 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2956 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 2957 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2957 2958
2958 //qDebug("*************************** "); 2959 //qDebug("*************************** ");
2959 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2960 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2960 QStringList er = remote->uidList(); 2961 QStringList er = remote->uidList();
2961 Addressee inR ;//= er.first(); 2962 Addressee inR ;//= er.first();
2962 Addressee inL; 2963 Addressee inL;
2963 2964
2964 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2965 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2965 2966
2966 int modulo = (er.count()/10)+1; 2967 int modulo = (er.count()/10)+1;
2967 int incCounter = 0; 2968 int incCounter = 0;
2968 while ( incCounter < er.count()) { 2969 while ( incCounter < er.count()) {
2969 if (syncManager->isProgressBarCanceled()) 2970 if (syncManager->isProgressBarCanceled())
2970 return false; 2971 return false;
2971 if ( incCounter % modulo == 0 ) 2972 if ( incCounter % modulo == 0 )
2972 syncManager->showProgressBar(incCounter); 2973 syncManager->showProgressBar(incCounter);
2973 2974
2974 uid = er[ incCounter ]; 2975 uid = er[ incCounter ];
2975 bool skipIncidence = false; 2976 bool skipIncidence = false;
2976 if ( uid.left(19) == QString("last-syncAddressee-") ) 2977 if ( uid.left(19) == QString("last-syncAddressee-") )
2977 skipIncidence = true; 2978 skipIncidence = true;
2978 QString idS,OidS; 2979 QString idS,OidS;
2979 qApp->processEvents(); 2980 qApp->processEvents();
2980 if ( !skipIncidence ) { 2981 if ( !skipIncidence ) {
2981 inL = local->findByUid( uid ); 2982 inL = local->findByUid( uid );
2982 inR = remote->findByUid( uid ); 2983 inR = remote->findByUid( uid );
2983 //inL.setResource( 0 ); 2984 //inL.setResource( 0 );
2984 //inR.setResource( 0 ); 2985 //inR.setResource( 0 );
2985 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2986 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2986 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2987 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2987 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2988 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2988 //qDebug("take %d %s ", take, inL.summary().latin1()); 2989 //qDebug("take %d %s ", take, inL.summary().latin1());
2989 if ( take == 3 ) 2990 if ( take == 3 )
2990 return false; 2991 return false;
2991 if ( take == 1 ) {// take local ********************** 2992 if ( take == 1 ) {// take local **********************
2992 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2993 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2993 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2994 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2994 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2995 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2995 local->insertAddressee( inL, false ); 2996 local->insertAddressee( inL, false );
2996 idS = inR.externalUID(); 2997 idS = inR.externalUID();
2997 OidS = inR.originalExternalUID(); 2998 OidS = inR.originalExternalUID();
2998 } 2999 }
2999 else 3000 else
3000 idS = inR.IDStr(); 3001 idS = inR.IDStr();
3001 remote->removeAddressee( inR ); 3002 remote->removeAddressee( inR );
3002 inR = inL; 3003 inR = inL;
3003 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3004 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3004 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3005 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3005 inR.setOriginalExternalUID( OidS ); 3006 inR.setOriginalExternalUID( OidS );
3006 inR.setExternalUID( idS ); 3007 inR.setExternalUID( idS );
3007 if ( syncManager->syncWithDesktop() ) { 3008 if ( syncManager->syncWithDesktop() ) {
3008 inR.setIDStr("changed" ); 3009 inR.setIDStr("changed" );
3009 } 3010 }
3010 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3011 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3011 } else { 3012 } else {
3012 inR.setIDStr( idS ); 3013 inR.setIDStr( idS );
3013 } 3014 }
3014 inR.setResource( 0 ); 3015 inR.setResource( 0 );
3015 remote->insertAddressee( inR , false); 3016 remote->insertAddressee( inR , false);
3016 ++changedRemote; 3017 ++changedRemote;
3017 } else { // take == 2 take remote ********************** 3018 } else { // take == 2 take remote **********************
3018 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3019 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3019 if ( inR.revision().date().year() < 2004 ) 3020 if ( inR.revision().date().year() < 2004 )
3020 inR.setRevision( modifiedCalendar ); 3021 inR.setRevision( modifiedCalendar );
3021 } 3022 }
3022 idS = inL.IDStr(); 3023 idS = inL.IDStr();
3023 local->removeAddressee( inL ); 3024 local->removeAddressee( inL );
3024 inL = inR; 3025 inL = inR;
3025 inL.setIDStr( idS ); 3026 inL.setIDStr( idS );
3026 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3027 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3027 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3028 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3028 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3029 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3029 } 3030 }
3030 inL.setResource( 0 ); 3031 inL.setResource( 0 );
3031 local->insertAddressee( inL , false ); 3032 local->insertAddressee( inL , false );
3032 ++changedLocal; 3033 ++changedLocal;
3033 } 3034 }
3034 } 3035 }
3035 } 3036 }
3036 } else { // no conflict ********** add or delete remote 3037 } else { // no conflict ********** add or delete remote
3037 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3038 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3038 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3039 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3039 QString des = addresseeLSync.note(); 3040 QString des = addresseeLSync.note();
3040 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3041 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3041 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3042 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3042 remote->insertAddressee( inR, false ); 3043 remote->insertAddressee( inR, false );
3043 ++deletedAddresseeR; 3044 ++deletedAddresseeR;
3044 } else { 3045 } else {
3045 inR.setRevision( modifiedCalendar ); 3046 inR.setRevision( modifiedCalendar );
3046 remote->insertAddressee( inR, false ); 3047 remote->insertAddressee( inR, false );
3047 inL = inR; 3048 inL = inR;
3048 inL.setIDStr( ":" ); 3049 inL.setIDStr( ":" );
3049 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3050 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3050 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3051 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3051 inL.setResource( 0 ); 3052 inL.setResource( 0 );
3052 local->insertAddressee( inL , false); 3053 local->insertAddressee( inL , false);
3053 ++addedAddressee; 3054 ++addedAddressee;
3054 } 3055 }
3055 } else { 3056 } else {
3056 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3057 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3057 inR.setRevision( modifiedCalendar ); 3058 inR.setRevision( modifiedCalendar );
3058 remote->insertAddressee( inR, false ); 3059 remote->insertAddressee( inR, false );
3059 inR.setResource( 0 ); 3060 inR.setResource( 0 );
3060 local->insertAddressee( inR, false ); 3061 local->insertAddressee( inR, false );
3061 ++addedAddressee; 3062 ++addedAddressee;
3062 } else { 3063 } else {
3063 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3064 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3064 remote->removeAddressee( inR ); 3065 remote->removeAddressee( inR );
3065 ++deletedAddresseeR; 3066 ++deletedAddresseeR;
3066 } 3067 }
3067 } 3068 }
3068 } else { 3069 } else {
3069 ++filteredIN; 3070 ++filteredIN;
3070 } 3071 }
3071 } 3072 }
3072 } 3073 }
3073 ++incCounter; 3074 ++incCounter;
3074 } 3075 }
3075 er.clear(); 3076 er.clear();
3076 QStringList el = local->uidList(); 3077 QStringList el = local->uidList();
3077 modulo = (el.count()/10)+1; 3078 modulo = (el.count()/10)+1;
3078 3079
3079 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3080 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3080 incCounter = 0; 3081 incCounter = 0;
3081 while ( incCounter < el.count()) { 3082 while ( incCounter < el.count()) {
3082 qApp->processEvents(); 3083 qApp->processEvents();
3083 if (syncManager->isProgressBarCanceled()) 3084 if (syncManager->isProgressBarCanceled())
3084 return false; 3085 return false;
3085 if ( incCounter % modulo == 0 ) 3086 if ( incCounter % modulo == 0 )
3086 syncManager->showProgressBar(incCounter); 3087 syncManager->showProgressBar(incCounter);
3087 uid = el[ incCounter ]; 3088 uid = el[ incCounter ];
3088 bool skipIncidence = false; 3089 bool skipIncidence = false;
3089 if ( uid.left(19) == QString("last-syncAddressee-") ) 3090 if ( uid.left(19) == QString("last-syncAddressee-") )
3090 skipIncidence = true; 3091 skipIncidence = true;
3091 if ( !skipIncidence ) { 3092 if ( !skipIncidence ) {
3092 inL = local->findByUid( uid ); 3093 inL = local->findByUid( uid );
3093 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3094 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3094 inR = remote->findByUid( uid ); 3095 inR = remote->findByUid( uid );
3095 if ( inR.isEmpty() ){ 3096 if ( inR.isEmpty() ){
3096 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3097 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3097 // no conflict ********** add or delete local 3098 // no conflict ********** add or delete local
3098 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3099 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3099 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3100 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3100 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3101 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3101 local->removeAddressee( inL ); 3102 local->removeAddressee( inL );
3102 ++deletedAddresseeL; 3103 ++deletedAddresseeL;
3103 } else { 3104 } else {
3104 if ( ! syncManager->mWriteBackExistingOnly ) { 3105 if ( ! syncManager->mWriteBackExistingOnly ) {
3105 inL.removeID(mCurrentSyncDevice ); 3106 inL.removeID(mCurrentSyncDevice );
3106 ++addedAddresseeR; 3107 ++addedAddresseeR;
3107 inL.setRevision( modifiedCalendar ); 3108 inL.setRevision( modifiedCalendar );
3108 local->insertAddressee( inL, false ); 3109 local->insertAddressee( inL, false );
3109 inR = inL; 3110 inR = inL;
3110 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3111 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3111 inR.setResource( 0 ); 3112 inR.setResource( 0 );
3112 remote->insertAddressee( inR, false ); 3113 remote->insertAddressee( inR, false );
3113 } 3114 }
3114 } 3115 }
3115 } else { 3116 } else {
3116 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3117 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3117 //qDebug("data %s ", inL.revision().toString().latin1()); 3118 //qDebug("data %s ", inL.revision().toString().latin1());
3118 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3119 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3119 local->removeAddressee( inL ); 3120 local->removeAddressee( inL );
3120 ++deletedAddresseeL; 3121 ++deletedAddresseeL;
3121 } else { 3122 } else {
3122 if ( ! syncManager->mWriteBackExistingOnly ) { 3123 if ( ! syncManager->mWriteBackExistingOnly ) {
3123 ++addedAddresseeR; 3124 ++addedAddresseeR;
3124 inL.setRevision( modifiedCalendar ); 3125 inL.setRevision( modifiedCalendar );
3125 local->insertAddressee( inL, false ); 3126 local->insertAddressee( inL, false );
3126 inR = inL; 3127 inR = inL;
3127 inR.setIDStr( ":" ); 3128 inR.setIDStr( ":" );
3128 inR.setResource( 0 ); 3129 inR.setResource( 0 );
3129 remote->insertAddressee( inR, false ); 3130 remote->insertAddressee( inR, false );
3130 } 3131 }
3131 } 3132 }
3132 } 3133 }
3133 } else { 3134 } else {
3134 ++filteredOUT; 3135 ++filteredOUT;
3135 } 3136 }
3136 } 3137 }
3137 } 3138 }
3138 } 3139 }
3139 ++incCounter; 3140 ++incCounter;
3140 } 3141 }
3141 el.clear(); 3142 el.clear();
3142 syncManager->hideProgressBar(); 3143 syncManager->hideProgressBar();
3143 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3144 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3144 // get rid of micro seconds 3145 // get rid of micro seconds
3145 QTime t = mLastAddressbookSync.time(); 3146 QTime t = mLastAddressbookSync.time();
3146 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3147 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3147 addresseeLSync.setRevision( mLastAddressbookSync ); 3148 addresseeLSync.setRevision( mLastAddressbookSync );
3148 addresseeRSync.setRevision( mLastAddressbookSync ); 3149 addresseeRSync.setRevision( mLastAddressbookSync );
3149 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3150 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3150 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3151 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3151 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3152 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3152 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3153 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3153 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3154 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3154 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3155 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3155 addresseeRSync.setNote( "" ) ; 3156 addresseeRSync.setNote( "" ) ;
3156 addresseeLSync.setNote( "" ); 3157 addresseeLSync.setNote( "" );
3157 3158
3158 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3159 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3159 remote->insertAddressee( addresseeRSync, false ); 3160 remote->insertAddressee( addresseeRSync, false );
3160 local->insertAddressee( addresseeLSync, false ); 3161 local->insertAddressee( addresseeLSync, false );
3161 QString mes; 3162 QString mes;
3162 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3163 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3163 qDebug( mes ); 3164 qDebug( mes );
3164 mes = i18n("Local addressbook changed!\n") +mes; 3165 mes = i18n("Local addressbook changed!\n") +mes;
3165 if ( syncManager->mShowSyncSummary ) { 3166 if ( syncManager->mShowSyncSummary ) {
3166 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3167 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3167 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3168 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3168 qDebug("KA: WB cancelled "); 3169 qDebug("KA: WB cancelled ");
3169 syncManager->mWriteBackFile = false; 3170 syncManager->mWriteBackFile = false;
3170 return syncOK; 3171 return syncOK;
3171 } 3172 }
3172 } 3173 }
3173 return syncOK; 3174 return syncOK;
3174} 3175}
3175 3176
3176 3177
3177//this is a overwritten callbackmethods from the syncinterface 3178//this is a overwritten callbackmethods from the syncinterface
3178bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3179bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3179{ 3180{
3180 3181
3181 //pending prepare addresseeview for output 3182 //pending prepare addresseeview for output
3182 //pending detect, if remote file has REV field. if not switch to external sync 3183 //pending detect, if remote file has REV field. if not switch to external sync
3183 mGlobalSyncMode = SYNC_MODE_NORMAL; 3184 mGlobalSyncMode = SYNC_MODE_NORMAL;
3184 if ( manager != syncManager ) 3185 if ( manager != syncManager )
3185 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3186 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3186 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3187 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3187 3188
3188 AddressBook abLocal(filename,"syncContact"); 3189 AddressBook abLocal(filename,"syncContact");
3189 bool syncOK = false; 3190 bool syncOK = false;
3190 if ( abLocal.load() ) { 3191 if ( abLocal.load() ) {
3191 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3192 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3192 bool external = false; 3193 bool external = false;
3193 bool isXML = false; 3194 bool isXML = false;
3194 if ( filename.right(4) == ".xml") { 3195 if ( filename.right(4) == ".xml") {
3195 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3196 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3196 isXML = true; 3197 isXML = true;
3197 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3198 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3198 } else { 3199 } else {
3199 external = !manager->mIsKapiFile; 3200 external = !manager->mIsKapiFile;
3200 if ( external ) { 3201 if ( external ) {
3201 qDebug("KA: Sync::Setting vcf mode to external "); 3202 qDebug("KA: Sync::Setting vcf mode to external ");
3202 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3203 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3203 AddressBook::Iterator it; 3204 AddressBook::Iterator it;
3204 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3205 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3205 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3206 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3206 (*it).computeCsum( mCurrentSyncDevice ); 3207 (*it).computeCsum( mCurrentSyncDevice );
3207 } 3208 }
3208 } 3209 }
3209 } 3210 }
3210 //AddressBook::Iterator it; 3211 //AddressBook::Iterator it;
3211 //QStringList vcards; 3212 //QStringList vcards;
3212 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3213 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3213 // qDebug("Name %s ", (*it).familyName().latin1()); 3214 // qDebug("Name %s ", (*it).familyName().latin1());
3214 //} 3215 //}
3215 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3216 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3216 syncManager->hideProgressBar(); 3217 syncManager->hideProgressBar();
3217 if ( syncOK ) { 3218 if ( syncOK ) {
3218 if ( syncManager->mWriteBackFile ) 3219 if ( syncManager->mWriteBackFile )
3219 { 3220 {
3220 if ( external ) 3221 if ( external )
3221 abLocal.removeSyncAddressees( !isXML); 3222 abLocal.removeSyncAddressees( !isXML);
3222 qDebug("KA: Sync::Saving remote AB "); 3223 qDebug("KA: Sync::Saving remote AB ");
3223 if ( ! abLocal.saveAB()) 3224 if ( ! abLocal.saveAB())
3224 qDebug("KA: sync::Error writing back AB to file "); 3225 qDebug("KA: sync::Error writing back AB to file ");
3225 if ( external ) { 3226 if ( external ) {
3226 // afterwrite processing 3227 // afterwrite processing
3227 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3228 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3228 } 3229 }
3229 } 3230 }
3230 } 3231 }
3231 setModified(); 3232 setModified();
3232 3233
3233 } 3234 }
3234 abLocal.removeResources(); 3235 abLocal.removeResources();
3235 if ( syncOK ) 3236 if ( syncOK )
3236 mViewManager->refreshView(); 3237 mViewManager->refreshView();
3237 return syncOK; 3238 return syncOK;
3238 3239
3239} 3240}
3240void KABCore::removeSyncInfo( QString syncProfile) 3241void KABCore::removeSyncInfo( QString syncProfile)
3241{ 3242{
3242 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3243 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3243 mAddressBook->removeSyncInfo( syncProfile ); 3244 mAddressBook->removeSyncInfo( syncProfile );
3244 setModified(); 3245 setModified();
3245} 3246}
3246 3247
3247 3248
3248//this is a overwritten callbackmethods from the syncinterface 3249//this is a overwritten callbackmethods from the syncinterface
3249bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3250bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3250{ 3251{
3251 if ( resource == "phone" ) 3252 if ( resource == "phone" )
3252 return syncPhone(); 3253 return syncPhone();
3253 disableBR( true ); 3254 disableBR( true );
3254 if ( manager != syncManager ) 3255 if ( manager != syncManager )
3255 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3256 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3256 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3257 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3257 3258
3258 AddressBook abLocal( resource,"syncContact"); 3259 AddressBook abLocal( resource,"syncContact");
3259 bool syncOK = false; 3260 bool syncOK = false;
3260 message(i18n("Loading DTM address data..."), false); 3261 message(i18n("Loading DTM address data..."), false);
3261 if ( abLocal.load() ) { 3262 if ( abLocal.load() ) {
3262 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3263 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3263 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3264 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3264 message(i18n("Sync preprocessing..."),false); 3265 message(i18n("Sync preprocessing..."),false);
3265 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3266 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3266 message(i18n("Synchronizing..."),false); 3267 message(i18n("Synchronizing..."),false);
3267 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3268 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3268 syncManager->hideProgressBar(); 3269 syncManager->hideProgressBar();
3269 if ( syncOK ) { 3270 if ( syncOK ) {
3270 if ( syncManager->mWriteBackFile ) { 3271 if ( syncManager->mWriteBackFile ) {
3271 abLocal.removeSyncAddressees( false ); 3272 abLocal.removeSyncAddressees( false );
3272 message(i18n("Saving DTM address data..."),false); 3273 message(i18n("Saving DTM address data..."),false);
3273 abLocal.saveAB(); 3274 abLocal.saveAB();
3274 message(i18n("Sync postprocessing..."),false); 3275 message(i18n("Sync postprocessing..."),false);
3275 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3276 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3276 } 3277 }
3277 } else 3278 } else
3278 message( i18n("Sync cancelled or failed.") ); 3279 message( i18n("Sync cancelled or failed.") );
3279 setModified(); 3280 setModified();
3280 } 3281 }
3281 abLocal.removeResources(); 3282 abLocal.removeResources();
3282 if ( syncOK ) { 3283 if ( syncOK ) {
3283 mViewManager->refreshView(); 3284 mViewManager->refreshView();
3284 message(i18n("DTM syncing finished.")); 3285 message(i18n("DTM syncing finished."));
3285 } 3286 }
3286 disableBR( false ); 3287 disableBR( false );
3287 return syncOK; 3288 return syncOK;
3288 3289
3289} 3290}
3290void KABCore::message( QString m, bool startTimer) 3291void KABCore::message( QString m, bool startTimer)
3291{ 3292{
3292 topLevelWidget()->setCaption( m ); 3293 topLevelWidget()->setCaption( m );
3293 qApp->processEvents(); 3294 qApp->processEvents();
3294 if ( startTimer ) 3295 if ( startTimer )
3295 mMessageTimer->start( 15000, true ); 3296 mMessageTimer->start( 15000, true );
3296 else 3297 else
3297 mMessageTimer->stop(); 3298 mMessageTimer->stop();
3298} 3299}
3299bool KABCore::syncPhone() 3300bool KABCore::syncPhone()
3300{ 3301{
3301 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3302 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3302 QString fileName = getPhoneFile(); 3303 QString fileName = getPhoneFile();
3303 if ( !PhoneAccess::readFromPhone( fileName) ) { 3304 if ( !PhoneAccess::readFromPhone( fileName) ) {
3304 message(i18n("Phone access failed!")); 3305 message(i18n("Phone access failed!"));
3305 return false; 3306 return false;
3306 } 3307 }
3307 AddressBook abLocal( fileName,"syncContact"); 3308 AddressBook abLocal( fileName,"syncContact");
3308 bool syncOK = false; 3309 bool syncOK = false;
3309 { 3310 {
3310 abLocal.importFromFile( fileName ); 3311 abLocal.importFromFile( fileName );
3311 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3312 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3312 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3313 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3313 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3314 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3314 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3315 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3315 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3316 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3316 syncManager->hideProgressBar(); 3317 syncManager->hideProgressBar();
3317 if ( syncOK ) { 3318 if ( syncOK ) {
3318 if ( syncManager->mWriteBackFile ) { 3319 if ( syncManager->mWriteBackFile ) {
3319 abLocal.removeSyncAddressees( true ); 3320 abLocal.removeSyncAddressees( true );
3320 abLocal.saveABphone( fileName ); 3321 abLocal.saveABphone( fileName );
3321 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3322 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3322 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3323 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3323 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3324 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3324 } 3325 }
3325 } 3326 }
3326 setModified(); 3327 setModified();
3327 } 3328 }
3328 abLocal.removeResources(); 3329 abLocal.removeResources();
3329 if ( syncOK ) 3330 if ( syncOK )
3330 mViewManager->refreshView(); 3331 mViewManager->refreshView();
3331 return syncOK; 3332 return syncOK;
3332} 3333}
3333void KABCore::getFile( bool success ) 3334void KABCore::getFile( bool success )
3334{ 3335{
3335 if ( ! success ) { 3336 if ( ! success ) {
3336 message( i18n("Error receiving file. Nothing changed!") ); 3337 message( i18n("Error receiving file. Nothing changed!") );
3337 return; 3338 return;
3338 } 3339 }
3339 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3340 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3340 if ( count ) 3341 if ( count )
3341 setModified( true ); 3342 setModified( true );
3342 message( i18n("Pi-Sync successful!") ); 3343 message( i18n("Pi-Sync successful!") );
3343 mViewManager->refreshView(); 3344 mViewManager->refreshView();
3344} 3345}
3345void KABCore::syncFileRequest() 3346void KABCore::syncFileRequest()
3346{ 3347{
3347 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3348 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3348 syncManager->slotSyncMenu( 999 ); 3349 syncManager->slotSyncMenu( 999 );
3349 } 3350 }
3350 mAddressBook->export2File( sentSyncFile() ); 3351 mAddressBook->export2File( sentSyncFile() );
3351} 3352}
3352QString KABCore::sentSyncFile() 3353QString KABCore::sentSyncFile()
3353{ 3354{
3354#ifdef DESKTOP_VERSION 3355#ifdef DESKTOP_VERSION
3355 return locateLocal( "tmp", "copysyncab.vcf" ); 3356 return locateLocal( "tmp", "copysyncab.vcf" );
3356#else 3357#else
3357 return QString( "/tmp/copysyncab.vcf" ); 3358 return QString( "/tmp/copysyncab.vcf" );
3358#endif 3359#endif
3359} 3360}
3360 3361
3361void KABCore::setCaptionBack() 3362void KABCore::setCaptionBack()
3362{ 3363{
3363 mMessageTimer->stop(); 3364 mMessageTimer->stop();
3364 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3365 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3365} 3366}
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 7200da9..f8f4c8a 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,1201 +1,1204 @@
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/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (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
59QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 59QCopTransferItem::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
75QCopTransferItem::QCopTransferItem() 75QCopTransferItem::QCopTransferItem()
76{ 76{
77} 77}
78 78
79/*********************************************************************************/ 79/*********************************************************************************/
80bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 80bool 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/*********************************************************************************/
115void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 115void 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/*********************************************************************************/
124bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 124bool 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
190QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 190QCopMapTransferItem::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/*********************************************************************************/
198bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 198bool 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/*********************************************************************************/
227bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 227bool 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
260QCopListTransferItem::~QCopListTransferItem() 260QCopListTransferItem::~QCopListTransferItem()
261{ 261{
262 262
263} 263}
264 264
265QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 265QCopListTransferItem::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/*********************************************************************************/
273bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 273bool 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/*********************************************************************************/
306bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 306bool 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
354ExternalAppHandler *ExternalAppHandler::sInstance = 0; 354ExternalAppHandler *ExternalAppHandler::sInstance = 0;
355static KStaticDeleter<ExternalAppHandler> staticDeleter; 355static KStaticDeleter<ExternalAppHandler> staticDeleter;
356 356
357ExternalAppHandler::ExternalAppHandler() 357ExternalAppHandler::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
381ExternalAppHandler::~ExternalAppHandler() 381ExternalAppHandler::~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
389void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, 389void 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
402void ExternalAppHandler::loadConfig() 402void 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 QString qtpath = QString::fromLatin1( getenv("QTDIR") ); 415 QString qtpath = QString::fromLatin1( getenv("QTDIR") );
416 416
417 //if qtopiapath is not set, fallback to qt 417 //if qtopiapath is not set, fallback to qt
418 if (qtopiapath.isEmpty()) 418 if (qtopiapath.isEmpty())
419 qtopiapath = qtpath; 419 qtopiapath = qtpath;
420 420
421 //if opiepath is not set, fallback to qtopia 421 //if opiepath is not set, fallback to qtopia
422 if (opiepath.isEmpty()) 422 if (opiepath.isEmpty())
423 opiepath = qtopiapath; 423 opiepath = qtopiapath;
424 424
425 425
426 426
427 //mailclients 427 //mailclients
428 QString mailmsg1 = "writeMail(QString,QString)"; 428 QString mailmsg1 = "writeMail(QString,QString)";
429 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 429 QString mailmsg2 = "writeMail(QMap(QString,QString))";
430 430
431 QString undefined = ""; 431 QString undefined = "";
432 432
433 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 433 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
434 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 434 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
435 435
436 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 436 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
437 ( QFile::exists( opiepath + "/bin/ompi" )) || 437 ( QFile::exists( opiepath + "/bin/ompi" )) ||
438 ( QFile::exists( qtpath + "/bin/ompi" ))) 438 ( QFile::exists( qtpath + "/bin/ompi" )))
439 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 439 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
440 440
441 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || 441 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) ||
442 ( QFile::exists( qtpath + "/bin/qtmail" ))) 442 ( QFile::exists( qtpath + "/bin/qtmail" )))
443 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 443 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
444 444
445 if ( QFile::exists( opiepath + "/bin/opiemail" )) 445 if ( QFile::exists( opiepath + "/bin/opiemail" ))
446 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 446 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
447 447
448 if ( QFile::exists( opiepath + "/bin/mailit" )) 448 if ( QFile::exists( opiepath + "/bin/mailit" ))
449 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 449 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
450 450
451 451
452 452
453 //phoneclients 453 //phoneclients
454 454
455 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 455 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
456 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 456 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
457 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 457 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
458 ( QFile::exists( opiepath + "/bin/kppi" ))) 458 ( QFile::exists( opiepath + "/bin/kppi" )))
459 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 459 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
460 460
461 //faxclients 461 //faxclients
462 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 462 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
463 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 463 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
464 464
465 //smsclients 465 //smsclients
466 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 466 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
467 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 467 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
468 468
469 //pagerclients 469 //pagerclients
470 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 470 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
471 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 471 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
472 472
473 //sipclients 473 //sipclients
474 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); 474 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined);
475 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); 475 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined);
476 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 476 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
477 ( QFile::exists( opiepath + "/bin/kppi" ))) 477 ( QFile::exists( opiepath + "/bin/kppi" )))
478 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 478 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
479 479
480} 480}
481 481
482ExternalAppHandler *ExternalAppHandler::instance() 482ExternalAppHandler *ExternalAppHandler::instance()
483{ 483{
484 if ( !sInstance ) { 484 if ( !sInstance ) {
485 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 485 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
486 sInstance->loadConfig(); 486 sInstance->loadConfig();
487 } 487 }
488 488
489 return sInstance; 489 return sInstance;
490} 490}
491 491
492void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 492void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
493{ 493{
494 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 494 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
495 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 495 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
496 mDefaultItems.append(dai); 496 mDefaultItems.append(dai);
497} 497}
498 498
499 499
500QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 500QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
501{ 501{
502 QList<DefaultAppItem> list; 502 QList<DefaultAppItem> list;
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) 508 if (dai->_type == type)
509 list.append(dai); 509 list.append(dai);
510 } 510 }
511 511
512 return list; 512 return list;
513} 513}
514 514
515DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 515DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
516{ 516{
517 DefaultAppItem* dai; 517 DefaultAppItem* dai;
518 518
519 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 519 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
520 { 520 {
521 if (dai->_type == type && dai->_id == clientid) 521 if (dai->_type == type && dai->_id == clientid)
522 return dai; 522 return dai;
523 } 523 }
524 524
525 return 0; 525 return 0;
526} 526}
527 527
528bool ExternalAppHandler::isEmailAppAvailable() 528bool ExternalAppHandler::isEmailAppAvailable()
529{ 529{
530#ifndef DESKTOP_VERSION 530#ifndef DESKTOP_VERSION
531 if (mEmailAppAvailable == UNDEFINED) 531 if (mEmailAppAvailable == UNDEFINED)
532 { 532 {
533 int client = KPimGlobalPrefs::instance()->mEmailClient; 533 int client = KPimGlobalPrefs::instance()->mEmailClient;
534 if (client == KPimGlobalPrefs::NONE_EMC) 534 if (client == KPimGlobalPrefs::NONE_EMC)
535 mEmailAppAvailable = UNAVAILABLE; 535 mEmailAppAvailable = UNAVAILABLE;
536 else 536 else
537 mEmailAppAvailable = AVAILABLE; 537 mEmailAppAvailable = AVAILABLE;
538 } 538 }
539 return (mEmailAppAvailable == AVAILABLE); 539 return (mEmailAppAvailable == AVAILABLE);
540 540
541#else //DESKTOP_VERSION 541#else //DESKTOP_VERSION
542 return false; 542 return false;
543#endif //DESKTOP_VERSION 543#endif //DESKTOP_VERSION
544} 544}
545 545
546bool ExternalAppHandler::isSMSAppAvailable() 546bool ExternalAppHandler::isSMSAppAvailable()
547{ 547{
548#ifndef DESKTOP_VERSION 548#ifndef DESKTOP_VERSION
549 if (mSMSAppAvailable == UNDEFINED) 549 if (mSMSAppAvailable == UNDEFINED)
550 { 550 {
551 int client = KPimGlobalPrefs::instance()->mSMSClient; 551 int client = KPimGlobalPrefs::instance()->mSMSClient;
552 if (client == KPimGlobalPrefs::NONE_SMC) 552 if (client == KPimGlobalPrefs::NONE_SMC)
553 mSMSAppAvailable = UNAVAILABLE; 553 mSMSAppAvailable = UNAVAILABLE;
554 else 554 else
555 mSMSAppAvailable = AVAILABLE; 555 mSMSAppAvailable = AVAILABLE;
556 } 556 }
557 557
558 return (mSMSAppAvailable == AVAILABLE); 558 return (mSMSAppAvailable == AVAILABLE);
559#else //DESKTOP_VERSION 559#else //DESKTOP_VERSION
560 return false; 560 return false;
561#endif //DESKTOP_VERSION 561#endif //DESKTOP_VERSION
562} 562}
563 563
564bool ExternalAppHandler::isPhoneAppAvailable() 564bool ExternalAppHandler::isPhoneAppAvailable()
565{ 565{
566#ifndef DESKTOP_VERSION 566#ifndef DESKTOP_VERSION
567 if (mPhoneAppAvailable == UNDEFINED) 567 if (mPhoneAppAvailable == UNDEFINED)
568 { 568 {
569 int client = KPimGlobalPrefs::instance()->mPhoneClient; 569 int client = KPimGlobalPrefs::instance()->mPhoneClient;
570 if (client == KPimGlobalPrefs::NONE_PHC) 570 if (client == KPimGlobalPrefs::NONE_PHC)
571 mPhoneAppAvailable = UNAVAILABLE; 571 mPhoneAppAvailable = UNAVAILABLE;
572 else 572 else
573 mPhoneAppAvailable = AVAILABLE; 573 mPhoneAppAvailable = AVAILABLE;
574 } 574 }
575 575
576 return (mPhoneAppAvailable == AVAILABLE); 576 return (mPhoneAppAvailable == AVAILABLE);
577#else //DESKTOP_VERSION 577#else //DESKTOP_VERSION
578 return false; 578 return false;
579#endif //DESKTOP_VERSION 579#endif //DESKTOP_VERSION
580} 580}
581 581
582bool ExternalAppHandler::isFaxAppAvailable() 582bool ExternalAppHandler::isFaxAppAvailable()
583{ 583{
584#ifndef DESKTOP_VERSION 584#ifndef DESKTOP_VERSION
585 if (mFaxAppAvailable == UNDEFINED) 585 if (mFaxAppAvailable == UNDEFINED)
586 { 586 {
587 int client = KPimGlobalPrefs::instance()->mFaxClient; 587 int client = KPimGlobalPrefs::instance()->mFaxClient;
588 if (client == KPimGlobalPrefs::NONE_FAC) 588 if (client == KPimGlobalPrefs::NONE_FAC)
589 mFaxAppAvailable = UNAVAILABLE; 589 mFaxAppAvailable = UNAVAILABLE;
590 else 590 else
591 mFaxAppAvailable = AVAILABLE; 591 mFaxAppAvailable = AVAILABLE;
592 } 592 }
593 593
594 return (mFaxAppAvailable == AVAILABLE); 594 return (mFaxAppAvailable == AVAILABLE);
595#else //DESKTOP_VERSION 595#else //DESKTOP_VERSION
596 return false; 596 return false;
597#endif //DESKTOP_VERSION 597#endif //DESKTOP_VERSION
598} 598}
599 599
600bool ExternalAppHandler::isPagerAppAvailable() 600bool ExternalAppHandler::isPagerAppAvailable()
601{ 601{
602#ifndef DESKTOP_VERSION 602#ifndef DESKTOP_VERSION
603 if (mPagerAppAvailable == UNDEFINED) 603 if (mPagerAppAvailable == UNDEFINED)
604 { 604 {
605 int client = KPimGlobalPrefs::instance()->mPagerClient; 605 int client = KPimGlobalPrefs::instance()->mPagerClient;
606 if (client == KPimGlobalPrefs::NONE_PAC) 606 if (client == KPimGlobalPrefs::NONE_PAC)
607 mPagerAppAvailable = UNAVAILABLE; 607 mPagerAppAvailable = UNAVAILABLE;
608 else 608 else
609 mPagerAppAvailable = AVAILABLE; 609 mPagerAppAvailable = AVAILABLE;
610 } 610 }
611 611
612 return (mPagerAppAvailable == AVAILABLE); 612 return (mPagerAppAvailable == AVAILABLE);
613#else //DESKTOP_VERSION 613#else //DESKTOP_VERSION
614 return false; 614 return false;
615#endif //DESKTOP_VERSION 615#endif //DESKTOP_VERSION
616} 616}
617 617
618 618
619bool ExternalAppHandler::isSIPAppAvailable() 619bool ExternalAppHandler::isSIPAppAvailable()
620{ 620{
621#ifndef DESKTOP_VERSION 621#ifndef DESKTOP_VERSION
622 if (mSIPAppAvailable == UNDEFINED) 622 if (mSIPAppAvailable == UNDEFINED)
623 { 623 {
624 int client = KPimGlobalPrefs::instance()->mSipClient; 624 int client = KPimGlobalPrefs::instance()->mSipClient;
625 if (client == KPimGlobalPrefs::NONE_SIC) 625 if (client == KPimGlobalPrefs::NONE_SIC)
626 mSIPAppAvailable = UNAVAILABLE; 626 mSIPAppAvailable = UNAVAILABLE;
627 else 627 else
628 mSIPAppAvailable = AVAILABLE; 628 mSIPAppAvailable = AVAILABLE;
629 } 629 }
630 630
631 return (mSIPAppAvailable == AVAILABLE); 631 return (mSIPAppAvailable == AVAILABLE);
632#else //DESKTOP_VERSION 632#else //DESKTOP_VERSION
633 return false; 633 return false;
634#endif //DESKTOP_VERSION 634#endif //DESKTOP_VERSION
635} 635}
636 636
637/************************************************************************** 637/**************************************************************************
638 * 638 *
639 **************************************************************************/ 639 **************************************************************************/
640 640
641 641
642//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 642//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
643bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 643bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
644{ 644{
645 645
646#ifndef DESKTOP_VERSION 646#ifndef DESKTOP_VERSION
647 QString channel; 647 QString channel;
648 QString message2; 648 QString message2;
649 QString parameters2; 649 QString parameters2;
650 650
651 651
652 int client = KPimGlobalPrefs::instance()->mEmailClient; 652 int client = KPimGlobalPrefs::instance()->mEmailClient;
653 if (client == KPimGlobalPrefs::OTHER_EMC) 653 if (client == KPimGlobalPrefs::OTHER_EMC)
654 { 654 {
655 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 655 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
656 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 656 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
657 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 657 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
658 } 658 }
659 else 659 else
660 { 660 {
661 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 661 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
662 if (!dai) 662 if (!dai)
663 { 663 {
664 qDebug("could not find configured email application."); 664 qDebug("could not find configured email application.");
665 return false; 665 return false;
666 } 666 }
667 channel = dai->_channel; 667 channel = dai->_channel;
668 message2 = dai->_message2; 668 message2 = dai->_message2;
669 parameters2 = dai->_parameters2; 669 parameters2 = dai->_parameters2;
670 } 670 }
671 671
672 //first check if one of the mailers need the emails right in the message. 672 //first check if one of the mailers need the emails right in the message.
673 message2 = translateMessage(message2, emails, urls); 673 message2 = translateMessage(message2, emails, urls);
674 674
675 675
676#ifdef DEBUG_EXT_APP_HANDLER 676#ifdef DEBUG_EXT_APP_HANDLER
677 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 677 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
678 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 678 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
679#endif 679#endif
680 680
681 681
682 QCopEnvelope e(channel.latin1(), message2.latin1()); 682 QCopEnvelope e(channel.latin1(), message2.latin1());
683 //US we need no names in the To field. The emailadresses are enough 683 //US we need no names in the To field. The emailadresses are enough
684 684
685 passParameters(&e, parameters2, emails, urls); 685 passParameters(&e, parameters2, emails, urls);
686 686
687 687
688 688
689#else 689#else
690 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 690 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
691#endif 691#endif
692 692
693 return true; 693 return true;
694} 694}
695 695
696/************************************************************************** 696/**************************************************************************
697 * 697 *
698 **************************************************************************/ 698 **************************************************************************/
699 699
700 700
701//calls the emailapplication and creates a mail with parameter emails as recipients 701//calls the emailapplication and creates a mail with parameter emails as recipients
702bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 702bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
703{ 703{
704#ifndef DESKTOP_VERSION 704#ifndef DESKTOP_VERSION
705 QString channel; 705 QString channel;
706 QString message; 706 QString message;
707 QString parameters; 707 QString parameters;
708 708
709 709
710 int client = KPimGlobalPrefs::instance()->mEmailClient; 710 int client = KPimGlobalPrefs::instance()->mEmailClient;
711 if (client == KPimGlobalPrefs::OTHER_EMC) 711 if (client == KPimGlobalPrefs::OTHER_EMC)
712 { 712 {
713 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 713 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
714 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 714 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
715 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 715 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
716 } 716 }
717 else 717 else
718 { 718 {
719 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 719 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
720 if (!dai) 720 if (!dai)
721 { 721 {
722 qDebug("could not find configured email application."); 722 qDebug("could not find configured email application.");
723 return false; 723 return false;
724 } 724 }
725 channel = dai->_channel; 725 channel = dai->_channel;
726 message = dai->_message; 726 message = dai->_message;
727 parameters = dai->_parameters; 727 parameters = dai->_parameters;
728 } 728 }
729 729
730 730
731 //first check if one of the mailers need the emails right in the message. 731 //first check if one of the mailers need the emails right in the message.
732 message = translateMessage(message, name, emailadress); 732 message = translateMessage(message, name, emailadress);
733 733
734 734
735#ifdef DEBUG_EXT_APP_HANDLER 735#ifdef DEBUG_EXT_APP_HANDLER
736 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 736 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
737 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 737 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
738#endif 738#endif
739 739
740 QCopEnvelope e(channel.latin1(), message.latin1()); 740 QCopEnvelope e(channel.latin1(), message.latin1());
741 //US we need no names in the To field. The emailadresses are enough 741 //US we need no names in the To field. The emailadresses are enough
742 742
743 passParameters(&e, parameters, name, emailadress); 743 passParameters(&e, parameters, name, emailadress);
744 744
745 745
746#else 746#else
747 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 747 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
748#endif 748#endif
749 749
750 750
751 return true; 751 return true;
752} 752}
753 753
754/************************************************************************** 754/**************************************************************************
755 * 755 *
756 **************************************************************************/ 756 **************************************************************************/
757 757
758//calls the emailapplication and creates a mail with parameter as recipients 758//calls the emailapplication and creates a mail with parameter as recipients
759// parameters format is 759// parameters format is
760// NAME <EMAIL>:SUBJECT 760// NAME <EMAIL>:SUBJECT
761bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 761bool ExternalAppHandler::mailToOneContact( const QString& adressline )
762{ 762{
763 QString line = adressline; 763 QString line = adressline;
764 764
765 int first = line.find( "<"); 765 int first = line.find( "<");
766 int last = line.find( ">"); 766 int last = line.find( ">");
767 QString name = line.left(first); 767 QString name = line.left(first);
768 QString emailadress = line.mid(first+1, last-first-1); 768 QString emailadress = line.mid(first+1, last-first-1);
769 769
770 //Subject can not be handled right now. 770 //Subject can not be handled right now.
771 return mailToOneContact( name, emailadress ); 771 return mailToOneContact( name, emailadress );
772 772
773} 773}
774 774
775 775
776/************************************************************************** 776/**************************************************************************
777 * 777 *
778 **************************************************************************/ 778 **************************************************************************/
779 779
780//calls the phoneapplication with the number 780//calls the phoneapplication with the number
781bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 781bool ExternalAppHandler::callByPhone( const QString& phonenumber )
782{ 782{
783#ifndef DESKTOP_VERSION 783#ifndef DESKTOP_VERSION
784 QString channel; 784 QString channel;
785 QString message; 785 QString message;
786 QString parameters; 786 QString parameters;
787 787
788 788
789 int client = KPimGlobalPrefs::instance()->mPhoneClient; 789 int client = KPimGlobalPrefs::instance()->mPhoneClient;
790 if (client == KPimGlobalPrefs::OTHER_PHC) 790 if (client == KPimGlobalPrefs::OTHER_PHC)
791 { 791 {
792 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 792 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
793 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 793 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
794 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 794 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
795 } 795 }
796 else 796 else
797 { 797 {
798 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 798 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
799 if (!dai) 799 if (!dai)
800 { 800 {
801 qDebug("could not find configured phone application."); 801 qDebug("could not find configured phone application.");
802 return false; 802 return false;
803 } 803 }
804 channel = dai->_channel; 804 channel = dai->_channel;
805 message = dai->_message; 805 message = dai->_message;
806 parameters = dai->_parameters; 806 parameters = dai->_parameters;
807 } 807 }
808 808
809 809
810 //first check if one of the mailers need the emails right in the message. 810 //first check if one of the mailers need the emails right in the message.
811 message = translateMessage(message, phonenumber, ""); 811 message = translateMessage(message, phonenumber, "");
812 812
813 813
814#ifdef DEBUG_EXT_APP_HANDLER 814#ifdef DEBUG_EXT_APP_HANDLER
815 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 815 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
816 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 816 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
817#endif 817#endif
818 818
819 QCopEnvelope e(channel.latin1(), message.latin1()); 819 QCopEnvelope e(channel.latin1(), message.latin1());
820 //US we need no names in the To field. The emailadresses are enough 820 //US we need no names in the To field. The emailadresses are enough
821 821
822 passParameters(&e, parameters, phonenumber, ""); 822 passParameters(&e, parameters, phonenumber, "");
823 823
824 824
825#else 825#else
826 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 826 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
827#endif 827#endif
828 828
829 829
830 return true; 830 return true;
831} 831}
832 832
833/************************************************************************** 833/**************************************************************************
834 * 834 *
835 **************************************************************************/ 835 **************************************************************************/
836 836
837//calls the smsapplication with the number 837//calls the smsapplication with the number
838bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 838bool ExternalAppHandler::callBySMS( const QString& phonenumber )
839{ 839{
840#ifndef DESKTOP_VERSION 840#ifndef DESKTOP_VERSION
841 QString channel; 841 QString channel;
842 QString message; 842 QString message;
843 QString parameters; 843 QString parameters;
844 844
845 845
846 int client = KPimGlobalPrefs::instance()->mSMSClient; 846 int client = KPimGlobalPrefs::instance()->mSMSClient;
847 if (client == KPimGlobalPrefs::OTHER_SMC) 847 if (client == KPimGlobalPrefs::OTHER_SMC)
848 { 848 {
849 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 849 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
850 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 850 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
851 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 851 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
852 } 852 }
853 else 853 else
854 { 854 {
855 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 855 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
856 if (!dai) 856 if (!dai)
857 { 857 {
858 qDebug("could not find configured sms application."); 858 qDebug("could not find configured sms application.");
859 return false; 859 return false;
860 } 860 }
861 channel = dai->_channel; 861 channel = dai->_channel;
862 message = dai->_message; 862 message = dai->_message;
863 parameters = dai->_parameters; 863 parameters = dai->_parameters;
864 } 864 }
865 865
866 866
867 //first check if one of the mailers need the emails right in the message. 867 //first check if one of the mailers need the emails right in the message.
868 message = translateMessage(message, phonenumber, ""); 868 message = translateMessage(message, phonenumber, "");
869 869
870 870
871#ifdef DEBUG_EXT_APP_HANDLER 871#ifdef DEBUG_EXT_APP_HANDLER
872 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 872 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
873 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 873 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
874#endif 874#endif
875 875
876 QCopEnvelope e(channel.latin1(), message.latin1()); 876 QCopEnvelope e(channel.latin1(), message.latin1());
877 //US we need no names in the To field. The emailadresses are enough 877 //US we need no names in the To field. The emailadresses are enough
878 878
879 passParameters(&e, parameters, phonenumber, ""); 879 passParameters(&e, parameters, phonenumber, "");
880 880
881 881
882#else 882#else
883 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 883 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
884#endif 884#endif
885 885
886 886
887 return true; 887 return true;
888} 888}
889 889
890/************************************************************************** 890/**************************************************************************
891 * 891 *
892 **************************************************************************/ 892 **************************************************************************/
893 893
894//calls the pagerapplication with the number 894//calls the pagerapplication with the number
895bool ExternalAppHandler::callByPager( const QString& pagernumber ) 895bool ExternalAppHandler::callByPager( const QString& pagernumber )
896{ 896{
897#ifndef DESKTOP_VERSION 897#ifndef DESKTOP_VERSION
898 QString channel; 898 QString channel;
899 QString message; 899 QString message;
900 QString parameters; 900 QString parameters;
901 901
902 902
903 int client = KPimGlobalPrefs::instance()->mPagerClient; 903 int client = KPimGlobalPrefs::instance()->mPagerClient;
904 if (client == KPimGlobalPrefs::OTHER_PAC) 904 if (client == KPimGlobalPrefs::OTHER_PAC)
905 { 905 {
906 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 906 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
907 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 907 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
908 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 908 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
909 } 909 }
910 else 910 else
911 { 911 {
912 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 912 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
913 if (!dai) 913 if (!dai)
914 { 914 {
915 qDebug("could not find configured pager application."); 915 qDebug("could not find configured pager application.");
916 return false; 916 return false;
917 } 917 }
918 channel = dai->_channel; 918 channel = dai->_channel;
919 message = dai->_message; 919 message = dai->_message;
920 parameters = dai->_parameters; 920 parameters = dai->_parameters;
921 } 921 }
922 922
923 923
924 //first check if one of the mailers need the emails right in the message. 924 //first check if one of the mailers need the emails right in the message.
925 message = translateMessage(message, pagernumber, ""); 925 message = translateMessage(message, pagernumber, "");
926 926
927 927
928#ifdef DEBUG_EXT_APP_HANDLER 928#ifdef DEBUG_EXT_APP_HANDLER
929 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 929 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
930 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 930 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
931#endif 931#endif
932 932
933 QCopEnvelope e(channel.latin1(), message.latin1()); 933 QCopEnvelope e(channel.latin1(), message.latin1());
934 //US we need no names in the To field. The emailadresses are enough 934 //US we need no names in the To field. The emailadresses are enough
935 935
936 passParameters(&e, parameters, pagernumber, ""); 936 passParameters(&e, parameters, pagernumber, "");
937 937
938 938
939#else 939#else
940 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 940 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
941#endif 941#endif
942 942
943 943
944 return true; 944 return true;
945} 945}
946 946
947/************************************************************************** 947/**************************************************************************
948 * 948 *
949 **************************************************************************/ 949 **************************************************************************/
950 950
951//calls the faxapplication with the number 951//calls the faxapplication with the number
952bool ExternalAppHandler::callByFax( const QString& faxnumber ) 952bool ExternalAppHandler::callByFax( const QString& faxnumber )
953{ 953{
954#ifndef DESKTOP_VERSION 954#ifndef DESKTOP_VERSION
955 QString channel; 955 QString channel;
956 QString message; 956 QString message;
957 QString parameters; 957 QString parameters;
958 958
959 959
960 int client = KPimGlobalPrefs::instance()->mFaxClient; 960 int client = KPimGlobalPrefs::instance()->mFaxClient;
961 if (client == KPimGlobalPrefs::OTHER_FAC) 961 if (client == KPimGlobalPrefs::OTHER_FAC)
962 { 962 {
963 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 963 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
964 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 964 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
965 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 965 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
966 } 966 }
967 else 967 else
968 { 968 {
969 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 969 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
970 if (!dai) 970 if (!dai)
971 { 971 {
972 qDebug("could not find configured fax application."); 972 qDebug("could not find configured fax application.");
973 return false; 973 return false;
974 } 974 }
975 channel = dai->_channel; 975 channel = dai->_channel;
976 message = dai->_message; 976 message = dai->_message;
977 parameters = dai->_parameters; 977 parameters = dai->_parameters;
978 } 978 }
979 979
980 980
981 //first check if one of the mailers need the emails right in the message. 981 //first check if one of the mailers need the emails right in the message.
982 message = translateMessage(message, faxnumber, ""); 982 message = translateMessage(message, faxnumber, "");
983 983
984 984
985#ifdef DEBUG_EXT_APP_HANDLER 985#ifdef DEBUG_EXT_APP_HANDLER
986 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 986 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
987 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 987 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
988#endif 988#endif
989 989
990 QCopEnvelope e(channel.latin1(), message.latin1()); 990 QCopEnvelope e(channel.latin1(), message.latin1());
991 //US we need no names in the To field. The emailadresses are enough 991 //US we need no names in the To field. The emailadresses are enough
992 992
993 passParameters(&e, parameters, faxnumber, ""); 993 passParameters(&e, parameters, faxnumber, "");
994 994
995 995
996#else 996#else
997 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 997 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
998#endif 998#endif
999 999
1000 1000
1001 return true; 1001 return true;
1002} 1002}
1003 1003
1004/************************************************************************** 1004/**************************************************************************
1005 * 1005 *
1006 **************************************************************************/ 1006 **************************************************************************/
1007 1007
1008//calls the sipapplication with the number 1008//calls the sipapplication with the number
1009bool ExternalAppHandler::callBySIP( const QString& sipnumber ) 1009bool ExternalAppHandler::callBySIP( const QString& sipnumber )
1010{ 1010{
1011#ifndef DESKTOP_VERSION 1011#ifndef DESKTOP_VERSION
1012 QString channel; 1012 QString channel;
1013 QString message; 1013 QString message;
1014 QString parameters; 1014 QString parameters;
1015 1015
1016 1016
1017 int client = KPimGlobalPrefs::instance()->mSipClient; 1017 int client = KPimGlobalPrefs::instance()->mSipClient;
1018 if (client == KPimGlobalPrefs::OTHER_SIC) 1018 if (client == KPimGlobalPrefs::OTHER_SIC)
1019 { 1019 {
1020 channel = KPimGlobalPrefs::instance()->mSipOtherChannel; 1020 channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
1021 message = KPimGlobalPrefs::instance()->mSipOtherMessage; 1021 message = KPimGlobalPrefs::instance()->mSipOtherMessage;
1022 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; 1022 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
1023 } 1023 }
1024 else 1024 else
1025 { 1025 {
1026 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); 1026 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
1027 if (!dai) 1027 if (!dai)
1028 { 1028 {
1029 qDebug("could not find configured sip application."); 1029 qDebug("could not find configured sip application.");
1030 return false; 1030 return false;
1031 } 1031 }
1032 channel = dai->_channel; 1032 channel = dai->_channel;
1033 message = dai->_message; 1033 message = dai->_message;
1034 parameters = dai->_parameters; 1034 parameters = dai->_parameters;
1035 } 1035 }
1036 1036
1037 1037
1038 //first check if one of the sip apps need the emails right in the message. 1038 //first check if one of the sip apps need the emails right in the message.
1039 message = translateMessage(message, sipnumber, ""); 1039 message = translateMessage(message, sipnumber, "");
1040 1040
1041 1041
1042#ifdef DEBUG_EXT_APP_HANDLER 1042#ifdef DEBUG_EXT_APP_HANDLER
1043 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1043 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1044 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); 1044 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
1045#endif 1045#endif
1046 1046
1047 QCopEnvelope e(channel.latin1(), message.latin1()); 1047 QCopEnvelope e(channel.latin1(), message.latin1());
1048 //US we need no names in the To field. The emailadresses are enough 1048 //US we need no names in the To field. The emailadresses are enough
1049 1049
1050 passParameters(&e, parameters, sipnumber, ""); 1050 passParameters(&e, parameters, sipnumber, "");
1051 1051
1052 1052
1053#else 1053#else
1054 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); 1054 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
1055#endif 1055#endif
1056 1056
1057 1057
1058 return true; 1058 return true;
1059} 1059}
1060 1060
1061 1061
1062/************************************************************************** 1062/**************************************************************************
1063 * 1063 *
1064 **************************************************************************/ 1064 **************************************************************************/
1065 1065
1066 1066
1067QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 1067QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
1068{ 1068{
1069 message = message.replace( QRegExp("%1"), param1 ); 1069 message = message.replace( QRegExp("%1"), param1 );
1070 return message.replace( QRegExp("%2"), param2 ); 1070 return message.replace( QRegExp("%2"), param2 );
1071} 1071}
1072 1072
1073/************************************************************************** 1073/**************************************************************************
1074 * 1074 *
1075 **************************************************************************/ 1075 **************************************************************************/
1076 1076
1077void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 1077void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
1078{ 1078{
1079#ifndef DESKTOP_VERSION 1079#ifndef DESKTOP_VERSION
1080 QMap<QString, QString> valmap; 1080 QMap<QString, QString> valmap;
1081 bool useValMap = false; 1081 bool useValMap = false;
1082 1082
1083 // first extract all parts of the parameters. 1083 // first extract all parts of the parameters.
1084 QStringList paramlist = QStringList::split(";", parameters); 1084 QStringList paramlist = QStringList::split(";", parameters);
1085 1085
1086 //Now check how many parts we have. 1086 //Now check how many parts we have.
1087 //=0 :no params to pass 1087 //=0 :no params to pass
1088 //>0 :parameters to pass 1088 //>0 :parameters to pass
1089 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1089 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
1090 { 1090 {
1091 QString param = (*it); 1091 QString param = (*it);
1092 QStringList keyvallist = QStringList::split("=", param); 1092 QStringList keyvallist = QStringList::split("=", param);
1093 1093
1094 //if we have keyvalue pairs, we assume that we pass a map to the envelope 1094 //if we have keyvalue pairs, we assume that we pass a map to the envelope
1095 QStringList::Iterator it2 = keyvallist.begin(); 1095 QStringList::Iterator it2 = keyvallist.begin();
1096 QString key = (*it2); 1096 QString key = (*it2);
1097 key = key.replace( QRegExp("%1"), param1 ); 1097 key = key.replace( QRegExp("%1"), param1 );
1098 key = key.replace( QRegExp("%2"), param2 ); 1098 key = key.replace( QRegExp("%2"), param2 );
1099 ++it2; 1099 ++it2;
1100 1100
1101 if(it2 != keyvallist.end()) 1101 if(it2 != keyvallist.end())
1102 { 1102 {
1103 QString value = (*it2); 1103 QString value = (*it2);
1104 value = value.replace( QRegExp("%1"), param1 ); 1104 value = value.replace( QRegExp("%1"), param1 );
1105 value = value.replace( QRegExp("%2"), param2 ); 1105 value = value.replace( QRegExp("%2"), param2 );
1106 1106
1107 valmap.insert(key, value); 1107 valmap.insert(key, value);
1108 useValMap = true; 1108 useValMap = true;
1109 } 1109 }
1110 else 1110 else
1111 { 1111 {
1112 // qDebug("pass parameter << %s", key.latin1()); 1112 // qDebug("pass parameter << %s", key.latin1());
1113 (*e) << key; 1113 (*e) << key;
1114 } 1114 }
1115 } 1115 }
1116 1116
1117 if (useValMap == true) 1117 if (useValMap == true)
1118 (*e) << valmap; 1118 (*e) << valmap;
1119 1119
1120#endif 1120#endif
1121 1121
1122} 1122}
1123 1123
1124 1124
1125 1125
1126/************************************************************************** 1126/**************************************************************************
1127 * 1127 *
1128 **************************************************************************/ 1128 **************************************************************************/
1129 1129
1130void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1130void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
1131{ 1131{
1132 1132
1133 if ( cmsg == "nextView()" ) { 1133 if ( cmsg == "nextView()" ) {
1134 qDebug("nextView()"); 1134 qDebug("nextView()");
1135 emit nextView(); 1135 emit nextView();
1136 return; 1136 return;
1137 } 1137 }
1138 1138
1139 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1139 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1140 if (!res) 1140 if (!res)
1141 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); 1141 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
1142 1142
1143 if (!res) 1143 if (!res)
1144 res = mDisplayDetails->appMessage( cmsg, data ); 1144 res = mDisplayDetails->appMessage( cmsg, data );
1145 1145
1146// if (!res) 1146// if (!res)
1147// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1147// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1148} 1148}
1149 1149
1150 1150
1151 1151
1152bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1152bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1153{ 1153{
1154 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1154 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1155 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 1155 // maybe we are sending to KA/Pi fom a different worldd...
1156 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application
1157 // for that reason we send the current QApplication::desktop()->width() to KA/Pi
1158 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() ));
1156} 1159}
1157 1160
1158bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1161bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1159{ 1162{
1160 QStringList list4, list5, list6; 1163 QStringList list4, list5, list6;
1161 1164
1162 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1165 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1163 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1166 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1164} 1167}
1165 1168
1166bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 1169bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
1167{ 1170{
1168 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1171 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1169 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 1172 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
1170} 1173}
1171 1174
1172bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1175bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1173{ 1176{
1174 QStringList list4, list5, list6; 1177 QStringList list4, list5, list6;
1175 1178
1176 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1179 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1177 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1180 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1178} 1181}
1179 1182
1180bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) 1183bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
1181{ 1184{
1182 mDisplayDetails->setSourceChannel(""); 1185 mDisplayDetails->setSourceChannel("");
1183 return mDisplayDetails->sendMessageToTarget("", name, email, uid); 1186 return mDisplayDetails->sendMessageToTarget("", name, email, uid);
1184} 1187}
1185 1188
1186bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1189bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1187{ 1190{
1188 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1191 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1189 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); 1192 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid);
1190} 1193}
1191 1194
1192bool 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) 1195bool 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)
1193{ 1196{
1194 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1197 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1195 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1198 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1196} 1199}
1197 1200
1198 1201
1199 1202
1200 1203
1201 1204