summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp33
-rw-r--r--kaddressbook/kabcore.h3
-rw-r--r--kaddressbook/mainembedded.cpp19
-rw-r--r--libkdepim/externalapphandler.cpp282
-rw-r--r--libkdepim/externalapphandler.h111
5 files changed, 435 insertions, 13 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 6807bed..e7c815e 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1971 +1,2004 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include "kabcore.h" 24#include "kabcore.h"
25 25
26#include <stdaddressbook.h> 26#include <stdaddressbook.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#include <qclipboard.h> 30#include <qclipboard.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qapplicaton.h> 33#include <qapplicaton.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qregexp.h> 35#include <qregexp.h>
36#include <qvbox.h> 36#include <qvbox.h>
37#include <kabc/addresseelist.h> 37#include <kabc/addresseelist.h>
38#include <kabc/errorhandler.h> 38#include <kabc/errorhandler.h>
39#include <kabc/resource.h> 39#include <kabc/resource.h>
40#include <kabc/vcardconverter.h> 40#include <kabc/vcardconverter.h>
41#include <kapplication.h> 41#include <kapplication.h>
42#include <kactionclasses.h> 42#include <kactionclasses.h>
43#include <kcmultidialog.h> 43#include <kcmultidialog.h>
44#include <kdebug.h> 44#include <kdebug.h>
45#include <kdeversion.h> 45#include <kdeversion.h>
46#include <kkeydialog.h> 46#include <kkeydialog.h>
47#include <kmessagebox.h> 47#include <kmessagebox.h>
48#include <kprinter.h> 48#include <kprinter.h>
49#include <kprotocolinfo.h> 49#include <kprotocolinfo.h>
50#include <kresources/selectdialog.h> 50#include <kresources/selectdialog.h>
51#include <kstandarddirs.h> 51#include <kstandarddirs.h>
52#include <ktempfile.h> 52#include <ktempfile.h>
53#include <kxmlguiclient.h> 53#include <kxmlguiclient.h>
54#include <kaboutdata.h> 54#include <kaboutdata.h>
55#include <libkdepim/categoryselectdialog.h> 55#include <libkdepim/categoryselectdialog.h>
56 56
57#include "addresseeutil.h" 57#include "addresseeutil.h"
58#include "addresseeeditordialog.h" 58#include "addresseeeditordialog.h"
59#include "extensionmanager.h" 59#include "extensionmanager.h"
60#include "kstdaction.h" 60#include "kstdaction.h"
61#include "kaddressbookservice.h" 61#include "kaddressbookservice.h"
62#include "ldapsearchdialog.h" 62#include "ldapsearchdialog.h"
63#include "printing/printingwizard.h" 63#include "printing/printingwizard.h"
64#else // KAB_EMBEDDED 64#else // KAB_EMBEDDED
65 65
66#include <kapplication.h> 66#include <kapplication.h>
67#include "KDGanttMinimizeSplitter.h" 67#include "KDGanttMinimizeSplitter.h"
68#include "kaddressbookmain.h" 68#include "kaddressbookmain.h"
69#include "kactioncollection.h" 69#include "kactioncollection.h"
70#include "addresseedialog.h"
71
70#include <qapp.h> 72#include <qapp.h>
71#include <qmenubar.h> 73#include <qmenubar.h>
72//#include <qtoolbar.h> 74//#include <qtoolbar.h>
73#include <qmessagebox.h> 75#include <qmessagebox.h>
74#include <kdebug.h> 76#include <kdebug.h>
75#include <kiconloader.h> // needed for SmallIcon 77#include <kiconloader.h> // needed for SmallIcon
76#include <kresources/kcmkresources.h> 78#include <kresources/kcmkresources.h>
77#include <ktoolbar.h> 79#include <ktoolbar.h>
78 80
79 81
80//#include <qlabel.h> 82//#include <qlabel.h>
81 83
82 84
83#ifndef DESKTOP_VERSION 85#ifndef DESKTOP_VERSION
84#include <qpe/ir.h> 86#include <qpe/ir.h>
85#endif 87#endif
86 88
87#endif // KAB_EMBEDDED 89#endif // KAB_EMBEDDED
88#include "kcmconfigs/kcmkabconfig.h" 90#include "kcmconfigs/kcmkabconfig.h"
89#include "kcmconfigs/kcmkdepimconfig.h" 91#include "kcmconfigs/kcmkdepimconfig.h"
90#include "kpimglobalprefs.h" 92#include "kpimglobalprefs.h"
91#include "externalapphandler.h" 93#include "externalapphandler.h"
92 94
93 95
94#include <kresources/selectdialog.h> 96#include <kresources/selectdialog.h>
95#include <kmessagebox.h> 97#include <kmessagebox.h>
96 98
97#include <picture.h> 99#include <picture.h>
98#include <resource.h> 100#include <resource.h>
99 101
100//US#include <qsplitter.h> 102//US#include <qsplitter.h>
101#include <qmap.h> 103#include <qmap.h>
102#include <qdir.h> 104#include <qdir.h>
103#include <qfile.h> 105#include <qfile.h>
104#include <qvbox.h> 106#include <qvbox.h>
105#include <qlayout.h> 107#include <qlayout.h>
106#include <qclipboard.h> 108#include <qclipboard.h>
107#include <qtextstream.h> 109#include <qtextstream.h>
108 110
109#include <libkdepim/categoryselectdialog.h> 111#include <libkdepim/categoryselectdialog.h>
110#include <kabc/vcardconverter.h> 112#include <kabc/vcardconverter.h>
111 113
112 114
113#include "addresseeutil.h" 115#include "addresseeutil.h"
114#include "undocmds.h" 116#include "undocmds.h"
115#include "addresseeeditordialog.h" 117#include "addresseeeditordialog.h"
116#include "viewmanager.h" 118#include "viewmanager.h"
117#include "details/detailsviewcontainer.h" 119#include "details/detailsviewcontainer.h"
118#include "kabprefs.h" 120#include "kabprefs.h"
119#include "xxportmanager.h" 121#include "xxportmanager.h"
120#include "incsearchwidget.h" 122#include "incsearchwidget.h"
121#include "jumpbuttonbar.h" 123#include "jumpbuttonbar.h"
122#include "extensionmanager.h" 124#include "extensionmanager.h"
123#include "addresseeconfig.h" 125#include "addresseeconfig.h"
124#include <kcmultidialog.h> 126#include <kcmultidialog.h>
125 127
126#ifdef _WIN32_ 128#ifdef _WIN32_
127 129
128#include "kaimportoldialog.h" 130#include "kaimportoldialog.h"
129#endif 131#endif
130 132
131bool pasteWithNewUid = true; 133bool pasteWithNewUid = true;
132 134
133#ifdef KAB_EMBEDDED 135#ifdef KAB_EMBEDDED
134KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 136KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
135 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 137 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
136 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 138 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
137 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 139 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
138#else //KAB_EMBEDDED 140#else //KAB_EMBEDDED
139KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 141KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
140 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 142 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
141 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 143 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
142 mReadWrite( readWrite ), mModified( false ) 144 mReadWrite( readWrite ), mModified( false )
143#endif //KAB_EMBEDDED 145#endif //KAB_EMBEDDED
144{ 146{
145 147
146 mExtensionBarSplitter = 0; 148 mExtensionBarSplitter = 0;
147 mIsPart = !parent->inherits( "KAddressBookMain" ); 149 mIsPart = !parent->inherits( "KAddressBookMain" );
148 150
149 mAddressBook = KABC::StdAddressBook::self(); 151 mAddressBook = KABC::StdAddressBook::self();
150 KABC::StdAddressBook::setAutomaticSave( false ); 152 KABC::StdAddressBook::setAutomaticSave( false );
151 153
152#ifndef KAB_EMBEDDED 154#ifndef KAB_EMBEDDED
153 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 155 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
154#endif //KAB_EMBEDDED 156#endif //KAB_EMBEDDED
155 157
156 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 158 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
157 SLOT( addressBookChanged() ) ); 159 SLOT( addressBookChanged() ) );
158 160
159 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 161 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
160 "X-Department", "KADDRESSBOOK" ); 162 "X-Department", "KADDRESSBOOK" );
161 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 163 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
162 "X-Profession", "KADDRESSBOOK" ); 164 "X-Profession", "KADDRESSBOOK" );
163 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 165 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
164 "X-AssistantsName", "KADDRESSBOOK" ); 166 "X-AssistantsName", "KADDRESSBOOK" );
165 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 167 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
166 "X-ManagersName", "KADDRESSBOOK" ); 168 "X-ManagersName", "KADDRESSBOOK" );
167 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 169 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
168 "X-SpousesName", "KADDRESSBOOK" ); 170 "X-SpousesName", "KADDRESSBOOK" );
169 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 171 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
170 "X-Office", "KADDRESSBOOK" ); 172 "X-Office", "KADDRESSBOOK" );
171 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 173 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
172 "X-IMAddress", "KADDRESSBOOK" ); 174 "X-IMAddress", "KADDRESSBOOK" );
173 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 175 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
174 "X-Anniversary", "KADDRESSBOOK" ); 176 "X-Anniversary", "KADDRESSBOOK" );
175 177
176 //US added this field to become compatible with Opie/qtopia addressbook 178 //US added this field to become compatible with Opie/qtopia addressbook
177 // values can be "female" or "male" or "". An empty field represents undefined. 179 // values can be "female" or "male" or "". An empty field represents undefined.
178 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 180 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
179 "X-Gender", "KADDRESSBOOK" ); 181 "X-Gender", "KADDRESSBOOK" );
180 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 182 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
181 "X-Children", "KADDRESSBOOK" ); 183 "X-Children", "KADDRESSBOOK" );
182 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 184 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
183 "X-FreeBusyUrl", "KADDRESSBOOK" ); 185 "X-FreeBusyUrl", "KADDRESSBOOK" );
184 186
185 initGUI(); 187 initGUI();
186 188
187 mIncSearchWidget->setFocus(); 189 mIncSearchWidget->setFocus();
188 190
189 191
190 connect( mViewManager, SIGNAL( selected( const QString& ) ), 192 connect( mViewManager, SIGNAL( selected( const QString& ) ),
191 SLOT( setContactSelected( const QString& ) ) ); 193 SLOT( setContactSelected( const QString& ) ) );
192 connect( mViewManager, SIGNAL( executed( const QString& ) ), 194 connect( mViewManager, SIGNAL( executed( const QString& ) ),
193 SLOT( executeContact( const QString& ) ) ); 195 SLOT( executeContact( const QString& ) ) );
194 196
195 connect( mViewManager, SIGNAL( deleteRequest( ) ), 197 connect( mViewManager, SIGNAL( deleteRequest( ) ),
196 SLOT( deleteContacts( ) ) ); 198 SLOT( deleteContacts( ) ) );
197 connect( mViewManager, SIGNAL( modified() ), 199 connect( mViewManager, SIGNAL( modified() ),
198 SLOT( setModified() ) ); 200 SLOT( setModified() ) );
199 201
200 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 202 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
201 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 203 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
202 204
203 connect( mXXPortManager, SIGNAL( modified() ), 205 connect( mXXPortManager, SIGNAL( modified() ),
204 SLOT( setModified() ) ); 206 SLOT( setModified() ) );
205 207
206 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 208 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
207 SLOT( incrementalSearch( const QString& ) ) ); 209 SLOT( incrementalSearch( const QString& ) ) );
208 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 210 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
209 mJumpButtonBar, SLOT( recreateButtons() ) ); 211 mJumpButtonBar, SLOT( recreateButtons() ) );
210 212
211 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 213 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
212 SLOT( sendMail( const QString& ) ) ); 214 SLOT( sendMail( const QString& ) ) );
213 215
216
217 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&, const QString&)));
218
219
214#ifndef KAB_EMBEDDED 220#ifndef KAB_EMBEDDED
215 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 221 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
216 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 222 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
217 223
218 connect( mDetails, SIGNAL( browse( const QString& ) ), 224 connect( mDetails, SIGNAL( browse( const QString& ) ),
219 SLOT( browse( const QString& ) ) ); 225 SLOT( browse( const QString& ) ) );
220 226
227
221 mAddressBookService = new KAddressBookService( this ); 228 mAddressBookService = new KAddressBookService( this );
222 229
223#endif //KAB_EMBEDDED 230#endif //KAB_EMBEDDED
224 mEditorDialog = 0; 231 mEditorDialog = 0;
225 createAddresseeEditorDialog( this ); 232 createAddresseeEditorDialog( this );
226 setModified( false ); 233 setModified( false );
227} 234}
228 235
229KABCore::~KABCore() 236KABCore::~KABCore()
230{ 237{
231 // save(); 238 // save();
232 //saveSettings(); 239 //saveSettings();
233 //KABPrefs::instance()->writeConfig(); 240 //KABPrefs::instance()->writeConfig();
234 delete AddresseeConfig::instance(); 241 delete AddresseeConfig::instance();
235 mAddressBook = 0; 242 mAddressBook = 0;
236 KABC::StdAddressBook::close(); 243 KABC::StdAddressBook::close();
237} 244}
238 245
239void KABCore::restoreSettings() 246void KABCore::restoreSettings()
240{ 247{
241 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 248 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
242 249
243 bool state; 250 bool state;
244 251
245 if (mMultipleViewsAtOnce) 252 if (mMultipleViewsAtOnce)
246 state = KABPrefs::instance()->mDetailsPageVisible; 253 state = KABPrefs::instance()->mDetailsPageVisible;
247 else 254 else
248 state = false; 255 state = false;
249 256
250 mActionDetails->setChecked( state ); 257 mActionDetails->setChecked( state );
251 setDetailsVisible( state ); 258 setDetailsVisible( state );
252 259
253 state = KABPrefs::instance()->mJumpButtonBarVisible; 260 state = KABPrefs::instance()->mJumpButtonBarVisible;
254 261
255 mActionJumpBar->setChecked( state ); 262 mActionJumpBar->setChecked( state );
256 setJumpButtonBarVisible( state ); 263 setJumpButtonBarVisible( state );
257/*US 264/*US
258 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 265 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
259 if ( splitterSize.count() == 0 ) { 266 if ( splitterSize.count() == 0 ) {
260 splitterSize.append( width() / 2 ); 267 splitterSize.append( width() / 2 );
261 splitterSize.append( width() / 2 ); 268 splitterSize.append( width() / 2 );
262 } 269 }
263 mMiniSplitter->setSizes( splitterSize ); 270 mMiniSplitter->setSizes( splitterSize );
264 if ( mExtensionBarSplitter ) { 271 if ( mExtensionBarSplitter ) {
265 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 272 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
266 if ( splitterSize.count() == 0 ) { 273 if ( splitterSize.count() == 0 ) {
267 splitterSize.append( width() / 2 ); 274 splitterSize.append( width() / 2 );
268 splitterSize.append( width() / 2 ); 275 splitterSize.append( width() / 2 );
269 } 276 }
270 mExtensionBarSplitter->setSizes( splitterSize ); 277 mExtensionBarSplitter->setSizes( splitterSize );
271 278
272 } 279 }
273*/ 280*/
274 mViewManager->restoreSettings(); 281 mViewManager->restoreSettings();
275 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 282 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
276 mExtensionManager->restoreSettings(); 283 mExtensionManager->restoreSettings();
277 284
278 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 285 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
279 if ( splitterSize.count() == 0 ) { 286 if ( splitterSize.count() == 0 ) {
280 splitterSize.append( width() / 2 ); 287 splitterSize.append( width() / 2 );
281 splitterSize.append( width() / 2 ); 288 splitterSize.append( width() / 2 );
282 } 289 }
283 mMiniSplitter->setSizes( splitterSize ); 290 mMiniSplitter->setSizes( splitterSize );
284 if ( mExtensionBarSplitter ) { 291 if ( mExtensionBarSplitter ) {
285 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 292 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
286 if ( splitterSize.count() == 0 ) { 293 if ( splitterSize.count() == 0 ) {
287 splitterSize.append( width() / 2 ); 294 splitterSize.append( width() / 2 );
288 splitterSize.append( width() / 2 ); 295 splitterSize.append( width() / 2 );
289 } 296 }
290 mExtensionBarSplitter->setSizes( splitterSize ); 297 mExtensionBarSplitter->setSizes( splitterSize );
291 298
292 } 299 }
293 300
294 301
295} 302}
296 303
297void KABCore::saveSettings() 304void KABCore::saveSettings()
298{ 305{
299 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 306 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
300 if ( mExtensionBarSplitter ) 307 if ( mExtensionBarSplitter )
301 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 308 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
302 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 309 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
303 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 310 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
304#ifndef KAB_EMBEDDED 311#ifndef KAB_EMBEDDED
305 312
306 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 313 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
307 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 314 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
308#endif //KAB_EMBEDDED 315#endif //KAB_EMBEDDED
309 mExtensionManager->saveSettings(); 316 mExtensionManager->saveSettings();
310 mViewManager->saveSettings(); 317 mViewManager->saveSettings();
311 318
312 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 319 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
313} 320}
314 321
315KABC::AddressBook *KABCore::addressBook() const 322KABC::AddressBook *KABCore::addressBook() const
316{ 323{
317 return mAddressBook; 324 return mAddressBook;
318} 325}
319 326
320KConfig *KABCore::config() 327KConfig *KABCore::config()
321{ 328{
322#ifndef KAB_EMBEDDED 329#ifndef KAB_EMBEDDED
323 return KABPrefs::instance()->config(); 330 return KABPrefs::instance()->config();
324#else //KAB_EMBEDDED 331#else //KAB_EMBEDDED
325 return KABPrefs::instance()->getConfig(); 332 return KABPrefs::instance()->getConfig();
326#endif //KAB_EMBEDDED 333#endif //KAB_EMBEDDED
327} 334}
328 335
329KActionCollection *KABCore::actionCollection() const 336KActionCollection *KABCore::actionCollection() const
330{ 337{
331 return mGUIClient->actionCollection(); 338 return mGUIClient->actionCollection();
332} 339}
333 340
334KABC::Field *KABCore::currentSearchField() const 341KABC::Field *KABCore::currentSearchField() const
335{ 342{
336 if (mIncSearchWidget) 343 if (mIncSearchWidget)
337 return mIncSearchWidget->currentField(); 344 return mIncSearchWidget->currentField();
338 else 345 else
339 return 0; 346 return 0;
340} 347}
341 348
342QStringList KABCore::selectedUIDs() const 349QStringList KABCore::selectedUIDs() const
343{ 350{
344 return mViewManager->selectedUids(); 351 return mViewManager->selectedUids();
345} 352}
346 353
347KABC::Resource *KABCore::requestResource( QWidget *parent ) 354KABC::Resource *KABCore::requestResource( QWidget *parent )
348{ 355{
349 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 356 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
350 357
351 QPtrList<KRES::Resource> kresResources; 358 QPtrList<KRES::Resource> kresResources;
352 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 359 QPtrListIterator<KABC::Resource> resIt( kabcResources );
353 KABC::Resource *resource; 360 KABC::Resource *resource;
354 while ( ( resource = resIt.current() ) != 0 ) { 361 while ( ( resource = resIt.current() ) != 0 ) {
355 ++resIt; 362 ++resIt;
356 if ( !resource->readOnly() ) { 363 if ( !resource->readOnly() ) {
357 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 364 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
358 if ( res ) 365 if ( res )
359 kresResources.append( res ); 366 kresResources.append( res );
360 } 367 }
361 } 368 }
362 369
363 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 370 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
364 return static_cast<KABC::Resource*>( res ); 371 return static_cast<KABC::Resource*>( res );
365} 372}
366 373
367#ifndef KAB_EMBEDDED 374#ifndef KAB_EMBEDDED
368KAboutData *KABCore::createAboutData() 375KAboutData *KABCore::createAboutData()
369#else //KAB_EMBEDDED 376#else //KAB_EMBEDDED
370void KABCore::createAboutData() 377void KABCore::createAboutData()
371#endif //KAB_EMBEDDED 378#endif //KAB_EMBEDDED
372{ 379{
373#ifndef KAB_EMBEDDED 380#ifndef KAB_EMBEDDED
374 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 381 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
375 "3.1", I18N_NOOP( "The KDE Address Book" ), 382 "3.1", I18N_NOOP( "The KDE Address Book" ),
376 KAboutData::License_GPL_V2, 383 KAboutData::License_GPL_V2,
377 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 384 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
378 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 385 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
379 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 386 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
380 about->addAuthor( "Cornelius Schumacher", 387 about->addAuthor( "Cornelius Schumacher",
381 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 388 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
382 "schumacher@kde.org" ); 389 "schumacher@kde.org" );
383 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 390 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
384 "mpilone@slac.com" ); 391 "mpilone@slac.com" );
385 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 392 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
386 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 393 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
387 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 394 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
388 "michel@klaralvdalens-datakonsult.se" ); 395 "michel@klaralvdalens-datakonsult.se" );
389 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 396 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
390 "hansen@kde.org" ); 397 "hansen@kde.org" );
391 398
392 return about; 399 return about;
393#endif //KAB_EMBEDDED 400#endif //KAB_EMBEDDED
394 401
395 QString version; 402 QString version;
396#include <../version> 403#include <../version>
397 QMessageBox::about( this, "About KAddressbook/Pi", 404 QMessageBox::about( this, "About KAddressbook/Pi",
398 "KAddressbook/Platform-independent\n" 405 "KAddressbook/Platform-independent\n"
399 "(KA/Pi) " +version + " - " + 406 "(KA/Pi) " +version + " - " +
400#ifdef DESKTOP_VERSION 407#ifdef DESKTOP_VERSION
401 "Desktop Edition\n" 408 "Desktop Edition\n"
402#else 409#else
403 "PDA-Edition\n" 410 "PDA-Edition\n"
404 "for: Zaurus 5500 / 7x0 / 8x0\n" 411 "for: Zaurus 5500 / 7x0 / 8x0\n"
405#endif 412#endif
406 413
407 "(c) 2004 Ulf Schenk\n" 414 "(c) 2004 Ulf Schenk\n"
408 "(c) 1997-2003, The KDE PIM Team\n" 415 "(c) 1997-2003, The KDE PIM Team\n"
409 "Tobias Koenig Current maintainer tokoe@kde.org\n" 416 "Tobias Koenig Current maintainer tokoe@kde.org\n"
410 "Don Sanders Original author\n" 417 "Don Sanders Original author\n"
411 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" 418 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n"
412 "Mike Pilone GUI and framework redesign mpilone@slac.com\n" 419 "Mike Pilone GUI and framework redesign mpilone@slac.com\n"
413 "Greg Stern DCOP interface\n" 420 "Greg Stern DCOP interface\n"
414 "Mark Westcot Contact pinning\n" 421 "Mark Westcot Contact pinning\n"
415 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 422 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
416 "Steffen Hansen LDAP Lookup hansen@kde.org\n" 423 "Steffen Hansen LDAP Lookup hansen@kde.org\n"
417#ifdef _WIN32_ 424#ifdef _WIN32_
418 "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" 425 "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n"
419#endif 426#endif
420 ); 427 );
421} 428}
422 429
423void KABCore::setContactSelected( const QString &uid ) 430void KABCore::setContactSelected( const QString &uid )
424{ 431{
425 KABC::Addressee addr = mAddressBook->findByUid( uid ); 432 KABC::Addressee addr = mAddressBook->findByUid( uid );
426 if ( !mDetails->isHidden() ) 433 if ( !mDetails->isHidden() )
427 mDetails->setAddressee( addr ); 434 mDetails->setAddressee( addr );
428 435
429 if ( !addr.isEmpty() ) { 436 if ( !addr.isEmpty() ) {
430 emit contactSelected( addr.formattedName() ); 437 emit contactSelected( addr.formattedName() );
431 KABC::Picture pic = addr.photo(); 438 KABC::Picture pic = addr.photo();
432 if ( pic.isIntern() ) { 439 if ( pic.isIntern() ) {
433//US emit contactSelected( pic.data() ); 440//US emit contactSelected( pic.data() );
434//US instead use: 441//US instead use:
435 QPixmap px; 442 QPixmap px;
436 if (pic.data().isNull() != true) 443 if (pic.data().isNull() != true)
437 { 444 {
438 px.convertFromImage(pic.data()); 445 px.convertFromImage(pic.data());
439 } 446 }
440 447
441 emit contactSelected( px ); 448 emit contactSelected( px );
442 } 449 }
443 } 450 }
444 451
445 452
446 mExtensionManager->setSelectionChanged(); 453 mExtensionManager->setSelectionChanged();
447 454
448 // update the actions 455 // update the actions
449 bool selected = !uid.isEmpty(); 456 bool selected = !uid.isEmpty();
450 457
451 if ( mReadWrite ) { 458 if ( mReadWrite ) {
452 mActionCut->setEnabled( selected ); 459 mActionCut->setEnabled( selected );
453 mActionPaste->setEnabled( selected ); 460 mActionPaste->setEnabled( selected );
454 } 461 }
455 462
456 mActionCopy->setEnabled( selected ); 463 mActionCopy->setEnabled( selected );
457 mActionDelete->setEnabled( selected ); 464 mActionDelete->setEnabled( selected );
458 mActionEditAddressee->setEnabled( selected ); 465 mActionEditAddressee->setEnabled( selected );
459 mActionMail->setEnabled( selected ); 466 mActionMail->setEnabled( selected );
460 mActionMailVCard->setEnabled( selected ); 467 mActionMailVCard->setEnabled( selected );
461 //if (mActionBeam) 468 //if (mActionBeam)
462 //mActionBeam->setEnabled( selected ); 469 //mActionBeam->setEnabled( selected );
463 470
464 if (mActionBeamVCard) 471 if (mActionBeamVCard)
465 mActionBeamVCard->setEnabled( selected ); 472 mActionBeamVCard->setEnabled( selected );
466 473
467 mActionWhoAmI->setEnabled( selected ); 474 mActionWhoAmI->setEnabled( selected );
468 mActionCategories->setEnabled( selected ); 475 mActionCategories->setEnabled( selected );
469} 476}
470 477
471void KABCore::sendMail() 478void KABCore::sendMail()
472{ 479{
473 sendMail( mViewManager->selectedEmails().join( ", " ) ); 480 sendMail( mViewManager->selectedEmails().join( ", " ) );
474} 481}
475 482
476void KABCore::sendMail( const QString& emaillist ) 483void KABCore::sendMail( const QString& emaillist )
477{ 484{
478 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 485 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
479 if (emaillist.contains(",") > 0) 486 if (emaillist.contains(",") > 0)
480 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 487 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
481 else 488 else
482 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 489 ExternalAppHandler::instance()->mailToOneContact( emaillist );
483} 490}
484 491
485 492
486 493
487void KABCore::mailVCard() 494void KABCore::mailVCard()
488{ 495{
489 QStringList uids = mViewManager->selectedUids(); 496 QStringList uids = mViewManager->selectedUids();
490 if ( !uids.isEmpty() ) 497 if ( !uids.isEmpty() )
491 mailVCard( uids ); 498 mailVCard( uids );
492} 499}
493 500
494void KABCore::mailVCard( const QStringList& uids ) 501void KABCore::mailVCard( const QStringList& uids )
495{ 502{
496 QStringList urls; 503 QStringList urls;
497 504
498// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 505// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
499 506
500 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 507 QString dirName = "/tmp/" + KApplication::randomString( 8 );
501 508
502 509
503 510
504 QDir().mkdir( dirName, true ); 511 QDir().mkdir( dirName, true );
505 512
506 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 513 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
507 KABC::Addressee a = mAddressBook->findByUid( *it ); 514 KABC::Addressee a = mAddressBook->findByUid( *it );
508 515
509 if ( a.isEmpty() ) 516 if ( a.isEmpty() )
510 continue; 517 continue;
511 518
512 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 519 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
513 520
514 QString fileName = dirName + "/" + name; 521 QString fileName = dirName + "/" + name;
515 522
516 QFile outFile(fileName); 523 QFile outFile(fileName);
517 524
518 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 525 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
519 KABC::VCardConverter converter; 526 KABC::VCardConverter converter;
520 QString vcard; 527 QString vcard;
521 528
522 converter.addresseeToVCard( a, vcard ); 529 converter.addresseeToVCard( a, vcard );
523 530
524 QTextStream t( &outFile ); // use a text stream 531 QTextStream t( &outFile ); // use a text stream
525 t.setEncoding( QTextStream::UnicodeUTF8 ); 532 t.setEncoding( QTextStream::UnicodeUTF8 );
526 t << vcard; 533 t << vcard;
527 534
528 outFile.close(); 535 outFile.close();
529 536
530 urls.append( fileName ); 537 urls.append( fileName );
531 } 538 }
532 } 539 }
533 540
534 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 541 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
535 542
536 543
537/*US 544/*US
538 kapp->invokeMailer( QString::null, QString::null, QString::null, 545 kapp->invokeMailer( QString::null, QString::null, QString::null,
539 QString::null, // subject 546 QString::null, // subject
540 QString::null, // body 547 QString::null, // body
541 QString::null, 548 QString::null,
542 urls ); // attachments 549 urls ); // attachments
543*/ 550*/
544 551
545} 552}
546 553
547/** 554/**
548 Beams the "WhoAmI contact. 555 Beams the "WhoAmI contact.
549*/ 556*/
550void KABCore::beamMySelf() 557void KABCore::beamMySelf()
551{ 558{
552 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 559 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
553 if (!a.isEmpty()) 560 if (!a.isEmpty())
554 { 561 {
555 QStringList uids; 562 QStringList uids;
556 uids << a.uid(); 563 uids << a.uid();
557 564
558 beamVCard(uids); 565 beamVCard(uids);
559 } else { 566 } else {
560 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 567 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
561 568
562 569
563 } 570 }
564} 571}
565 572
566void KABCore::beamVCard() 573void KABCore::beamVCard()
567{ 574{
568 QStringList uids = mViewManager->selectedUids(); 575 QStringList uids = mViewManager->selectedUids();
569 if ( !uids.isEmpty() ) 576 if ( !uids.isEmpty() )
570 beamVCard( uids ); 577 beamVCard( uids );
571} 578}
572 579
573 580
574void KABCore::beamVCard(const QStringList& uids) 581void KABCore::beamVCard(const QStringList& uids)
575{ 582{
576/*US 583/*US
577 QString beamFilename; 584 QString beamFilename;
578 Opie::OPimContact c; 585 Opie::OPimContact c;
579 if ( actionPersonal->isOn() ) { 586 if ( actionPersonal->isOn() ) {
580 beamFilename = addressbookPersonalVCardName(); 587 beamFilename = addressbookPersonalVCardName();
581 if ( !QFile::exists( beamFilename ) ) 588 if ( !QFile::exists( beamFilename ) )
582 return; // can't beam a non-existent file 589 return; // can't beam a non-existent file
583 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 590 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
584 beamFilename ); 591 beamFilename );
585 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 592 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
586 Opie::OPimContactAccess::List allList = access->allRecords(); 593 Opie::OPimContactAccess::List allList = access->allRecords();
587 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 594 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
588 c = *it; 595 c = *it;
589 596
590 delete access; 597 delete access;
591 } else { 598 } else {
592 unlink( beamfile ); // delete if exists 599 unlink( beamfile ); // delete if exists
593 mkdir("/tmp/obex/", 0755); 600 mkdir("/tmp/obex/", 0755);
594 c = m_abView -> currentEntry(); 601 c = m_abView -> currentEntry();
595 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 602 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
596 beamfile ); 603 beamfile );
597 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 604 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
598 access->add( c ); 605 access->add( c );
599 access->save(); 606 access->save();
600 delete access; 607 delete access;
601 608
602 beamFilename = beamfile; 609 beamFilename = beamfile;
603 } 610 }
604 611
605 owarn << "Beaming: " << beamFilename << oendl; 612 owarn << "Beaming: " << beamFilename << oendl;
606*/ 613*/
607 614
608#if 0 615#if 0
609 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 616 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
610 617
611 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 618 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
612 619
613 QString name = "contact.vcf"; 620 QString name = "contact.vcf";
614 621
615 QString fileName = dirName + "/" + name; 622 QString fileName = dirName + "/" + name;
616#endif 623#endif
617 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 624 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
618 // 625 //
619 QString fileName = "/tmp/kdepimbeamfile"; 626 QString fileName = "/tmp/kdepimbeamfile";
620 627
621 628
622 //QDir().mkdir( dirName, true ); 629 //QDir().mkdir( dirName, true );
623 630
624 QFile outFile(fileName); 631 QFile outFile(fileName);
625 KABC::VCardConverter converter; 632 KABC::VCardConverter converter;
626 QString description; 633 QString description;
627 634
628 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 635 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
629 636
630 QTextStream t( &outFile ); // use a text stream 637 QTextStream t( &outFile ); // use a text stream
631 t.setEncoding( QTextStream::UnicodeUTF8 ); 638 t.setEncoding( QTextStream::UnicodeUTF8 );
632 639
633 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 640 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
634 KABC::Addressee a = mAddressBook->findByUid( *it ); 641 KABC::Addressee a = mAddressBook->findByUid( *it );
635 642
636 if ( a.isEmpty() ) 643 if ( a.isEmpty() )
637 continue; 644 continue;
638 645
639 if (description.isEmpty()) 646 if (description.isEmpty())
640 description = a.formattedName(); 647 description = a.formattedName();
641 648
642 QString vcard; 649 QString vcard;
643 converter.addresseeToVCard( a, vcard ); 650 converter.addresseeToVCard( a, vcard );
644 t << vcard; 651 t << vcard;
645 652
646 } 653 }
647 } else { 654 } else {
648 qDebug("Error open temp beam file "); 655 qDebug("Error open temp beam file ");
649 return; 656 return;
650 } 657 }
651 658
652 outFile.close(); 659 outFile.close();
653 660
654#ifndef DESKTOP_VERSION 661#ifndef DESKTOP_VERSION
655 Ir *ir = new Ir( this ); 662 Ir *ir = new Ir( this );
656 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 663 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
657 ir->send( fileName, description, "text/x-vCard" ); 664 ir->send( fileName, description, "text/x-vCard" );
658#endif 665#endif
659 666
660} 667}
661 668
662void KABCore::beamDone( Ir *ir ) 669void KABCore::beamDone( Ir *ir )
663{ 670{
664#ifndef DESKTOP_VERSION 671#ifndef DESKTOP_VERSION
665 delete ir; 672 delete ir;
666#endif 673#endif
667} 674}
668 675
669 676
670void KABCore::browse( const QString& url ) 677void KABCore::browse( const QString& url )
671{ 678{
672#ifndef KAB_EMBEDDED 679#ifndef KAB_EMBEDDED
673 kapp->invokeBrowser( url ); 680 kapp->invokeBrowser( url );
674#else //KAB_EMBEDDED 681#else //KAB_EMBEDDED
675 qDebug("KABCore::browse must be fixed"); 682 qDebug("KABCore::browse must be fixed");
676#endif //KAB_EMBEDDED 683#endif //KAB_EMBEDDED
677} 684}
678 685
679void KABCore::selectAllContacts() 686void KABCore::selectAllContacts()
680{ 687{
681 mViewManager->setSelected( QString::null, true ); 688 mViewManager->setSelected( QString::null, true );
682} 689}
683 690
684void KABCore::deleteContacts() 691void KABCore::deleteContacts()
685{ 692{
686 QStringList uidList = mViewManager->selectedUids(); 693 QStringList uidList = mViewManager->selectedUids();
687 deleteContacts( uidList ); 694 deleteContacts( uidList );
688} 695}
689 696
690void KABCore::deleteContacts( const QStringList &uids ) 697void KABCore::deleteContacts( const QStringList &uids )
691{ 698{
692 if ( uids.count() > 0 ) { 699 if ( uids.count() > 0 ) {
693 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 700 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
694 UndoStack::instance()->push( command ); 701 UndoStack::instance()->push( command );
695 RedoStack::instance()->clear(); 702 RedoStack::instance()->clear();
696 703
697 // now if we deleted anything, refresh 704 // now if we deleted anything, refresh
698 setContactSelected( QString::null ); 705 setContactSelected( QString::null );
699 setModified( true ); 706 setModified( true );
700 } 707 }
701} 708}
702 709
703void KABCore::copyContacts() 710void KABCore::copyContacts()
704{ 711{
705 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 712 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
706 713
707 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 714 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
708 715
709 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 716 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
710 717
711 QClipboard *cb = QApplication::clipboard(); 718 QClipboard *cb = QApplication::clipboard();
712 cb->setText( clipText ); 719 cb->setText( clipText );
713} 720}
714 721
715void KABCore::cutContacts() 722void KABCore::cutContacts()
716{ 723{
717 QStringList uidList = mViewManager->selectedUids(); 724 QStringList uidList = mViewManager->selectedUids();
718 725
719//US if ( uidList.size() > 0 ) { 726//US if ( uidList.size() > 0 ) {
720 if ( uidList.count() > 0 ) { 727 if ( uidList.count() > 0 ) {
721 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 728 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
722 UndoStack::instance()->push( command ); 729 UndoStack::instance()->push( command );
723 RedoStack::instance()->clear(); 730 RedoStack::instance()->clear();
724 731
725 setModified( true ); 732 setModified( true );
726 } 733 }
727} 734}
728 735
729void KABCore::pasteContacts() 736void KABCore::pasteContacts()
730{ 737{
731 QClipboard *cb = QApplication::clipboard(); 738 QClipboard *cb = QApplication::clipboard();
732 739
733 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 740 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
734 741
735 pasteContacts( list ); 742 pasteContacts( list );
736} 743}
737 744
738void KABCore::pasteContacts( KABC::Addressee::List &list ) 745void KABCore::pasteContacts( KABC::Addressee::List &list )
739{ 746{
740 KABC::Resource *resource = requestResource( this ); 747 KABC::Resource *resource = requestResource( this );
741 KABC::Addressee::List::Iterator it; 748 KABC::Addressee::List::Iterator it;
742 for ( it = list.begin(); it != list.end(); ++it ) 749 for ( it = list.begin(); it != list.end(); ++it )
743 (*it).setResource( resource ); 750 (*it).setResource( resource );
744 751
745 PwPasteCommand *command = new PwPasteCommand( this, list ); 752 PwPasteCommand *command = new PwPasteCommand( this, list );
746 UndoStack::instance()->push( command ); 753 UndoStack::instance()->push( command );
747 RedoStack::instance()->clear(); 754 RedoStack::instance()->clear();
748 755
749 setModified( true ); 756 setModified( true );
750} 757}
751 758
752void KABCore::setWhoAmI() 759void KABCore::setWhoAmI()
753{ 760{
754 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 761 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
755 762
756 if ( addrList.count() > 1 ) { 763 if ( addrList.count() > 1 ) {
757 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 764 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
758 return; 765 return;
759 } 766 }
760 767
761 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 768 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
762 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 769 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
763 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 770 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
764} 771}
765 772
766void KABCore::setCategories() 773void KABCore::setCategories()
767{ 774{
768 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 775 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
769 if ( !dlg.exec() ) 776 if ( !dlg.exec() )
770 return; 777 return;
771 778
772 bool merge = false; 779 bool merge = false;
773 QString msg = i18n( "Merge with existing categories?" ); 780 QString msg = i18n( "Merge with existing categories?" );
774 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 781 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
775 merge = true; 782 merge = true;
776 783
777 QStringList categories = dlg.selectedCategories(); 784 QStringList categories = dlg.selectedCategories();
778 785
779 QStringList uids = mViewManager->selectedUids(); 786 QStringList uids = mViewManager->selectedUids();
780 QStringList::Iterator it; 787 QStringList::Iterator it;
781 for ( it = uids.begin(); it != uids.end(); ++it ) { 788 for ( it = uids.begin(); it != uids.end(); ++it ) {
782 KABC::Addressee addr = mAddressBook->findByUid( *it ); 789 KABC::Addressee addr = mAddressBook->findByUid( *it );
783 if ( !addr.isEmpty() ) { 790 if ( !addr.isEmpty() ) {
784 if ( !merge ) 791 if ( !merge )
785 addr.setCategories( categories ); 792 addr.setCategories( categories );
786 else { 793 else {
787 QStringList addrCategories = addr.categories(); 794 QStringList addrCategories = addr.categories();
788 QStringList::Iterator catIt; 795 QStringList::Iterator catIt;
789 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 796 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
790 if ( !addrCategories.contains( *catIt ) ) 797 if ( !addrCategories.contains( *catIt ) )
791 addrCategories.append( *catIt ); 798 addrCategories.append( *catIt );
792 } 799 }
793 addr.setCategories( addrCategories ); 800 addr.setCategories( addrCategories );
794 } 801 }
795 802
796 mAddressBook->insertAddressee( addr ); 803 mAddressBook->insertAddressee( addr );
797 } 804 }
798 } 805 }
799 806
800 if ( uids.count() > 0 ) 807 if ( uids.count() > 0 )
801 setModified( true ); 808 setModified( true );
802} 809}
803 810
804void KABCore::setSearchFields( const KABC::Field::List &fields ) 811void KABCore::setSearchFields( const KABC::Field::List &fields )
805{ 812{
806 mIncSearchWidget->setFields( fields ); 813 mIncSearchWidget->setFields( fields );
807} 814}
808 815
809void KABCore::incrementalSearch( const QString& text ) 816void KABCore::incrementalSearch( const QString& text )
810{ 817{
811 mViewManager->setSelected( QString::null, false ); 818 mViewManager->setSelected( QString::null, false );
812 819
813 if ( !text.isEmpty() ) { 820 if ( !text.isEmpty() ) {
814 KABC::Field *field = mIncSearchWidget->currentField(); 821 KABC::Field *field = mIncSearchWidget->currentField();
815 822
816 QString pattern = text.lower(); 823 QString pattern = text.lower();
817 824
818#if 1 //KDE_VERSION >= 319 825#if 1 //KDE_VERSION >= 319
819 KABC::AddresseeList list( mAddressBook->allAddressees() ); 826 KABC::AddresseeList list( mAddressBook->allAddressees() );
820 if ( field ) { 827 if ( field ) {
821 list.sortByField( field ); 828 list.sortByField( field );
822 KABC::AddresseeList::Iterator it; 829 KABC::AddresseeList::Iterator it;
823 for ( it = list.begin(); it != list.end(); ++it ) { 830 for ( it = list.begin(); it != list.end(); ++it ) {
824 if ( field->value( *it ).lower().startsWith( pattern ) ) { 831 if ( field->value( *it ).lower().startsWith( pattern ) ) {
825 mViewManager->setSelected( (*it).uid(), true ); 832 mViewManager->setSelected( (*it).uid(), true );
826 return; 833 return;
827 } 834 }
828 } 835 }
829 } else { 836 } else {
830 KABC::AddresseeList::Iterator it; 837 KABC::AddresseeList::Iterator it;
831 for ( it = list.begin(); it != list.end(); ++it ) { 838 for ( it = list.begin(); it != list.end(); ++it ) {
832 KABC::Field::List fieldList = mIncSearchWidget->fields(); 839 KABC::Field::List fieldList = mIncSearchWidget->fields();
833 KABC::Field::List::ConstIterator fieldIt; 840 KABC::Field::List::ConstIterator fieldIt;
834 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 841 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
835 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 842 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
836 mViewManager->setSelected( (*it).uid(), true ); 843 mViewManager->setSelected( (*it).uid(), true );
837 return; 844 return;
838 } 845 }
839 } 846 }
840 } 847 }
841 } 848 }
842#else 849#else
843 KABC::AddressBook::Iterator it; 850 KABC::AddressBook::Iterator it;
844 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 851 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
845 if ( field ) { 852 if ( field ) {
846 if ( field->value( *it ).lower().startsWith( pattern ) ) { 853 if ( field->value( *it ).lower().startsWith( pattern ) ) {
847 mViewManager->setSelected( (*it).uid(), true ); 854 mViewManager->setSelected( (*it).uid(), true );
848 return; 855 return;
849 } 856 }
850 } else { 857 } else {
851 KABC::Field::List fieldList = mIncSearchWidget->fields(); 858 KABC::Field::List fieldList = mIncSearchWidget->fields();
852 KABC::Field::List::ConstIterator fieldIt; 859 KABC::Field::List::ConstIterator fieldIt;
853 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 860 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
854 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 861 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
855 mViewManager->setSelected( (*it).uid(), true ); 862 mViewManager->setSelected( (*it).uid(), true );
856 return; 863 return;
857 } 864 }
858 } 865 }
859 } 866 }
860 } 867 }
861#endif 868#endif
862 } 869 }
863} 870}
864 871
865void KABCore::setModified() 872void KABCore::setModified()
866{ 873{
867 setModified( true ); 874 setModified( true );
868} 875}
869 876
870void KABCore::setModifiedWOrefresh() 877void KABCore::setModifiedWOrefresh()
871{ 878{
872 // qDebug("KABCore::setModifiedWOrefresh() "); 879 // qDebug("KABCore::setModifiedWOrefresh() ");
873 mModified = true; 880 mModified = true;
874 mActionSave->setEnabled( mModified ); 881 mActionSave->setEnabled( mModified );
875#ifdef DESKTOP_VERSION 882#ifdef DESKTOP_VERSION
876 mDetails->refreshView(); 883 mDetails->refreshView();
877#endif 884#endif
878 885
879} 886}
880void KABCore::setModified( bool modified ) 887void KABCore::setModified( bool modified )
881{ 888{
882 mModified = modified; 889 mModified = modified;
883 mActionSave->setEnabled( mModified ); 890 mActionSave->setEnabled( mModified );
884 891
885 if ( modified ) 892 if ( modified )
886 mJumpButtonBar->recreateButtons(); 893 mJumpButtonBar->recreateButtons();
887 894
888 mViewManager->refreshView(); 895 mViewManager->refreshView();
889 mDetails->refreshView(); 896 mDetails->refreshView();
890 897
891} 898}
892 899
893bool KABCore::modified() const 900bool KABCore::modified() const
894{ 901{
895 return mModified; 902 return mModified;
896} 903}
897 904
898void KABCore::contactModified( const KABC::Addressee &addr ) 905void KABCore::contactModified( const KABC::Addressee &addr )
899{ 906{
900 907
901 Command *command = 0; 908 Command *command = 0;
902 QString uid; 909 QString uid;
903 910
904 // check if it exists already 911 // check if it exists already
905 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 912 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
906 if ( origAddr.isEmpty() ) 913 if ( origAddr.isEmpty() )
907 command = new PwNewCommand( mAddressBook, addr ); 914 command = new PwNewCommand( mAddressBook, addr );
908 else { 915 else {
909 command = new PwEditCommand( mAddressBook, origAddr, addr ); 916 command = new PwEditCommand( mAddressBook, origAddr, addr );
910 uid = addr.uid(); 917 uid = addr.uid();
911 } 918 }
912 919
913 UndoStack::instance()->push( command ); 920 UndoStack::instance()->push( command );
914 RedoStack::instance()->clear(); 921 RedoStack::instance()->clear();
915 922
916 setModified( true ); 923 setModified( true );
917} 924}
918 925
919void KABCore::newContact() 926void KABCore::newContact()
920{ 927{
921 928
922 929
923 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 930 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
924 931
925 QPtrList<KRES::Resource> kresResources; 932 QPtrList<KRES::Resource> kresResources;
926 QPtrListIterator<KABC::Resource> it( kabcResources ); 933 QPtrListIterator<KABC::Resource> it( kabcResources );
927 KABC::Resource *resource; 934 KABC::Resource *resource;
928 while ( ( resource = it.current() ) != 0 ) { 935 while ( ( resource = it.current() ) != 0 ) {
929 ++it; 936 ++it;
930 if ( !resource->readOnly() ) { 937 if ( !resource->readOnly() ) {
931 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 938 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
932 if ( res ) 939 if ( res )
933 kresResources.append( res ); 940 kresResources.append( res );
934 } 941 }
935 } 942 }
936 943
937 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 944 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
938 resource = static_cast<KABC::Resource*>( res ); 945 resource = static_cast<KABC::Resource*>( res );
939 946
940 if ( resource ) { 947 if ( resource ) {
941 KABC::Addressee addr; 948 KABC::Addressee addr;
942 addr.setResource( resource ); 949 addr.setResource( resource );
943 mEditorDialog->setAddressee( addr ); 950 mEditorDialog->setAddressee( addr );
944 KApplication::execDialog ( mEditorDialog ); 951 KApplication::execDialog ( mEditorDialog );
945 952
946 } else 953 } else
947 return; 954 return;
948 955
949 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 956 // mEditorDict.insert( dialog->addressee().uid(), dialog );
950 957
951 958
952} 959}
953 960
954void KABCore::addEmail( QString aStr ) 961void KABCore::addEmail( QString aStr )
955{ 962{
956#ifndef KAB_EMBEDDED 963#ifndef KAB_EMBEDDED
957 QString fullName, email; 964 QString fullName, email;
958 965
959 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 966 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
960 967
961 // Try to lookup the addressee matching the email address 968 // Try to lookup the addressee matching the email address
962 bool found = false; 969 bool found = false;
963 QStringList emailList; 970 QStringList emailList;
964 KABC::AddressBook::Iterator it; 971 KABC::AddressBook::Iterator it;
965 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 972 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
966 emailList = (*it).emails(); 973 emailList = (*it).emails();
967 if ( emailList.contains( email ) > 0 ) { 974 if ( emailList.contains( email ) > 0 ) {
968 found = true; 975 found = true;
969 (*it).setNameFromString( fullName ); 976 (*it).setNameFromString( fullName );
970 editContact( (*it).uid() ); 977 editContact( (*it).uid() );
971 } 978 }
972 } 979 }
973 980
974 if ( !found ) { 981 if ( !found ) {
975 KABC::Addressee addr; 982 KABC::Addressee addr;
976 addr.setNameFromString( fullName ); 983 addr.setNameFromString( fullName );
977 addr.insertEmail( email, true ); 984 addr.insertEmail( email, true );
978 985
979 mAddressBook->insertAddressee( addr ); 986 mAddressBook->insertAddressee( addr );
980 mViewManager->refreshView( addr.uid() ); 987 mViewManager->refreshView( addr.uid() );
981 editContact( addr.uid() ); 988 editContact( addr.uid() );
982 } 989 }
983#else //KAB_EMBEDDED 990#else //KAB_EMBEDDED
984 qDebug("KABCore::addEmail finsih method"); 991 qDebug("KABCore::addEmail finsih method");
985#endif //KAB_EMBEDDED 992#endif //KAB_EMBEDDED
986} 993}
987 994
988void KABCore::importVCard( const KURL &url, bool showPreview ) 995void KABCore::importVCard( const KURL &url, bool showPreview )
989{ 996{
990 mXXPortManager->importVCard( url, showPreview ); 997 mXXPortManager->importVCard( url, showPreview );
991} 998}
992void KABCore::importFromOL() 999void KABCore::importFromOL()
993{ 1000{
994#ifdef _WIN32_ 1001#ifdef _WIN32_
995 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1002 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
996 idgl->exec(); 1003 idgl->exec();
997 KABC::Addressee::List list = idgl->getAddressList(); 1004 KABC::Addressee::List list = idgl->getAddressList();
998 if ( list.count() > 0 ) { 1005 if ( list.count() > 0 ) {
999 KABC::Addressee::List listNew; 1006 KABC::Addressee::List listNew;
1000 KABC::Addressee::List listExisting; 1007 KABC::Addressee::List listExisting;
1001 KABC::Addressee::List::Iterator it; 1008 KABC::Addressee::List::Iterator it;
1002 KABC::AddressBook::Iterator iter; 1009 KABC::AddressBook::Iterator iter;
1003 for ( it = list.begin(); it != list.end(); ++it ) { 1010 for ( it = list.begin(); it != list.end(); ++it ) {
1004 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1011 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1005 listNew.append( (*it) ); 1012 listNew.append( (*it) );
1006 else 1013 else
1007 listExisting.append( (*it) ); 1014 listExisting.append( (*it) );
1008 } 1015 }
1009 if ( listExisting.count() > 0 ) 1016 if ( listExisting.count() > 0 )
1010 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1017 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1011 if ( listNew.count() > 0 ) { 1018 if ( listNew.count() > 0 ) {
1012 pasteWithNewUid = false; 1019 pasteWithNewUid = false;
1013 pasteContacts( listNew ); 1020 pasteContacts( listNew );
1014 pasteWithNewUid = true; 1021 pasteWithNewUid = true;
1015 } 1022 }
1016 } 1023 }
1017 delete idgl; 1024 delete idgl;
1018#endif 1025#endif
1019} 1026}
1020 1027
1021void KABCore::importVCard( const QString &vCard, bool showPreview ) 1028void KABCore::importVCard( const QString &vCard, bool showPreview )
1022{ 1029{
1023 mXXPortManager->importVCard( vCard, showPreview ); 1030 mXXPortManager->importVCard( vCard, showPreview );
1024} 1031}
1025 1032
1026//US added a second method without defaultparameter 1033//US added a second method without defaultparameter
1027void KABCore::editContact2() { 1034void KABCore::editContact2() {
1028 editContact( QString::null ); 1035 editContact( QString::null );
1029} 1036}
1030 1037
1031void KABCore::editContact( const QString &uid ) 1038void KABCore::editContact( const QString &uid )
1032{ 1039{
1033 1040
1034 if ( mExtensionManager->isQuickEditVisible() ) 1041 if ( mExtensionManager->isQuickEditVisible() )
1035 return; 1042 return;
1036 1043
1037 // First, locate the contact entry 1044 // First, locate the contact entry
1038 QString localUID = uid; 1045 QString localUID = uid;
1039 if ( localUID.isNull() ) { 1046 if ( localUID.isNull() ) {
1040 QStringList uidList = mViewManager->selectedUids(); 1047 QStringList uidList = mViewManager->selectedUids();
1041 if ( uidList.count() > 0 ) 1048 if ( uidList.count() > 0 )
1042 localUID = *( uidList.at( 0 ) ); 1049 localUID = *( uidList.at( 0 ) );
1043 } 1050 }
1044 1051
1045 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1052 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1046 if ( !addr.isEmpty() ) { 1053 if ( !addr.isEmpty() ) {
1047 mEditorDialog->setAddressee( addr ); 1054 mEditorDialog->setAddressee( addr );
1048 KApplication::execDialog ( mEditorDialog ); 1055 KApplication::execDialog ( mEditorDialog );
1049 } 1056 }
1050} 1057}
1051 1058
1052/** 1059/**
1053 Shows or edits the detail view for the given uid. If the uid is QString::null, 1060 Shows or edits the detail view for the given uid. If the uid is QString::null,
1054 the method will try to find a selected addressee in the view. 1061 the method will try to find a selected addressee in the view.
1055 */ 1062 */
1056void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1063void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1057{ 1064{
1058 if ( mMultipleViewsAtOnce ) 1065 if ( mMultipleViewsAtOnce )
1059 { 1066 {
1060 editContact( uid ); 1067 editContact( uid );
1061 } 1068 }
1062 else 1069 else
1063 { 1070 {
1064 setDetailsVisible( true ); 1071 setDetailsVisible( true );
1065 mActionDetails->setChecked(true); 1072 mActionDetails->setChecked(true);
1066 } 1073 }
1067 1074
1068} 1075}
1069 1076
1070void KABCore::save() 1077void KABCore::save()
1071{ 1078{
1072 if ( !mModified ) 1079 if ( !mModified )
1073 return; 1080 return;
1074 QString text = i18n( "There was an error while attempting to save\n the " 1081 QString text = i18n( "There was an error while attempting to save\n the "
1075 "address book. Please check that some \nother application is " 1082 "address book. Please check that some \nother application is "
1076 "not using it. " ); 1083 "not using it. " );
1077 statusMessage(i18n("Saving addressbook ... ")); 1084 statusMessage(i18n("Saving addressbook ... "));
1078#ifndef KAB_EMBEDDED 1085#ifndef KAB_EMBEDDED
1079 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1086 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1080 if ( !b || !b->save() ) { 1087 if ( !b || !b->save() ) {
1081 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1088 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1082 } 1089 }
1083#else //KAB_EMBEDDED 1090#else //KAB_EMBEDDED
1084 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1091 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1085 if ( !b || !b->save() ) { 1092 if ( !b || !b->save() ) {
1086 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1093 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1087 } 1094 }
1088#endif //KAB_EMBEDDED 1095#endif //KAB_EMBEDDED
1089 1096
1090 statusMessage(i18n("Addressbook saved!")); 1097 statusMessage(i18n("Addressbook saved!"));
1091 setModified( false ); 1098 setModified( false );
1092} 1099}
1093 1100
1094void KABCore::statusMessage(QString mess , int time ) 1101void KABCore::statusMessage(QString mess , int time )
1095{ 1102{
1096 //topLevelWidget()->setCaption( mess ); 1103 //topLevelWidget()->setCaption( mess );
1097 // pending setting timer to revome message 1104 // pending setting timer to revome message
1098} 1105}
1099void KABCore::undo() 1106void KABCore::undo()
1100{ 1107{
1101 UndoStack::instance()->undo(); 1108 UndoStack::instance()->undo();
1102 1109
1103 // Refresh the view 1110 // Refresh the view
1104 mViewManager->refreshView(); 1111 mViewManager->refreshView();
1105} 1112}
1106 1113
1107void KABCore::redo() 1114void KABCore::redo()
1108{ 1115{
1109 RedoStack::instance()->redo(); 1116 RedoStack::instance()->redo();
1110 1117
1111 // Refresh the view 1118 // Refresh the view
1112 mViewManager->refreshView(); 1119 mViewManager->refreshView();
1113} 1120}
1114 1121
1115void KABCore::setJumpButtonBarVisible( bool visible ) 1122void KABCore::setJumpButtonBarVisible( bool visible )
1116{ 1123{
1117 if (mMultipleViewsAtOnce) 1124 if (mMultipleViewsAtOnce)
1118 { 1125 {
1119 if ( visible ) 1126 if ( visible )
1120 mJumpButtonBar->show(); 1127 mJumpButtonBar->show();
1121 else 1128 else
1122 mJumpButtonBar->hide(); 1129 mJumpButtonBar->hide();
1123 } 1130 }
1124 else 1131 else
1125 { 1132 {
1126 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1133 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1127 if (mViewManager->isVisible()) 1134 if (mViewManager->isVisible())
1128 { 1135 {
1129 if ( visible ) 1136 if ( visible )
1130 mJumpButtonBar->show(); 1137 mJumpButtonBar->show();
1131 else 1138 else
1132 mJumpButtonBar->hide(); 1139 mJumpButtonBar->hide();
1133 } 1140 }
1134 else 1141 else
1135 { 1142 {
1136 mJumpButtonBar->hide(); 1143 mJumpButtonBar->hide();
1137 } 1144 }
1138 } 1145 }
1139} 1146}
1140 1147
1141 1148
1142void KABCore::setDetailsToState() 1149void KABCore::setDetailsToState()
1143{ 1150{
1144 setDetailsVisible( mActionDetails->isChecked() ); 1151 setDetailsVisible( mActionDetails->isChecked() );
1145} 1152}
1146 1153
1147 1154
1148 1155
1149void KABCore::setDetailsVisible( bool visible ) 1156void KABCore::setDetailsVisible( bool visible )
1150{ 1157{
1151 if (visible && mDetails->isHidden()) 1158 if (visible && mDetails->isHidden())
1152 { 1159 {
1153 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1160 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1154 if ( addrList.count() > 0 ) 1161 if ( addrList.count() > 0 )
1155 mDetails->setAddressee( addrList[ 0 ] ); 1162 mDetails->setAddressee( addrList[ 0 ] );
1156 } 1163 }
1157 1164
1158 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1165 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1159 // the listview and the detailview. We do that by changing the splitbar size. 1166 // the listview and the detailview. We do that by changing the splitbar size.
1160 if (mMultipleViewsAtOnce) 1167 if (mMultipleViewsAtOnce)
1161 { 1168 {
1162 if ( visible ) 1169 if ( visible )
1163 mDetails->show(); 1170 mDetails->show();
1164 else 1171 else
1165 mDetails->hide(); 1172 mDetails->hide();
1166 } 1173 }
1167 else 1174 else
1168 { 1175 {
1169 if ( visible ) { 1176 if ( visible ) {
1170 mViewManager->hide(); 1177 mViewManager->hide();
1171 mDetails->show(); 1178 mDetails->show();
1172 } 1179 }
1173 else { 1180 else {
1174 mViewManager->show(); 1181 mViewManager->show();
1175 mDetails->hide(); 1182 mDetails->hide();
1176 } 1183 }
1177 setJumpButtonBarVisible( !visible ); 1184 setJumpButtonBarVisible( !visible );
1178 } 1185 }
1179 1186
1180} 1187}
1181 1188
1182void KABCore::extensionChanged( int id ) 1189void KABCore::extensionChanged( int id )
1183{ 1190{
1184 //change the details view only for non desktop systems 1191 //change the details view only for non desktop systems
1185#ifndef DESKTOP_VERSION 1192#ifndef DESKTOP_VERSION
1186 1193
1187 if (id == 0) 1194 if (id == 0)
1188 { 1195 {
1189 //the user disabled the extension. 1196 //the user disabled the extension.
1190 1197
1191 if (mMultipleViewsAtOnce) 1198 if (mMultipleViewsAtOnce)
1192 { // enable detailsview again 1199 { // enable detailsview again
1193 setDetailsVisible( true ); 1200 setDetailsVisible( true );
1194 mActionDetails->setChecked( true ); 1201 mActionDetails->setChecked( true );
1195 } 1202 }
1196 else 1203 else
1197 { //go back to the listview 1204 { //go back to the listview
1198 setDetailsVisible( false ); 1205 setDetailsVisible( false );
1199 mActionDetails->setChecked( false ); 1206 mActionDetails->setChecked( false );
1200 mActionDetails->setEnabled(true); 1207 mActionDetails->setEnabled(true);
1201 } 1208 }
1202 1209
1203 } 1210 }
1204 else 1211 else
1205 { 1212 {
1206 //the user enabled the extension. 1213 //the user enabled the extension.
1207 setDetailsVisible( false ); 1214 setDetailsVisible( false );
1208 mActionDetails->setChecked( false ); 1215 mActionDetails->setChecked( false );
1209 1216
1210 if (!mMultipleViewsAtOnce) 1217 if (!mMultipleViewsAtOnce)
1211 { 1218 {
1212 mActionDetails->setEnabled(false); 1219 mActionDetails->setEnabled(false);
1213 } 1220 }
1214 1221
1215 mExtensionManager->setSelectionChanged(); 1222 mExtensionManager->setSelectionChanged();
1216 1223
1217 } 1224 }
1218 1225
1219#endif// DESKTOP_VERSION 1226#endif// DESKTOP_VERSION
1220 1227
1221} 1228}
1222 1229
1223 1230
1224void KABCore::extensionModified( const KABC::Addressee::List &list ) 1231void KABCore::extensionModified( const KABC::Addressee::List &list )
1225{ 1232{
1226 1233
1227 if ( list.count() != 0 ) { 1234 if ( list.count() != 0 ) {
1228 KABC::Addressee::List::ConstIterator it; 1235 KABC::Addressee::List::ConstIterator it;
1229 for ( it = list.begin(); it != list.end(); ++it ) 1236 for ( it = list.begin(); it != list.end(); ++it )
1230 mAddressBook->insertAddressee( *it ); 1237 mAddressBook->insertAddressee( *it );
1231 if ( list.count() > 1 ) 1238 if ( list.count() > 1 )
1232 setModified(); 1239 setModified();
1233 else 1240 else
1234 setModifiedWOrefresh(); 1241 setModifiedWOrefresh();
1235 } 1242 }
1236 if ( list.count() == 0 ) 1243 if ( list.count() == 0 )
1237 mViewManager->refreshView(); 1244 mViewManager->refreshView();
1238 else 1245 else
1239 mViewManager->refreshView( list[ 0 ].uid() ); 1246 mViewManager->refreshView( list[ 0 ].uid() );
1240 1247
1241 1248
1242 1249
1243} 1250}
1244 1251
1245QString KABCore::getNameByPhone( const QString &phone ) 1252QString KABCore::getNameByPhone( const QString &phone )
1246{ 1253{
1247#ifndef KAB_EMBEDDED 1254#ifndef KAB_EMBEDDED
1248 QRegExp r( "[/*/-/ ]" ); 1255 QRegExp r( "[/*/-/ ]" );
1249 QString localPhone( phone ); 1256 QString localPhone( phone );
1250 1257
1251 bool found = false; 1258 bool found = false;
1252 QString ownerName = ""; 1259 QString ownerName = "";
1253 KABC::AddressBook::Iterator iter; 1260 KABC::AddressBook::Iterator iter;
1254 KABC::PhoneNumber::List::Iterator phoneIter; 1261 KABC::PhoneNumber::List::Iterator phoneIter;
1255 KABC::PhoneNumber::List phoneList; 1262 KABC::PhoneNumber::List phoneList;
1256 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1263 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1257 phoneList = (*iter).phoneNumbers(); 1264 phoneList = (*iter).phoneNumbers();
1258 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1265 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1259 ++phoneIter) { 1266 ++phoneIter) {
1260 // Get rid of separator chars so just the numbers are compared. 1267 // Get rid of separator chars so just the numbers are compared.
1261 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1268 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1262 ownerName = (*iter).formattedName(); 1269 ownerName = (*iter).formattedName();
1263 found = true; 1270 found = true;
1264 } 1271 }
1265 } 1272 }
1266 } 1273 }
1267 1274
1268 return ownerName; 1275 return ownerName;
1269#else //KAB_EMBEDDED 1276#else //KAB_EMBEDDED
1270 qDebug("KABCore::getNameByPhone finsih method"); 1277 qDebug("KABCore::getNameByPhone finsih method");
1271 return ""; 1278 return "";
1272#endif //KAB_EMBEDDED 1279#endif //KAB_EMBEDDED
1273 1280
1274} 1281}
1275 1282
1276void KABCore::openConfigDialog() 1283void KABCore::openConfigDialog()
1277{ 1284{
1278 KABPrefs* kab_prefs = KABPrefs::instance(); 1285 KABPrefs* kab_prefs = KABPrefs::instance();
1279 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); 1286 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance();
1280 1287
1281 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1288 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1282 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1289 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1283 ConfigureDialog->addModule(kabcfg ); 1290 ConfigureDialog->addModule(kabcfg );
1284 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1291 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1285 ConfigureDialog->addModule(kdelibcfg ); 1292 ConfigureDialog->addModule(kdelibcfg );
1286 1293
1287 1294
1288 1295
1289 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1296 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1290 this, SLOT( configurationChanged() ) ); 1297 this, SLOT( configurationChanged() ) );
1291 connect( ConfigureDialog, SIGNAL( okClicked() ), 1298 connect( ConfigureDialog, SIGNAL( okClicked() ),
1292 this, SLOT( configurationChanged() ) ); 1299 this, SLOT( configurationChanged() ) );
1293 saveSettings(); 1300 saveSettings();
1294 ConfigureDialog->showMaximized(); 1301 ConfigureDialog->showMaximized();
1295 if ( ConfigureDialog->exec() ) 1302 if ( ConfigureDialog->exec() )
1296 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1303 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1297 delete ConfigureDialog; 1304 delete ConfigureDialog;
1298} 1305}
1299 1306
1300void KABCore::openLDAPDialog() 1307void KABCore::openLDAPDialog()
1301{ 1308{
1302#ifndef KAB_EMBEDDED 1309#ifndef KAB_EMBEDDED
1303 if ( !mLdapSearchDialog ) { 1310 if ( !mLdapSearchDialog ) {
1304 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1311 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1305 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1312 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1306 SLOT( refreshView() ) ); 1313 SLOT( refreshView() ) );
1307 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1314 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1308 SLOT( setModified() ) ); 1315 SLOT( setModified() ) );
1309 } else 1316 } else
1310 mLdapSearchDialog->restoreSettings(); 1317 mLdapSearchDialog->restoreSettings();
1311 1318
1312 if ( mLdapSearchDialog->isOK() ) 1319 if ( mLdapSearchDialog->isOK() )
1313 mLdapSearchDialog->exec(); 1320 mLdapSearchDialog->exec();
1314#else //KAB_EMBEDDED 1321#else //KAB_EMBEDDED
1315 qDebug("KABCore::openLDAPDialog() finsih method"); 1322 qDebug("KABCore::openLDAPDialog() finsih method");
1316#endif //KAB_EMBEDDED 1323#endif //KAB_EMBEDDED
1317} 1324}
1318 1325
1319void KABCore::print() 1326void KABCore::print()
1320{ 1327{
1321#ifndef KAB_EMBEDDED 1328#ifndef KAB_EMBEDDED
1322 KPrinter printer; 1329 KPrinter printer;
1323 if ( !printer.setup( this ) ) 1330 if ( !printer.setup( this ) )
1324 return; 1331 return;
1325 1332
1326 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1333 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1327 mViewManager->selectedUids(), this ); 1334 mViewManager->selectedUids(), this );
1328 1335
1329 wizard.exec(); 1336 wizard.exec();
1330#else //KAB_EMBEDDED 1337#else //KAB_EMBEDDED
1331 qDebug("KABCore::print() finsih method"); 1338 qDebug("KABCore::print() finsih method");
1332#endif //KAB_EMBEDDED 1339#endif //KAB_EMBEDDED
1333 1340
1334} 1341}
1335 1342
1336 1343
1337void KABCore::addGUIClient( KXMLGUIClient *client ) 1344void KABCore::addGUIClient( KXMLGUIClient *client )
1338{ 1345{
1339 if ( mGUIClient ) 1346 if ( mGUIClient )
1340 mGUIClient->insertChildClient( client ); 1347 mGUIClient->insertChildClient( client );
1341 else 1348 else
1342 KMessageBox::error( this, "no KXMLGUICLient"); 1349 KMessageBox::error( this, "no KXMLGUICLient");
1343} 1350}
1344 1351
1345 1352
1346void KABCore::configurationChanged() 1353void KABCore::configurationChanged()
1347{ 1354{
1348 mExtensionManager->reconfigure(); 1355 mExtensionManager->reconfigure();
1349} 1356}
1350 1357
1351void KABCore::addressBookChanged() 1358void KABCore::addressBookChanged()
1352{ 1359{
1353/*US 1360/*US
1354 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1361 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1355 while ( it.current() ) { 1362 while ( it.current() ) {
1356 if ( it.current()->dirty() ) { 1363 if ( it.current()->dirty() ) {
1357 QString text = i18n( "Data has been changed externally. Unsaved " 1364 QString text = i18n( "Data has been changed externally. Unsaved "
1358 "changes will be lost." ); 1365 "changes will be lost." );
1359 KMessageBox::information( this, text ); 1366 KMessageBox::information( this, text );
1360 } 1367 }
1361 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1368 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1362 ++it; 1369 ++it;
1363 } 1370 }
1364*/ 1371*/
1365 if (mEditorDialog) 1372 if (mEditorDialog)
1366 { 1373 {
1367 if (mEditorDialog->dirty()) 1374 if (mEditorDialog->dirty())
1368 { 1375 {
1369 QString text = i18n( "Data has been changed externally. Unsaved " 1376 QString text = i18n( "Data has been changed externally. Unsaved "
1370 "changes will be lost." ); 1377 "changes will be lost." );
1371 KMessageBox::information( this, text ); 1378 KMessageBox::information( this, text );
1372 } 1379 }
1373 QString currentuid = mEditorDialog->addressee().uid(); 1380 QString currentuid = mEditorDialog->addressee().uid();
1374 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1381 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1375 } 1382 }
1376 mViewManager->refreshView(); 1383 mViewManager->refreshView();
1377// mDetails->refreshView(); 1384// mDetails->refreshView();
1378 1385
1379 1386
1380} 1387}
1381 1388
1382AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1389AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1383 const char *name ) 1390 const char *name )
1384{ 1391{
1385 1392
1386 if ( mEditorDialog == 0 ) { 1393 if ( mEditorDialog == 0 ) {
1387 mEditorDialog = new AddresseeEditorDialog( this, parent, 1394 mEditorDialog = new AddresseeEditorDialog( this, parent,
1388 name ? name : "editorDialog" ); 1395 name ? name : "editorDialog" );
1389 1396
1390 1397
1391 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1398 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1392 SLOT( contactModified( const KABC::Addressee& ) ) ); 1399 SLOT( contactModified( const KABC::Addressee& ) ) );
1393 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1400 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1394 // SLOT( slotEditorDestroyed( const QString& ) ) ); 1401 // SLOT( slotEditorDestroyed( const QString& ) ) );
1395 } 1402 }
1396 1403
1397 return mEditorDialog; 1404 return mEditorDialog;
1398} 1405}
1399 1406
1400void KABCore::slotEditorDestroyed( const QString &uid ) 1407void KABCore::slotEditorDestroyed( const QString &uid )
1401{ 1408{
1402 //mEditorDict.remove( uid ); 1409 //mEditorDict.remove( uid );
1403} 1410}
1404 1411
1405void KABCore::initGUI() 1412void KABCore::initGUI()
1406{ 1413{
1407#ifndef KAB_EMBEDDED 1414#ifndef KAB_EMBEDDED
1408 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1415 QHBoxLayout *topLayout = new QHBoxLayout( this );
1409 topLayout->setSpacing( KDialogBase::spacingHint() ); 1416 topLayout->setSpacing( KDialogBase::spacingHint() );
1410 1417
1411 mExtensionBarSplitter = new QSplitter( this ); 1418 mExtensionBarSplitter = new QSplitter( this );
1412 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1419 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1413 1420
1414 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1421 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1415 1422
1416 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1423 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1417 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1424 mIncSearchWidget = new IncSearchWidget( viewSpace );
1418 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1425 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1419 SLOT( incrementalSearch( const QString& ) ) ); 1426 SLOT( incrementalSearch( const QString& ) ) );
1420 1427
1421 mViewManager = new ViewManager( this, viewSpace ); 1428 mViewManager = new ViewManager( this, viewSpace );
1422 viewSpace->setStretchFactor( mViewManager, 1 ); 1429 viewSpace->setStretchFactor( mViewManager, 1 );
1423 1430
1424 mDetails = new ViewContainer( mDetailsSplitter ); 1431 mDetails = new ViewContainer( mDetailsSplitter );
1425 1432
1426 mJumpButtonBar = new JumpButtonBar( this, this ); 1433 mJumpButtonBar = new JumpButtonBar( this, this );
1427 1434
1428 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1435 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1429 1436
1430 topLayout->addWidget( mExtensionBarSplitter ); 1437 topLayout->addWidget( mExtensionBarSplitter );
1431 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1438 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1432 topLayout->addWidget( mJumpButtonBar ); 1439 topLayout->addWidget( mJumpButtonBar );
1433 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1440 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1434 1441
1435 mXXPortManager = new XXPortManager( this, this ); 1442 mXXPortManager = new XXPortManager( this, this );
1436 1443
1437#else //KAB_EMBEDDED 1444#else //KAB_EMBEDDED
1438 //US initialize viewMenu before settingup viewmanager. 1445 //US initialize viewMenu before settingup viewmanager.
1439 // Viewmanager needs this menu to plugin submenues. 1446 // Viewmanager needs this menu to plugin submenues.
1440 viewMenu = new QPopupMenu( this ); 1447 viewMenu = new QPopupMenu( this );
1441 settingsMenu = new QPopupMenu( this ); 1448 settingsMenu = new QPopupMenu( this );
1442 //filterMenu = new QPopupMenu( this ); 1449 //filterMenu = new QPopupMenu( this );
1443 ImportMenu = new QPopupMenu( this ); 1450 ImportMenu = new QPopupMenu( this );
1444 ExportMenu = new QPopupMenu( this ); 1451 ExportMenu = new QPopupMenu( this );
1445 1452
1446 changeMenu= new QPopupMenu( this ); 1453 changeMenu= new QPopupMenu( this );
1447 1454
1448//US since we have no splitter for the embedded system, setup 1455//US since we have no splitter for the embedded system, setup
1449// a layout with two frames. One left and one right. 1456// a layout with two frames. One left and one right.
1450 1457
1451 QBoxLayout *topLayout; 1458 QBoxLayout *topLayout;
1452 1459
1453 // = new QHBoxLayout( this ); 1460 // = new QHBoxLayout( this );
1454// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1461// QBoxLayout *topLayout = (QBoxLayout*)layout();
1455 1462
1456// QWidget *mainBox = new QWidget( this ); 1463// QWidget *mainBox = new QWidget( this );
1457// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1464// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1458 1465
1459#ifdef DESKTOP_VERSION 1466#ifdef DESKTOP_VERSION
1460 topLayout = new QHBoxLayout( this ); 1467 topLayout = new QHBoxLayout( this );
1461 1468
1462 1469
1463 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1470 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1464 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1471 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1465 1472
1466 topLayout->addWidget(mMiniSplitter ); 1473 topLayout->addWidget(mMiniSplitter );
1467 1474
1468 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1475 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1469 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1476 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1470 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1477 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1471 mDetails = new ViewContainer( mMiniSplitter ); 1478 mDetails = new ViewContainer( mMiniSplitter );
1472 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1479 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1473#else 1480#else
1474 if ( QApplication::desktop()->width() > 480 ) { 1481 if ( QApplication::desktop()->width() > 480 ) {
1475 topLayout = new QHBoxLayout( this ); 1482 topLayout = new QHBoxLayout( this );
1476 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1483 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1477 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1484 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1478 } else { 1485 } else {
1479 1486
1480 topLayout = new QHBoxLayout( this ); 1487 topLayout = new QHBoxLayout( this );
1481 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1488 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1482 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1489 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1483 } 1490 }
1484 1491
1485 topLayout->addWidget(mMiniSplitter ); 1492 topLayout->addWidget(mMiniSplitter );
1486 mViewManager = new ViewManager( this, mMiniSplitter ); 1493 mViewManager = new ViewManager( this, mMiniSplitter );
1487 mDetails = new ViewContainer( mMiniSplitter ); 1494 mDetails = new ViewContainer( mMiniSplitter );
1488 1495
1489 1496
1490 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1497 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1491#endif 1498#endif
1492 //eh->hide(); 1499 //eh->hide();
1493 // topLayout->addWidget(mExtensionManager ); 1500 // topLayout->addWidget(mExtensionManager );
1494 1501
1495 1502
1496/*US 1503/*US
1497#ifndef KAB_NOSPLITTER 1504#ifndef KAB_NOSPLITTER
1498 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1505 QHBoxLayout *topLayout = new QHBoxLayout( this );
1499//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1506//US topLayout->setSpacing( KDialogBase::spacingHint() );
1500 topLayout->setSpacing( 10 ); 1507 topLayout->setSpacing( 10 );
1501 1508
1502 mDetailsSplitter = new QSplitter( this ); 1509 mDetailsSplitter = new QSplitter( this );
1503 1510
1504 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1511 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1505 1512
1506 mViewManager = new ViewManager( this, viewSpace ); 1513 mViewManager = new ViewManager( this, viewSpace );
1507 viewSpace->setStretchFactor( mViewManager, 1 ); 1514 viewSpace->setStretchFactor( mViewManager, 1 );
1508 1515
1509 mDetails = new ViewContainer( mDetailsSplitter ); 1516 mDetails = new ViewContainer( mDetailsSplitter );
1510 1517
1511 topLayout->addWidget( mDetailsSplitter ); 1518 topLayout->addWidget( mDetailsSplitter );
1512 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1519 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1513#else //KAB_NOSPLITTER 1520#else //KAB_NOSPLITTER
1514 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1521 QHBoxLayout *topLayout = new QHBoxLayout( this );
1515//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1522//US topLayout->setSpacing( KDialogBase::spacingHint() );
1516 topLayout->setSpacing( 10 ); 1523 topLayout->setSpacing( 10 );
1517 1524
1518// mDetailsSplitter = new QSplitter( this ); 1525// mDetailsSplitter = new QSplitter( this );
1519 1526
1520 QVBox *viewSpace = new QVBox( this ); 1527 QVBox *viewSpace = new QVBox( this );
1521 1528
1522 mViewManager = new ViewManager( this, viewSpace ); 1529 mViewManager = new ViewManager( this, viewSpace );
1523 viewSpace->setStretchFactor( mViewManager, 1 ); 1530 viewSpace->setStretchFactor( mViewManager, 1 );
1524 1531
1525 mDetails = new ViewContainer( this ); 1532 mDetails = new ViewContainer( this );
1526 1533
1527 topLayout->addWidget( viewSpace ); 1534 topLayout->addWidget( viewSpace );
1528// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1535// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1529 topLayout->addWidget( mDetails ); 1536 topLayout->addWidget( mDetails );
1530#endif //KAB_NOSPLITTER 1537#endif //KAB_NOSPLITTER
1531*/ 1538*/
1532 1539
1533 1540
1534#endif //KAB_EMBEDDED 1541#endif //KAB_EMBEDDED
1535 initActions(); 1542 initActions();
1536 1543
1537#ifdef KAB_EMBEDDED 1544#ifdef KAB_EMBEDDED
1538 addActionsManually(); 1545 addActionsManually();
1539 //US make sure the export and import menues are initialized before creating the xxPortManager. 1546 //US make sure the export and import menues are initialized before creating the xxPortManager.
1540 mXXPortManager = new XXPortManager( this, this ); 1547 mXXPortManager = new XXPortManager( this, this );
1541 1548
1542 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1549 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1543 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1550 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1544 // mActionQuit->plug ( mMainWindow->toolBar()); 1551 // mActionQuit->plug ( mMainWindow->toolBar());
1545 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1552 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1546 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1553 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1547 // mIncSearchWidget->hide(); 1554 // mIncSearchWidget->hide();
1548 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1555 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1549 SLOT( incrementalSearch( const QString& ) ) ); 1556 SLOT( incrementalSearch( const QString& ) ) );
1550 1557
1551 1558
1552 mJumpButtonBar = new JumpButtonBar( this, this ); 1559 mJumpButtonBar = new JumpButtonBar( this, this );
1553 1560
1554 topLayout->addWidget( mJumpButtonBar ); 1561 topLayout->addWidget( mJumpButtonBar );
1555//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1562//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1556 1563
1557// mMainWindow->getIconToolBar()->raise(); 1564// mMainWindow->getIconToolBar()->raise();
1558 1565
1559#endif //KAB_EMBEDDED 1566#endif //KAB_EMBEDDED
1560 1567
1561} 1568}
1562void KABCore::initActions() 1569void KABCore::initActions()
1563{ 1570{
1564//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1571//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1565 1572
1566#ifndef KAB_EMBEDDED 1573#ifndef KAB_EMBEDDED
1567 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1574 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1568 SLOT( clipboardDataChanged() ) ); 1575 SLOT( clipboardDataChanged() ) );
1569#endif //KAB_EMBEDDED 1576#endif //KAB_EMBEDDED
1570 1577
1571 // file menu 1578 // file menu
1572 if ( mIsPart ) { 1579 if ( mIsPart ) {
1573 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1580 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1574 SLOT( sendMail() ), actionCollection(), 1581 SLOT( sendMail() ), actionCollection(),
1575 "kaddressbook_mail" ); 1582 "kaddressbook_mail" );
1576 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1583 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1577 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1584 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1578 1585
1579 } else { 1586 } else {
1580 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1587 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1581 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1588 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1582 } 1589 }
1583 1590
1584 1591
1585 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1592 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1586 SLOT( save() ), actionCollection(), "file_sync" ); 1593 SLOT( save() ), actionCollection(), "file_sync" );
1587 1594
1588 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1595 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1589 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1596 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1590 1597
1591 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1598 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1592 this, SLOT( mailVCard() ), 1599 this, SLOT( mailVCard() ),
1593 actionCollection(), "file_mail_vcard"); 1600 actionCollection(), "file_mail_vcard");
1594 1601
1595 mActionBeamVCard = 0; 1602 mActionBeamVCard = 0;
1596 mActionBeam = 0; 1603 mActionBeam = 0;
1597 1604
1598#ifndef DESKTOP_VERSION 1605#ifndef DESKTOP_VERSION
1599 if ( Ir::supported() ) { 1606 if ( Ir::supported() ) {
1600 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1607 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1601 SLOT( beamVCard() ), actionCollection(), 1608 SLOT( beamVCard() ), actionCollection(),
1602 "kaddressbook_beam_vcard" ); 1609 "kaddressbook_beam_vcard" );
1603 1610
1604 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1611 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1605 SLOT( beamMySelf() ), actionCollection(), 1612 SLOT( beamMySelf() ), actionCollection(),
1606 "kaddressbook_beam_myself" ); 1613 "kaddressbook_beam_myself" );
1607 } 1614 }
1608#endif 1615#endif
1609 1616
1610 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1617 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1611 this, SLOT( editContact2() ), 1618 this, SLOT( editContact2() ),
1612 actionCollection(), "file_properties" ); 1619 actionCollection(), "file_properties" );
1613 1620
1614#ifdef KAB_EMBEDDED 1621#ifdef KAB_EMBEDDED
1615 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1622 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1616 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1623 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1617 mMainWindow, SLOT( exit() ), 1624 mMainWindow, SLOT( exit() ),
1618 actionCollection(), "quit" ); 1625 actionCollection(), "quit" );
1619#endif //KAB_EMBEDDED 1626#endif //KAB_EMBEDDED
1620 1627
1621 // edit menu 1628 // edit menu
1622 if ( mIsPart ) { 1629 if ( mIsPart ) {
1623 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1630 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1624 SLOT( copyContacts() ), actionCollection(), 1631 SLOT( copyContacts() ), actionCollection(),
1625 "kaddressbook_copy" ); 1632 "kaddressbook_copy" );
1626 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1633 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1627 SLOT( cutContacts() ), actionCollection(), 1634 SLOT( cutContacts() ), actionCollection(),
1628 "kaddressbook_cut" ); 1635 "kaddressbook_cut" );
1629 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1636 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1630 SLOT( pasteContacts() ), actionCollection(), 1637 SLOT( pasteContacts() ), actionCollection(),
1631 "kaddressbook_paste" ); 1638 "kaddressbook_paste" );
1632 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1639 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1633 SLOT( selectAllContacts() ), actionCollection(), 1640 SLOT( selectAllContacts() ), actionCollection(),
1634 "kaddressbook_select_all" ); 1641 "kaddressbook_select_all" );
1635 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1642 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1636 SLOT( undo() ), actionCollection(), 1643 SLOT( undo() ), actionCollection(),
1637 "kaddressbook_undo" ); 1644 "kaddressbook_undo" );
1638 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1645 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1639 this, SLOT( redo() ), actionCollection(), 1646 this, SLOT( redo() ), actionCollection(),
1640 "kaddressbook_redo" ); 1647 "kaddressbook_redo" );
1641 } else { 1648 } else {
1642 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1649 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1643 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1650 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1644 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1651 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1645 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1652 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1646 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1653 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1647 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1654 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1648 } 1655 }
1649 1656
1650 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1657 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1651 Key_Delete, this, SLOT( deleteContacts() ), 1658 Key_Delete, this, SLOT( deleteContacts() ),
1652 actionCollection(), "edit_delete" ); 1659 actionCollection(), "edit_delete" );
1653 1660
1654 mActionUndo->setEnabled( false ); 1661 mActionUndo->setEnabled( false );
1655 mActionRedo->setEnabled( false ); 1662 mActionRedo->setEnabled( false );
1656 1663
1657 // settings menu 1664 // settings menu
1658#ifdef KAB_EMBEDDED 1665#ifdef KAB_EMBEDDED
1659//US special menuentry to configure the addressbook resources. On KDE 1666//US special menuentry to configure the addressbook resources. On KDE
1660// you do that through the control center !!! 1667// you do that through the control center !!!
1661 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1668 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1662 SLOT( configureResources() ), actionCollection(), 1669 SLOT( configureResources() ), actionCollection(),
1663 "kaddressbook_configure_resources" ); 1670 "kaddressbook_configure_resources" );
1664#endif //KAB_EMBEDDED 1671#endif //KAB_EMBEDDED
1665 1672
1666 if ( mIsPart ) { 1673 if ( mIsPart ) {
1667 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1674 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1668 SLOT( openConfigDialog() ), actionCollection(), 1675 SLOT( openConfigDialog() ), actionCollection(),
1669 "kaddressbook_configure" ); 1676 "kaddressbook_configure" );
1670 1677
1671 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1678 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1672 this, SLOT( configureKeyBindings() ), actionCollection(), 1679 this, SLOT( configureKeyBindings() ), actionCollection(),
1673 "kaddressbook_configure_shortcuts" ); 1680 "kaddressbook_configure_shortcuts" );
1674#ifdef KAB_EMBEDDED 1681#ifdef KAB_EMBEDDED
1675 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1682 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1676 mActionConfigureToolbars->setEnabled( false ); 1683 mActionConfigureToolbars->setEnabled( false );
1677#endif //KAB_EMBEDDED 1684#endif //KAB_EMBEDDED
1678 1685
1679 } else { 1686 } else {
1680 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1687 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1681 1688
1682 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1689 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1683 } 1690 }
1684 1691
1685 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1692 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1686 actionCollection(), "options_show_jump_bar" ); 1693 actionCollection(), "options_show_jump_bar" );
1687 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1694 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1688 1695
1689 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1696 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1690 actionCollection(), "options_show_details" ); 1697 actionCollection(), "options_show_details" );
1691 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1698 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1692 1699
1693 // misc 1700 // misc
1694 // only enable LDAP lookup if we can handle the protocol 1701 // only enable LDAP lookup if we can handle the protocol
1695#ifndef KAB_EMBEDDED 1702#ifndef KAB_EMBEDDED
1696 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1703 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1697 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1704 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1698 this, SLOT( openLDAPDialog() ), actionCollection(), 1705 this, SLOT( openLDAPDialog() ), actionCollection(),
1699 "ldap_lookup" ); 1706 "ldap_lookup" );
1700 } 1707 }
1701#else //KAB_EMBEDDED 1708#else //KAB_EMBEDDED
1702 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1709 //qDebug("KABCore::initActions() LDAP has to be implemented");
1703#endif //KAB_EMBEDDED 1710#endif //KAB_EMBEDDED
1704 1711
1705 1712
1706 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1713 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1707 SLOT( setWhoAmI() ), actionCollection(), 1714 SLOT( setWhoAmI() ), actionCollection(),
1708 "set_personal" ); 1715 "set_personal" );
1709 1716
1710 1717
1711 1718
1712 1719
1713 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1720 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1714 SLOT( setCategories() ), actionCollection(), 1721 SLOT( setCategories() ), actionCollection(),
1715 "edit_set_categories" ); 1722 "edit_set_categories" );
1716 1723
1717 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1724 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1718 SLOT( removeVoice() ), actionCollection(), 1725 SLOT( removeVoice() ), actionCollection(),
1719 "remove_voice" ); 1726 "remove_voice" );
1720 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, 1727 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
1721 SLOT( importFromOL() ), actionCollection(), 1728 SLOT( importFromOL() ), actionCollection(),
1722 "import_OL" ); 1729 "import_OL" );
1723#ifdef KAB_EMBEDDED 1730#ifdef KAB_EMBEDDED
1724 mActionLicence = new KAction( i18n( "Licence" ), "licence", 0, 1731 mActionLicence = new KAction( i18n( "Licence" ), "licence", 0,
1725 this, SLOT( showLicence() ), actionCollection(), 1732 this, SLOT( showLicence() ), actionCollection(),
1726 "licence_about_data" ); 1733 "licence_about_data" );
1727 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1734 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1728 this, SLOT( createAboutData() ), actionCollection(), 1735 this, SLOT( createAboutData() ), actionCollection(),
1729 "kaddressbook_about_data" ); 1736 "kaddressbook_about_data" );
1730#endif //KAB_EMBEDDED 1737#endif //KAB_EMBEDDED
1731 1738
1732 clipboardDataChanged(); 1739 clipboardDataChanged();
1733 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1740 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1734 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1741 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1735} 1742}
1736 1743
1737//US we need this function, to plug all actions into the correct menues. 1744//US we need this function, to plug all actions into the correct menues.
1738// KDE uses a XML format to plug the actions, but we work her without this overhead. 1745// KDE uses a XML format to plug the actions, but we work her without this overhead.
1739void KABCore::addActionsManually() 1746void KABCore::addActionsManually()
1740{ 1747{
1741//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1748//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1742 1749
1743#ifdef KAB_EMBEDDED 1750#ifdef KAB_EMBEDDED
1744 QPopupMenu *fileMenu = new QPopupMenu( this ); 1751 QPopupMenu *fileMenu = new QPopupMenu( this );
1745 QPopupMenu *editMenu = new QPopupMenu( this ); 1752 QPopupMenu *editMenu = new QPopupMenu( this );
1746 QPopupMenu *helpMenu = new QPopupMenu( this ); 1753 QPopupMenu *helpMenu = new QPopupMenu( this );
1747 1754
1748 KToolBar* tb = mMainWindow->toolBar(); 1755 KToolBar* tb = mMainWindow->toolBar();
1749 1756
1750#ifdef DESKTOP_VERSION 1757#ifdef DESKTOP_VERSION
1751 QMenuBar* mb = mMainWindow->menuBar(); 1758 QMenuBar* mb = mMainWindow->menuBar();
1752 1759
1753 //US setup menubar. 1760 //US setup menubar.
1754 //Disable the following block if you do not want to have a menubar. 1761 //Disable the following block if you do not want to have a menubar.
1755 mb->insertItem( "&File", fileMenu ); 1762 mb->insertItem( "&File", fileMenu );
1756 mb->insertItem( "&Edit", editMenu ); 1763 mb->insertItem( "&Edit", editMenu );
1757 mb->insertItem( "&View", viewMenu ); 1764 mb->insertItem( "&View", viewMenu );
1758 mb->insertItem( "&Settings", settingsMenu ); 1765 mb->insertItem( "&Settings", settingsMenu );
1759 mb->insertItem( "&Change selected", changeMenu ); 1766 mb->insertItem( "&Change selected", changeMenu );
1760 mb->insertItem( "&Help", helpMenu ); 1767 mb->insertItem( "&Help", helpMenu );
1761 mIncSearchWidget = new IncSearchWidget( tb ); 1768 mIncSearchWidget = new IncSearchWidget( tb );
1762 // tb->insertWidget(-1, 0, mIncSearchWidget); 1769 // tb->insertWidget(-1, 0, mIncSearchWidget);
1763 1770
1764#else 1771#else
1765 //US setup toolbar 1772 //US setup toolbar
1766 QMenuBar *menuBarTB = new QMenuBar( tb ); 1773 QMenuBar *menuBarTB = new QMenuBar( tb );
1767 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1774 QPopupMenu *popupBarTB = new QPopupMenu( this );
1768 menuBarTB->insertItem( "ME", popupBarTB); 1775 menuBarTB->insertItem( "ME", popupBarTB);
1769 tb->insertWidget(-1, 0, menuBarTB); 1776 tb->insertWidget(-1, 0, menuBarTB);
1770 mIncSearchWidget = new IncSearchWidget( tb ); 1777 mIncSearchWidget = new IncSearchWidget( tb );
1771 1778
1772 tb->enableMoving(false); 1779 tb->enableMoving(false);
1773 popupBarTB->insertItem( "&File", fileMenu ); 1780 popupBarTB->insertItem( "&File", fileMenu );
1774 popupBarTB->insertItem( "&Edit", editMenu ); 1781 popupBarTB->insertItem( "&Edit", editMenu );
1775 popupBarTB->insertItem( "&View", viewMenu ); 1782 popupBarTB->insertItem( "&View", viewMenu );
1776 popupBarTB->insertItem( "&Settings", settingsMenu ); 1783 popupBarTB->insertItem( "&Settings", settingsMenu );
1777 mViewManager->getFilterAction()->plug ( popupBarTB); 1784 mViewManager->getFilterAction()->plug ( popupBarTB);
1778 popupBarTB->insertItem( "&Change selected", changeMenu ); 1785 popupBarTB->insertItem( "&Change selected", changeMenu );
1779 popupBarTB->insertItem( "&Help", helpMenu ); 1786 popupBarTB->insertItem( "&Help", helpMenu );
1780 if (QApplication::desktop()->width() > 320 ) { 1787 if (QApplication::desktop()->width() > 320 ) {
1781 // mViewManager->getFilterAction()->plug ( tb); 1788 // mViewManager->getFilterAction()->plug ( tb);
1782 } 1789 }
1783#endif 1790#endif
1784 // mActionQuit->plug ( mMainWindow->toolBar()); 1791 // mActionQuit->plug ( mMainWindow->toolBar());
1785 1792
1786 1793
1787 1794
1788 //US Now connect the actions with the menue entries. 1795 //US Now connect the actions with the menue entries.
1789 mActionPrint->plug( fileMenu ); 1796 mActionPrint->plug( fileMenu );
1790 mActionMail->plug( fileMenu ); 1797 mActionMail->plug( fileMenu );
1791 fileMenu->insertSeparator(); 1798 fileMenu->insertSeparator();
1792 1799
1793 mActionNewContact->plug( fileMenu ); 1800 mActionNewContact->plug( fileMenu );
1794 mActionNewContact->plug( tb ); 1801 mActionNewContact->plug( tb );
1795 1802
1796 mActionEditAddressee->plug( fileMenu ); 1803 mActionEditAddressee->plug( fileMenu );
1797 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1804 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1798 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1805 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1799 mActionEditAddressee->plug( tb ); 1806 mActionEditAddressee->plug( tb );
1800 1807
1801 fileMenu->insertSeparator(); 1808 fileMenu->insertSeparator();
1802 mActionSave->plug( fileMenu ); 1809 mActionSave->plug( fileMenu );
1803 fileMenu->insertItem( "&Import", ImportMenu ); 1810 fileMenu->insertItem( "&Import", ImportMenu );
1804 fileMenu->insertItem( "&Emport", ExportMenu ); 1811 fileMenu->insertItem( "&Emport", ExportMenu );
1805 fileMenu->insertSeparator(); 1812 fileMenu->insertSeparator();
1806 mActionMailVCard->plug( fileMenu ); 1813 mActionMailVCard->plug( fileMenu );
1807#ifndef DESKTOP_VERSION 1814#ifndef DESKTOP_VERSION
1808 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1815 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1809 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1816 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1810#endif 1817#endif
1811 fileMenu->insertSeparator(); 1818 fileMenu->insertSeparator();
1812 mActionQuit->plug( fileMenu ); 1819 mActionQuit->plug( fileMenu );
1813#ifdef _WIN32_ 1820#ifdef _WIN32_
1814 mActionImportOL->plug( ImportMenu ); 1821 mActionImportOL->plug( ImportMenu );
1815#endif 1822#endif
1816 // edit menu 1823 // edit menu
1817 mActionUndo->plug( editMenu ); 1824 mActionUndo->plug( editMenu );
1818 mActionRedo->plug( editMenu ); 1825 mActionRedo->plug( editMenu );
1819 editMenu->insertSeparator(); 1826 editMenu->insertSeparator();
1820 mActionCut->plug( editMenu ); 1827 mActionCut->plug( editMenu );
1821 mActionCopy->plug( editMenu ); 1828 mActionCopy->plug( editMenu );
1822 mActionPaste->plug( editMenu ); 1829 mActionPaste->plug( editMenu );
1823 mActionDelete->plug( editMenu ); 1830 mActionDelete->plug( editMenu );
1824 editMenu->insertSeparator(); 1831 editMenu->insertSeparator();
1825 mActionSelectAll->plug( editMenu ); 1832 mActionSelectAll->plug( editMenu );
1826 1833
1827 mActionRemoveVoice->plug( changeMenu ); 1834 mActionRemoveVoice->plug( changeMenu );
1828 // settings menu 1835 // settings menu
1829//US special menuentry to configure the addressbook resources. On KDE 1836//US special menuentry to configure the addressbook resources. On KDE
1830// you do that through the control center !!! 1837// you do that through the control center !!!
1831 mActionConfigResources->plug( settingsMenu ); 1838 mActionConfigResources->plug( settingsMenu );
1832 settingsMenu->insertSeparator(); 1839 settingsMenu->insertSeparator();
1833 1840
1834 mActionConfigKAddressbook->plug( settingsMenu ); 1841 mActionConfigKAddressbook->plug( settingsMenu );
1835 1842
1836 if ( mIsPart ) { 1843 if ( mIsPart ) {
1837 mActionConfigShortcuts->plug( settingsMenu ); 1844 mActionConfigShortcuts->plug( settingsMenu );
1838 mActionConfigureToolbars->plug( settingsMenu ); 1845 mActionConfigureToolbars->plug( settingsMenu );
1839 1846
1840 } else { 1847 } else {
1841 mActionKeyBindings->plug( settingsMenu ); 1848 mActionKeyBindings->plug( settingsMenu );
1842 } 1849 }
1843 1850
1844 settingsMenu->insertSeparator(); 1851 settingsMenu->insertSeparator();
1845 1852
1846 mActionJumpBar->plug( settingsMenu ); 1853 mActionJumpBar->plug( settingsMenu );
1847 mActionDetails->plug( settingsMenu ); 1854 mActionDetails->plug( settingsMenu );
1848 if (!KABPrefs::instance()->mMultipleViewsAtOnce ) 1855 if (!KABPrefs::instance()->mMultipleViewsAtOnce )
1849 mActionDetails->plug( tb ); 1856 mActionDetails->plug( tb );
1850 settingsMenu->insertSeparator(); 1857 settingsMenu->insertSeparator();
1851 1858
1852 mActionWhoAmI->plug( settingsMenu ); 1859 mActionWhoAmI->plug( settingsMenu );
1853 mActionCategories->plug( settingsMenu ); 1860 mActionCategories->plug( settingsMenu );
1854 1861
1855 mActionAboutKAddressbook->plug( helpMenu ); 1862 mActionAboutKAddressbook->plug( helpMenu );
1856 mActionLicence->plug( helpMenu ); 1863 mActionLicence->plug( helpMenu );
1857 1864
1858 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 1865 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
1859 1866
1860 mActionSave->plug( tb ); 1867 mActionSave->plug( tb );
1861 mViewManager->getFilterAction()->plug ( tb); 1868 mViewManager->getFilterAction()->plug ( tb);
1862 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 1869 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
1863 mActionUndo->plug( tb ); 1870 mActionUndo->plug( tb );
1864 mActionDelete->plug( tb ); 1871 mActionDelete->plug( tb );
1865 mActionRedo->plug( tb ); 1872 mActionRedo->plug( tb );
1866 } 1873 }
1867 } 1874 }
1868 //mActionQuit->plug ( tb ); 1875 //mActionQuit->plug ( tb );
1869 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1876 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1870 1877
1871 //US link the searchwidget first to this. 1878 //US link the searchwidget first to this.
1872 // The real linkage to the toolbar happens later. 1879 // The real linkage to the toolbar happens later.
1873//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1880//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1874//US tb->insertItem( mIncSearchWidget ); 1881//US tb->insertItem( mIncSearchWidget );
1875/*US 1882/*US
1876 mIncSearchWidget = new IncSearchWidget( tb ); 1883 mIncSearchWidget = new IncSearchWidget( tb );
1877 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1884 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1878 SLOT( incrementalSearch( const QString& ) ) ); 1885 SLOT( incrementalSearch( const QString& ) ) );
1879 1886
1880 mJumpButtonBar = new JumpButtonBar( this, this ); 1887 mJumpButtonBar = new JumpButtonBar( this, this );
1881 1888
1882//US topLayout->addWidget( mJumpButtonBar ); 1889//US topLayout->addWidget( mJumpButtonBar );
1883 this->layout()->add( mJumpButtonBar ); 1890 this->layout()->add( mJumpButtonBar );
1884*/ 1891*/
1885 1892
1886#endif //KAB_EMBEDDED 1893#endif //KAB_EMBEDDED
1887} 1894}
1888void KABCore::showLicence() 1895void KABCore::showLicence()
1889{ 1896{
1890 KApplication::showLicence(); 1897 KApplication::showLicence();
1891} 1898}
1892void KABCore::removeVoice() 1899void KABCore::removeVoice()
1893{ 1900{
1894 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 ) 1901 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 )
1895 return; 1902 return;
1896 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1903 KABC::Addressee::List list = mViewManager->selectedAddressees();
1897 KABC::Addressee::List::Iterator it; 1904 KABC::Addressee::List::Iterator it;
1898 for ( it = list.begin(); it != list.end(); ++it ) { 1905 for ( it = list.begin(); it != list.end(); ++it ) {
1899 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1906 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1900 PhoneNumber::List::Iterator phoneIt; 1907 PhoneNumber::List::Iterator phoneIt;
1901 bool found = false; 1908 bool found = false;
1902 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1909 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1903 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1910 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1904 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1911 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1905 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1912 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1906 (*it).insertPhoneNumber( (*phoneIt) ); 1913 (*it).insertPhoneNumber( (*phoneIt) );
1907 found = true; 1914 found = true;
1908 } 1915 }
1909 } 1916 }
1910 1917
1911 } 1918 }
1912 if ( found ) 1919 if ( found )
1913 contactModified((*it) ); 1920 contactModified((*it) );
1914 } 1921 }
1915} 1922}
1916 1923
1917 1924
1918 1925
1919void KABCore::clipboardDataChanged() 1926void KABCore::clipboardDataChanged()
1920{ 1927{
1921 1928
1922 if ( mReadWrite ) 1929 if ( mReadWrite )
1923 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1930 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1924 1931
1925} 1932}
1926 1933
1927void KABCore::updateActionMenu() 1934void KABCore::updateActionMenu()
1928{ 1935{
1929 UndoStack *undo = UndoStack::instance(); 1936 UndoStack *undo = UndoStack::instance();
1930 RedoStack *redo = RedoStack::instance(); 1937 RedoStack *redo = RedoStack::instance();
1931 1938
1932 if ( undo->isEmpty() ) 1939 if ( undo->isEmpty() )
1933 mActionUndo->setText( i18n( "Undo" ) ); 1940 mActionUndo->setText( i18n( "Undo" ) );
1934 else 1941 else
1935 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1942 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1936 1943
1937 mActionUndo->setEnabled( !undo->isEmpty() ); 1944 mActionUndo->setEnabled( !undo->isEmpty() );
1938 1945
1939 if ( !redo->top() ) 1946 if ( !redo->top() )
1940 mActionRedo->setText( i18n( "Redo" ) ); 1947 mActionRedo->setText( i18n( "Redo" ) );
1941 else 1948 else
1942 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1949 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1943 1950
1944 mActionRedo->setEnabled( !redo->isEmpty() ); 1951 mActionRedo->setEnabled( !redo->isEmpty() );
1945} 1952}
1946 1953
1947void KABCore::configureKeyBindings() 1954void KABCore::configureKeyBindings()
1948{ 1955{
1949#ifndef KAB_EMBEDDED 1956#ifndef KAB_EMBEDDED
1950 KKeyDialog::configure( actionCollection(), true ); 1957 KKeyDialog::configure( actionCollection(), true );
1951#else //KAB_EMBEDDED 1958#else //KAB_EMBEDDED
1952 qDebug("KABCore::configureKeyBindings() not implemented"); 1959 qDebug("KABCore::configureKeyBindings() not implemented");
1953#endif //KAB_EMBEDDED 1960#endif //KAB_EMBEDDED
1954} 1961}
1955 1962
1956#ifdef KAB_EMBEDDED 1963#ifdef KAB_EMBEDDED
1957void KABCore::configureResources() 1964void KABCore::configureResources()
1958{ 1965{
1959 KRES::KCMKResources dlg( this, "" , 0 ); 1966 KRES::KCMKResources dlg( this, "" , 0 );
1960 1967
1961 if ( !dlg.exec() ) 1968 if ( !dlg.exec() )
1962 return; 1969 return;
1963 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 1970 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
1964} 1971}
1965#endif //KAB_EMBEDDED 1972#endif //KAB_EMBEDDED
1966 1973
1967 1974
1975/* this method will be called through the QCop interface from Ko/Pi to select addresses
1976 * for the attendees list of an event.
1977 */
1978void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid, const QString& param1)
1979{
1980 //param1 is usually empty for this kind of request
1981
1982 QStringList nameList;
1983 QStringList emailList;
1984 QStringList uidList;
1985
1986 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
1987 uint i=0;
1988 for (i=0; i < list.count(); i++)
1989 {
1990 nameList.append(list[i].realName());
1991 emailList.append(list[i].preferredEmail());
1992 uidList.append(list[i].uid());
1993 }
1994
1995 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
1996
1997}
1998
1999
2000
1968 2001
1969#ifndef KAB_EMBEDDED 2002#ifndef KAB_EMBEDDED
1970#include "kabcore.moc" 2003#include "kabcore.moc"
1971#endif //KAB_EMBEDDED 2004#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index d4d28f1..fe778af 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,449 +1,452 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32 32
33#include <qwidget.h> 33#include <qwidget.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35 35
36namespace KABC { 36namespace KABC {
37class AddressBook; 37class AddressBook;
38} 38}
39 39
40#ifndef KAB_EMBEDDED 40#ifndef KAB_EMBEDDED
41class KAboutData; 41class KAboutData;
42class KConfig; 42class KConfig;
43 43
44class KAddressBookService; 44class KAddressBookService;
45class LDAPSearchDialog; 45class LDAPSearchDialog;
46#else //KAB_EMBEDDED 46#else //KAB_EMBEDDED
47class KAddressBookMain; 47class KAddressBookMain;
48//US class QAction; 48//US class QAction;
49#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
50class KCMultiDialog; 50class KCMultiDialog;
51class KXMLGUIClient; 51class KXMLGUIClient;
52class ExtensionManager; 52class ExtensionManager;
53class XXPortManager; 53class XXPortManager;
54class JumpButtonBar; 54class JumpButtonBar;
55class IncSearchWidget; 55class IncSearchWidget;
56class KDGanttMinimizeSplitter; 56class KDGanttMinimizeSplitter;
57class KAction; 57class KAction;
58class KActionCollection; 58class KActionCollection;
59class KToggleAction; 59class KToggleAction;
60 60
61class QAction; 61class QAction;
62class QMenuBar; 62class QMenuBar;
63class QSplitter; 63class QSplitter;
64class ViewContainer; 64class ViewContainer;
65class ViewManager; 65class ViewManager;
66class AddresseeEditorDialog; 66class AddresseeEditorDialog;
67class Ir; 67class Ir;
68 68
69class KABCore : public QWidget 69class KABCore : public QWidget
70{ 70{
71 Q_OBJECT 71 Q_OBJECT
72 72
73 public: 73 public:
74 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 74 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
75 75
76 76
77 ~KABCore(); 77 ~KABCore();
78 78
79 79
80#ifdef KAB_EMBEDDED 80#ifdef KAB_EMBEDDED
81 //US added functionality 81 //US added functionality
82 QPopupMenu* getViewMenu() {return viewMenu;} 82 QPopupMenu* getViewMenu() {return viewMenu;}
83 QPopupMenu* getFilterMenu() {return filterMenu;} 83 QPopupMenu* getFilterMenu() {return filterMenu;}
84 QPopupMenu* getSettingsMenu() {return settingsMenu;} 84 QPopupMenu* getSettingsMenu() {return settingsMenu;}
85 void addActionsManually(); 85 void addActionsManually();
86#endif //KAB_EMBEDDED 86#endif //KAB_EMBEDDED
87 /** 87 /**
88 Restores the global settings. 88 Restores the global settings.
89 */ 89 */
90 void restoreSettings(); 90 void restoreSettings();
91 91
92 /** 92 /**
93 Saves the global settings. 93 Saves the global settings.
94 */ 94 */
95 void saveSettings(); 95 void saveSettings();
96 96
97 /** 97 /**
98 Returns a pointer to the StdAddressBook of the application. 98 Returns a pointer to the StdAddressBook of the application.
99 */ 99 */
100 KABC::AddressBook *addressBook() const; 100 KABC::AddressBook *addressBook() const;
101 101
102 /** 102 /**
103 Returns a pointer to the KConfig object of the application. 103 Returns a pointer to the KConfig object of the application.
104 */ 104 */
105 static KConfig *config(); 105 static KConfig *config();
106 106
107 /** 107 /**
108 Returns a pointer to the global KActionCollection object. So 108 Returns a pointer to the global KActionCollection object. So
109 other classes can register their actions easily. 109 other classes can register their actions easily.
110 */ 110 */
111 KActionCollection *actionCollection() const; 111 KActionCollection *actionCollection() const;
112 112
113 /** 113 /**
114 Returns the current search field of the Incremental Search Widget. 114 Returns the current search field of the Incremental Search Widget.
115 */ 115 */
116 KABC::Field *currentSearchField() const; 116 KABC::Field *currentSearchField() const;
117 117
118 /** 118 /**
119 Returns the uid list of the currently selected contacts. 119 Returns the uid list of the currently selected contacts.
120 */ 120 */
121 QStringList selectedUIDs() const; 121 QStringList selectedUIDs() const;
122 122
123 /** 123 /**
124 Displays the ResourceSelectDialog and returns the selected 124 Displays the ResourceSelectDialog and returns the selected
125 resource or a null pointer if no resource was selected by 125 resource or a null pointer if no resource was selected by
126 the user. 126 the user.
127 */ 127 */
128 KABC::Resource *requestResource( QWidget *parent ); 128 KABC::Resource *requestResource( QWidget *parent );
129 129
130#ifndef KAB_EMBEDDED 130#ifndef KAB_EMBEDDED
131 static KAboutData *createAboutData(); 131 static KAboutData *createAboutData();
132#endif //KAB_EMBEDDED 132#endif //KAB_EMBEDDED
133 133
134#ifdef KAB_EMBEDDED 134#ifdef KAB_EMBEDDED
135 inline QPopupMenu* getImportMenu() { return ImportMenu;} 135 inline QPopupMenu* getImportMenu() { return ImportMenu;}
136 inline QPopupMenu* getExportMenu() { return ExportMenu;} 136 inline QPopupMenu* getExportMenu() { return ExportMenu;}
137#endif //KAB_EMBEDDED 137#endif //KAB_EMBEDDED
138 138
139 public slots: 139 public slots:
140#ifdef KAB_EMBEDDED 140#ifdef KAB_EMBEDDED
141 void createAboutData(); 141 void createAboutData();
142#endif //KAB_EMBEDDED 142#endif //KAB_EMBEDDED
143 143
144 void statusMessage(QString, int time = 0 ); 144 void statusMessage(QString, int time = 0 );
145 void showLicence(); 145 void showLicence();
146 /** 146 /**
147 Is called whenever a contact is selected in the view. 147 Is called whenever a contact is selected in the view.
148 */ 148 */
149 void setContactSelected( const QString &uid ); 149 void setContactSelected( const QString &uid );
150 150
151 /** 151 /**
152 Opens the preferred mail composer with all selected contacts as 152 Opens the preferred mail composer with all selected contacts as
153 arguments. 153 arguments.
154 */ 154 */
155 void sendMail(); 155 void sendMail();
156 156
157 /** 157 /**
158 Opens the preferred mail composer with the given contacts as 158 Opens the preferred mail composer with the given contacts as
159 arguments. 159 arguments.
160 */ 160 */
161 void sendMail( const QString& email ); 161 void sendMail( const QString& email );
162 162
163 163
164 void mailVCard(); 164 void mailVCard();
165 void mailVCard(const QStringList& uids); 165 void mailVCard(const QStringList& uids);
166 166
167 /** 167 /**
168 Beams the "WhoAmI contact. 168 Beams the "WhoAmI contact.
169 */ 169 */
170 void beamMySelf(); 170 void beamMySelf();
171 171
172 void beamVCard(); 172 void beamVCard();
173 void beamVCard(const QStringList& uids); 173 void beamVCard(const QStringList& uids);
174 void beamDone( Ir *ir ); 174 void beamDone( Ir *ir );
175 175
176 176
177 /** 177 /**
178 Starts the preferred web browser with the given URL as argument. 178 Starts the preferred web browser with the given URL as argument.
179 */ 179 */
180 void browse( const QString& url ); 180 void browse( const QString& url );
181 181
182 /** 182 /**
183 Select all contacts in the view. 183 Select all contacts in the view.
184 */ 184 */
185 void selectAllContacts(); 185 void selectAllContacts();
186 186
187 /** 187 /**
188 Deletes all selected contacts from the address book. 188 Deletes all selected contacts from the address book.
189 */ 189 */
190 void deleteContacts(); 190 void deleteContacts();
191 191
192 /** 192 /**
193 Deletes given contacts from the address book. 193 Deletes given contacts from the address book.
194 194
195 @param uids The uids of the contacts, which shall be deleted. 195 @param uids The uids of the contacts, which shall be deleted.
196 */ 196 */
197 void deleteContacts( const QStringList &uids ); 197 void deleteContacts( const QStringList &uids );
198 198
199 /** 199 /**
200 Copys the selected contacts into clipboard for later pasting. 200 Copys the selected contacts into clipboard for later pasting.
201 */ 201 */
202 void copyContacts(); 202 void copyContacts();
203 203
204 /** 204 /**
205 Cuts the selected contacts and stores them for later pasting. 205 Cuts the selected contacts and stores them for later pasting.
206 */ 206 */
207 void cutContacts(); 207 void cutContacts();
208 208
209 /** 209 /**
210 Paste contacts from clipboard into the address book. 210 Paste contacts from clipboard into the address book.
211 */ 211 */
212 void pasteContacts(); 212 void pasteContacts();
213 213
214 /** 214 /**
215 Paste given contacts into the address book. 215 Paste given contacts into the address book.
216 216
217 @param list The list of addressee, which shall be pasted. 217 @param list The list of addressee, which shall be pasted.
218 */ 218 */
219 void pasteContacts( KABC::Addressee::List &list ); 219 void pasteContacts( KABC::Addressee::List &list );
220 220
221 /** 221 /**
222 Sets the whoAmI contact, that is used by many other programs to 222 Sets the whoAmI contact, that is used by many other programs to
223 get personal information about the current user. 223 get personal information about the current user.
224 */ 224 */
225 void setWhoAmI(); 225 void setWhoAmI();
226 226
227 /** 227 /**
228 Displays the category dialog and applies the result to all 228 Displays the category dialog and applies the result to all
229 selected contacts. 229 selected contacts.
230 */ 230 */
231 void setCategories(); 231 void setCategories();
232 232
233 /** 233 /**
234 Sets the field list of the Incremental Search Widget. 234 Sets the field list of the Incremental Search Widget.
235 */ 235 */
236 void setSearchFields( const KABC::Field::List &fields ); 236 void setSearchFields( const KABC::Field::List &fields );
237 237
238 /** 238 /**
239 Search with the current search field for a contact, that matches 239 Search with the current search field for a contact, that matches
240 the given text, and selects it in the view. 240 the given text, and selects it in the view.
241 */ 241 */
242 void incrementalSearch( const QString& text ); 242 void incrementalSearch( const QString& text );
243 243
244 /** 244 /**
245 Marks the address book as modified. 245 Marks the address book as modified.
246 */ 246 */
247 void setModified(); 247 void setModified();
248 /** 248 /**
249 Marks the address book as modified without refreshing the view. 249 Marks the address book as modified without refreshing the view.
250 */ 250 */
251 void setModifiedWOrefresh(); 251 void setModifiedWOrefresh();
252 252
253 /** 253 /**
254 Marks the address book as modified concerning the argument. 254 Marks the address book as modified concerning the argument.
255 */ 255 */
256 void setModified( bool modified ); 256 void setModified( bool modified );
257 257
258 /** 258 /**
259 Returns whether the address book is modified. 259 Returns whether the address book is modified.
260 */ 260 */
261 bool modified() const; 261 bool modified() const;
262 262
263 /** 263 /**
264 Called whenever an contact is modified in the contact editor 264 Called whenever an contact is modified in the contact editor
265 dialog or the quick edit. 265 dialog or the quick edit.
266 */ 266 */
267 void contactModified( const KABC::Addressee &addr ); 267 void contactModified( const KABC::Addressee &addr );
268 268
269 /** 269 /**
270 DCOP METHODS. 270 DCOP METHODS.
271 */ 271 */
272 void addEmail( QString addr ); 272 void addEmail( QString addr );
273 void importVCard( const KURL& url, bool showPreview ); 273 void importVCard( const KURL& url, bool showPreview );
274 void importVCard( const QString& vCard, bool showPreview ); 274 void importVCard( const QString& vCard, bool showPreview );
275 void newContact(); 275 void newContact();
276 QString getNameByPhone( const QString& phone ); 276 QString getNameByPhone( const QString& phone );
277 /** 277 /**
278 END DCOP METHODS 278 END DCOP METHODS
279 */ 279 */
280 280
281 /** 281 /**
282 Saves the contents of the AddressBook back to disk. 282 Saves the contents of the AddressBook back to disk.
283 */ 283 */
284 void save(); 284 void save();
285 285
286 /** 286 /**
287 Undos the last command using the undo stack. 287 Undos the last command using the undo stack.
288 */ 288 */
289 void undo(); 289 void undo();
290 290
291 /** 291 /**
292 Redos the last command that was undone, using the redo stack. 292 Redos the last command that was undone, using the redo stack.
293 */ 293 */
294 void redo(); 294 void redo();
295 295
296 /** 296 /**
297 Shows the edit dialog for the given uid. If the uid is QString::null, 297 Shows the edit dialog for the given uid. If the uid is QString::null,
298 the method will try to find a selected addressee in the view. 298 the method will try to find a selected addressee in the view.
299 */ 299 */
300 void editContact( const QString &uid /*US = QString::null*/ ); 300 void editContact( const QString &uid /*US = QString::null*/ );
301//US added a second method without defaultparameter 301//US added a second method without defaultparameter
302 void editContact2(); 302 void editContact2();
303 303
304 /** 304 /**
305 Shows or edits the detail view for the given uid. If the uid is QString::null, 305 Shows or edits the detail view for the given uid. If the uid is QString::null,
306 the method will try to find a selected addressee in the view. 306 the method will try to find a selected addressee in the view.
307 */ 307 */
308 void executeContact( const QString &uid /*US = QString::null*/ ); 308 void executeContact( const QString &uid /*US = QString::null*/ );
309 309
310 /** 310 /**
311 Launches the configuration dialog. 311 Launches the configuration dialog.
312 */ 312 */
313 void openConfigDialog(); 313 void openConfigDialog();
314 314
315 /** 315 /**
316 Launches the ldap search dialog. 316 Launches the ldap search dialog.
317 */ 317 */
318 void openLDAPDialog(); 318 void openLDAPDialog();
319 319
320 /** 320 /**
321 Creates a KAddressBookPrinter, which will display the print 321 Creates a KAddressBookPrinter, which will display the print
322 dialog and do the printing. 322 dialog and do the printing.
323 */ 323 */
324 void print(); 324 void print();
325 325
326 /** 326 /**
327 Registers a new GUI client, so plugins can register its actions. 327 Registers a new GUI client, so plugins can register its actions.
328 */ 328 */
329 void addGUIClient( KXMLGUIClient *client ); 329 void addGUIClient( KXMLGUIClient *client );
330 330
331 void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid, const QString& param1);
332
333
331 signals: 334 signals:
332 void contactSelected( const QString &name ); 335 void contactSelected( const QString &name );
333 void contactSelected( const QPixmap &pixmap ); 336 void contactSelected( const QPixmap &pixmap );
334 public slots: 337 public slots:
335 void setDetailsVisible( bool visible ); 338 void setDetailsVisible( bool visible );
336 void setDetailsToState(); 339 void setDetailsToState();
337 private slots: 340 private slots:
338 void setJumpButtonBarVisible( bool visible ); 341 void setJumpButtonBarVisible( bool visible );
339 void importFromOL(); 342 void importFromOL();
340 void extensionModified( const KABC::Addressee::List &list ); 343 void extensionModified( const KABC::Addressee::List &list );
341 void extensionChanged( int id ); 344 void extensionChanged( int id );
342 void clipboardDataChanged(); 345 void clipboardDataChanged();
343 void updateActionMenu(); 346 void updateActionMenu();
344 void configureKeyBindings(); 347 void configureKeyBindings();
345 void removeVoice(); 348 void removeVoice();
346#ifdef KAB_EMBEDDED 349#ifdef KAB_EMBEDDED
347 void configureResources(); 350 void configureResources();
348#endif //KAB_EMBEDDED 351#endif //KAB_EMBEDDED
349 352
350 void slotEditorDestroyed( const QString &uid ); 353 void slotEditorDestroyed( const QString &uid );
351 void configurationChanged(); 354 void configurationChanged();
352 void addressBookChanged(); 355 void addressBookChanged();
353 356
354 private: 357 private:
355 void initGUI(); 358 void initGUI();
356 void initActions(); 359 void initActions();
357 360
358 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 361 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
359 const char *name = 0 ); 362 const char *name = 0 );
360 363
361 KXMLGUIClient *mGUIClient; 364 KXMLGUIClient *mGUIClient;
362 365
363 KABC::AddressBook *mAddressBook; 366 KABC::AddressBook *mAddressBook;
364 367
365 ViewManager *mViewManager; 368 ViewManager *mViewManager;
366 // QSplitter *mDetailsSplitter; 369 // QSplitter *mDetailsSplitter;
367 KDGanttMinimizeSplitter *mExtensionBarSplitter; 370 KDGanttMinimizeSplitter *mExtensionBarSplitter;
368 ViewContainer *mDetails; 371 ViewContainer *mDetails;
369 KDGanttMinimizeSplitter* mMiniSplitter; 372 KDGanttMinimizeSplitter* mMiniSplitter;
370 XXPortManager *mXXPortManager; 373 XXPortManager *mXXPortManager;
371 JumpButtonBar *mJumpButtonBar; 374 JumpButtonBar *mJumpButtonBar;
372 IncSearchWidget *mIncSearchWidget; 375 IncSearchWidget *mIncSearchWidget;
373 ExtensionManager *mExtensionManager; 376 ExtensionManager *mExtensionManager;
374 377
375 KCMultiDialog *mConfigureDialog; 378 KCMultiDialog *mConfigureDialog;
376 379
377#ifndef KAB_EMBEDDED 380#ifndef KAB_EMBEDDED
378 LDAPSearchDialog *mLdapSearchDialog; 381 LDAPSearchDialog *mLdapSearchDialog;
379#endif //KAB_EMBEDDED 382#endif //KAB_EMBEDDED
380 // QDict<AddresseeEditorDialog> mEditorDict; 383 // QDict<AddresseeEditorDialog> mEditorDict;
381 AddresseeEditorDialog *mEditorDialog; 384 AddresseeEditorDialog *mEditorDialog;
382 bool mReadWrite; 385 bool mReadWrite;
383 bool mModified; 386 bool mModified;
384 bool mIsPart; 387 bool mIsPart;
385 bool mMultipleViewsAtOnce; 388 bool mMultipleViewsAtOnce;
386 389
387 390
388 //US file menu 391 //US file menu
389 KAction *mActionMail; 392 KAction *mActionMail;
390 KAction *mActionBeam; 393 KAction *mActionBeam;
391 KAction* mActionPrint; 394 KAction* mActionPrint;
392 KAction* mActionNewContact; 395 KAction* mActionNewContact;
393 KAction *mActionSave; 396 KAction *mActionSave;
394 KAction *mActionEditAddressee; 397 KAction *mActionEditAddressee;
395 KAction *mActionMailVCard; 398 KAction *mActionMailVCard;
396 KAction *mActionBeamVCard; 399 KAction *mActionBeamVCard;
397 400
398 KAction *mActionQuit; 401 KAction *mActionQuit;
399 402
400 //US edit menu 403 //US edit menu
401 KAction *mActionCopy; 404 KAction *mActionCopy;
402 KAction *mActionCut; 405 KAction *mActionCut;
403 KAction *mActionPaste; 406 KAction *mActionPaste;
404 KAction *mActionSelectAll; 407 KAction *mActionSelectAll;
405 KAction *mActionUndo; 408 KAction *mActionUndo;
406 KAction *mActionRedo; 409 KAction *mActionRedo;
407 KAction *mActionDelete; 410 KAction *mActionDelete;
408 411
409 //US settings menu 412 //US settings menu
410 KAction *mActionConfigResources; 413 KAction *mActionConfigResources;
411 KAction *mActionConfigKAddressbook; 414 KAction *mActionConfigKAddressbook;
412 KAction *mActionConfigShortcuts; 415 KAction *mActionConfigShortcuts;
413 KAction *mActionConfigureToolbars; 416 KAction *mActionConfigureToolbars;
414 KAction *mActionKeyBindings; 417 KAction *mActionKeyBindings;
415 KToggleAction *mActionJumpBar; 418 KToggleAction *mActionJumpBar;
416 KToggleAction *mActionDetails; 419 KToggleAction *mActionDetails;
417 KAction *mActionWhoAmI; 420 KAction *mActionWhoAmI;
418 KAction *mActionCategories; 421 KAction *mActionCategories;
419 KAction *mActionAboutKAddressbook; 422 KAction *mActionAboutKAddressbook;
420 KAction *mActionLicence; 423 KAction *mActionLicence;
421 424
422 KAction *mActionDeleteView; 425 KAction *mActionDeleteView;
423 426
424 QPopupMenu *viewMenu; 427 QPopupMenu *viewMenu;
425 QPopupMenu *filterMenu; 428 QPopupMenu *filterMenu;
426 QPopupMenu *settingsMenu; 429 QPopupMenu *settingsMenu;
427 QPopupMenu *changeMenu; 430 QPopupMenu *changeMenu;
428 431
429//US QAction *mActionSave; 432//US QAction *mActionSave;
430 QPopupMenu *ImportMenu; 433 QPopupMenu *ImportMenu;
431 QPopupMenu *ExportMenu; 434 QPopupMenu *ExportMenu;
432 //LR additional methods 435 //LR additional methods
433 KAction *mActionRemoveVoice; 436 KAction *mActionRemoveVoice;
434 KAction * mActionImportOL; 437 KAction * mActionImportOL;
435 438
436#ifndef KAB_EMBEDDED 439#ifndef KAB_EMBEDDED
437 KAddressBookService *mAddressBookService; 440 KAddressBookService *mAddressBookService;
438#endif //KAB_EMBEDDED 441#endif //KAB_EMBEDDED
439 442
440 class KABCorePrivate; 443 class KABCorePrivate;
441 KABCorePrivate *d; 444 KABCorePrivate *d;
442 445
443#ifdef KAB_EMBEDDED 446#ifdef KAB_EMBEDDED
444 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 447 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
445#endif //KAB_EMBEDDED 448#endif //KAB_EMBEDDED
446 449
447}; 450};
448 451
449#endif 452#endif
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 7f368eb..850e5b2 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -1,191 +1,192 @@
1#ifndef DESKTOP_VERSION 1#ifndef DESKTOP_VERSION
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#else 4#else
5#include <qapplication.h> 5#include <qapplication.h>
6#include <qwindowsstyle.h> 6#include <qwindowsstyle.h>
7#include <qplatinumstyle.h> 7#include <qplatinumstyle.h>
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#endif 9#endif
10 10
11#include <kstandarddirs.h> 11#include <kstandarddirs.h>
12#include <kglobal.h> 12#include <kglobal.h>
13#include <stdio.h> 13#include <stdio.h>
14#include <qdir.h> 14#include <qdir.h>
15#include "kaddressbookmain.h" 15#include "kaddressbookmain.h"
16#include "externalapphandler.h"
16 17
17int main( int argc, char **argv ) 18int main( int argc, char **argv )
18{ 19{
19#ifndef DESKTOP_VERSION 20#ifndef DESKTOP_VERSION
20 QPEApplication a( argc, argv ); 21 QPEApplication a( argc, argv );
21 a.setKeepRunning (); 22 a.setKeepRunning ();
22#else 23#else
23 QApplication a( argc, argv ); 24 QApplication a( argc, argv );
24 QApplication::setStyle( new QPlatinumStyle ()); 25 QApplication::setStyle( new QPlatinumStyle ());
25#endif 26#endif
26 27
27 bool exitHelp = false; 28 bool exitHelp = false;
28 if ( argc > 1 ) { 29 if ( argc > 1 ) {
29 QString command = argv[1]; 30 QString command = argv[1];
30 if ( command == "-help" ){ 31 if ( command == "-help" ){
31 printf("KA/E command line commands:\n"); 32 printf("KA/E command line commands:\n");
32 printf(" no command: Start KA/E in usual way\n"); 33 printf(" no command: Start KA/E in usual way\n");
33 printf(" -help: This output\n"); 34 printf(" -help: This output\n");
34 printf(" KA/E is exiting now. Bye!\n"); 35 printf(" KA/E is exiting now. Bye!\n");
35 exitHelp = true; 36 exitHelp = true;
36 } 37 }
37 } 38 }
38 if ( ! exitHelp ) { 39 if ( ! exitHelp ) {
39 40
40 KGlobal::setAppName( "kaddressbook" ); 41 KGlobal::setAppName( "kaddressbook" );
41#ifndef DESKTOP_VERSION 42#ifndef DESKTOP_VERSION
42 if ( QApplication::desktop()->width() > 320 ) 43 if ( QApplication::desktop()->width() > 320 )
43 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/"); 44 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
44 else 45 else
45 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/"); 46 KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
46#else 47#else
47 QString fileName ; 48 QString fileName ;
48 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; 49 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
49 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 50 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
50 QApplication::addLibraryPath ( qApp->applicationDirPath () ); 51 QApplication::addLibraryPath ( qApp->applicationDirPath () );
51 52
52#endif 53#endif
53 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); 54 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
54 KAddressBookMain m ; 55 KAddressBookMain m ;
55//US MainWindow m; 56//US MainWindow m;
56//US QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 57 QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
57 58
58#ifndef DESKTOP_VERSION 59#ifndef DESKTOP_VERSION
59 a.showMainWidget( &m ); 60 a.showMainWidget( &m );
60#else 61#else
61 a.setMainWidget( &m ); 62 a.setMainWidget( &m );
62 m.resize (640, 480 ); 63 m.resize (640, 480 );
63 m.show(); 64 m.show();
64#endif 65#endif
65 a.exec(); 66 a.exec();
66 67
67 } 68 }
68 qDebug("KA: Bye! "); 69 qDebug("KA: Bye! ");
69} 70}
70 71
71/* 72/*
72#include <stdlib.h> 73#include <stdlib.h>
73 74
74#include <qstring.h> 75#include <qstring.h>
75 76
76#include <kabc/stdaddressbook.h> 77#include <kabc/stdaddressbook.h>
77#include <kaboutdata.h> 78#include <kaboutdata.h>
78#include <kcmdlineargs.h> 79#include <kcmdlineargs.h>
79#include <kcrash.h> 80#include <kcrash.h>
80#include <kdebug.h> 81#include <kdebug.h>
81#include <klocale.h> 82#include <klocale.h>
82#include <kstartupinfo.h> 83#include <kstartupinfo.h>
83#include <kuniqueapplication.h> 84#include <kuniqueapplication.h>
84#include <kwin.h> 85#include <kwin.h>
85 86
86#include "kaddressbookmain.h" 87#include "kaddressbookmain.h"
87#include "kabcore.h" 88#include "kabcore.h"
88 89
89extern "C" { 90extern "C" {
90 91
91void crashHandler( int ) 92void crashHandler( int )
92{ 93{
93 KABC::StdAddressBook::handleCrash(); 94 KABC::StdAddressBook::handleCrash();
94 ::exit( 0 ); 95 ::exit( 0 );
95} 96}
96 97
97} 98}
98 99
99class KAddressBookApp : public KUniqueApplication { 100class KAddressBookApp : public KUniqueApplication {
100 public: 101 public:
101 KAddressBookApp() : mMainWin( 0 ) {} 102 KAddressBookApp() : mMainWin( 0 ) {}
102 ~KAddressBookApp() {} 103 ~KAddressBookApp() {}
103 104
104 int newInstance(); 105 int newInstance();
105 106
106 private: 107 private:
107 KAddressBookMain *mMainWin; 108 KAddressBookMain *mMainWin;
108}; 109};
109 110
110int KAddressBookApp::newInstance() 111int KAddressBookApp::newInstance()
111{ 112{
112 if ( isRestored() ) { 113 if ( isRestored() ) {
113 // There can only be one main window 114 // There can only be one main window
114 if ( KMainWindow::canBeRestored( 1 ) ) { 115 if ( KMainWindow::canBeRestored( 1 ) ) {
115 mMainWin = new KAddressBookMain; 116 mMainWin = new KAddressBookMain;
116 mMainWin->show(); 117 mMainWin->show();
117 mMainWin->restore( 1 ); 118 mMainWin->restore( 1 );
118 } 119 }
119 } else { 120 } else {
120 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); 121 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
121 122
122 QCString addrStr = args->getOption( "addr" ); 123 QCString addrStr = args->getOption( "addr" );
123 QCString uidStr = args->getOption( "uid" ); 124 QCString uidStr = args->getOption( "uid" );
124 QString addr; 125 QString addr;
125 QString uid; 126 QString uid;
126 if ( !addrStr.isEmpty() ) 127 if ( !addrStr.isEmpty() )
127 addr = QString::fromLocal8Bit( addrStr ); 128 addr = QString::fromLocal8Bit( addrStr );
128 if ( !uidStr.isEmpty() ) 129 if ( !uidStr.isEmpty() )
129 uid = QString::fromLocal8Bit( uidStr ); 130 uid = QString::fromLocal8Bit( uidStr );
130 131
131 132
132 if ( args->isSet( "editor-only" ) ) { 133 if ( args->isSet( "editor-only" ) ) {
133 if ( !mMainWin ) 134 if ( !mMainWin )
134 mMainWin = new KAddressBookMain; 135 mMainWin = new KAddressBookMain;
135 KStartupInfo::appStarted(); 136 KStartupInfo::appStarted();
136 mMainWin->hide(); 137 mMainWin->hide();
137 } else { 138 } else {
138 if ( mMainWin ) { 139 if ( mMainWin ) {
139 mMainWin->show(); 140 mMainWin->show();
140 KWin::setActiveWindow( mMainWin->winId() ); 141 KWin::setActiveWindow( mMainWin->winId() );
141 } else { 142 } else {
142 mMainWin = new KAddressBookMain; 143 mMainWin = new KAddressBookMain;
143 mMainWin->show(); 144 mMainWin->show();
144 } 145 }
145 } 146 }
146 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do 147 // Can not see why anyone would pass both a uid and an email address, so I'll leave it that two contact editors will show if they do
147 if ( !addr.isEmpty() ) 148 if ( !addr.isEmpty() )
148 mMainWin->addEmail( addr ); 149 mMainWin->addEmail( addr );
149 150
150 if ( !uid.isEmpty() ) 151 if ( !uid.isEmpty() )
151 mMainWin->showContactEditor( uid ); 152 mMainWin->showContactEditor( uid );
152 if ( args->isSet( "new-contact" ) ) { 153 if ( args->isSet( "new-contact" ) ) {
153 mMainWin->newContact(); 154 mMainWin->newContact();
154 } 155 }
155 } 156 }
156 157
157 KCrash::setEmergencySaveFunction( crashHandler ); 158 KCrash::setEmergencySaveFunction( crashHandler );
158 159
159 return 0; 160 return 0;
160} 161}
161 162
162// the dummy argument is required, because KMail apparently sends an empty 163// the dummy argument is required, because KMail apparently sends an empty
163// argument. 164// argument.
164static KCmdLineOptions kmoptions[] = 165static KCmdLineOptions kmoptions[] =
165{ 166{
166 { "a", 0 , 0 }, 167 { "a", 0 , 0 },
167 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 }, 168 { "addr <email>", I18N_NOOP( "Shows contact editor with given email address" ), 0 },
168 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 }, 169 { "uid <uid>", I18N_NOOP( "Shows contact editor with given uid" ), 0 },
169 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 }, 170 { "editor-only", I18N_NOOP( "Launches in editor only mode" ), 0 },
170 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 }, 171 { "new-contact", I18N_NOOP( "Launches editor for the new contact" ), 0 },
171 { "+[argument]", I18N_NOOP( "dummy argument" ), 0}, 172 { "+[argument]", I18N_NOOP( "dummy argument" ), 0},
172 { 0, 0, 0} 173 { 0, 0, 0}
173}; 174};
174 175
175int main( int argc, char *argv[] ) 176int main( int argc, char *argv[] )
176{ 177{
177 KLocale::setMainCatalogue( "kaddressbook" ); 178 KLocale::setMainCatalogue( "kaddressbook" );
178 179
179 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() ); 180 KCmdLineArgs::init( argc, argv, KABCore::createAboutData() );
180 KCmdLineArgs::addCmdLineOptions( kmoptions ); 181 KCmdLineArgs::addCmdLineOptions( kmoptions );
181 KUniqueApplication::addCmdLineOptions(); 182 KUniqueApplication::addCmdLineOptions();
182 183
183 if ( !KAddressBookApp::start() ) 184 if ( !KAddressBookApp::start() )
184 exit( 0 ); 185 exit( 0 );
185 186
186 KAddressBookApp app; 187 KAddressBookApp app;
187 KGlobal::locale()->insertCatalogue( "libkdepim" ); 188 KGlobal::locale()->insertCatalogue( "libkdepim" );
188 189
189 return app.exec(); 190 return app.exec();
190} 191}
191*/ 192*/
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 35638b1..64caa7d 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,681 +1,959 @@
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 <qtopia/qcopenvelope_qws.h> 37#include <qtopia/qcopenvelope_qws.h>
38#endif 38#endif
39 39
40#include <kstaticdeleter.h> 40#include <kstaticdeleter.h>
41#include <kmessagebox.h> 41#include <kmessagebox.h>
42 42
43 43
44#include "externalapphandler.h" 44#include "externalapphandler.h"
45 45
46#include "kpimglobalprefs.h" 46#include "kpimglobalprefs.h"
47 47
48/*********************************************************************************
49 *
50 ********************************************************************************/
51
52
53QCopTransferItem::QCopTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
54 : _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
55{
56 //sourceMessage passes later three parameters: sourceChannel, uid, param1
57 _sourceMessageParameters = "(QString,QString,QString)";
58}
59
60/*********************************************************************************/
61
62QCopTransferItem::QCopTransferItem()
63{
64}
65
66/*********************************************************************************/
67bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1)
68{
69
70#ifndef DESKTOP_VERSION
71 //sourceMessage passes two parameters: sourceChannel, uid
72 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
73
74 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
75 qDebug("passing sourcechannel(%s), uid(%s), param1(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1());
76
77 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
78
79 e << _sourceChannel << uid << param1;
80
81 return true;
82
83#else
84 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
85 return false;
86#endif
87
88}
89
90
91/*********************************************************************************/
92void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
93{
94
95 if (_sourceChannel.isEmpty())
96 _sourceChannel = sourceChannel;
97}
98
99
100/*********************************************************************************/
101bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
102{
103/*US
104 // copied from old mail2
105 static int ii = 0;
106
107 // block second call
108 if ( ii < 2 ) {
109 ++ii;
110 if ( ii > 1 ) {
111 qDebug("qcop call blocked ");
112 return true;
113 }
114 }
115*/
116 qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
117
118 //we are in the target and get a request from the source
119 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
120 {
121 QDataStream stream( data, IO_ReadOnly );
122
123
124 QString sourceChannel;
125 QString uid;
126 QString param1;
48 127
128 stream >> sourceChannel >> uid >> param1;
49 129
130 emit receivedMessageFromSource(sourceChannel, uid, param1);
50 131
132 return true;
133 }
134
135 return false;
136}
137
138
139/*********************************************************************************
140 *
141 ********************************************************************************/
142
143
144QCopMapTransferItem::QCopMapTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
145 : QCopTransferItem(sourceMessage, targetChannel,targetMessage)
146{
147 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
148 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
149}
150
151/*********************************************************************************/
152bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
153{
154#ifndef DESKTOP_VERSION
155 //targetMessage passes two parameters: uid, map
156 QString targetMessage = _targetMessage + _targetMessageParameters;
157
158 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
159 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
51 160
161 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
162 //US we need no names in the To field. The emailadresses are enough
163
164 e << uid << nameEmailMap;
165
166 return true;
167
168#else
169 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
170 return false;
171#endif
172
173}
174
175
176/*********************************************************************************/
177bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
178{
179 bool res = QCopTransferItem::appMessage( cmsg, data );
180
181 if (res == false)
182 {
183 QDataStream stream( data, IO_ReadOnly );
184
185 qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
186
187 //we are in the source and get an answer from the target
188 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
189 {
190 QMap<QString,QString> adrMap;
191 QString uid;
192
193 stream >> uid >> adrMap;
194
195 emit receivedMessageFromTarget(uid, adrMap);
196
197
198 return true;
199 }
200 }
201
202 return false;
203}
204
205
206/*********************************************************************************
207 *
208 ********************************************************************************/
209
210
211QCopListTransferItem::QCopListTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
212 : QCopTransferItem(sourceMessage, targetChannel,targetMessage)
213{
214 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
215 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)";
216}
217
218/*********************************************************************************/
219bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
220{
221#ifndef DESKTOP_VERSION
222 //targetMessage passes two parameters: uid, map
223 QString targetMessage = _targetMessage + _targetMessageParameters;
224
225 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
226 qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1());
227
228 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
229 //US we need no names in the To field. The emailadresses are enough
230
231 e << uid << list1 << list2 << list3;
232
233 return true;
234
235#else
236 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
237 return false;
238#endif
239
240}
241
242
243/*********************************************************************************/
244bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
245{
246 bool res = QCopTransferItem::appMessage( cmsg, data );
247
248 if (res == false)
249 {
250 QDataStream stream( data, IO_ReadOnly );
251
252 qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
253
254 //we are in the source and get an answer from the target
255 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
256 {
257 QStringList list1;
258 QStringList list2;
259 QStringList list3;
260 QString uid;
261
262 stream >> uid >> list1 >> list2 >> list3;
263
264 emit receivedMessageFromTarget(uid, list1, list2, list3);
265
266
267 return true;
268 }
269 }
270
271 return false;
272}
273
274
275
276/*********************************************************************************
277 *
278 ********************************************************************************/
52 279
53 280
54ExternalAppHandler *ExternalAppHandler::sInstance = 0; 281ExternalAppHandler *ExternalAppHandler::sInstance = 0;
55static KStaticDeleter<ExternalAppHandler> staticDeleter; 282static KStaticDeleter<ExternalAppHandler> staticDeleter;
56 283
57
58ExternalAppHandler::ExternalAppHandler() 284ExternalAppHandler::ExternalAppHandler()
59{ 285{
60 mDefaultItems.setAutoDelete(true); 286 mDefaultItems.setAutoDelete(true);
287
288 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem("requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
289 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&, const QString&)));
290 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
291
292//US mFindByEmailFromKAPITransfer = new QCopListTransferItem("requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
293//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
294//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
295
296
61} 297}
62 298
63ExternalAppHandler::~ExternalAppHandler() 299ExternalAppHandler::~ExternalAppHandler()
64{ 300{
65} 301}
66 302
67void ExternalAppHandler::loadConfig() 303void ExternalAppHandler::loadConfig()
68{ 304{
69 305
70 mDefaultItems.clear(); 306 mDefaultItems.clear();
71 307
72 mEmailAppAvailable = UNDEFINED; 308 mEmailAppAvailable = UNDEFINED;
73 mPhoneAppAvailable = UNDEFINED; 309 mPhoneAppAvailable = UNDEFINED;
74 mFaxAppAvailable = UNDEFINED; 310 mFaxAppAvailable = UNDEFINED;
75 mSMSAppAvailable = UNDEFINED; 311 mSMSAppAvailable = UNDEFINED;
76 mPagerAppAvailable = UNDEFINED; 312 mPagerAppAvailable = UNDEFINED;
77 313
78 314
79 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 315 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
80 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 316 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
81 317
82 if (opiepath.isEmpty()) 318 if (opiepath.isEmpty())
83 opiepath = qtopiapath; 319 opiepath = qtopiapath;
84 320
85 //mailclients 321 //mailclients
86 QString mailmsg1 = "writeMail(QString,QString)"; 322 QString mailmsg1 = "writeMail(QString,QString)";
87 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 323 QString mailmsg2 = "writeMail(QMap(QString,QString))";
88 324
89 QString undefined = ""; 325 QString undefined = "";
90 326
91 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 327 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
92 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 328 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
93 329
94 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 330 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
95 ( QFile::exists( opiepath + "/bin/ompi" ))) 331 ( QFile::exists( opiepath + "/bin/ompi" )))
96 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 332 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
97 333
98 if ( QFile::exists( qtopiapath + "/bin/qtmail" )) 334 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
99 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 335 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
100 336
101 if ( QFile::exists( opiepath + "/bin/opiemail" )) 337 if ( QFile::exists( opiepath + "/bin/opiemail" ))
102 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 338 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
103 339
104 340
105 341
106 //phoneclients 342 //phoneclients
107 343
108 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 344 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
109 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 345 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
110 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 346 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
111 ( QFile::exists( opiepath + "/bin/kppi" ))) 347 ( QFile::exists( opiepath + "/bin/kppi" )))
112 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 348 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
113 349
114 //faxclients 350 //faxclients
115 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 351 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
116 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 352 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
117 353
118 //smsclients 354 //smsclients
119 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 355 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
120 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 356 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
121 357
122 //pagerclients 358 //pagerclients
123 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 359 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
124 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 360 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
125 361
126} 362}
127 363
128ExternalAppHandler *ExternalAppHandler::instance() 364ExternalAppHandler *ExternalAppHandler::instance()
129{ 365{
130 if ( !sInstance ) { 366 if ( !sInstance ) {
131 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 367 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
132 sInstance->loadConfig(); 368 sInstance->loadConfig();
133 } 369 }
134 370
135 return sInstance; 371 return sInstance;
136} 372}
137 373
138void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 374void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
139{ 375{
140 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 376 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
141 377
142 mDefaultItems.append(dai); 378 mDefaultItems.append(dai);
143} 379}
144 380
145 381
146QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 382QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
147{ 383{
148 QList<DefaultAppItem> list; 384 QList<DefaultAppItem> list;
149 385
150 DefaultAppItem* dai; 386 DefaultAppItem* dai;
151 387
152 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 388 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
153 { 389 {
154 if (dai->_type == type) 390 if (dai->_type == type)
155 list.append(dai); 391 list.append(dai);
156 } 392 }
157 393
158 return list; 394 return list;
159} 395}
160 396
161DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 397DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
162{ 398{
163 DefaultAppItem* dai; 399 DefaultAppItem* dai;
164 400
165 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 401 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
166 { 402 {
167 if (dai->_type == type && dai->_id == clientid) 403 if (dai->_type == type && dai->_id == clientid)
168 return dai; 404 return dai;
169 } 405 }
170 406
171 return 0; 407 return 0;
172} 408}
173 409
174bool ExternalAppHandler::isEmailAppAvailable() 410bool ExternalAppHandler::isEmailAppAvailable()
175{ 411{
176#ifndef DESKTOP_VERSION 412#ifndef DESKTOP_VERSION
177 if (mEmailAppAvailable == UNDEFINED) 413 if (mEmailAppAvailable == UNDEFINED)
178 { 414 {
179 int client = KPimGlobalPrefs::instance()->mEmailClient; 415 int client = KPimGlobalPrefs::instance()->mEmailClient;
180 if (client == KPimGlobalPrefs::NONE_EMC) 416 if (client == KPimGlobalPrefs::NONE_EMC)
181 mEmailAppAvailable = UNAVAILABLE; 417 mEmailAppAvailable = UNAVAILABLE;
182 else 418 else
183 mEmailAppAvailable = AVAILABLE; 419 mEmailAppAvailable = AVAILABLE;
184 } 420 }
185 return (mEmailAppAvailable == AVAILABLE); 421 return (mEmailAppAvailable == AVAILABLE);
186 422
187#else //DESKTOP_VERSION 423#else //DESKTOP_VERSION
188 return false; 424 return false;
189#endif //DESKTOP_VERSION 425#endif //DESKTOP_VERSION
190} 426}
191 427
192bool ExternalAppHandler::isSMSAppAvailable() 428bool ExternalAppHandler::isSMSAppAvailable()
193{ 429{
194#ifndef DESKTOP_VERSION 430#ifndef DESKTOP_VERSION
195 if (mSMSAppAvailable == UNDEFINED) 431 if (mSMSAppAvailable == UNDEFINED)
196 { 432 {
197 int client = KPimGlobalPrefs::instance()->mSMSClient; 433 int client = KPimGlobalPrefs::instance()->mSMSClient;
198 if (client == KPimGlobalPrefs::NONE_SMC) 434 if (client == KPimGlobalPrefs::NONE_SMC)
199 mSMSAppAvailable = UNAVAILABLE; 435 mSMSAppAvailable = UNAVAILABLE;
200 else 436 else
201 mSMSAppAvailable = AVAILABLE; 437 mSMSAppAvailable = AVAILABLE;
202 } 438 }
203 439
204 return (mSMSAppAvailable == AVAILABLE); 440 return (mSMSAppAvailable == AVAILABLE);
205#else //DESKTOP_VERSION 441#else //DESKTOP_VERSION
206 return false; 442 return false;
207#endif //DESKTOP_VERSION 443#endif //DESKTOP_VERSION
208} 444}
209 445
210bool ExternalAppHandler::isPhoneAppAvailable() 446bool ExternalAppHandler::isPhoneAppAvailable()
211{ 447{
212#ifndef DESKTOP_VERSION 448#ifndef DESKTOP_VERSION
213 if (mPhoneAppAvailable == UNDEFINED) 449 if (mPhoneAppAvailable == UNDEFINED)
214 { 450 {
215 int client = KPimGlobalPrefs::instance()->mPhoneClient; 451 int client = KPimGlobalPrefs::instance()->mPhoneClient;
216 if (client == KPimGlobalPrefs::NONE_PHC) 452 if (client == KPimGlobalPrefs::NONE_PHC)
217 mPhoneAppAvailable = UNAVAILABLE; 453 mPhoneAppAvailable = UNAVAILABLE;
218 else 454 else
219 mPhoneAppAvailable = AVAILABLE; 455 mPhoneAppAvailable = AVAILABLE;
220 } 456 }
221 457
222 return (mPhoneAppAvailable == AVAILABLE); 458 return (mPhoneAppAvailable == AVAILABLE);
223#else //DESKTOP_VERSION 459#else //DESKTOP_VERSION
224 return false; 460 return false;
225#endif //DESKTOP_VERSION 461#endif //DESKTOP_VERSION
226} 462}
227 463
228bool ExternalAppHandler::isFaxAppAvailable() 464bool ExternalAppHandler::isFaxAppAvailable()
229{ 465{
230#ifndef DESKTOP_VERSION 466#ifndef DESKTOP_VERSION
231 if (mFaxAppAvailable == UNDEFINED) 467 if (mFaxAppAvailable == UNDEFINED)
232 { 468 {
233 int client = KPimGlobalPrefs::instance()->mFaxClient; 469 int client = KPimGlobalPrefs::instance()->mFaxClient;
234 if (client == KPimGlobalPrefs::NONE_FAC) 470 if (client == KPimGlobalPrefs::NONE_FAC)
235 mFaxAppAvailable = UNAVAILABLE; 471 mFaxAppAvailable = UNAVAILABLE;
236 else 472 else
237 mFaxAppAvailable = AVAILABLE; 473 mFaxAppAvailable = AVAILABLE;
238 } 474 }
239 475
240 return (mFaxAppAvailable == AVAILABLE); 476 return (mFaxAppAvailable == AVAILABLE);
241#else //DESKTOP_VERSION 477#else //DESKTOP_VERSION
242 return false; 478 return false;
243#endif //DESKTOP_VERSION 479#endif //DESKTOP_VERSION
244} 480}
245 481
246bool ExternalAppHandler::isPagerAppAvailable() 482bool ExternalAppHandler::isPagerAppAvailable()
247{ 483{
248#ifndef DESKTOP_VERSION 484#ifndef DESKTOP_VERSION
249 if (mPagerAppAvailable == UNDEFINED) 485 if (mPagerAppAvailable == UNDEFINED)
250 { 486 {
251 int client = KPimGlobalPrefs::instance()->mPagerClient; 487 int client = KPimGlobalPrefs::instance()->mPagerClient;
252 if (client == KPimGlobalPrefs::NONE_PAC) 488 if (client == KPimGlobalPrefs::NONE_PAC)
253 mPagerAppAvailable = UNAVAILABLE; 489 mPagerAppAvailable = UNAVAILABLE;
254 else 490 else
255 mPagerAppAvailable = AVAILABLE; 491 mPagerAppAvailable = AVAILABLE;
256 } 492 }
257 493
258 return (mPagerAppAvailable == AVAILABLE); 494 return (mPagerAppAvailable == AVAILABLE);
259#else //DESKTOP_VERSION 495#else //DESKTOP_VERSION
260 return false; 496 return false;
261#endif //DESKTOP_VERSION 497#endif //DESKTOP_VERSION
262} 498}
263 499
264/************************************************************************** 500/**************************************************************************
265 * 501 *
266 **************************************************************************/ 502 **************************************************************************/
267 503
268 504
269//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 505//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
270bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 506bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
271{ 507{
272 508
273#ifndef DESKTOP_VERSION 509#ifndef DESKTOP_VERSION
274 QString channel; 510 QString channel;
275 QString message2; 511 QString message2;
276 QString parameters2; 512 QString parameters2;
277 513
278 514
279 int client = KPimGlobalPrefs::instance()->mEmailClient; 515 int client = KPimGlobalPrefs::instance()->mEmailClient;
280 if (client == KPimGlobalPrefs::OTHER_EMC) 516 if (client == KPimGlobalPrefs::OTHER_EMC)
281 { 517 {
282 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 518 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
283 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 519 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
284 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 520 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
285 } 521 }
286 else 522 else
287 { 523 {
288 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 524 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
289 if (!dai) 525 if (!dai)
290 { 526 {
291 qDebug("could not find configured email application."); 527 qDebug("could not find configured email application.");
292 return false; 528 return false;
293 } 529 }
294 channel = dai->_channel; 530 channel = dai->_channel;
295 message2 = dai->_message2; 531 message2 = dai->_message2;
296 parameters2 = dai->_parameters2; 532 parameters2 = dai->_parameters2;
297 } 533 }
298 534
299 //first check if one of the mailers need the emails right in the message. 535 //first check if one of the mailers need the emails right in the message.
300 message2 = translateMessage(message2, emails, urls); 536 message2 = translateMessage(message2, emails, urls);
301 537
302 538
303 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 539 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
304 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 540 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
305 541
306 542
307 QCopEnvelope e(channel.latin1(), message2.latin1()); 543 QCopEnvelope e(channel.latin1(), message2.latin1());
308 //US we need no names in the To field. The emailadresses are enough 544 //US we need no names in the To field. The emailadresses are enough
309 545
310 passParameters(&e, parameters2, emails, urls); 546 passParameters(&e, parameters2, emails, urls);
311 547
312 548
313 549
314#else 550#else
315 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 551 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
316#endif 552#endif
317 553
318 return true; 554 return true;
319} 555}
320 556
321/************************************************************************** 557/**************************************************************************
322 * 558 *
323 **************************************************************************/ 559 **************************************************************************/
324 560
325 561
326//calls the emailapplication and creates a mail with parameter emails as recipients 562//calls the emailapplication and creates a mail with parameter emails as recipients
327bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 563bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
328{ 564{
329#ifndef DESKTOP_VERSION 565#ifndef DESKTOP_VERSION
330 QString channel; 566 QString channel;
331 QString message; 567 QString message;
332 QString parameters; 568 QString parameters;
333 569
334 570
335 int client = KPimGlobalPrefs::instance()->mEmailClient; 571 int client = KPimGlobalPrefs::instance()->mEmailClient;
336 if (client == KPimGlobalPrefs::OTHER_EMC) 572 if (client == KPimGlobalPrefs::OTHER_EMC)
337 { 573 {
338 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 574 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
339 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 575 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
340 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 576 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
341 } 577 }
342 else 578 else
343 { 579 {
344 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 580 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
345 if (!dai) 581 if (!dai)
346 { 582 {
347 qDebug("could not find configured email application."); 583 qDebug("could not find configured email application.");
348 return false; 584 return false;
349 } 585 }
350 channel = dai->_channel; 586 channel = dai->_channel;
351 message = dai->_message; 587 message = dai->_message;
352 parameters = dai->_parameters; 588 parameters = dai->_parameters;
353 } 589 }
354 590
355 591
356 //first check if one of the mailers need the emails right in the message. 592 //first check if one of the mailers need the emails right in the message.
357 message = translateMessage(message, name, emailadress); 593 message = translateMessage(message, name, emailadress);
358 594
359 595
360 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 596 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
361 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 597 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
362 598
363 QCopEnvelope e(channel.latin1(), message.latin1()); 599 QCopEnvelope e(channel.latin1(), message.latin1());
364 //US we need no names in the To field. The emailadresses are enough 600 //US we need no names in the To field. The emailadresses are enough
365 601
366 passParameters(&e, parameters, name, emailadress); 602 passParameters(&e, parameters, name, emailadress);
367 603
368 604
369#else 605#else
370 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 606 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) );
371#endif 607#endif
372 608
373 609
374 return true; 610 return true;
375} 611}
376 612
377/************************************************************************** 613/**************************************************************************
378 * 614 *
379 **************************************************************************/ 615 **************************************************************************/
380 616
381//calls the emailapplication and creates a mail with parameter as recipients 617//calls the emailapplication and creates a mail with parameter as recipients
382// parameters format is 618// parameters format is
383// NAME <EMAIL>:SUBJECT 619// NAME <EMAIL>:SUBJECT
384bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 620bool ExternalAppHandler::mailToOneContact( const QString& adressline )
385{ 621{
386 QString line = adressline; 622 QString line = adressline;
387 623
388 int first = line.find( "<"); 624 int first = line.find( "<");
389 int last = line.find( ">"); 625 int last = line.find( ">");
390 QString name = line.left(first); 626 QString name = line.left(first);
391 QString emailadress = line.mid(first+1, last-first-1); 627 QString emailadress = line.mid(first+1, last-first-1);
392 628
393 //Subject can not be handled right now. 629 //Subject can not be handled right now.
394 mailToOneContact( name, emailadress ); 630 return mailToOneContact( name, emailadress );
631
395} 632}
396 633
397 634
398/************************************************************************** 635/**************************************************************************
399 * 636 *
400 **************************************************************************/ 637 **************************************************************************/
401 638
402//calls the phoneapplication with the number 639//calls the phoneapplication with the number
403bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 640bool ExternalAppHandler::callByPhone( const QString& phonenumber )
404{ 641{
405#ifndef DESKTOP_VERSION 642#ifndef DESKTOP_VERSION
406 QString channel; 643 QString channel;
407 QString message; 644 QString message;
408 QString parameters; 645 QString parameters;
409 646
410 647
411 int client = KPimGlobalPrefs::instance()->mPhoneClient; 648 int client = KPimGlobalPrefs::instance()->mPhoneClient;
412 if (client == KPimGlobalPrefs::OTHER_PHC) 649 if (client == KPimGlobalPrefs::OTHER_PHC)
413 { 650 {
414 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 651 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
415 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 652 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
416 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 653 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
417 } 654 }
418 else 655 else
419 { 656 {
420 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 657 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
421 if (!dai) 658 if (!dai)
422 { 659 {
423 qDebug("could not find configured phone application."); 660 qDebug("could not find configured phone application.");
424 return false; 661 return false;
425 } 662 }
426 channel = dai->_channel; 663 channel = dai->_channel;
427 message = dai->_message; 664 message = dai->_message;
428 parameters = dai->_parameters; 665 parameters = dai->_parameters;
429 } 666 }
430 667
431 668
432 //first check if one of the mailers need the emails right in the message. 669 //first check if one of the mailers need the emails right in the message.
433 message = translateMessage(message, phonenumber, ""); 670 message = translateMessage(message, phonenumber, "");
434 671
435 672
436 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 673 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
437 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 674 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
438 675
439 QCopEnvelope e(channel.latin1(), message.latin1()); 676 QCopEnvelope e(channel.latin1(), message.latin1());
440 //US we need no names in the To field. The emailadresses are enough 677 //US we need no names in the To field. The emailadresses are enough
441 678
442 passParameters(&e, parameters, phonenumber, ""); 679 passParameters(&e, parameters, phonenumber, "");
443 680
444 681
445#else 682#else
446 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 683 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
447#endif 684#endif
448 685
449 686
450 return true; 687 return true;
451} 688}
452 689
453/************************************************************************** 690/**************************************************************************
454 * 691 *
455 **************************************************************************/ 692 **************************************************************************/
456 693
457//calls the smsapplication with the number 694//calls the smsapplication with the number
458bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 695bool ExternalAppHandler::callBySMS( const QString& phonenumber )
459{ 696{
460#ifndef DESKTOP_VERSION 697#ifndef DESKTOP_VERSION
461 QString channel; 698 QString channel;
462 QString message; 699 QString message;
463 QString parameters; 700 QString parameters;
464 701
465 702
466 int client = KPimGlobalPrefs::instance()->mSMSClient; 703 int client = KPimGlobalPrefs::instance()->mSMSClient;
467 if (client == KPimGlobalPrefs::OTHER_SMC) 704 if (client == KPimGlobalPrefs::OTHER_SMC)
468 { 705 {
469 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 706 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
470 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 707 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
471 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 708 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
472 } 709 }
473 else 710 else
474 { 711 {
475 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 712 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
476 if (!dai) 713 if (!dai)
477 { 714 {
478 qDebug("could not find configured sms application."); 715 qDebug("could not find configured sms application.");
479 return false; 716 return false;
480 } 717 }
481 channel = dai->_channel; 718 channel = dai->_channel;
482 message = dai->_message; 719 message = dai->_message;
483 parameters = dai->_parameters; 720 parameters = dai->_parameters;
484 } 721 }
485 722
486 723
487 //first check if one of the mailers need the emails right in the message. 724 //first check if one of the mailers need the emails right in the message.
488 message = translateMessage(message, phonenumber, ""); 725 message = translateMessage(message, phonenumber, "");
489 726
490 727
491 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 728 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
492 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 729 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
493 730
494 QCopEnvelope e(channel.latin1(), message.latin1()); 731 QCopEnvelope e(channel.latin1(), message.latin1());
495 //US we need no names in the To field. The emailadresses are enough 732 //US we need no names in the To field. The emailadresses are enough
496 733
497 passParameters(&e, parameters, phonenumber, ""); 734 passParameters(&e, parameters, phonenumber, "");
498 735
499 736
500#else 737#else
501 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 738 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
502#endif 739#endif
503 740
504 741
505 return true; 742 return true;
506} 743}
507 744
508/************************************************************************** 745/**************************************************************************
509 * 746 *
510 **************************************************************************/ 747 **************************************************************************/
511 748
512//calls the pagerapplication with the number 749//calls the pagerapplication with the number
513bool ExternalAppHandler::callByPager( const QString& pagernumber ) 750bool ExternalAppHandler::callByPager( const QString& pagernumber )
514{ 751{
515#ifndef DESKTOP_VERSION 752#ifndef DESKTOP_VERSION
516 QString channel; 753 QString channel;
517 QString message; 754 QString message;
518 QString parameters; 755 QString parameters;
519 756
520 757
521 int client = KPimGlobalPrefs::instance()->mPagerClient; 758 int client = KPimGlobalPrefs::instance()->mPagerClient;
522 if (client == KPimGlobalPrefs::OTHER_PAC) 759 if (client == KPimGlobalPrefs::OTHER_PAC)
523 { 760 {
524 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 761 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
525 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 762 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
526 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 763 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
527 } 764 }
528 else 765 else
529 { 766 {
530 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 767 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
531 if (!dai) 768 if (!dai)
532 { 769 {
533 qDebug("could not find configured pager application."); 770 qDebug("could not find configured pager application.");
534 return false; 771 return false;
535 } 772 }
536 channel = dai->_channel; 773 channel = dai->_channel;
537 message = dai->_message; 774 message = dai->_message;
538 parameters = dai->_parameters; 775 parameters = dai->_parameters;
539 } 776 }
540 777
541 778
542 //first check if one of the mailers need the emails right in the message. 779 //first check if one of the mailers need the emails right in the message.
543 message = translateMessage(message, pagernumber, ""); 780 message = translateMessage(message, pagernumber, "");
544 781
545 782
546 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 783 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
547 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 784 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
548 785
549 QCopEnvelope e(channel.latin1(), message.latin1()); 786 QCopEnvelope e(channel.latin1(), message.latin1());
550 //US we need no names in the To field. The emailadresses are enough 787 //US we need no names in the To field. The emailadresses are enough
551 788
552 passParameters(&e, parameters, pagernumber, ""); 789 passParameters(&e, parameters, pagernumber, "");
553 790
554 791
555#else 792#else
556 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 793 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
557#endif 794#endif
558 795
559 796
560 return true; 797 return true;
561} 798}
562 799
563/************************************************************************** 800/**************************************************************************
564 * 801 *
565 **************************************************************************/ 802 **************************************************************************/
566 803
567//calls the faxapplication with the number 804//calls the faxapplication with the number
568bool ExternalAppHandler::callByFax( const QString& faxnumber ) 805bool ExternalAppHandler::callByFax( const QString& faxnumber )
569{ 806{
570#ifndef DESKTOP_VERSION 807#ifndef DESKTOP_VERSION
571 QString channel; 808 QString channel;
572 QString message; 809 QString message;
573 QString parameters; 810 QString parameters;
574 811
575 812
576 int client = KPimGlobalPrefs::instance()->mFaxClient; 813 int client = KPimGlobalPrefs::instance()->mFaxClient;
577 if (client == KPimGlobalPrefs::OTHER_FAC) 814 if (client == KPimGlobalPrefs::OTHER_FAC)
578 { 815 {
579 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 816 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
580 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 817 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
581 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 818 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
582 } 819 }
583 else 820 else
584 { 821 {
585 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 822 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
586 if (!dai) 823 if (!dai)
587 { 824 {
588 qDebug("could not find configured fax application."); 825 qDebug("could not find configured fax application.");
589 return false; 826 return false;
590 } 827 }
591 channel = dai->_channel; 828 channel = dai->_channel;
592 message = dai->_message; 829 message = dai->_message;
593 parameters = dai->_parameters; 830 parameters = dai->_parameters;
594 } 831 }
595 832
596 833
597 //first check if one of the mailers need the emails right in the message. 834 //first check if one of the mailers need the emails right in the message.
598 message = translateMessage(message, faxnumber, ""); 835 message = translateMessage(message, faxnumber, "");
599 836
600 837
601 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 838 qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
602 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 839 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
603 840
604 QCopEnvelope e(channel.latin1(), message.latin1()); 841 QCopEnvelope e(channel.latin1(), message.latin1());
605 //US we need no names in the To field. The emailadresses are enough 842 //US we need no names in the To field. The emailadresses are enough
606 843
607 passParameters(&e, parameters, faxnumber, ""); 844 passParameters(&e, parameters, faxnumber, "");
608 845
609 846
610#else 847#else
611 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 848 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
612#endif 849#endif
613 850
614 851
615 return true; 852 return true;
616} 853}
617 854
618/************************************************************************** 855/**************************************************************************
619 * 856 *
620 **************************************************************************/ 857 **************************************************************************/
621 858
622 859
623QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 860QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
624{ 861{
625 message = message.replace( QRegExp("%1"), param1 ); 862 message = message.replace( QRegExp("%1"), param1 );
626 return message.replace( QRegExp("%2"), param2 ); 863 return message.replace( QRegExp("%2"), param2 );
627} 864}
628 865
629/************************************************************************** 866/**************************************************************************
630 * 867 *
631 **************************************************************************/ 868 **************************************************************************/
632 869
633void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 870void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
634{ 871{
635#ifndef DESKTOP_VERSION 872#ifndef DESKTOP_VERSION
636 QMap<QString, QString> valmap; 873 QMap<QString, QString> valmap;
637 bool useValMap = false; 874 bool useValMap = false;
638 875
639 // first extract all parts of the parameters. 876 // first extract all parts of the parameters.
640 QStringList paramlist = QStringList::split(";", parameters); 877 QStringList paramlist = QStringList::split(";", parameters);
641 878
642 //Now check how many parts we have. 879 //Now check how many parts we have.
643 //=0 :no params to pass 880 //=0 :no params to pass
644 //>0 :parameters to pass 881 //>0 :parameters to pass
645 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 882 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
646 { 883 {
647 QString param = (*it); 884 QString param = (*it);
648 QStringList keyvallist = QStringList::split("=", param); 885 QStringList keyvallist = QStringList::split("=", param);
649 886
650 //if we have keyvalue pairs, we assume that we pass a map to the envelope 887 //if we have keyvalue pairs, we assume that we pass a map to the envelope
651 QStringList::Iterator it2 = keyvallist.begin(); 888 QStringList::Iterator it2 = keyvallist.begin();
652 QString key = (*it2); 889 QString key = (*it2);
653 key = key.replace( QRegExp("%1"), param1 ); 890 key = key.replace( QRegExp("%1"), param1 );
654 key = key.replace( QRegExp("%2"), param2 ); 891 key = key.replace( QRegExp("%2"), param2 );
655 ++it2; 892 ++it2;
656 893
657 if(it2 != keyvallist.end()) 894 if(it2 != keyvallist.end())
658 { 895 {
659 QString value = (*it2); 896 QString value = (*it2);
660 value = value.replace( QRegExp("%1"), param1 ); 897 value = value.replace( QRegExp("%1"), param1 );
661 value = value.replace( QRegExp("%2"), param2 ); 898 value = value.replace( QRegExp("%2"), param2 );
662 899
663 valmap.insert(key, value); 900 valmap.insert(key, value);
664 useValMap = true; 901 useValMap = true;
665 } 902 }
666 else 903 else
667 { 904 {
668 // qDebug("pass parameter << %s", key.latin1()); 905 // qDebug("pass parameter << %s", key.latin1());
669 (*e) << key; 906 (*e) << key;
670 } 907 }
671 } 908 }
672 909
673 if (useValMap == true) 910 if (useValMap == true)
674 (*e) << valmap; 911 (*e) << valmap;
675 912
676#endif 913#endif
677 914
678} 915}
679 916
680 917
681 918
919/**************************************************************************
920 *
921 **************************************************************************/
922
923void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
924{
925 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
926
927// if (!res)
928// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
929}
930
931
932
933bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid)
934{
935 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
936 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(uid, QString::null);
937}
938
939bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
940{
941 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
942 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(uid, list1, list2, list3);
943}
944
945bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QString& email)
946{
947 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
948 return mFindByEmailFromKAPITransfer->sendMessageToTarget(uid, email);
949}
950
951bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
952{
953 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
954 return mFindByEmailFromKAPITransfer->sendMessageToSource(uid, list1, list2, list3);
955}
956
957
958
959
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h
index 3cf9e06..7c8de4e 100644
--- a/libkdepim/externalapphandler.h
+++ b/libkdepim/externalapphandler.h
@@ -1,145 +1,252 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
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#ifndef EXTERNALAPPHANDLER_H 31#ifndef EXTERNALAPPHANDLER_H
32#define EXTERNALAPPHANDLER_H 32#define EXTERNALAPPHANDLER_H
33 33
34#include <qobject.h>
34#include <qlist.h> 35#include <qlist.h>
36#include <qmap.h>
35 37
36class QCopEnvelope; 38class QCopEnvelope;
37 39
38 40
39class ExternalAppHandler; 41class ExternalAppHandler;
42class QCopTransferItem : public QObject
43{
44 Q_OBJECT
45 public:
46 QCopTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
47 QCopTransferItem();
48
49 bool sendMessageToTarget(const QString& uid, const QString& param1);
50
51 void setSourceChannel(const QString& sourceChannel);
52
53 virtual bool appMessage( const QCString& msg, const QByteArray& data );
54
55
56 signals:
57 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1);
58
59
60 public:
61 QString _sourceChannel;
62 QString _sourceMessage;
63 QString _sourceMessageParameters;
64 QString _targetChannel;
65 QString _targetMessage;
66 QString _targetMessageParameters;
67
68};
69
70/*********************************************************************************
71 *
72 ********************************************************************************/
73
74class QCopMapTransferItem : public QCopTransferItem
75{
76 Q_OBJECT
77 public:
78 QCopMapTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
79
80 bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap);
81
82
83 virtual bool appMessage( const QCString& msg, const QByteArray& data );
84
85
86 signals:
87 void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap);
88
89};
90
91/*********************************************************************************
92 *
93 ********************************************************************************/
94
95class QCopListTransferItem : public QCopTransferItem
96{
97 Q_OBJECT
98 public:
99 QCopListTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
100
101 bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3);
102
103
104 virtual bool appMessage( const QCString& msg, const QByteArray& data );
105
106
107 signals:
108 void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3);
109
110};
111
112/*********************************************************************************
113 *
114 ********************************************************************************/
115
40 116
41class DefaultAppItem 117class DefaultAppItem
42{ 118{
43 public: 119 public:
44 DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) 120 DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2)
45 : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) 121 : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2)
46 {} 122 {}
47 123
48 DefaultAppItem() 124 DefaultAppItem()
49 { } 125 { }
50 126
51 public: 127 public:
52 int _type; 128 int _type;
53 int _id; 129 int _id;
54 QString _label; 130 QString _label;
55 QString _channel; 131 QString _channel;
56 QString _message; 132 QString _message;
57 QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; 133 QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ;
58 QString _message2; 134 QString _message2;
59 QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; 135 QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ;
60 136
61}; 137};
62 138
63class ExternalAppHandler 139/*********************************************************************************
140 *
141 ********************************************************************************/
142
143class ExternalAppHandler : public QObject
64{ 144{
145 Q_OBJECT
65 public: 146 public:
66 virtual ~ExternalAppHandler(); 147 virtual ~ExternalAppHandler();
67 148
68 static ExternalAppHandler *instance(); 149 static ExternalAppHandler *instance();
69 150
70 enum Types { 151 enum Types {
71 EMAIL = 0, 152 EMAIL = 0,
72 PHONE = 1, 153 PHONE = 1,
73 SMS = 2, 154 SMS = 2,
74 FAX = 3, 155 FAX = 3,
75 PAGER = 4 156 PAGER = 4
76 }; 157 };
77 158
78 enum Availability { 159 enum Availability {
79 UNDEFINED = -1, 160 UNDEFINED = -1,
80 UNAVAILABLE = 0, 161 UNAVAILABLE = 0,
81 AVAILABLE = 1 162 AVAILABLE = 1
82 }; 163 };
83 164
84 //calls the emailapplication with a number of attachments that need to be send. 165 //calls the emailapplication with a number of attachments that need to be send.
85 //either parameter can be left empty. 166 //either parameter can be left empty.
86 bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); 167 bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls );
87 168
88 //calls the emailapplication and creates a mail with parameter emailadress as recipients 169 //calls the emailapplication and creates a mail with parameter emailadress as recipients
89 bool mailToOneContact( const QString& name, const QString& emailadress ); 170 bool mailToOneContact( const QString& name, const QString& emailadress );
90 171
91 //calls the emailapplication and creates a mail with parameter as recipients 172 //calls the emailapplication and creates a mail with parameter as recipients
92 // parameters format is 173 // parameters format is
93 // NAME <EMAIL>:SUBJECT 174 // NAME <EMAIL>:SUBJECT
94 bool mailToOneContact( const QString& adressline ); 175 bool mailToOneContact( const QString& adressline );
95 176
96 //calls the phoneapplication with the number 177 //calls the phoneapplication with the number
97 bool callByPhone( const QString& phonenumber ); 178 bool callByPhone( const QString& phonenumber );
98 179
99 //calls the smsapplication with the number 180 //calls the smsapplication with the number
100 bool callBySMS( const QString& phonenumber ); 181 bool callBySMS( const QString& phonenumber );
101 182
102 //calls the pagerapplication with the number 183 //calls the pagerapplication with the number
103 bool callByPager( const QString& pagernumber ); 184 bool callByPager( const QString& pagernumber );
104 185
105 //calls the faxapplication with the number 186 //calls the faxapplication with the number
106 bool callByFax( const QString& faxnumber ); 187 bool callByFax( const QString& faxnumber );
107 188
108 bool isEmailAppAvailable(); 189 bool isEmailAppAvailable();
109 bool isSMSAppAvailable(); 190 bool isSMSAppAvailable();
110 bool isPhoneAppAvailable(); 191 bool isPhoneAppAvailable();
111 bool isFaxAppAvailable(); 192 bool isFaxAppAvailable();
112 bool isPagerAppAvailable(); 193 bool isPagerAppAvailable();
113 194
114 195
196 //Call this method on the source when you want to select names from the addressbook by using QCop
197 bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid);
198 //Call this method on the target when you want to return the name/email map to the source (client).
199 bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& name, const QStringList& email, const QStringList& uid);
200
201 bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QString& email);
202 bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& name, const QStringList& email, const QStringList& uid);
203
115 204
116 //loadConfig clears the cache and checks again if the applications are available or not 205 //loadConfig clears the cache and checks again if the applications are available or not
117 void loadConfig(); 206 void loadConfig();
118 207
119 QList<DefaultAppItem> getAvailableDefaultItems(Types); 208 QList<DefaultAppItem> getAvailableDefaultItems(Types);
120 DefaultAppItem* getDefaultItem(Types, int); 209 DefaultAppItem* getDefaultItem(Types, int);
121 210
211 public slots:
212 void appMessage( const QCString& msg, const QByteArray& data );
213
214
215 signals:
216 // Emmitted when the target app receives a request from the source app
217 void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid, const QString& param1);
218
219 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi
220 // The first parameter is a uniqueid. It can be used to identify the event
221 void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
222
223 void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email);
224 void receivedFindBbyEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
225
122 226
123 private: 227 private:
124 ExternalAppHandler(); 228 ExternalAppHandler();
125 QList<DefaultAppItem> mDefaultItems; 229 QList<DefaultAppItem> mDefaultItems;
126 230
127 Availability mEmailAppAvailable; 231 Availability mEmailAppAvailable;
128 Availability mPhoneAppAvailable; 232 Availability mPhoneAppAvailable;
129 Availability mFaxAppAvailable; 233 Availability mFaxAppAvailable;
130 Availability mSMSAppAvailable; 234 Availability mSMSAppAvailable;
131 Availability mPagerAppAvailable; 235 Availability mPagerAppAvailable;
132 236
237 QCopListTransferItem* mNameEmailUidListFromKAPITransfer;
238 QCopListTransferItem* mFindByEmailFromKAPITransfer;
239
133 240
134 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); 241 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2);
135 242
136 QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; 243 QString& translateMessage(QString& message, const QString& param1, const QString& param2) const;
137 void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; 244 void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const;
138 245
139 246
140 static ExternalAppHandler *sInstance; 247 static ExternalAppHandler *sInstance;
141 248
142
143}; 249};
144 250
251
145#endif 252#endif