summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-08 20:03:23 (UTC)
committer zautrix <zautrix>2004-10-08 20:03:23 (UTC)
commit10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34 (patch) (unidiff)
tree3105b985a9dbedd31dff52e14fe667eeff4f9ff4
parent13bd085e06b76228321f5a004759fcdf19cca711 (diff)
downloadkdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.zip
kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.gz
kdepimpi-10a0e05cc4962d9412a7a5faf3d69a3caf6d1c34.tar.bz2
added contact phone support
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp32
-rw-r--r--kabc/addressee.h4
-rw-r--r--kabc/phonenumber.cpp23
-rw-r--r--kabc/phonenumber.h2
-rw-r--r--kaddressbook/kabcore.cpp23
5 files changed, 80 insertions, 4 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 25c77f6..e571980 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -1,829 +1,861 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30 30
31#include <ksharedptr.h> 31#include <ksharedptr.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kapplication.h> 33#include <kapplication.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kidmanager.h> 35#include <kidmanager.h>
36//US 36//US
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h> 38#include <libkcal/syncdefines.h>
39 39
40//US #include "resource.h" 40//US #include "resource.h"
41#include "addressee.h" 41#include "addressee.h"
42 42
43using namespace KABC; 43using namespace KABC;
44 44
45static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
46static bool matchBinaryPatternA( int value, int pattern ); 46static bool matchBinaryPatternA( int value, int pattern );
47static bool matchBinaryPatternP( int value, int pattern ); 47static bool matchBinaryPatternP( int value, int pattern );
48 48
49struct Addressee::AddresseeData : public KShared 49struct Addressee::AddresseeData : public KShared
50{ 50{
51 QString uid; 51 QString uid;
52 QString name; 52 QString name;
53 QString formattedName; 53 QString formattedName;
54 QString familyName; 54 QString familyName;
55 QString givenName; 55 QString givenName;
56 QString additionalName; 56 QString additionalName;
57 QString prefix; 57 QString prefix;
58 QString suffix; 58 QString suffix;
59 QString nickName; 59 QString nickName;
60 QDateTime birthday; 60 QDateTime birthday;
61 QString mailer; 61 QString mailer;
62 TimeZone timeZone; 62 TimeZone timeZone;
63 Geo geo; 63 Geo geo;
64 QString title; 64 QString title;
65 QString role; 65 QString role;
66 QString organization; 66 QString organization;
67 QString note; 67 QString note;
68 QString productId; 68 QString productId;
69 QDateTime revision; 69 QDateTime revision;
70 QString sortString; 70 QString sortString;
71 QString externalUID; 71 QString externalUID;
72 QString originalExternalUID; 72 QString originalExternalUID;
73 KURL url; 73 KURL url;
74 Secrecy secrecy; 74 Secrecy secrecy;
75 Picture logo; 75 Picture logo;
76 Picture photo; 76 Picture photo;
77 Sound sound; 77 Sound sound;
78 Agent agent; 78 Agent agent;
79 QString mExternalId; 79 QString mExternalId;
80 PhoneNumber::List phoneNumbers; 80 PhoneNumber::List phoneNumbers;
81 Address::List addresses; 81 Address::List addresses;
82 Key::List keys; 82 Key::List keys;
83 QStringList emails; 83 QStringList emails;
84 QStringList categories; 84 QStringList categories;
85 QStringList custom; 85 QStringList custom;
86 int mTempSyncStat; 86 int mTempSyncStat;
87 Resource *resource; 87 Resource *resource;
88 88
89 bool empty :1; 89 bool empty :1;
90 bool changed :1; 90 bool changed :1;
91}; 91};
92 92
93Addressee::Addressee() 93Addressee::Addressee()
94{ 94{
95 mData = new AddresseeData; 95 mData = new AddresseeData;
96 mData->empty = true; 96 mData->empty = true;
97 mData->changed = false; 97 mData->changed = false;
98 mData->resource = 0; 98 mData->resource = 0;
99 mData->mExternalId = ":"; 99 mData->mExternalId = ":";
100 mData->revision = QDateTime ( QDate( 2003,1,1)); 100 mData->revision = QDateTime ( QDate( 2003,1,1));
101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; 101 mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 102}
103 103
104Addressee::~Addressee() 104Addressee::~Addressee()
105{ 105{
106} 106}
107 107
108Addressee::Addressee( const Addressee &a ) 108Addressee::Addressee( const Addressee &a )
109{ 109{
110 mData = a.mData; 110 mData = a.mData;
111} 111}
112 112
113Addressee &Addressee::operator=( const Addressee &a ) 113Addressee &Addressee::operator=( const Addressee &a )
114{ 114{
115 mData = a.mData; 115 mData = a.mData;
116 return (*this); 116 return (*this);
117} 117}
118 118
119Addressee Addressee::copy() 119Addressee Addressee::copy()
120{ 120{
121 Addressee a; 121 Addressee a;
122 *(a.mData) = *mData; 122 *(a.mData) = *mData;
123 return a; 123 return a;
124} 124}
125 125
126void Addressee::detach() 126void Addressee::detach()
127{ 127{
128 if ( mData.count() == 1 ) return; 128 if ( mData.count() == 1 ) return;
129 *this = copy(); 129 *this = copy();
130} 130}
131 131
132bool Addressee::operator==( const Addressee &a ) const 132bool Addressee::operator==( const Addressee &a ) const
133{ 133{
134 if ( uid() != a.uid() ) return false; 134 if ( uid() != a.uid() ) return false;
135 if ( mData->name != a.mData->name ) return false; 135 if ( mData->name != a.mData->name ) return false;
136 if ( mData->formattedName != a.mData->formattedName ) return false; 136 if ( mData->formattedName != a.mData->formattedName ) return false;
137 if ( mData->familyName != a.mData->familyName ) return false; 137 if ( mData->familyName != a.mData->familyName ) return false;
138 if ( mData->givenName != a.mData->givenName ) return false; 138 if ( mData->givenName != a.mData->givenName ) return false;
139 if ( mData->additionalName != a.mData->additionalName ) return false; 139 if ( mData->additionalName != a.mData->additionalName ) return false;
140 if ( mData->prefix != a.mData->prefix ) return false; 140 if ( mData->prefix != a.mData->prefix ) return false;
141 if ( mData->suffix != a.mData->suffix ) return false; 141 if ( mData->suffix != a.mData->suffix ) return false;
142 if ( mData->nickName != a.mData->nickName ) return false; 142 if ( mData->nickName != a.mData->nickName ) return false;
143 if ( mData->birthday != a.mData->birthday ) return false; 143 if ( mData->birthday != a.mData->birthday ) return false;
144 if ( mData->mailer != a.mData->mailer ) return false; 144 if ( mData->mailer != a.mData->mailer ) return false;
145 if ( mData->timeZone != a.mData->timeZone ) return false; 145 if ( mData->timeZone != a.mData->timeZone ) return false;
146 if ( mData->geo != a.mData->geo ) return false; 146 if ( mData->geo != a.mData->geo ) return false;
147 if ( mData->title != a.mData->title ) return false; 147 if ( mData->title != a.mData->title ) return false;
148 if ( mData->role != a.mData->role ) return false; 148 if ( mData->role != a.mData->role ) return false;
149 if ( mData->organization != a.mData->organization ) return false; 149 if ( mData->organization != a.mData->organization ) return false;
150 if ( mData->note != a.mData->note ) return false; 150 if ( mData->note != a.mData->note ) return false;
151 if ( mData->productId != a.mData->productId ) return false; 151 if ( mData->productId != a.mData->productId ) return false;
152 //if ( mData->revision != a.mData->revision ) return false; 152 //if ( mData->revision != a.mData->revision ) return false;
153 if ( mData->sortString != a.mData->sortString ) return false; 153 if ( mData->sortString != a.mData->sortString ) return false;
154 if ( mData->secrecy != a.mData->secrecy ) return false; 154 if ( mData->secrecy != a.mData->secrecy ) return false;
155 if ( mData->logo != a.mData->logo ) return false; 155 if ( mData->logo != a.mData->logo ) return false;
156 if ( mData->photo != a.mData->photo ) return false; 156 if ( mData->photo != a.mData->photo ) return false;
157 if ( mData->sound != a.mData->sound ) return false; 157 if ( mData->sound != a.mData->sound ) return false;
158 if ( mData->agent != a.mData->agent ) return false; 158 if ( mData->agent != a.mData->agent ) return false;
159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) && 159 if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
160 ( mData->url != a.mData->url ) ) return false; 160 ( mData->url != a.mData->url ) ) return false;
161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; 161 if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
162 if ( mData->addresses != a.mData->addresses ) return false; 162 if ( mData->addresses != a.mData->addresses ) return false;
163 if ( mData->keys != a.mData->keys ) return false; 163 if ( mData->keys != a.mData->keys ) return false;
164 if ( mData->emails != a.mData->emails ) return false; 164 if ( mData->emails != a.mData->emails ) return false;
165 if ( mData->categories != a.mData->categories ) return false; 165 if ( mData->categories != a.mData->categories ) return false;
166 if ( mData->custom != a.mData->custom ) return false; 166 if ( mData->custom != a.mData->custom ) return false;
167 167
168 return true; 168 return true;
169} 169}
170 170
171bool Addressee::operator!=( const Addressee &a ) const 171bool Addressee::operator!=( const Addressee &a ) const
172{ 172{
173 return !( a == *this ); 173 return !( a == *this );
174} 174}
175 175
176bool Addressee::isEmpty() const 176bool Addressee::isEmpty() const
177{ 177{
178 return mData->empty; 178 return mData->empty;
179} 179}
180ulong Addressee::getCsum4List( const QStringList & attList) 180ulong Addressee::getCsum4List( const QStringList & attList)
181{ 181{
182 int max = attList.count(); 182 int max = attList.count();
183 ulong cSum = 0; 183 ulong cSum = 0;
184 int j,k,i; 184 int j,k,i;
185 int add; 185 int add;
186 for ( i = 0; i < max ; ++i ) { 186 for ( i = 0; i < max ; ++i ) {
187 QString s = attList[i]; 187 QString s = attList[i];
188 if ( ! s.isEmpty() ){ 188 if ( ! s.isEmpty() ){
189 j = s.length(); 189 j = s.length();
190 for ( k = 0; k < j; ++k ) { 190 for ( k = 0; k < j; ++k ) {
191 int mul = k +1; 191 int mul = k +1;
192 add = s[k].unicode (); 192 add = s[k].unicode ();
193 if ( k < 16 ) 193 if ( k < 16 )
194 mul = mul * mul; 194 mul = mul * mul;
195 int ii = i+1; 195 int ii = i+1;
196 add = add * mul *ii*ii*ii; 196 add = add * mul *ii*ii*ii;
197 cSum += add; 197 cSum += add;
198 } 198 }
199 } 199 }
200 200
201 } 201 }
202 //QString dump = attList.join(","); 202 //QString dump = attList.join(",");
203 //qDebug("csum: %d %s", cSum,dump.latin1()); 203 //qDebug("csum: %d %s", cSum,dump.latin1());
204 204
205 return cSum; 205 return cSum;
206 206
207} 207}
208void Addressee::computeCsum(const QString &dev) 208void Addressee::computeCsum(const QString &dev)
209{ 209{
210 QStringList l; 210 QStringList l;
211 if ( !mData->name.isEmpty() ) l.append(mData->name); 211 if ( !mData->name.isEmpty() ) l.append(mData->name);
212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 212 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 213 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 214 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
215 if ( !mData->additionalName ) l.append( mData->additionalName ); 215 if ( !mData->additionalName ) l.append( mData->additionalName );
216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 216 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 217 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 218 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 219 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 220 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 221 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 222 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
223 if ( !mData->title .isEmpty() ) l.append( mData->title ); 223 if ( !mData->title .isEmpty() ) l.append( mData->title );
224 if ( !mData->role.isEmpty() ) l.append( mData->role ); 224 if ( !mData->role.isEmpty() ) l.append( mData->role );
225 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 225 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
226 if ( !mData->note.isEmpty() ) l.append( mData->note ); 226 if ( !mData->note.isEmpty() ) l.append( mData->note );
227 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 227 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 228 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 229 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
230 // if ( !mData->logo.isEmpty() ) l.append( ); 230 // if ( !mData->logo.isEmpty() ) l.append( );
231 //if ( !mData->photo.isEmpty() ) l.append( ); 231 //if ( !mData->photo.isEmpty() ) l.append( );
232 //if ( !mData->sound.isEmpty() ) l.append( ); 232 //if ( !mData->sound.isEmpty() ) l.append( );
233 //if ( !mData->agent.isEmpty() ) l.append( ); 233 //if ( !mData->agent.isEmpty() ) l.append( );
234 //if ( mData->url.isValid() ) l.append( ); 234 //if ( mData->url.isValid() ) l.append( );
235#if 0 235#if 0
236 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 236 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
237 if ( !mData->addresses.isEmpty() ) l.append( ); 237 if ( !mData->addresses.isEmpty() ) l.append( );
238 //if ( !mData->keys.isEmpty() ) l.append( ); 238 //if ( !mData->keys.isEmpty() ) l.append( );
239 if ( !mData->emails.isEmpty() ) l.append( ); 239 if ( !mData->emails.isEmpty() ) l.append( );
240 if ( !mData->categories .isEmpty() ) l.append( ); 240 if ( !mData->categories .isEmpty() ) l.append( );
241 if ( !mData->custom.isEmpty() ) l.append( ); 241 if ( !mData->custom.isEmpty() ) l.append( );
242#endif 242#endif
243 KABC::PhoneNumber::List phoneNumbers; 243 KABC::PhoneNumber::List phoneNumbers;
244 KABC::PhoneNumber::List::Iterator phoneIter; 244 KABC::PhoneNumber::List::Iterator phoneIter;
245 245
246 QStringList t; 246 QStringList t;
247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 247 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
248 ++phoneIter ) 248 ++phoneIter )
249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 249 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
250 t.sort(); 250 t.sort();
251 uint iii; 251 uint iii;
252 for ( iii = 0; iii < t.count(); ++iii) 252 for ( iii = 0; iii < t.count(); ++iii)
253 l.append( t[iii] ); 253 l.append( t[iii] );
254 t = mData->emails; 254 t = mData->emails;
255 t.sort(); 255 t.sort();
256 for ( iii = 0; iii < t.count(); ++iii) 256 for ( iii = 0; iii < t.count(); ++iii)
257 l.append( t[iii] ); 257 l.append( t[iii] );
258 t = mData->categories; 258 t = mData->categories;
259 t.sort(); 259 t.sort();
260 for ( iii = 0; iii < t.count(); ++iii) 260 for ( iii = 0; iii < t.count(); ++iii)
261 l.append( t[iii] ); 261 l.append( t[iii] );
262 t = mData->custom; 262 t = mData->custom;
263 t.sort(); 263 t.sort();
264 for ( iii = 0; iii < t.count(); ++iii) 264 for ( iii = 0; iii < t.count(); ++iii)
265 l.append( t[iii] ); 265 l.append( t[iii] );
266 KABC::Address::List::Iterator addressIter; 266 KABC::Address::List::Iterator addressIter;
267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 267 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
268 ++addressIter ) { 268 ++addressIter ) {
269 t = (*addressIter).asList(); 269 t = (*addressIter).asList();
270 t.sort(); 270 t.sort();
271 for ( iii = 0; iii < t.count(); ++iii) 271 for ( iii = 0; iii < t.count(); ++iii)
272 l.append( t[iii] ); 272 l.append( t[iii] );
273 } 273 }
274 uint cs = getCsum4List(l); 274 uint cs = getCsum4List(l);
275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 275 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
276 setCsum( dev, QString::number (cs )); 276 setCsum( dev, QString::number (cs ));
277} 277}
278 278
279void Addressee::mergeContact( const Addressee& ad ) 279void Addressee::mergeContact( const Addressee& ad )
280{ 280{
281 281
282 detach(); 282 detach();
283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 283 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 284 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 285 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 286 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 287 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 288 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 289 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 290 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
291 if ( !mData->birthday.isValid() ) 291 if ( !mData->birthday.isValid() )
292 if ( ad.mData->birthday.isValid()) 292 if ( ad.mData->birthday.isValid())
293 mData->birthday = ad.mData->birthday; 293 mData->birthday = ad.mData->birthday;
294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 294 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 295 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 296 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 297 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 298 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 299 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 300 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 301 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 302 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 303 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 304 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
305 305
306 // pending: 306 // pending:
307 // merging phonenumbers 307 // merging phonenumbers
308 // merging addresses 308 // merging addresses
309 // merging emails; 309 // merging emails;
310 // merging categories; 310 // merging categories;
311 // merging custom; 311 // merging custom;
312 // merging keys 312 // merging keys
313 qDebug("merge contact %s ", ad.uid().latin1()); 313 qDebug("merge contact %s ", ad.uid().latin1());
314 setUid( ad.uid() ); 314 setUid( ad.uid() );
315 setRevision( ad.revision() ); 315 setRevision( ad.revision() );
316} 316}
317 317
318// removes all emails but the first
319// needed by phone sync
320void Addressee::simplifyEmails()
321{
322 if ( mData->emails.count() == 0 ) return ;
323 QString email = mData->emails.first();
324 detach();
325 mData->emails.clear();
326 mData->emails.append( email );
327}
328
329void Addressee::simplifyPhoneNumbers()
330{
331 KABC::PhoneNumber::List removeNumbers;
332 KABC::PhoneNumber::List::Iterator phoneIter;
333 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
334 ++phoneIter ) {
335 if ( ! ( *phoneIter ).simplifyNumber() )
336 removeNumbers.append( ( *phoneIter ) );
337 }
338 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
339 ++phoneIter ) {
340 removePhoneNumber(( *phoneIter ));
341 }
342}
343void Addressee::simplifyPhoneNumberTypes()
344{
345 KABC::PhoneNumber::List::Iterator phoneIter;
346 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
347 ++phoneIter )
348 ( *phoneIter ).simplifyType();
349}
318void Addressee::removeID(const QString &prof) 350void Addressee::removeID(const QString &prof)
319{ 351{
320 detach(); 352 detach();
321 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 353 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
322 354
323} 355}
324void Addressee::setID( const QString & prof , const QString & id ) 356void Addressee::setID( const QString & prof , const QString & id )
325{ 357{
326 detach(); 358 detach();
327 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 359 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
328 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 360 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
329} 361}
330void Addressee::setTempSyncStat( int id ) 362void Addressee::setTempSyncStat( int id )
331{ 363{
332 if ( mData->mTempSyncStat == id ) return; 364 if ( mData->mTempSyncStat == id ) return;
333 detach(); 365 detach();
334 mData->mTempSyncStat = id; 366 mData->mTempSyncStat = id;
335} 367}
336int Addressee::tempSyncStat() const 368int Addressee::tempSyncStat() const
337{ 369{
338 return mData->mTempSyncStat; 370 return mData->mTempSyncStat;
339} 371}
340 372
341QString Addressee::getID( const QString & prof) 373QString Addressee::getID( const QString & prof)
342{ 374{
343 return KIdManager::getId ( mData->mExternalId, prof ); 375 return KIdManager::getId ( mData->mExternalId, prof );
344} 376}
345 377
346void Addressee::setCsum( const QString & prof , const QString & id ) 378void Addressee::setCsum( const QString & prof , const QString & id )
347{ 379{
348 detach(); 380 detach();
349 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 381 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
350 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 382 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
351 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 383 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
352} 384}
353 385
354QString Addressee::getCsum( const QString & prof) 386QString Addressee::getCsum( const QString & prof)
355{ 387{
356 return KIdManager::getCsum ( mData->mExternalId, prof ); 388 return KIdManager::getCsum ( mData->mExternalId, prof );
357} 389}
358 390
359void Addressee::setIDStr( const QString & s ) 391void Addressee::setIDStr( const QString & s )
360{ 392{
361 detach(); 393 detach();
362 mData->mExternalId = s; 394 mData->mExternalId = s;
363} 395}
364 396
365QString Addressee::IDStr() const 397QString Addressee::IDStr() const
366{ 398{
367 return mData->mExternalId; 399 return mData->mExternalId;
368} 400}
369 401
370void Addressee::setExternalUID( const QString &id ) 402void Addressee::setExternalUID( const QString &id )
371{ 403{
372 if ( id == mData->externalUID ) return; 404 if ( id == mData->externalUID ) return;
373 detach(); 405 detach();
374 mData->empty = false; 406 mData->empty = false;
375 mData->externalUID = id; 407 mData->externalUID = id;
376} 408}
377 409
378QString Addressee::externalUID() const 410QString Addressee::externalUID() const
379{ 411{
380 return mData->externalUID; 412 return mData->externalUID;
381} 413}
382void Addressee::setOriginalExternalUID( const QString &id ) 414void Addressee::setOriginalExternalUID( const QString &id )
383{ 415{
384 if ( id == mData->originalExternalUID ) return; 416 if ( id == mData->originalExternalUID ) return;
385 detach(); 417 detach();
386 mData->empty = false; 418 mData->empty = false;
387 //qDebug("*******Set orig uid %s ", id.latin1()); 419 //qDebug("*******Set orig uid %s ", id.latin1());
388 mData->originalExternalUID = id; 420 mData->originalExternalUID = id;
389} 421}
390 422
391QString Addressee::originalExternalUID() const 423QString Addressee::originalExternalUID() const
392{ 424{
393 return mData->originalExternalUID; 425 return mData->originalExternalUID;
394} 426}
395 427
396void Addressee::setUid( const QString &id ) 428void Addressee::setUid( const QString &id )
397{ 429{
398 if ( id == mData->uid ) return; 430 if ( id == mData->uid ) return;
399 detach(); 431 detach();
400 //qDebug("****setuid %s ", id.latin1()); 432 //qDebug("****setuid %s ", id.latin1());
401 mData->empty = false; 433 mData->empty = false;
402 mData->uid = id; 434 mData->uid = id;
403} 435}
404 436
405QString Addressee::uid() const 437QString Addressee::uid() const
406{ 438{
407 if ( mData->uid.isEmpty() ) 439 if ( mData->uid.isEmpty() )
408 mData->uid = KApplication::randomString( 10 ); 440 mData->uid = KApplication::randomString( 10 );
409 441
410 return mData->uid; 442 return mData->uid;
411} 443}
412 444
413QString Addressee::uidLabel() 445QString Addressee::uidLabel()
414{ 446{
415 return i18n("Unique Identifier"); 447 return i18n("Unique Identifier");
416} 448}
417 449
418void Addressee::setName( const QString &name ) 450void Addressee::setName( const QString &name )
419{ 451{
420 if ( name == mData->name ) return; 452 if ( name == mData->name ) return;
421 detach(); 453 detach();
422 mData->empty = false; 454 mData->empty = false;
423 mData->name = name; 455 mData->name = name;
424} 456}
425 457
426QString Addressee::name() const 458QString Addressee::name() const
427{ 459{
428 return mData->name; 460 return mData->name;
429} 461}
430 462
431QString Addressee::nameLabel() 463QString Addressee::nameLabel()
432{ 464{
433 return i18n("Name"); 465 return i18n("Name");
434} 466}
435 467
436 468
437void Addressee::setFormattedName( const QString &formattedName ) 469void Addressee::setFormattedName( const QString &formattedName )
438{ 470{
439 if ( formattedName == mData->formattedName ) return; 471 if ( formattedName == mData->formattedName ) return;
440 detach(); 472 detach();
441 mData->empty = false; 473 mData->empty = false;
442 mData->formattedName = formattedName; 474 mData->formattedName = formattedName;
443} 475}
444 476
445QString Addressee::formattedName() const 477QString Addressee::formattedName() const
446{ 478{
447 return mData->formattedName; 479 return mData->formattedName;
448} 480}
449 481
450QString Addressee::formattedNameLabel() 482QString Addressee::formattedNameLabel()
451{ 483{
452 return i18n("Formatted Name"); 484 return i18n("Formatted Name");
453} 485}
454 486
455 487
456void Addressee::setFamilyName( const QString &familyName ) 488void Addressee::setFamilyName( const QString &familyName )
457{ 489{
458 if ( familyName == mData->familyName ) return; 490 if ( familyName == mData->familyName ) return;
459 detach(); 491 detach();
460 mData->empty = false; 492 mData->empty = false;
461 mData->familyName = familyName; 493 mData->familyName = familyName;
462} 494}
463 495
464QString Addressee::familyName() const 496QString Addressee::familyName() const
465{ 497{
466 return mData->familyName; 498 return mData->familyName;
467} 499}
468 500
469QString Addressee::familyNameLabel() 501QString Addressee::familyNameLabel()
470{ 502{
471 return i18n("Family Name"); 503 return i18n("Family Name");
472} 504}
473 505
474 506
475void Addressee::setGivenName( const QString &givenName ) 507void Addressee::setGivenName( const QString &givenName )
476{ 508{
477 if ( givenName == mData->givenName ) return; 509 if ( givenName == mData->givenName ) return;
478 detach(); 510 detach();
479 mData->empty = false; 511 mData->empty = false;
480 mData->givenName = givenName; 512 mData->givenName = givenName;
481} 513}
482 514
483QString Addressee::givenName() const 515QString Addressee::givenName() const
484{ 516{
485 return mData->givenName; 517 return mData->givenName;
486} 518}
487 519
488QString Addressee::givenNameLabel() 520QString Addressee::givenNameLabel()
489{ 521{
490 return i18n("Given Name"); 522 return i18n("Given Name");
491} 523}
492 524
493 525
494void Addressee::setAdditionalName( const QString &additionalName ) 526void Addressee::setAdditionalName( const QString &additionalName )
495{ 527{
496 if ( additionalName == mData->additionalName ) return; 528 if ( additionalName == mData->additionalName ) return;
497 detach(); 529 detach();
498 mData->empty = false; 530 mData->empty = false;
499 mData->additionalName = additionalName; 531 mData->additionalName = additionalName;
500} 532}
501 533
502QString Addressee::additionalName() const 534QString Addressee::additionalName() const
503{ 535{
504 return mData->additionalName; 536 return mData->additionalName;
505} 537}
506 538
507QString Addressee::additionalNameLabel() 539QString Addressee::additionalNameLabel()
508{ 540{
509 return i18n("Additional Names"); 541 return i18n("Additional Names");
510} 542}
511 543
512 544
513void Addressee::setPrefix( const QString &prefix ) 545void Addressee::setPrefix( const QString &prefix )
514{ 546{
515 if ( prefix == mData->prefix ) return; 547 if ( prefix == mData->prefix ) return;
516 detach(); 548 detach();
517 mData->empty = false; 549 mData->empty = false;
518 mData->prefix = prefix; 550 mData->prefix = prefix;
519} 551}
520 552
521QString Addressee::prefix() const 553QString Addressee::prefix() const
522{ 554{
523 return mData->prefix; 555 return mData->prefix;
524} 556}
525 557
526QString Addressee::prefixLabel() 558QString Addressee::prefixLabel()
527{ 559{
528 return i18n("Honorific Prefixes"); 560 return i18n("Honorific Prefixes");
529} 561}
530 562
531 563
532void Addressee::setSuffix( const QString &suffix ) 564void Addressee::setSuffix( const QString &suffix )
533{ 565{
534 if ( suffix == mData->suffix ) return; 566 if ( suffix == mData->suffix ) return;
535 detach(); 567 detach();
536 mData->empty = false; 568 mData->empty = false;
537 mData->suffix = suffix; 569 mData->suffix = suffix;
538} 570}
539 571
540QString Addressee::suffix() const 572QString Addressee::suffix() const
541{ 573{
542 return mData->suffix; 574 return mData->suffix;
543} 575}
544 576
545QString Addressee::suffixLabel() 577QString Addressee::suffixLabel()
546{ 578{
547 return i18n("Honorific Suffixes"); 579 return i18n("Honorific Suffixes");
548} 580}
549 581
550 582
551void Addressee::setNickName( const QString &nickName ) 583void Addressee::setNickName( const QString &nickName )
552{ 584{
553 if ( nickName == mData->nickName ) return; 585 if ( nickName == mData->nickName ) return;
554 detach(); 586 detach();
555 mData->empty = false; 587 mData->empty = false;
556 mData->nickName = nickName; 588 mData->nickName = nickName;
557} 589}
558 590
559QString Addressee::nickName() const 591QString Addressee::nickName() const
560{ 592{
561 return mData->nickName; 593 return mData->nickName;
562} 594}
563 595
564QString Addressee::nickNameLabel() 596QString Addressee::nickNameLabel()
565{ 597{
566 return i18n("Nick Name"); 598 return i18n("Nick Name");
567} 599}
568 600
569 601
570void Addressee::setBirthday( const QDateTime &birthday ) 602void Addressee::setBirthday( const QDateTime &birthday )
571{ 603{
572 if ( birthday == mData->birthday ) return; 604 if ( birthday == mData->birthday ) return;
573 detach(); 605 detach();
574 mData->empty = false; 606 mData->empty = false;
575 mData->birthday = birthday; 607 mData->birthday = birthday;
576} 608}
577 609
578QDateTime Addressee::birthday() const 610QDateTime Addressee::birthday() const
579{ 611{
580 return mData->birthday; 612 return mData->birthday;
581} 613}
582 614
583QString Addressee::birthdayLabel() 615QString Addressee::birthdayLabel()
584{ 616{
585 return i18n("Birthday"); 617 return i18n("Birthday");
586} 618}
587 619
588 620
589QString Addressee::homeAddressStreetLabel() 621QString Addressee::homeAddressStreetLabel()
590{ 622{
591 return i18n("Home Address Street"); 623 return i18n("Home Address Street");
592} 624}
593 625
594 626
595QString Addressee::homeAddressLocalityLabel() 627QString Addressee::homeAddressLocalityLabel()
596{ 628{
597 return i18n("Home Address Locality"); 629 return i18n("Home Address Locality");
598} 630}
599 631
600 632
601QString Addressee::homeAddressRegionLabel() 633QString Addressee::homeAddressRegionLabel()
602{ 634{
603 return i18n("Home Address Region"); 635 return i18n("Home Address Region");
604} 636}
605 637
606 638
607QString Addressee::homeAddressPostalCodeLabel() 639QString Addressee::homeAddressPostalCodeLabel()
608{ 640{
609 return i18n("Home Address Postal Code"); 641 return i18n("Home Address Postal Code");
610} 642}
611 643
612 644
613QString Addressee::homeAddressCountryLabel() 645QString Addressee::homeAddressCountryLabel()
614{ 646{
615 return i18n("Home Address Country"); 647 return i18n("Home Address Country");
616} 648}
617 649
618 650
619QString Addressee::homeAddressLabelLabel() 651QString Addressee::homeAddressLabelLabel()
620{ 652{
621 return i18n("Home Address Label"); 653 return i18n("Home Address Label");
622} 654}
623 655
624 656
625QString Addressee::businessAddressStreetLabel() 657QString Addressee::businessAddressStreetLabel()
626{ 658{
627 return i18n("Business Address Street"); 659 return i18n("Business Address Street");
628} 660}
629 661
630 662
631QString Addressee::businessAddressLocalityLabel() 663QString Addressee::businessAddressLocalityLabel()
632{ 664{
633 return i18n("Business Address Locality"); 665 return i18n("Business Address Locality");
634} 666}
635 667
636 668
637QString Addressee::businessAddressRegionLabel() 669QString Addressee::businessAddressRegionLabel()
638{ 670{
639 return i18n("Business Address Region"); 671 return i18n("Business Address Region");
640} 672}
641 673
642 674
643QString Addressee::businessAddressPostalCodeLabel() 675QString Addressee::businessAddressPostalCodeLabel()
644{ 676{
645 return i18n("Business Address Postal Code"); 677 return i18n("Business Address Postal Code");
646} 678}
647 679
648 680
649QString Addressee::businessAddressCountryLabel() 681QString Addressee::businessAddressCountryLabel()
650{ 682{
651 return i18n("Business Address Country"); 683 return i18n("Business Address Country");
652} 684}
653 685
654 686
655QString Addressee::businessAddressLabelLabel() 687QString Addressee::businessAddressLabelLabel()
656{ 688{
657 return i18n("Business Address Label"); 689 return i18n("Business Address Label");
658} 690}
659 691
660 692
661QString Addressee::homePhoneLabel() 693QString Addressee::homePhoneLabel()
662{ 694{
663 return i18n("Home Phone"); 695 return i18n("Home Phone");
664} 696}
665 697
666 698
667QString Addressee::businessPhoneLabel() 699QString Addressee::businessPhoneLabel()
668{ 700{
669 return i18n("Business Phone"); 701 return i18n("Business Phone");
670} 702}
671 703
672 704
673QString Addressee::mobilePhoneLabel() 705QString Addressee::mobilePhoneLabel()
674{ 706{
675 return i18n("Mobile Phone"); 707 return i18n("Mobile Phone");
676} 708}
677 709
678 710
679QString Addressee::homeFaxLabel() 711QString Addressee::homeFaxLabel()
680{ 712{
681 return i18n("Home Fax"); 713 return i18n("Home Fax");
682} 714}
683 715
684 716
685QString Addressee::businessFaxLabel() 717QString Addressee::businessFaxLabel()
686{ 718{
687 return i18n("Business Fax"); 719 return i18n("Business Fax");
688} 720}
689 721
690 722
691QString Addressee::carPhoneLabel() 723QString Addressee::carPhoneLabel()
692{ 724{
693 return i18n("Car Phone"); 725 return i18n("Car Phone");
694} 726}
695 727
696 728
697QString Addressee::isdnLabel() 729QString Addressee::isdnLabel()
698{ 730{
699 return i18n("ISDN"); 731 return i18n("ISDN");
700} 732}
701 733
702 734
703QString Addressee::pagerLabel() 735QString Addressee::pagerLabel()
704{ 736{
705 return i18n("Pager"); 737 return i18n("Pager");
706} 738}
707 739
708QString Addressee::sipLabel() 740QString Addressee::sipLabel()
709{ 741{
710 return i18n("SIP"); 742 return i18n("SIP");
711} 743}
712 744
713QString Addressee::emailLabel() 745QString Addressee::emailLabel()
714{ 746{
715 return i18n("Email Address"); 747 return i18n("Email Address");
716} 748}
717 749
718 750
719void Addressee::setMailer( const QString &mailer ) 751void Addressee::setMailer( const QString &mailer )
720{ 752{
721 if ( mailer == mData->mailer ) return; 753 if ( mailer == mData->mailer ) return;
722 detach(); 754 detach();
723 mData->empty = false; 755 mData->empty = false;
724 mData->mailer = mailer; 756 mData->mailer = mailer;
725} 757}
726 758
727QString Addressee::mailer() const 759QString Addressee::mailer() const
728{ 760{
729 return mData->mailer; 761 return mData->mailer;
730} 762}
731 763
732QString Addressee::mailerLabel() 764QString Addressee::mailerLabel()
733{ 765{
734 return i18n("Mail Client"); 766 return i18n("Mail Client");
735} 767}
736 768
737 769
738void Addressee::setTimeZone( const TimeZone &timeZone ) 770void Addressee::setTimeZone( const TimeZone &timeZone )
739{ 771{
740 if ( timeZone == mData->timeZone ) return; 772 if ( timeZone == mData->timeZone ) return;
741 detach(); 773 detach();
742 mData->empty = false; 774 mData->empty = false;
743 mData->timeZone = timeZone; 775 mData->timeZone = timeZone;
744} 776}
745 777
746TimeZone Addressee::timeZone() const 778TimeZone Addressee::timeZone() const
747{ 779{
748 return mData->timeZone; 780 return mData->timeZone;
749} 781}
750 782
751QString Addressee::timeZoneLabel() 783QString Addressee::timeZoneLabel()
752{ 784{
753 return i18n("Time Zone"); 785 return i18n("Time Zone");
754} 786}
755 787
756 788
757void Addressee::setGeo( const Geo &geo ) 789void Addressee::setGeo( const Geo &geo )
758{ 790{
759 if ( geo == mData->geo ) return; 791 if ( geo == mData->geo ) return;
760 detach(); 792 detach();
761 mData->empty = false; 793 mData->empty = false;
762 mData->geo = geo; 794 mData->geo = geo;
763} 795}
764 796
765Geo Addressee::geo() const 797Geo Addressee::geo() const
766{ 798{
767 return mData->geo; 799 return mData->geo;
768} 800}
769 801
770QString Addressee::geoLabel() 802QString Addressee::geoLabel()
771{ 803{
772 return i18n("Geographic Position"); 804 return i18n("Geographic Position");
773} 805}
774 806
775 807
776void Addressee::setTitle( const QString &title ) 808void Addressee::setTitle( const QString &title )
777{ 809{
778 if ( title == mData->title ) return; 810 if ( title == mData->title ) return;
779 detach(); 811 detach();
780 mData->empty = false; 812 mData->empty = false;
781 mData->title = title; 813 mData->title = title;
782} 814}
783 815
784QString Addressee::title() const 816QString Addressee::title() const
785{ 817{
786 return mData->title; 818 return mData->title;
787} 819}
788 820
789QString Addressee::titleLabel() 821QString Addressee::titleLabel()
790{ 822{
791 return i18n("Title"); 823 return i18n("Title");
792} 824}
793 825
794 826
795void Addressee::setRole( const QString &role ) 827void Addressee::setRole( const QString &role )
796{ 828{
797 if ( role == mData->role ) return; 829 if ( role == mData->role ) return;
798 detach(); 830 detach();
799 mData->empty = false; 831 mData->empty = false;
800 mData->role = role; 832 mData->role = role;
801} 833}
802 834
803QString Addressee::role() const 835QString Addressee::role() const
804{ 836{
805 return mData->role; 837 return mData->role;
806} 838}
807 839
808QString Addressee::roleLabel() 840QString Addressee::roleLabel()
809{ 841{
810 return i18n("Role"); 842 return i18n("Role");
811} 843}
812 844
813 845
814void Addressee::setOrganization( const QString &organization ) 846void Addressee::setOrganization( const QString &organization )
815{ 847{
816 if ( organization == mData->organization ) return; 848 if ( organization == mData->organization ) return;
817 detach(); 849 detach();
818 mData->empty = false; 850 mData->empty = false;
819 mData->organization = organization; 851 mData->organization = organization;
820} 852}
821 853
822QString Addressee::organization() const 854QString Addressee::organization() const
823{ 855{
824 return mData->organization; 856 return mData->organization;
825} 857}
826 858
827QString Addressee::organizationLabel() 859QString Addressee::organizationLabel()
828{ 860{
829 return i18n("Organization"); 861 return i18n("Organization");
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 8baa888..4cafa86 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -1,631 +1,635 @@
1/*** Warning! This file has been generated by the script makeaddressee ***/ 1/*** Warning! This file has been generated by the script makeaddressee ***/
2/* 2/*
3 This file is part of libkabc. 3 This file is part of libkabc.
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22/* 22/*
23Enhanced Version of the file for platform independent KDE tools. 23Enhanced Version of the file for platform independent KDE tools.
24Copyright (c) 2004 Ulf Schenk 24Copyright (c) 2004 Ulf Schenk
25 25
26$Id$ 26$Id$
27*/ 27*/
28 28
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad ); 119 void mergeContact( const Addressee& ad );
120 void simplifyEmails();
121 void simplifyPhoneNumbers();
122 void simplifyPhoneNumberTypes();
123
120 /** 124 /**
121 Set unique identifier. 125 Set unique identifier.
122 */ 126 */
123 void setUid( const QString &uid ); 127 void setUid( const QString &uid );
124 /** 128 /**
125 Return unique identifier. 129 Return unique identifier.
126 */ 130 */
127 QString uid() const; 131 QString uid() const;
128 /** 132 /**
129 Return translated label for uid field. 133 Return translated label for uid field.
130 */ 134 */
131 static QString uidLabel(); 135 static QString uidLabel();
132 136
133 /** 137 /**
134 Set name. 138 Set name.
135 */ 139 */
136 void setName( const QString &name ); 140 void setName( const QString &name );
137 /** 141 /**
138 Return name. 142 Return name.
139 */ 143 */
140 QString name() const; 144 QString name() const;
141 /** 145 /**
142 Return translated label for name field. 146 Return translated label for name field.
143 */ 147 */
144 static QString nameLabel(); 148 static QString nameLabel();
145 149
146 /** 150 /**
147 Set formatted name. 151 Set formatted name.
148 */ 152 */
149 void setFormattedName( const QString &formattedName ); 153 void setFormattedName( const QString &formattedName );
150 /** 154 /**
151 Return formatted name. 155 Return formatted name.
152 */ 156 */
153 QString formattedName() const; 157 QString formattedName() const;
154 /** 158 /**
155 Return translated label for formattedName field. 159 Return translated label for formattedName field.
156 */ 160 */
157 static QString formattedNameLabel(); 161 static QString formattedNameLabel();
158 162
159 /** 163 /**
160 Set family name. 164 Set family name.
161 */ 165 */
162 void setFamilyName( const QString &familyName ); 166 void setFamilyName( const QString &familyName );
163 /** 167 /**
164 Return family name. 168 Return family name.
165 */ 169 */
166 QString familyName() const; 170 QString familyName() const;
167 /** 171 /**
168 Return translated label for familyName field. 172 Return translated label for familyName field.
169 */ 173 */
170 static QString familyNameLabel(); 174 static QString familyNameLabel();
171 175
172 /** 176 /**
173 Set given name. 177 Set given name.
174 */ 178 */
175 void setGivenName( const QString &givenName ); 179 void setGivenName( const QString &givenName );
176 /** 180 /**
177 Return given name. 181 Return given name.
178 */ 182 */
179 QString givenName() const; 183 QString givenName() const;
180 /** 184 /**
181 Return translated label for givenName field. 185 Return translated label for givenName field.
182 */ 186 */
183 static QString givenNameLabel(); 187 static QString givenNameLabel();
184 188
185 /** 189 /**
186 Set additional names. 190 Set additional names.
187 */ 191 */
188 void setAdditionalName( const QString &additionalName ); 192 void setAdditionalName( const QString &additionalName );
189 /** 193 /**
190 Return additional names. 194 Return additional names.
191 */ 195 */
192 QString additionalName() const; 196 QString additionalName() const;
193 /** 197 /**
194 Return translated label for additionalName field. 198 Return translated label for additionalName field.
195 */ 199 */
196 static QString additionalNameLabel(); 200 static QString additionalNameLabel();
197 201
198 /** 202 /**
199 Set honorific prefixes. 203 Set honorific prefixes.
200 */ 204 */
201 void setPrefix( const QString &prefix ); 205 void setPrefix( const QString &prefix );
202 /** 206 /**
203 Return honorific prefixes. 207 Return honorific prefixes.
204 */ 208 */
205 QString prefix() const; 209 QString prefix() const;
206 /** 210 /**
207 Return translated label for prefix field. 211 Return translated label for prefix field.
208 */ 212 */
209 static QString prefixLabel(); 213 static QString prefixLabel();
210 214
211 /** 215 /**
212 Set honorific suffixes. 216 Set honorific suffixes.
213 */ 217 */
214 void setSuffix( const QString &suffix ); 218 void setSuffix( const QString &suffix );
215 /** 219 /**
216 Return honorific suffixes. 220 Return honorific suffixes.
217 */ 221 */
218 QString suffix() const; 222 QString suffix() const;
219 /** 223 /**
220 Return translated label for suffix field. 224 Return translated label for suffix field.
221 */ 225 */
222 static QString suffixLabel(); 226 static QString suffixLabel();
223 227
224 /** 228 /**
225 Set nick name. 229 Set nick name.
226 */ 230 */
227 void setNickName( const QString &nickName ); 231 void setNickName( const QString &nickName );
228 /** 232 /**
229 Return nick name. 233 Return nick name.
230 */ 234 */
231 QString nickName() const; 235 QString nickName() const;
232 /** 236 /**
233 Return translated label for nickName field. 237 Return translated label for nickName field.
234 */ 238 */
235 static QString nickNameLabel(); 239 static QString nickNameLabel();
236 240
237 /** 241 /**
238 Set birthday. 242 Set birthday.
239 */ 243 */
240 void setBirthday( const QDateTime &birthday ); 244 void setBirthday( const QDateTime &birthday );
241 /** 245 /**
242 Return birthday. 246 Return birthday.
243 */ 247 */
244 QDateTime birthday() const; 248 QDateTime birthday() const;
245 /** 249 /**
246 Return translated label for birthday field. 250 Return translated label for birthday field.
247 */ 251 */
248 static QString birthdayLabel(); 252 static QString birthdayLabel();
249 253
250 /** 254 /**
251 Return translated label for homeAddressStreet field. 255 Return translated label for homeAddressStreet field.
252 */ 256 */
253 static QString homeAddressStreetLabel(); 257 static QString homeAddressStreetLabel();
254 258
255 /** 259 /**
256 Return translated label for homeAddressLocality field. 260 Return translated label for homeAddressLocality field.
257 */ 261 */
258 static QString homeAddressLocalityLabel(); 262 static QString homeAddressLocalityLabel();
259 263
260 /** 264 /**
261 Return translated label for homeAddressRegion field. 265 Return translated label for homeAddressRegion field.
262 */ 266 */
263 static QString homeAddressRegionLabel(); 267 static QString homeAddressRegionLabel();
264 268
265 /** 269 /**
266 Return translated label for homeAddressPostalCode field. 270 Return translated label for homeAddressPostalCode field.
267 */ 271 */
268 static QString homeAddressPostalCodeLabel(); 272 static QString homeAddressPostalCodeLabel();
269 273
270 /** 274 /**
271 Return translated label for homeAddressCountry field. 275 Return translated label for homeAddressCountry field.
272 */ 276 */
273 static QString homeAddressCountryLabel(); 277 static QString homeAddressCountryLabel();
274 278
275 /** 279 /**
276 Return translated label for homeAddressLabel field. 280 Return translated label for homeAddressLabel field.
277 */ 281 */
278 static QString homeAddressLabelLabel(); 282 static QString homeAddressLabelLabel();
279 283
280 /** 284 /**
281 Return translated label for businessAddressStreet field. 285 Return translated label for businessAddressStreet field.
282 */ 286 */
283 static QString businessAddressStreetLabel(); 287 static QString businessAddressStreetLabel();
284 288
285 /** 289 /**
286 Return translated label for businessAddressLocality field. 290 Return translated label for businessAddressLocality field.
287 */ 291 */
288 static QString businessAddressLocalityLabel(); 292 static QString businessAddressLocalityLabel();
289 293
290 /** 294 /**
291 Return translated label for businessAddressRegion field. 295 Return translated label for businessAddressRegion field.
292 */ 296 */
293 static QString businessAddressRegionLabel(); 297 static QString businessAddressRegionLabel();
294 298
295 /** 299 /**
296 Return translated label for businessAddressPostalCode field. 300 Return translated label for businessAddressPostalCode field.
297 */ 301 */
298 static QString businessAddressPostalCodeLabel(); 302 static QString businessAddressPostalCodeLabel();
299 303
300 /** 304 /**
301 Return translated label for businessAddressCountry field. 305 Return translated label for businessAddressCountry field.
302 */ 306 */
303 static QString businessAddressCountryLabel(); 307 static QString businessAddressCountryLabel();
304 308
305 /** 309 /**
306 Return translated label for businessAddressLabel field. 310 Return translated label for businessAddressLabel field.
307 */ 311 */
308 static QString businessAddressLabelLabel(); 312 static QString businessAddressLabelLabel();
309 313
310 /** 314 /**
311 Return translated label for homePhone field. 315 Return translated label for homePhone field.
312 */ 316 */
313 static QString homePhoneLabel(); 317 static QString homePhoneLabel();
314 318
315 /** 319 /**
316 Return translated label for businessPhone field. 320 Return translated label for businessPhone field.
317 */ 321 */
318 static QString businessPhoneLabel(); 322 static QString businessPhoneLabel();
319 323
320 /** 324 /**
321 Return translated label for mobilePhone field. 325 Return translated label for mobilePhone field.
322 */ 326 */
323 static QString mobilePhoneLabel(); 327 static QString mobilePhoneLabel();
324 328
325 /** 329 /**
326 Return translated label for homeFax field. 330 Return translated label for homeFax field.
327 */ 331 */
328 static QString homeFaxLabel(); 332 static QString homeFaxLabel();
329 333
330 /** 334 /**
331 Return translated label for businessFax field. 335 Return translated label for businessFax field.
332 */ 336 */
333 static QString businessFaxLabel(); 337 static QString businessFaxLabel();
334 338
335 /** 339 /**
336 Return translated label for carPhone field. 340 Return translated label for carPhone field.
337 */ 341 */
338 static QString carPhoneLabel(); 342 static QString carPhoneLabel();
339 343
340 /** 344 /**
341 Return translated label for isdn field. 345 Return translated label for isdn field.
342 */ 346 */
343 static QString isdnLabel(); 347 static QString isdnLabel();
344 348
345 /** 349 /**
346 Return translated label for pager field. 350 Return translated label for pager field.
347 */ 351 */
348 static QString pagerLabel(); 352 static QString pagerLabel();
349 353
350 /** 354 /**
351 Return translated label for sip field. 355 Return translated label for sip field.
352 */ 356 */
353 static QString sipLabel(); 357 static QString sipLabel();
354 358
355 /** 359 /**
356 Return translated label for email field. 360 Return translated label for email field.
357 */ 361 */
358 static QString emailLabel(); 362 static QString emailLabel();
359 363
360 /** 364 /**
361 Set mail client. 365 Set mail client.
362 */ 366 */
363 void setMailer( const QString &mailer ); 367 void setMailer( const QString &mailer );
364 /** 368 /**
365 Return mail client. 369 Return mail client.
366 */ 370 */
367 QString mailer() const; 371 QString mailer() const;
368 /** 372 /**
369 Return translated label for mailer field. 373 Return translated label for mailer field.
370 */ 374 */
371 static QString mailerLabel(); 375 static QString mailerLabel();
372 376
373 /** 377 /**
374 Set time zone. 378 Set time zone.
375 */ 379 */
376 void setTimeZone( const TimeZone &timeZone ); 380 void setTimeZone( const TimeZone &timeZone );
377 /** 381 /**
378 Return time zone. 382 Return time zone.
379 */ 383 */
380 TimeZone timeZone() const; 384 TimeZone timeZone() const;
381 /** 385 /**
382 Return translated label for timeZone field. 386 Return translated label for timeZone field.
383 */ 387 */
384 static QString timeZoneLabel(); 388 static QString timeZoneLabel();
385 389
386 /** 390 /**
387 Set geographic position. 391 Set geographic position.
388 */ 392 */
389 void setGeo( const Geo &geo ); 393 void setGeo( const Geo &geo );
390 /** 394 /**
391 Return geographic position. 395 Return geographic position.
392 */ 396 */
393 Geo geo() const; 397 Geo geo() const;
394 /** 398 /**
395 Return translated label for geo field. 399 Return translated label for geo field.
396 */ 400 */
397 static QString geoLabel(); 401 static QString geoLabel();
398 402
399 /** 403 /**
400 Set title. 404 Set title.
401 */ 405 */
402 void setTitle( const QString &title ); 406 void setTitle( const QString &title );
403 /** 407 /**
404 Return title. 408 Return title.
405 */ 409 */
406 QString title() const; 410 QString title() const;
407 /** 411 /**
408 Return translated label for title field. 412 Return translated label for title field.
409 */ 413 */
410 static QString titleLabel(); 414 static QString titleLabel();
411 415
412 /** 416 /**
413 Set role. 417 Set role.
414 */ 418 */
415 void setRole( const QString &role ); 419 void setRole( const QString &role );
416 /** 420 /**
417 Return role. 421 Return role.
418 */ 422 */
419 QString role() const; 423 QString role() const;
420 /** 424 /**
421 Return translated label for role field. 425 Return translated label for role field.
422 */ 426 */
423 static QString roleLabel(); 427 static QString roleLabel();
424 428
425 /** 429 /**
426 Set organization. 430 Set organization.
427 */ 431 */
428 void setOrganization( const QString &organization ); 432 void setOrganization( const QString &organization );
429 /** 433 /**
430 Return organization. 434 Return organization.
431 */ 435 */
432 QString organization() const; 436 QString organization() const;
433 /** 437 /**
434 Return translated label for organization field. 438 Return translated label for organization field.
435 */ 439 */
436 static QString organizationLabel(); 440 static QString organizationLabel();
437 441
438 /** 442 /**
439 Set note. 443 Set note.
440 */ 444 */
441 void setNote( const QString &note ); 445 void setNote( const QString &note );
442 /** 446 /**
443 Return note. 447 Return note.
444 */ 448 */
445 QString note() const; 449 QString note() const;
446 /** 450 /**
447 Return translated label for note field. 451 Return translated label for note field.
448 */ 452 */
449 static QString noteLabel(); 453 static QString noteLabel();
450 454
451 /** 455 /**
452 Set product identifier. 456 Set product identifier.
453 */ 457 */
454 void setProductId( const QString &productId ); 458 void setProductId( const QString &productId );
455 /** 459 /**
456 Return product identifier. 460 Return product identifier.
457 */ 461 */
458 QString productId() const; 462 QString productId() const;
459 /** 463 /**
460 Return translated label for productId field. 464 Return translated label for productId field.
461 */ 465 */
462 static QString productIdLabel(); 466 static QString productIdLabel();
463 467
464 /** 468 /**
465 Set revision date. 469 Set revision date.
466 */ 470 */
467 void setRevision( const QDateTime &revision ); 471 void setRevision( const QDateTime &revision );
468 /** 472 /**
469 Return revision date. 473 Return revision date.
470 */ 474 */
471 QDateTime revision() const; 475 QDateTime revision() const;
472 /** 476 /**
473 Return translated label for revision field. 477 Return translated label for revision field.
474 */ 478 */
475 static QString revisionLabel(); 479 static QString revisionLabel();
476 480
477 /** 481 /**
478 Set sort string. 482 Set sort string.
479 */ 483 */
480 void setSortString( const QString &sortString ); 484 void setSortString( const QString &sortString );
481 /** 485 /**
482 Return sort string. 486 Return sort string.
483 */ 487 */
484 QString sortString() const; 488 QString sortString() const;
485 /** 489 /**
486 Return translated label for sortString field. 490 Return translated label for sortString field.
487 */ 491 */
488 static QString sortStringLabel(); 492 static QString sortStringLabel();
489 493
490 /** 494 /**
491 Set URL. 495 Set URL.
492 */ 496 */
493 void setUrl( const KURL &url ); 497 void setUrl( const KURL &url );
494 /** 498 /**
495 Return URL. 499 Return URL.
496 */ 500 */
497 KURL url() const; 501 KURL url() const;
498 /** 502 /**
499 Return translated label for url field. 503 Return translated label for url field.
500 */ 504 */
501 static QString urlLabel(); 505 static QString urlLabel();
502 506
503 /** 507 /**
504 Set security class. 508 Set security class.
505 */ 509 */
506 void setSecrecy( const Secrecy &secrecy ); 510 void setSecrecy( const Secrecy &secrecy );
507 /** 511 /**
508 Return security class. 512 Return security class.
509 */ 513 */
510 Secrecy secrecy() const; 514 Secrecy secrecy() const;
511 /** 515 /**
512 Return translated label for secrecy field. 516 Return translated label for secrecy field.
513 */ 517 */
514 static QString secrecyLabel(); 518 static QString secrecyLabel();
515 519
516 /** 520 /**
517 Set logo. 521 Set logo.
518 */ 522 */
519 void setLogo( const Picture &logo ); 523 void setLogo( const Picture &logo );
520 /** 524 /**
521 Return logo. 525 Return logo.
522 */ 526 */
523 Picture logo() const; 527 Picture logo() const;
524 /** 528 /**
525 Return translated label for logo field. 529 Return translated label for logo field.
526 */ 530 */
527 static QString logoLabel(); 531 static QString logoLabel();
528 532
529 /** 533 /**
530 Set photo. 534 Set photo.
531 */ 535 */
532 void setPhoto( const Picture &photo ); 536 void setPhoto( const Picture &photo );
533 /** 537 /**
534 Return photo. 538 Return photo.
535 */ 539 */
536 Picture photo() const; 540 Picture photo() const;
537 /** 541 /**
538 Return translated label for photo field. 542 Return translated label for photo field.
539 */ 543 */
540 static QString photoLabel(); 544 static QString photoLabel();
541 545
542 /** 546 /**
543 Set sound. 547 Set sound.
544 */ 548 */
545 void setSound( const Sound &sound ); 549 void setSound( const Sound &sound );
546 /** 550 /**
547 Return sound. 551 Return sound.
548 */ 552 */
549 Sound sound() const; 553 Sound sound() const;
550 /** 554 /**
551 Return translated label for sound field. 555 Return translated label for sound field.
552 */ 556 */
553 static QString soundLabel(); 557 static QString soundLabel();
554 558
555 /** 559 /**
556 Set agent. 560 Set agent.
557 */ 561 */
558 void setAgent( const Agent &agent ); 562 void setAgent( const Agent &agent );
559 /** 563 /**
560 Return agent. 564 Return agent.
561 */ 565 */
562 Agent agent() const; 566 Agent agent() const;
563 /** 567 /**
564 Return translated label for agent field. 568 Return translated label for agent field.
565 */ 569 */
566 static QString agentLabel(); 570 static QString agentLabel();
567 571
568 /** 572 /**
569 Set name fields by parsing the given string and trying to associate the 573 Set name fields by parsing the given string and trying to associate the
570 parts of the string with according fields. This function should probably 574 parts of the string with according fields. This function should probably
571 be a bit more clever. 575 be a bit more clever.
572 */ 576 */
573 void setNameFromString( const QString & ); 577 void setNameFromString( const QString & );
574 578
575 /** 579 /**
576 Return the name of the addressee. This is calculated from all the name 580 Return the name of the addressee. This is calculated from all the name
577 fields. 581 fields.
578 */ 582 */
579 QString realName() const; 583 QString realName() const;
580 584
581 /** 585 /**
582 Return the name that consists of all name parts. 586 Return the name that consists of all name parts.
583 */ 587 */
584 QString assembledName() const; 588 QString assembledName() const;
585 589
586 /** 590 /**
587 Return email address including real name. 591 Return email address including real name.
588 592
589 @param email Email address to be used to construct the full email string. 593 @param email Email address to be used to construct the full email string.
590 If this is QString::null the preferred email address is used. 594 If this is QString::null the preferred email address is used.
591 */ 595 */
592 QString fullEmail( const QString &email=QString::null ) const; 596 QString fullEmail( const QString &email=QString::null ) const;
593 597
594 /** 598 /**
595 Insert an email address. If the email address already exists in this 599 Insert an email address. If the email address already exists in this
596 addressee it is not duplicated. 600 addressee it is not duplicated.
597 601
598 @param email Email address 602 @param email Email address
599 @param preferred Set to true, if this is the preferred email address of 603 @param preferred Set to true, if this is the preferred email address of
600 the addressee. 604 the addressee.
601 */ 605 */
602 void insertEmail( const QString &email, bool preferred=false ); 606 void insertEmail( const QString &email, bool preferred=false );
603 607
604 /** 608 /**
605 Remove email address. If the email address doesn't exist, nothing happens. 609 Remove email address. If the email address doesn't exist, nothing happens.
606 */ 610 */
607 void removeEmail( const QString &email ); 611 void removeEmail( const QString &email );
608 612
609 /** 613 /**
610 Return preferred email address. This is the first email address or the 614 Return preferred email address. This is the first email address or the
611 last one added with @ref insertEmail() with a set preferred parameter. 615 last one added with @ref insertEmail() with a set preferred parameter.
612 */ 616 */
613 QString preferredEmail() const; 617 QString preferredEmail() const;
614 618
615 /** 619 /**
616 Return list of all email addresses. 620 Return list of all email addresses.
617 */ 621 */
618 QStringList emails() const; 622 QStringList emails() const;
619 623
620 /** 624 /**
621 Set the emails to @param. 625 Set the emails to @param.
622 The first email address gets the preferred one! 626 The first email address gets the preferred one!
623 @param list The list of email addresses. 627 @param list The list of email addresses.
624 */ 628 */
625 void setEmails( const QStringList& list); 629 void setEmails( const QStringList& list);
626 630
627 /** 631 /**
628 Insert a phone number. If a phone number with the same id already exists 632 Insert a phone number. If a phone number with the same id already exists
629 in this addressee it is not duplicated. 633 in this addressee it is not duplicated.
630 */ 634 */
631 void insertPhoneNumber( const PhoneNumber &phoneNumber ); 635 void insertPhoneNumber( const PhoneNumber &phoneNumber );
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 7aeb2ee..e5abc0e 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -1,202 +1,225 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kapplication.h> 28#include <kapplication.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "phonenumber.h" 31#include "phonenumber.h"
32 32
33using namespace KABC; 33using namespace KABC;
34 34
35PhoneNumber::PhoneNumber() : 35PhoneNumber::PhoneNumber() :
36 mType( Home ) 36 mType( Home )
37{ 37{
38 init(); 38 init();
39} 39}
40 40
41PhoneNumber::PhoneNumber( const QString &number, int type ) : 41PhoneNumber::PhoneNumber( const QString &number, int type ) :
42 mType( type ), mNumber( number ) 42 mType( type ), mNumber( number )
43{ 43{
44 init(); 44 init();
45} 45}
46 46
47PhoneNumber::~PhoneNumber() 47PhoneNumber::~PhoneNumber()
48{ 48{
49} 49}
50 50
51void PhoneNumber::init() 51void PhoneNumber::init()
52{ 52{
53 mId = KApplication::randomString( 8 ); 53 mId = KApplication::randomString( 8 );
54} 54}
55 55
56bool PhoneNumber::operator==( const PhoneNumber &p ) const 56bool PhoneNumber::operator==( const PhoneNumber &p ) const
57{ 57{
58 if ( mNumber != p.mNumber ) return false; 58 if ( mNumber != p.mNumber ) return false;
59 if ( mType != p.mType ) return false; 59 if ( mType != p.mType ) return false;
60 60
61 return true; 61 return true;
62} 62}
63 63
64bool PhoneNumber::operator!=( const PhoneNumber &p ) const 64bool PhoneNumber::operator!=( const PhoneNumber &p ) const
65{ 65{
66 return !( p == *this ); 66 return !( p == *this );
67} 67}
68 68
69bool PhoneNumber::simplifyNumber()
70{
71 QString Number;
72 int i;
73 Number = mNumber.stripWhiteSpace ();
74 mNumber = "";
75 if ( Number.at(0) == '+' )
76 mNumber += "+";
77 for ( i = 0; i < Number.length(); ++i) {
78 if ( Number.at(i).isDigit() )
79 mNumber += Number.at(i);
80 }
81 return ( mNumber.length() > 0 );
82}
83// make cellphone compatible
84void PhoneNumber::simplifyType()
85{
86 if ( mType & Fax ) mType = Fax;
87 else if ( mType & Cell ) mType = Cell;
88 else if ( mType & Work ) mType = Work ;
89 else if ( mType & Home ) mType = Home;
90 else mType = Pref;
91}
69void PhoneNumber::setId( const QString &id ) 92void PhoneNumber::setId( const QString &id )
70{ 93{
71 mId = id; 94 mId = id;
72} 95}
73 96
74QString PhoneNumber::id() const 97QString PhoneNumber::id() const
75{ 98{
76 return mId; 99 return mId;
77} 100}
78 101
79void PhoneNumber::setNumber( const QString &number ) 102void PhoneNumber::setNumber( const QString &number )
80{ 103{
81 mNumber = number; 104 mNumber = number;
82} 105}
83 106
84QString PhoneNumber::number() const 107QString PhoneNumber::number() const
85{ 108{
86 return mNumber; 109 return mNumber;
87} 110}
88 111
89void PhoneNumber::setType( int type ) 112void PhoneNumber::setType( int type )
90{ 113{
91 mType = type; 114 mType = type;
92} 115}
93 116
94int PhoneNumber::type() const 117int PhoneNumber::type() const
95{ 118{
96 return mType; 119 return mType;
97} 120}
98 121
99QString PhoneNumber::typeLabel() const 122QString PhoneNumber::typeLabel() const
100{ 123{
101 QString label; 124 QString label;
102 bool first = true; 125 bool first = true;
103 126
104 TypeList list = typeList(); 127 TypeList list = typeList();
105 128
106 TypeList::Iterator it; 129 TypeList::Iterator it;
107 for ( it = list.begin(); it != list.end(); ++it ) { 130 for ( it = list.begin(); it != list.end(); ++it ) {
108 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 131 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
109 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 132 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
110 if ( first ) 133 if ( first )
111 first = false; 134 first = false;
112 } 135 }
113 } 136 }
114 137
115 return label; 138 return label;
116} 139}
117 140
118QString PhoneNumber::label() const 141QString PhoneNumber::label() const
119{ 142{
120 return typeLabel( type() ); 143 return typeLabel( type() );
121} 144}
122 145
123PhoneNumber::TypeList PhoneNumber::typeList() 146PhoneNumber::TypeList PhoneNumber::typeList()
124{ 147{
125 TypeList list; 148 TypeList list;
126 149
127 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 150 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
128 << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; 151 << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip;
129 152
130 return list; 153 return list;
131} 154}
132 155
133QString PhoneNumber::label( int type ) 156QString PhoneNumber::label( int type )
134{ 157{
135 return typeLabel( type ); 158 return typeLabel( type );
136} 159}
137 160
138QString PhoneNumber::typeLabel( int type ) 161QString PhoneNumber::typeLabel( int type )
139{ 162{
140 QString typeString; 163 QString typeString;
141 164
142 if ((type & Home) == Home) 165 if ((type & Home) == Home)
143 typeString += i18n("Home"); 166 typeString += i18n("Home");
144 else if ((type & Work) == Work) 167 else if ((type & Work) == Work)
145 typeString += i18n("Work"); 168 typeString += i18n("Work");
146 169
147 if (!typeString.isEmpty()) 170 if (!typeString.isEmpty())
148 typeString += " "; 171 typeString += " ";
149 172
150 if ((type & Cell) == Cell) 173 if ((type & Cell) == Cell)
151 typeString += i18n("Mobile"); 174 typeString += i18n("Mobile");
152 else if ((type & Fax) == Fax) 175 else if ((type & Fax) == Fax)
153 typeString += i18n("Fax"); 176 typeString += i18n("Fax");
154 else if ((type & Msg) == Msg) 177 else if ((type & Msg) == Msg)
155 typeString += i18n("Messenger"); 178 typeString += i18n("Messenger");
156 else if ((type & Voice) == Voice) { 179 else if ((type & Voice) == Voice) {
157// add nothing in case of the Voice flag 180// add nothing in case of the Voice flag
158// typeString += i18n("Voice"); 181// typeString += i18n("Voice");
159 } 182 }
160 else if ((type & Video) == Video) 183 else if ((type & Video) == Video)
161 typeString += i18n("Video"); 184 typeString += i18n("Video");
162 else if ((type & Bbs) == Bbs) 185 else if ((type & Bbs) == Bbs)
163 typeString += i18n("Mailbox"); 186 typeString += i18n("Mailbox");
164 else if ((type & Modem) == Modem) 187 else if ((type & Modem) == Modem)
165 typeString += i18n("Modem"); 188 typeString += i18n("Modem");
166 else if ((type & Car) == Car) 189 else if ((type & Car) == Car)
167 typeString += i18n("Car"); 190 typeString += i18n("Car");
168 else if ((type & Isdn) == Isdn) 191 else if ((type & Isdn) == Isdn)
169 typeString += i18n("ISDN"); 192 typeString += i18n("ISDN");
170 else if ((type & Pcs) == Pcs) 193 else if ((type & Pcs) == Pcs)
171 typeString += i18n("PCS"); 194 typeString += i18n("PCS");
172 else if ((type & Pager) == Pager) 195 else if ((type & Pager) == Pager)
173 typeString += i18n("Pager"); 196 typeString += i18n("Pager");
174 else if ((type & Sip) == Sip) 197 else if ((type & Sip) == Sip)
175 typeString += i18n("SIP"); 198 typeString += i18n("SIP");
176 199
177 // add the prefered flag 200 // add the prefered flag
178 if (!typeString.isEmpty()) 201 if (!typeString.isEmpty())
179 typeString += " "; 202 typeString += " ";
180 203
181 if ((type & Pref) == Pref) 204 if ((type & Pref) == Pref)
182 typeString += i18n("(p)"); 205 typeString += i18n("(p)");
183 206
184 //if we still have no match, return "other" 207 //if we still have no match, return "other"
185 if (typeString.isEmpty()) 208 if (typeString.isEmpty())
186 return i18n("Other"); 209 return i18n("Other");
187 210
188 211
189 return typeString; 212 return typeString;
190} 213}
191 214
192QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) 215QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone )
193{ 216{
194 return s << phone.mId << phone.mType << phone.mNumber; 217 return s << phone.mId << phone.mType << phone.mNumber;
195} 218}
196 219
197QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) 220QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone )
198{ 221{
199 s >> phone.mId >> phone.mType >> phone.mNumber; 222 s >> phone.mId >> phone.mType >> phone.mNumber;
200 223
201 return s; 224 return s;
202} 225}
diff --git a/kabc/phonenumber.h b/kabc/phonenumber.h
index 1df344f..410a52f 100644
--- a/kabc/phonenumber.h
+++ b/kabc/phonenumber.h
@@ -1,166 +1,168 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_PHONENUMBER_H 28#ifndef KABC_PHONENUMBER_H
29#define KABC_PHONENUMBER_H 29#define KABC_PHONENUMBER_H
30 30
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32#include <qstring.h> 32#include <qstring.h>
33 33
34namespace KABC { 34namespace KABC {
35 35
36/** 36/**
37 @short Phonenumber information. 37 @short Phonenumber information.
38 38
39 This class provides phone number information. A phone number is classified by 39 This class provides phone number information. A phone number is classified by
40 a type. The following types are available, it's possible to use multiple types 40 a type. The following types are available, it's possible to use multiple types
41 @ref Types for a number by combining them through a logical or. 41 @ref Types for a number by combining them through a logical or.
42*/ 42*/
43class PhoneNumber 43class PhoneNumber
44{ 44{
45 friend QDataStream &operator<<( QDataStream &, const PhoneNumber & ); 45 friend QDataStream &operator<<( QDataStream &, const PhoneNumber & );
46 friend QDataStream &operator>>( QDataStream &, PhoneNumber & ); 46 friend QDataStream &operator>>( QDataStream &, PhoneNumber & );
47 47
48 public: 48 public:
49 typedef QValueList<PhoneNumber> List; 49 typedef QValueList<PhoneNumber> List;
50 typedef QValueList<int> TypeList; 50 typedef QValueList<int> TypeList;
51 51
52 /** 52 /**
53 @li @p Home - Home number 53 @li @p Home - Home number
54 @li @p Work - Office number 54 @li @p Work - Office number
55 @li @p Msg - Messaging 55 @li @p Msg - Messaging
56 @li @p Pref - Preferred number 56 @li @p Pref - Preferred number
57 @li @p Voice - Voice 57 @li @p Voice - Voice
58 @li @p Fax - Fax machine 58 @li @p Fax - Fax machine
59 @li @p Cell - Cell phone 59 @li @p Cell - Cell phone
60 @li @p Video - Video phone 60 @li @p Video - Video phone
61 @li @p Bbs - Mailbox 61 @li @p Bbs - Mailbox
62 @li @p Modem - Modem 62 @li @p Modem - Modem
63 @li @p Car - Car phone 63 @li @p Car - Car phone
64 @li @p Isdn - ISDN connection 64 @li @p Isdn - ISDN connection
65 @li @p Pcs - Personal Communication Service 65 @li @p Pcs - Personal Communication Service
66 @li @p Pager - Pager 66 @li @p Pager - Pager
67 @li @p SIP - VoIP 67 @li @p SIP - VoIP
68 */ 68 */
69 enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32, 69 enum Types { Home = 1, Work = 2, Msg = 4, Pref = 8, Voice = 16, Fax = 32,
70 Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024, 70 Cell = 64, Video = 128, Bbs = 256, Modem = 512, Car = 1024,
71 Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 }; 71 Isdn = 2048, Pcs = 4096, Pager = 8192, Sip = 16384 };
72 72
73 /** 73 /**
74 Create an empty phone number object. 74 Create an empty phone number object.
75 */ 75 */
76 PhoneNumber(); 76 PhoneNumber();
77 77
78 /** 78 /**
79 Create a phonenumber object. 79 Create a phonenumber object.
80 80
81 @param number Number 81 @param number Number
82 @param type Type as defined in enum. Multiple types can be 82 @param type Type as defined in enum. Multiple types can be
83 specified by combining them by a logical or. 83 specified by combining them by a logical or.
84 */ 84 */
85 PhoneNumber( const QString &number, int type = Home ); 85 PhoneNumber( const QString &number, int type = Home );
86 86
87 /** 87 /**
88 Destructor. 88 Destructor.
89 */ 89 */
90 ~PhoneNumber(); 90 ~PhoneNumber();
91 91
92 bool operator==( const PhoneNumber & ) const; 92 bool operator==( const PhoneNumber & ) const;
93 bool operator!=( const PhoneNumber & ) const; 93 bool operator!=( const PhoneNumber & ) const;
94 94
95 /** 95 /**
96 Sets the unique identifier. 96 Sets the unique identifier.
97 */ 97 */
98 void setId( const QString &id ); 98 void setId( const QString &id );
99 99
100 /** 100 /**
101 Returns the unique identifier. 101 Returns the unique identifier.
102 */ 102 */
103 QString id() const; 103 QString id() const;
104 104
105 /** 105 /**
106 Sets the number. 106 Sets the number.
107 */ 107 */
108 void setNumber( const QString & ); 108 void setNumber( const QString & );
109 109
110 /** 110 /**
111 Returns the number. 111 Returns the number.
112 */ 112 */
113 QString number() const; 113 QString number() const;
114 114
115 /** 115 /**
116 Sets the type. Multiple types can be specified by combining them by 116 Sets the type. Multiple types can be specified by combining them by
117 a logical or. 117 a logical or.
118 */ 118 */
119 void setType( int ); 119 void setType( int );
120 120
121 /** 121 /**
122 Returns the type. Can be a multiple types combined by a logical or. 122 Returns the type. Can be a multiple types combined by a logical or.
123 */ 123 */
124 int type() const; 124 int type() const;
125 125
126 /** 126 /**
127 Returns a translated string of all types the address has. 127 Returns a translated string of all types the address has.
128 */ 128 */
129 QString typeLabel() const; 129 QString typeLabel() const;
130 130
131 /** 131 /**
132 Returns the translated label for phone number depending on its type. 132 Returns the translated label for phone number depending on its type.
133 */ 133 */
134 QString label() const; 134 QString label() const;
135 135
136 /** 136 /**
137 Returns a list of all available types 137 Returns a list of all available types
138 */ 138 */
139 static TypeList typeList(); 139 static TypeList typeList();
140 140
141 /** 141 /**
142 Returns the translated label for phone number type. 142 Returns the translated label for phone number type.
143 */ 143 */
144 static QString typeLabel( int type ); 144 static QString typeLabel( int type );
145 145
146 /** 146 /**
147 Returns the translated label for phone number type. 147 Returns the translated label for phone number type.
148 @obsolete 148 @obsolete
149 */ 149 */
150 static QString label( int type ); 150 static QString label( int type );
151 bool simplifyNumber();
152 void simplifyType();
151 153
152 private: 154 private:
153 void init(); 155 void init();
154 156
155 QString mId; 157 QString mId;
156 158
157 int mType; 159 int mType;
158 QString mNumber; 160 QString mNumber;
159}; 161};
160 162
161QDataStream &operator<<( QDataStream &, const PhoneNumber & ); 163QDataStream &operator<<( QDataStream &, const PhoneNumber & );
162QDataStream &operator>>( QDataStream &, PhoneNumber & ); 164QDataStream &operator>>( QDataStream &, PhoneNumber & );
163 165
164} 166}
165 167
166#endif 168#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index c5406bf..939296f 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -190,1045 +190,1060 @@ class KAex2phonePrefs : public QDialog
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207bool pasteWithNewUid = true; 207bool pasteWithNewUid = true;
208 208
209#ifdef KAB_EMBEDDED 209#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 214#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 218 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220{ 220{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 222 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 223 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 224 mIsPart = !parent->inherits( "KAddressBookMain" );
225 225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 mEditorDialog = 0; 310 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 311 createAddresseeEditorDialog( this );
312 setModified( false ); 312 setModified( false );
313} 313}
314 314
315KABCore::~KABCore() 315KABCore::~KABCore()
316{ 316{
317 // save(); 317 // save();
318 //saveSettings(); 318 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 319 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 320 delete AddresseeConfig::instance();
321 mAddressBook = 0; 321 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 322 KABC::StdAddressBook::close();
323 323
324 delete syncManager; 324 delete syncManager;
325} 325}
326 326
327void KABCore::restoreSettings() 327void KABCore::restoreSettings()
328{ 328{
329 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 329 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
330 330
331 bool state; 331 bool state;
332 332
333 if (mMultipleViewsAtOnce) 333 if (mMultipleViewsAtOnce)
334 state = KABPrefs::instance()->mDetailsPageVisible; 334 state = KABPrefs::instance()->mDetailsPageVisible;
335 else 335 else
336 state = false; 336 state = false;
337 337
338 mActionDetails->setChecked( state ); 338 mActionDetails->setChecked( state );
339 setDetailsVisible( state ); 339 setDetailsVisible( state );
340 340
341 state = KABPrefs::instance()->mJumpButtonBarVisible; 341 state = KABPrefs::instance()->mJumpButtonBarVisible;
342 342
343 mActionJumpBar->setChecked( state ); 343 mActionJumpBar->setChecked( state );
344 setJumpButtonBarVisible( state ); 344 setJumpButtonBarVisible( state );
345/*US 345/*US
346 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 346 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
347 if ( splitterSize.count() == 0 ) { 347 if ( splitterSize.count() == 0 ) {
348 splitterSize.append( width() / 2 ); 348 splitterSize.append( width() / 2 );
349 splitterSize.append( width() / 2 ); 349 splitterSize.append( width() / 2 );
350 } 350 }
351 mMiniSplitter->setSizes( splitterSize ); 351 mMiniSplitter->setSizes( splitterSize );
352 if ( mExtensionBarSplitter ) { 352 if ( mExtensionBarSplitter ) {
353 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 353 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
354 if ( splitterSize.count() == 0 ) { 354 if ( splitterSize.count() == 0 ) {
355 splitterSize.append( width() / 2 ); 355 splitterSize.append( width() / 2 );
356 splitterSize.append( width() / 2 ); 356 splitterSize.append( width() / 2 );
357 } 357 }
358 mExtensionBarSplitter->setSizes( splitterSize ); 358 mExtensionBarSplitter->setSizes( splitterSize );
359 359
360 } 360 }
361*/ 361*/
362 mViewManager->restoreSettings(); 362 mViewManager->restoreSettings();
363 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 363 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
364 mExtensionManager->restoreSettings(); 364 mExtensionManager->restoreSettings();
365#ifdef DESKTOP_VERSION 365#ifdef DESKTOP_VERSION
366 int wid = width(); 366 int wid = width();
367 if ( wid < 10 ) 367 if ( wid < 10 )
368 wid = 400; 368 wid = 400;
369#else 369#else
370 int wid = QApplication::desktop()->width(); 370 int wid = QApplication::desktop()->width();
371 if ( wid < 640 ) 371 if ( wid < 640 )
372 wid = QApplication::desktop()->height(); 372 wid = QApplication::desktop()->height();
373#endif 373#endif
374 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 374 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
375 if ( true /*splitterSize.count() == 0*/ ) { 375 if ( true /*splitterSize.count() == 0*/ ) {
376 splitterSize.append( wid / 2 ); 376 splitterSize.append( wid / 2 );
377 splitterSize.append( wid / 2 ); 377 splitterSize.append( wid / 2 );
378 } 378 }
379 mMiniSplitter->setSizes( splitterSize ); 379 mMiniSplitter->setSizes( splitterSize );
380 if ( mExtensionBarSplitter ) { 380 if ( mExtensionBarSplitter ) {
381 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 381 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
382 if ( true /*splitterSize.count() == 0*/ ) { 382 if ( true /*splitterSize.count() == 0*/ ) {
383 splitterSize.append( wid / 2 ); 383 splitterSize.append( wid / 2 );
384 splitterSize.append( wid / 2 ); 384 splitterSize.append( wid / 2 );
385 } 385 }
386 mExtensionBarSplitter->setSizes( splitterSize ); 386 mExtensionBarSplitter->setSizes( splitterSize );
387 387
388 } 388 }
389 389
390 390
391} 391}
392 392
393void KABCore::saveSettings() 393void KABCore::saveSettings()
394{ 394{
395 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 395 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
396 if ( mExtensionBarSplitter ) 396 if ( mExtensionBarSplitter )
397 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 397 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
398 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 398 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
399 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 399 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
400#ifndef KAB_EMBEDDED 400#ifndef KAB_EMBEDDED
401 401
402 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 402 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
403 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 403 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
404#endif //KAB_EMBEDDED 404#endif //KAB_EMBEDDED
405 mExtensionManager->saveSettings(); 405 mExtensionManager->saveSettings();
406 mViewManager->saveSettings(); 406 mViewManager->saveSettings();
407 407
408 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 408 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
409} 409}
410 410
411KABC::AddressBook *KABCore::addressBook() const 411KABC::AddressBook *KABCore::addressBook() const
412{ 412{
413 return mAddressBook; 413 return mAddressBook;
414} 414}
415 415
416KConfig *KABCore::config() 416KConfig *KABCore::config()
417{ 417{
418#ifndef KAB_EMBEDDED 418#ifndef KAB_EMBEDDED
419 return KABPrefs::instance()->config(); 419 return KABPrefs::instance()->config();
420#else //KAB_EMBEDDED 420#else //KAB_EMBEDDED
421 return KABPrefs::instance()->getConfig(); 421 return KABPrefs::instance()->getConfig();
422#endif //KAB_EMBEDDED 422#endif //KAB_EMBEDDED
423} 423}
424 424
425KActionCollection *KABCore::actionCollection() const 425KActionCollection *KABCore::actionCollection() const
426{ 426{
427 return mGUIClient->actionCollection(); 427 return mGUIClient->actionCollection();
428} 428}
429 429
430KABC::Field *KABCore::currentSearchField() const 430KABC::Field *KABCore::currentSearchField() const
431{ 431{
432 if (mIncSearchWidget) 432 if (mIncSearchWidget)
433 return mIncSearchWidget->currentField(); 433 return mIncSearchWidget->currentField();
434 else 434 else
435 return 0; 435 return 0;
436} 436}
437 437
438QStringList KABCore::selectedUIDs() const 438QStringList KABCore::selectedUIDs() const
439{ 439{
440 return mViewManager->selectedUids(); 440 return mViewManager->selectedUids();
441} 441}
442 442
443KABC::Resource *KABCore::requestResource( QWidget *parent ) 443KABC::Resource *KABCore::requestResource( QWidget *parent )
444{ 444{
445 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 445 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
446 446
447 QPtrList<KRES::Resource> kresResources; 447 QPtrList<KRES::Resource> kresResources;
448 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 448 QPtrListIterator<KABC::Resource> resIt( kabcResources );
449 KABC::Resource *resource; 449 KABC::Resource *resource;
450 while ( ( resource = resIt.current() ) != 0 ) { 450 while ( ( resource = resIt.current() ) != 0 ) {
451 ++resIt; 451 ++resIt;
452 if ( !resource->readOnly() ) { 452 if ( !resource->readOnly() ) {
453 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 453 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
454 if ( res ) 454 if ( res )
455 kresResources.append( res ); 455 kresResources.append( res );
456 } 456 }
457 } 457 }
458 458
459 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 459 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
460 return static_cast<KABC::Resource*>( res ); 460 return static_cast<KABC::Resource*>( res );
461} 461}
462 462
463#ifndef KAB_EMBEDDED 463#ifndef KAB_EMBEDDED
464KAboutData *KABCore::createAboutData() 464KAboutData *KABCore::createAboutData()
465#else //KAB_EMBEDDED 465#else //KAB_EMBEDDED
466void KABCore::createAboutData() 466void KABCore::createAboutData()
467#endif //KAB_EMBEDDED 467#endif //KAB_EMBEDDED
468{ 468{
469#ifndef KAB_EMBEDDED 469#ifndef KAB_EMBEDDED
470 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 470 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
471 "3.1", I18N_NOOP( "The KDE Address Book" ), 471 "3.1", I18N_NOOP( "The KDE Address Book" ),
472 KAboutData::License_GPL_V2, 472 KAboutData::License_GPL_V2,
473 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 473 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
474 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 474 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
475 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 475 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
476 about->addAuthor( "Cornelius Schumacher", 476 about->addAuthor( "Cornelius Schumacher",
477 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 477 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
478 "schumacher@kde.org" ); 478 "schumacher@kde.org" );
479 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 479 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
480 "mpilone@slac.com" ); 480 "mpilone@slac.com" );
481 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 481 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
482 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 482 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
483 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 483 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
484 "michel@klaralvdalens-datakonsult.se" ); 484 "michel@klaralvdalens-datakonsult.se" );
485 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 485 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
486 "hansen@kde.org" ); 486 "hansen@kde.org" );
487 487
488 return about; 488 return about;
489#endif //KAB_EMBEDDED 489#endif //KAB_EMBEDDED
490 490
491 QString version; 491 QString version;
492#include <../version> 492#include <../version>
493 QMessageBox::about( this, "About KAddressbook/Pi", 493 QMessageBox::about( this, "About KAddressbook/Pi",
494 "KAddressbook/Platform-independent\n" 494 "KAddressbook/Platform-independent\n"
495 "(KA/Pi) " +version + " - " + 495 "(KA/Pi) " +version + " - " +
496#ifdef DESKTOP_VERSION 496#ifdef DESKTOP_VERSION
497 "Desktop Edition\n" 497 "Desktop Edition\n"
498#else 498#else
499 "PDA-Edition\n" 499 "PDA-Edition\n"
500 "for: Zaurus 5500 / 7x0 / 8x0\n" 500 "for: Zaurus 5500 / 7x0 / 8x0\n"
501#endif 501#endif
502 502
503 "(c) 2004 Ulf Schenk\n" 503 "(c) 2004 Ulf Schenk\n"
504 "(c) 2004 Lutz Rogowski\n" 504 "(c) 2004 Lutz Rogowski\n"
505 "(c) 1997-2003, The KDE PIM Team\n" 505 "(c) 1997-2003, The KDE PIM Team\n"
506 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 506 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
507 "Don Sanders Original author\n" 507 "Don Sanders Original author\n"
508 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 508 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
509 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 509 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
510 "Greg Stern DCOP interface\n" 510 "Greg Stern DCOP interface\n"
511 "Mark Westcot Contact pinning\n" 511 "Mark Westcot Contact pinning\n"
512 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 512 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
513 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 513 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
514#ifdef _WIN32_ 514#ifdef _WIN32_
515 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 515 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
516#endif 516#endif
517 ); 517 );
518} 518}
519 519
520void KABCore::setContactSelected( const QString &uid ) 520void KABCore::setContactSelected( const QString &uid )
521{ 521{
522 KABC::Addressee addr = mAddressBook->findByUid( uid ); 522 KABC::Addressee addr = mAddressBook->findByUid( uid );
523 if ( !mDetails->isHidden() ) 523 if ( !mDetails->isHidden() )
524 mDetails->setAddressee( addr ); 524 mDetails->setAddressee( addr );
525 525
526 if ( !addr.isEmpty() ) { 526 if ( !addr.isEmpty() ) {
527 emit contactSelected( addr.formattedName() ); 527 emit contactSelected( addr.formattedName() );
528 KABC::Picture pic = addr.photo(); 528 KABC::Picture pic = addr.photo();
529 if ( pic.isIntern() ) { 529 if ( pic.isIntern() ) {
530//US emit contactSelected( pic.data() ); 530//US emit contactSelected( pic.data() );
531//US instead use: 531//US instead use:
532 QPixmap px; 532 QPixmap px;
533 if (pic.data().isNull() != true) 533 if (pic.data().isNull() != true)
534 { 534 {
535 px.convertFromImage(pic.data()); 535 px.convertFromImage(pic.data());
536 } 536 }
537 537
538 emit contactSelected( px ); 538 emit contactSelected( px );
539 } 539 }
540 } 540 }
541 541
542 542
543 mExtensionManager->setSelectionChanged(); 543 mExtensionManager->setSelectionChanged();
544 544
545 // update the actions 545 // update the actions
546 bool selected = !uid.isEmpty(); 546 bool selected = !uid.isEmpty();
547 547
548 if ( mReadWrite ) { 548 if ( mReadWrite ) {
549 mActionCut->setEnabled( selected ); 549 mActionCut->setEnabled( selected );
550 mActionPaste->setEnabled( selected ); 550 mActionPaste->setEnabled( selected );
551 } 551 }
552 552
553 mActionCopy->setEnabled( selected ); 553 mActionCopy->setEnabled( selected );
554 mActionDelete->setEnabled( selected ); 554 mActionDelete->setEnabled( selected );
555 mActionEditAddressee->setEnabled( selected ); 555 mActionEditAddressee->setEnabled( selected );
556 mActionMail->setEnabled( selected ); 556 mActionMail->setEnabled( selected );
557 mActionMailVCard->setEnabled( selected ); 557 mActionMailVCard->setEnabled( selected );
558 //if (mActionBeam) 558 //if (mActionBeam)
559 //mActionBeam->setEnabled( selected ); 559 //mActionBeam->setEnabled( selected );
560 560
561 if (mActionBeamVCard) 561 if (mActionBeamVCard)
562 mActionBeamVCard->setEnabled( selected ); 562 mActionBeamVCard->setEnabled( selected );
563 563
564 mActionExport2phone->setEnabled( selected ); 564 mActionExport2phone->setEnabled( selected );
565 mActionWhoAmI->setEnabled( selected ); 565 mActionWhoAmI->setEnabled( selected );
566 mActionCategories->setEnabled( selected ); 566 mActionCategories->setEnabled( selected );
567} 567}
568 568
569void KABCore::sendMail() 569void KABCore::sendMail()
570{ 570{
571 sendMail( mViewManager->selectedEmails().join( ", " ) ); 571 sendMail( mViewManager->selectedEmails().join( ", " ) );
572} 572}
573 573
574void KABCore::sendMail( const QString& emaillist ) 574void KABCore::sendMail( const QString& emaillist )
575{ 575{
576 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 576 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
577 if (emaillist.contains(",") > 0) 577 if (emaillist.contains(",") > 0)
578 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 578 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
579 else 579 else
580 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 580 ExternalAppHandler::instance()->mailToOneContact( emaillist );
581} 581}
582 582
583 583
584 584
585void KABCore::mailVCard() 585void KABCore::mailVCard()
586{ 586{
587 QStringList uids = mViewManager->selectedUids(); 587 QStringList uids = mViewManager->selectedUids();
588 if ( !uids.isEmpty() ) 588 if ( !uids.isEmpty() )
589 mailVCard( uids ); 589 mailVCard( uids );
590} 590}
591 591
592void KABCore::mailVCard( const QStringList& uids ) 592void KABCore::mailVCard( const QStringList& uids )
593{ 593{
594 QStringList urls; 594 QStringList urls;
595 595
596// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 596// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
597 597
598 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 598 QString dirName = "/tmp/" + KApplication::randomString( 8 );
599 599
600 600
601 601
602 QDir().mkdir( dirName, true ); 602 QDir().mkdir( dirName, true );
603 603
604 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 604 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
605 KABC::Addressee a = mAddressBook->findByUid( *it ); 605 KABC::Addressee a = mAddressBook->findByUid( *it );
606 606
607 if ( a.isEmpty() ) 607 if ( a.isEmpty() )
608 continue; 608 continue;
609 609
610 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 610 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
611 611
612 QString fileName = dirName + "/" + name; 612 QString fileName = dirName + "/" + name;
613 613
614 QFile outFile(fileName); 614 QFile outFile(fileName);
615 615
616 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 616 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
617 KABC::VCardConverter converter; 617 KABC::VCardConverter converter;
618 QString vcard; 618 QString vcard;
619 619
620 converter.addresseeToVCard( a, vcard ); 620 converter.addresseeToVCard( a, vcard );
621 621
622 QTextStream t( &outFile ); // use a text stream 622 QTextStream t( &outFile ); // use a text stream
623 t.setEncoding( QTextStream::UnicodeUTF8 ); 623 t.setEncoding( QTextStream::UnicodeUTF8 );
624 t << vcard; 624 t << vcard;
625 625
626 outFile.close(); 626 outFile.close();
627 627
628 urls.append( fileName ); 628 urls.append( fileName );
629 } 629 }
630 } 630 }
631 631
632 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 632 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
633 633
634 634
635/*US 635/*US
636 kapp->invokeMailer( QString::null, QString::null, QString::null, 636 kapp->invokeMailer( QString::null, QString::null, QString::null,
637 QString::null, // subject 637 QString::null, // subject
638 QString::null, // body 638 QString::null, // body
639 QString::null, 639 QString::null,
640 urls ); // attachments 640 urls ); // attachments
641*/ 641*/
642 642
643} 643}
644 644
645/** 645/**
646 Beams the "WhoAmI contact. 646 Beams the "WhoAmI contact.
647*/ 647*/
648void KABCore::beamMySelf() 648void KABCore::beamMySelf()
649{ 649{
650 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 650 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
651 if (!a.isEmpty()) 651 if (!a.isEmpty())
652 { 652 {
653 QStringList uids; 653 QStringList uids;
654 uids << a.uid(); 654 uids << a.uid();
655 655
656 beamVCard(uids); 656 beamVCard(uids);
657 } else { 657 } else {
658 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 658 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
659 659
660 660
661 } 661 }
662} 662}
663 663
664void KABCore::export2phone() 664void KABCore::export2phone()
665{ 665{
666 666
667 KAex2phonePrefs ex2phone; 667 KAex2phonePrefs ex2phone;
668 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 668 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
669 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 669 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
670 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 670 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
671 671
672 if ( !ex2phone.exec() ) { 672 if ( !ex2phone.exec() ) {
673 return; 673 return;
674 } 674 }
675 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 675 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
676 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 676 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
677 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 677 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
678 678
679 679
680 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 680 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
681 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 681 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
682 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 682 KPimGlobalPrefs::instance()->mEx2PhoneModel );
683 683
684 QStringList uids = mViewManager->selectedUids(); 684 QStringList uids = mViewManager->selectedUids();
685 if ( uids.isEmpty() ) 685 if ( uids.isEmpty() )
686 return; 686 return;
687 687
688#ifdef _WIN32_ 688#ifdef _WIN32_
689 QString fileName = locateLocal("tmp", "tempfile.vcf"); 689 QString fileName = locateLocal("tmp", "tempfile.vcf");
690#else 690#else
691 QString fileName = "/tmp/kdepimtemp.vcf"; 691 QString fileName = "/tmp/kdepimtemp.vcf";
692#endif 692#endif
693 693
694 KABC::VCardConverter converter; 694 KABC::VCardConverter converter;
695 QString description; 695 QString description;
696 QString datastream; 696 QString datastream;
697 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 697 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
698 KABC::Addressee a = mAddressBook->findByUid( *it ); 698 KABC::Addressee a = mAddressBook->findByUid( *it );
699 699
700 if ( a.isEmpty() ) 700 if ( a.isEmpty() )
701 continue; 701 continue;
702 a.simplifyEmails();
703 a.simplifyPhoneNumbers();
704 a.simplifyPhoneNumberTypes();
702 705
703 if (description.isEmpty()) 706 if (description.isEmpty())
704 description = a.formattedName(); 707 description = a.formattedName();
705
706 QString vcard; 708 QString vcard;
709 QString vcardnew;
707 converter.addresseeToVCard( a, vcard ); 710 converter.addresseeToVCard( a, vcard );
708 int start = 0; 711 int start = 0;
709 int next; 712 int next;
710 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 713 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
711 int semi = vcard.find(";", next); 714 int semi = vcard.find(";", next);
712 int dopp = vcard.find(":", next); 715 int dopp = vcard.find(":", next);
713 int sep; 716 int sep;
714 if ( semi < dopp && semi >= 0 ) 717 if ( semi < dopp && semi >= 0 )
715 sep = semi ; 718 sep = semi ;
716 else 719 else
717 sep = dopp; 720 sep = dopp;
718 datastream +=vcard.mid( start, next - start); 721 vcardnew +=vcard.mid( start, next - start);
719 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 722 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
720 start = sep; 723 start = sep;
721 } 724 }
722 datastream += vcard.mid( start,vcard.length() ); 725 vcardnew += vcard.mid( start,vcard.length() );
726 vcard = "";
727 start = 0;
728 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
729 int sep = vcardnew.find(":", next);
730 vcard +=vcardnew.mid( start, next - start+3);
731 start = sep;
732 }
733 vcard += vcardnew.mid( start,vcardnew.length() );
734 vcard.replace ( QRegExp(";;;") , "" );
735 vcard.replace ( QRegExp(";;") , "" );
736 datastream += vcard;
737
723 } 738 }
724 QFile outFile(fileName); 739 QFile outFile(fileName);
725 if ( outFile.open(IO_WriteOnly) ) { 740 if ( outFile.open(IO_WriteOnly) ) {
726 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 741 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
727 QTextStream t( &outFile ); // use a text stream 742 QTextStream t( &outFile ); // use a text stream
728 t.setEncoding( QTextStream::UnicodeUTF8 ); 743 t.setEncoding( QTextStream::UnicodeUTF8 );
729 t <<datastream; 744 t <<datastream;
730 outFile.close(); 745 outFile.close();
731 if ( PhoneAccess::writeToPhone( fileName ) ) 746 if ( PhoneAccess::writeToPhone( fileName ) )
732 qDebug("Export okay "); 747 qDebug("Export okay ");
733 else 748 else
734 qDebug("Error export contacts "); 749 qDebug("Error export contacts ");
735 750
736 } else { 751 } else {
737 qDebug("Error open temp file "); 752 qDebug("Error open temp file ");
738 return; 753 return;
739 } 754 }
740 755
741 756
742#if 0 757#if 0
743 758
744 setCaption( i18n("Writing to phone...")); 759 setCaption( i18n("Writing to phone..."));
745 if ( PhoneFormat::writeToPhone( cal ) ) 760 if ( PhoneFormat::writeToPhone( cal ) )
746 setCaption( i18n("Export to phone successful!")); 761 setCaption( i18n("Export to phone successful!"));
747 else 762 else
748 setCaption( i18n("Error exporting to phone!")); 763 setCaption( i18n("Error exporting to phone!"));
749#endif 764#endif
750 765
751 766
752} 767}
753void KABCore::beamVCard() 768void KABCore::beamVCard()
754{ 769{
755 QStringList uids = mViewManager->selectedUids(); 770 QStringList uids = mViewManager->selectedUids();
756 if ( !uids.isEmpty() ) 771 if ( !uids.isEmpty() )
757 beamVCard( uids ); 772 beamVCard( uids );
758} 773}
759 774
760 775
761void KABCore::beamVCard(const QStringList& uids) 776void KABCore::beamVCard(const QStringList& uids)
762{ 777{
763/*US 778/*US
764 QString beamFilename; 779 QString beamFilename;
765 Opie::OPimContact c; 780 Opie::OPimContact c;
766 if ( actionPersonal->isOn() ) { 781 if ( actionPersonal->isOn() ) {
767 beamFilename = addressbookPersonalVCardName(); 782 beamFilename = addressbookPersonalVCardName();
768 if ( !QFile::exists( beamFilename ) ) 783 if ( !QFile::exists( beamFilename ) )
769 return; // can't beam a non-existent file 784 return; // can't beam a non-existent file
770 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 785 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
771 beamFilename ); 786 beamFilename );
772 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 787 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
773 Opie::OPimContactAccess::List allList = access->allRecords(); 788 Opie::OPimContactAccess::List allList = access->allRecords();
774 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 789 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
775 c = *it; 790 c = *it;
776 791
777 delete access; 792 delete access;
778 } else { 793 } else {
779 unlink( beamfile ); // delete if exists 794 unlink( beamfile ); // delete if exists
780 mkdir("/tmp/obex/", 0755); 795 mkdir("/tmp/obex/", 0755);
781 c = m_abView -> currentEntry(); 796 c = m_abView -> currentEntry();
782 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 797 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
783 beamfile ); 798 beamfile );
784 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 799 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
785 access->add( c ); 800 access->add( c );
786 access->save(); 801 access->save();
787 delete access; 802 delete access;
788 803
789 beamFilename = beamfile; 804 beamFilename = beamfile;
790 } 805 }
791 806
792 owarn << "Beaming: " << beamFilename << oendl; 807 owarn << "Beaming: " << beamFilename << oendl;
793*/ 808*/
794 809
795#if 0 810#if 0
796 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 811 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
797 812
798 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 813 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
799 814
800 QString name = "contact.vcf"; 815 QString name = "contact.vcf";
801 816
802 QString fileName = dirName + "/" + name; 817 QString fileName = dirName + "/" + name;
803#endif 818#endif
804 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 819 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
805 // 820 //
806 QString fileName = "/tmp/kapibeamfile.vcf"; 821 QString fileName = "/tmp/kapibeamfile.vcf";
807 822
808 823
809 //QDir().mkdir( dirName, true ); 824 //QDir().mkdir( dirName, true );
810 825
811 826
812 KABC::VCardConverter converter; 827 KABC::VCardConverter converter;
813 QString description; 828 QString description;
814 QString datastream; 829 QString datastream;
815 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 830 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
816 KABC::Addressee a = mAddressBook->findByUid( *it ); 831 KABC::Addressee a = mAddressBook->findByUid( *it );
817 832
818 if ( a.isEmpty() ) 833 if ( a.isEmpty() )
819 continue; 834 continue;
820 835
821 if (description.isEmpty()) 836 if (description.isEmpty())
822 description = a.formattedName(); 837 description = a.formattedName();
823 838
824 QString vcard; 839 QString vcard;
825 converter.addresseeToVCard( a, vcard ); 840 converter.addresseeToVCard( a, vcard );
826 int start = 0; 841 int start = 0;
827 int next; 842 int next;
828 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 843 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
829 int semi = vcard.find(";", next); 844 int semi = vcard.find(";", next);
830 int dopp = vcard.find(":", next); 845 int dopp = vcard.find(":", next);
831 int sep; 846 int sep;
832 if ( semi < dopp && semi >= 0 ) 847 if ( semi < dopp && semi >= 0 )
833 sep = semi ; 848 sep = semi ;
834 else 849 else
835 sep = dopp; 850 sep = dopp;
836 datastream +=vcard.mid( start, next - start); 851 datastream +=vcard.mid( start, next - start);
837 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 852 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
838 start = sep; 853 start = sep;
839 } 854 }
840 datastream += vcard.mid( start,vcard.length() ); 855 datastream += vcard.mid( start,vcard.length() );
841 } 856 }
842#ifndef DESKTOP_VERSION 857#ifndef DESKTOP_VERSION
843 QFile outFile(fileName); 858 QFile outFile(fileName);
844 if ( outFile.open(IO_WriteOnly) ) { 859 if ( outFile.open(IO_WriteOnly) ) {
845 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 860 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
846 QTextStream t( &outFile ); // use a text stream 861 QTextStream t( &outFile ); // use a text stream
847 t.setEncoding( QTextStream::UnicodeUTF8 ); 862 t.setEncoding( QTextStream::UnicodeUTF8 );
848 t <<datastream; 863 t <<datastream;
849 outFile.close(); 864 outFile.close();
850 Ir *ir = new Ir( this ); 865 Ir *ir = new Ir( this );
851 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 866 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
852 ir->send( fileName, description, "text/x-vCard" ); 867 ir->send( fileName, description, "text/x-vCard" );
853 } else { 868 } else {
854 qDebug("Error open temp beam file "); 869 qDebug("Error open temp beam file ");
855 return; 870 return;
856 } 871 }
857#endif 872#endif
858 873
859} 874}
860 875
861void KABCore::beamDone( Ir *ir ) 876void KABCore::beamDone( Ir *ir )
862{ 877{
863#ifndef DESKTOP_VERSION 878#ifndef DESKTOP_VERSION
864 delete ir; 879 delete ir;
865#endif 880#endif
866} 881}
867 882
868 883
869void KABCore::browse( const QString& url ) 884void KABCore::browse( const QString& url )
870{ 885{
871#ifndef KAB_EMBEDDED 886#ifndef KAB_EMBEDDED
872 kapp->invokeBrowser( url ); 887 kapp->invokeBrowser( url );
873#else //KAB_EMBEDDED 888#else //KAB_EMBEDDED
874 qDebug("KABCore::browse must be fixed"); 889 qDebug("KABCore::browse must be fixed");
875#endif //KAB_EMBEDDED 890#endif //KAB_EMBEDDED
876} 891}
877 892
878void KABCore::selectAllContacts() 893void KABCore::selectAllContacts()
879{ 894{
880 mViewManager->setSelected( QString::null, true ); 895 mViewManager->setSelected( QString::null, true );
881} 896}
882 897
883void KABCore::deleteContacts() 898void KABCore::deleteContacts()
884{ 899{
885 QStringList uidList = mViewManager->selectedUids(); 900 QStringList uidList = mViewManager->selectedUids();
886 deleteContacts( uidList ); 901 deleteContacts( uidList );
887} 902}
888 903
889void KABCore::deleteContacts( const QStringList &uids ) 904void KABCore::deleteContacts( const QStringList &uids )
890{ 905{
891 if ( uids.count() > 0 ) { 906 if ( uids.count() > 0 ) {
892 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 907 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
893 UndoStack::instance()->push( command ); 908 UndoStack::instance()->push( command );
894 RedoStack::instance()->clear(); 909 RedoStack::instance()->clear();
895 910
896 // now if we deleted anything, refresh 911 // now if we deleted anything, refresh
897 setContactSelected( QString::null ); 912 setContactSelected( QString::null );
898 setModified( true ); 913 setModified( true );
899 } 914 }
900} 915}
901 916
902void KABCore::copyContacts() 917void KABCore::copyContacts()
903{ 918{
904 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 919 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
905 920
906 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 921 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
907 922
908 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 923 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
909 924
910 QClipboard *cb = QApplication::clipboard(); 925 QClipboard *cb = QApplication::clipboard();
911 cb->setText( clipText ); 926 cb->setText( clipText );
912} 927}
913 928
914void KABCore::cutContacts() 929void KABCore::cutContacts()
915{ 930{
916 QStringList uidList = mViewManager->selectedUids(); 931 QStringList uidList = mViewManager->selectedUids();
917 932
918//US if ( uidList.size() > 0 ) { 933//US if ( uidList.size() > 0 ) {
919 if ( uidList.count() > 0 ) { 934 if ( uidList.count() > 0 ) {
920 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 935 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
921 UndoStack::instance()->push( command ); 936 UndoStack::instance()->push( command );
922 RedoStack::instance()->clear(); 937 RedoStack::instance()->clear();
923 938
924 setModified( true ); 939 setModified( true );
925 } 940 }
926} 941}
927 942
928void KABCore::pasteContacts() 943void KABCore::pasteContacts()
929{ 944{
930 QClipboard *cb = QApplication::clipboard(); 945 QClipboard *cb = QApplication::clipboard();
931 946
932 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 947 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
933 948
934 pasteContacts( list ); 949 pasteContacts( list );
935} 950}
936 951
937void KABCore::pasteContacts( KABC::Addressee::List &list ) 952void KABCore::pasteContacts( KABC::Addressee::List &list )
938{ 953{
939 KABC::Resource *resource = requestResource( this ); 954 KABC::Resource *resource = requestResource( this );
940 KABC::Addressee::List::Iterator it; 955 KABC::Addressee::List::Iterator it;
941 for ( it = list.begin(); it != list.end(); ++it ) 956 for ( it = list.begin(); it != list.end(); ++it )
942 (*it).setResource( resource ); 957 (*it).setResource( resource );
943 958
944 PwPasteCommand *command = new PwPasteCommand( this, list ); 959 PwPasteCommand *command = new PwPasteCommand( this, list );
945 UndoStack::instance()->push( command ); 960 UndoStack::instance()->push( command );
946 RedoStack::instance()->clear(); 961 RedoStack::instance()->clear();
947 962
948 setModified( true ); 963 setModified( true );
949} 964}
950 965
951void KABCore::setWhoAmI() 966void KABCore::setWhoAmI()
952{ 967{
953 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 968 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
954 969
955 if ( addrList.count() > 1 ) { 970 if ( addrList.count() > 1 ) {
956 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 971 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
957 return; 972 return;
958 } 973 }
959 974
960 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 975 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
961 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 976 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
962 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 977 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
963} 978}
964 979
965void KABCore::setCategories() 980void KABCore::setCategories()
966{ 981{
967 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 982 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
968 if ( !dlg.exec() ) 983 if ( !dlg.exec() )
969 return; 984 return;
970 985
971 bool merge = false; 986 bool merge = false;
972 QString msg = i18n( "Merge with existing categories?" ); 987 QString msg = i18n( "Merge with existing categories?" );
973 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 988 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
974 merge = true; 989 merge = true;
975 990
976 QStringList categories = dlg.selectedCategories(); 991 QStringList categories = dlg.selectedCategories();
977 992
978 QStringList uids = mViewManager->selectedUids(); 993 QStringList uids = mViewManager->selectedUids();
979 QStringList::Iterator it; 994 QStringList::Iterator it;
980 for ( it = uids.begin(); it != uids.end(); ++it ) { 995 for ( it = uids.begin(); it != uids.end(); ++it ) {
981 KABC::Addressee addr = mAddressBook->findByUid( *it ); 996 KABC::Addressee addr = mAddressBook->findByUid( *it );
982 if ( !addr.isEmpty() ) { 997 if ( !addr.isEmpty() ) {
983 if ( !merge ) 998 if ( !merge )
984 addr.setCategories( categories ); 999 addr.setCategories( categories );
985 else { 1000 else {
986 QStringList addrCategories = addr.categories(); 1001 QStringList addrCategories = addr.categories();
987 QStringList::Iterator catIt; 1002 QStringList::Iterator catIt;
988 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1003 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
989 if ( !addrCategories.contains( *catIt ) ) 1004 if ( !addrCategories.contains( *catIt ) )
990 addrCategories.append( *catIt ); 1005 addrCategories.append( *catIt );
991 } 1006 }
992 addr.setCategories( addrCategories ); 1007 addr.setCategories( addrCategories );
993 } 1008 }
994 1009
995 mAddressBook->insertAddressee( addr ); 1010 mAddressBook->insertAddressee( addr );
996 } 1011 }
997 } 1012 }
998 1013
999 if ( uids.count() > 0 ) 1014 if ( uids.count() > 0 )
1000 setModified( true ); 1015 setModified( true );
1001} 1016}
1002 1017
1003void KABCore::setSearchFields( const KABC::Field::List &fields ) 1018void KABCore::setSearchFields( const KABC::Field::List &fields )
1004{ 1019{
1005 mIncSearchWidget->setFields( fields ); 1020 mIncSearchWidget->setFields( fields );
1006} 1021}
1007 1022
1008void KABCore::incrementalSearch( const QString& text ) 1023void KABCore::incrementalSearch( const QString& text )
1009{ 1024{
1010 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1025 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1011} 1026}
1012 1027
1013void KABCore::setModified() 1028void KABCore::setModified()
1014{ 1029{
1015 setModified( true ); 1030 setModified( true );
1016} 1031}
1017 1032
1018void KABCore::setModifiedWOrefresh() 1033void KABCore::setModifiedWOrefresh()
1019{ 1034{
1020 // qDebug("KABCore::setModifiedWOrefresh() "); 1035 // qDebug("KABCore::setModifiedWOrefresh() ");
1021 mModified = true; 1036 mModified = true;
1022 mActionSave->setEnabled( mModified ); 1037 mActionSave->setEnabled( mModified );
1023#ifdef DESKTOP_VERSION 1038#ifdef DESKTOP_VERSION
1024 mDetails->refreshView(); 1039 mDetails->refreshView();
1025#endif 1040#endif
1026 1041
1027} 1042}
1028void KABCore::setModified( bool modified ) 1043void KABCore::setModified( bool modified )
1029{ 1044{
1030 mModified = modified; 1045 mModified = modified;
1031 mActionSave->setEnabled( mModified ); 1046 mActionSave->setEnabled( mModified );
1032 1047
1033 if ( modified ) 1048 if ( modified )
1034 mJumpButtonBar->recreateButtons(); 1049 mJumpButtonBar->recreateButtons();
1035 1050
1036 mViewManager->refreshView(); 1051 mViewManager->refreshView();
1037 mDetails->refreshView(); 1052 mDetails->refreshView();
1038 1053
1039} 1054}
1040 1055
1041bool KABCore::modified() const 1056bool KABCore::modified() const
1042{ 1057{
1043 return mModified; 1058 return mModified;
1044} 1059}
1045 1060
1046void KABCore::contactModified( const KABC::Addressee &addr ) 1061void KABCore::contactModified( const KABC::Addressee &addr )
1047{ 1062{
1048 1063
1049 Command *command = 0; 1064 Command *command = 0;
1050 QString uid; 1065 QString uid;
1051 1066
1052 // check if it exists already 1067 // check if it exists already
1053 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1068 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1054 if ( origAddr.isEmpty() ) 1069 if ( origAddr.isEmpty() )
1055 command = new PwNewCommand( mAddressBook, addr ); 1070 command = new PwNewCommand( mAddressBook, addr );
1056 else { 1071 else {
1057 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1072 command = new PwEditCommand( mAddressBook, origAddr, addr );
1058 uid = addr.uid(); 1073 uid = addr.uid();
1059 } 1074 }
1060 1075
1061 UndoStack::instance()->push( command ); 1076 UndoStack::instance()->push( command );
1062 RedoStack::instance()->clear(); 1077 RedoStack::instance()->clear();
1063 1078
1064 setModified( true ); 1079 setModified( true );
1065} 1080}
1066 1081
1067void KABCore::newContact() 1082void KABCore::newContact()
1068{ 1083{
1069 1084
1070 1085
1071 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1086 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1072 1087
1073 QPtrList<KRES::Resource> kresResources; 1088 QPtrList<KRES::Resource> kresResources;
1074 QPtrListIterator<KABC::Resource> it( kabcResources ); 1089 QPtrListIterator<KABC::Resource> it( kabcResources );
1075 KABC::Resource *resource; 1090 KABC::Resource *resource;
1076 while ( ( resource = it.current() ) != 0 ) { 1091 while ( ( resource = it.current() ) != 0 ) {
1077 ++it; 1092 ++it;
1078 if ( !resource->readOnly() ) { 1093 if ( !resource->readOnly() ) {
1079 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1094 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1080 if ( res ) 1095 if ( res )
1081 kresResources.append( res ); 1096 kresResources.append( res );
1082 } 1097 }
1083 } 1098 }
1084 1099
1085 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1100 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1086 resource = static_cast<KABC::Resource*>( res ); 1101 resource = static_cast<KABC::Resource*>( res );
1087 1102
1088 if ( resource ) { 1103 if ( resource ) {
1089 KABC::Addressee addr; 1104 KABC::Addressee addr;
1090 addr.setResource( resource ); 1105 addr.setResource( resource );
1091 mEditorDialog->setAddressee( addr ); 1106 mEditorDialog->setAddressee( addr );
1092 KApplication::execDialog ( mEditorDialog ); 1107 KApplication::execDialog ( mEditorDialog );
1093 1108
1094 } else 1109 } else
1095 return; 1110 return;
1096 1111
1097 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1112 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1098 1113
1099 1114
1100} 1115}
1101 1116
1102void KABCore::addEmail( QString aStr ) 1117void KABCore::addEmail( QString aStr )
1103{ 1118{
1104#ifndef KAB_EMBEDDED 1119#ifndef KAB_EMBEDDED
1105 QString fullName, email; 1120 QString fullName, email;
1106 1121
1107 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1122 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1108 1123
1109 // Try to lookup the addressee matching the email address 1124 // Try to lookup the addressee matching the email address
1110 bool found = false; 1125 bool found = false;
1111 QStringList emailList; 1126 QStringList emailList;
1112 KABC::AddressBook::Iterator it; 1127 KABC::AddressBook::Iterator it;
1113 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1128 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1114 emailList = (*it).emails(); 1129 emailList = (*it).emails();
1115 if ( emailList.contains( email ) > 0 ) { 1130 if ( emailList.contains( email ) > 0 ) {
1116 found = true; 1131 found = true;
1117 (*it).setNameFromString( fullName ); 1132 (*it).setNameFromString( fullName );
1118 editContact( (*it).uid() ); 1133 editContact( (*it).uid() );
1119 } 1134 }
1120 } 1135 }
1121 1136
1122 if ( !found ) { 1137 if ( !found ) {
1123 KABC::Addressee addr; 1138 KABC::Addressee addr;
1124 addr.setNameFromString( fullName ); 1139 addr.setNameFromString( fullName );
1125 addr.insertEmail( email, true ); 1140 addr.insertEmail( email, true );
1126 1141
1127 mAddressBook->insertAddressee( addr ); 1142 mAddressBook->insertAddressee( addr );
1128 mViewManager->refreshView( addr.uid() ); 1143 mViewManager->refreshView( addr.uid() );
1129 editContact( addr.uid() ); 1144 editContact( addr.uid() );
1130 } 1145 }
1131#else //KAB_EMBEDDED 1146#else //KAB_EMBEDDED
1132 qDebug("KABCore::addEmail finsih method"); 1147 qDebug("KABCore::addEmail finsih method");
1133#endif //KAB_EMBEDDED 1148#endif //KAB_EMBEDDED
1134} 1149}
1135 1150
1136void KABCore::importVCard( const KURL &url, bool showPreview ) 1151void KABCore::importVCard( const KURL &url, bool showPreview )
1137{ 1152{
1138 mXXPortManager->importVCard( url, showPreview ); 1153 mXXPortManager->importVCard( url, showPreview );
1139} 1154}
1140void KABCore::importFromOL() 1155void KABCore::importFromOL()
1141{ 1156{
1142#ifdef _WIN32_ 1157#ifdef _WIN32_
1143 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1158 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1144 idgl->exec(); 1159 idgl->exec();
1145 KABC::Addressee::List list = idgl->getAddressList(); 1160 KABC::Addressee::List list = idgl->getAddressList();
1146 if ( list.count() > 0 ) { 1161 if ( list.count() > 0 ) {
1147 KABC::Addressee::List listNew; 1162 KABC::Addressee::List listNew;
1148 KABC::Addressee::List listExisting; 1163 KABC::Addressee::List listExisting;
1149 KABC::Addressee::List::Iterator it; 1164 KABC::Addressee::List::Iterator it;
1150 KABC::AddressBook::Iterator iter; 1165 KABC::AddressBook::Iterator iter;
1151 for ( it = list.begin(); it != list.end(); ++it ) { 1166 for ( it = list.begin(); it != list.end(); ++it ) {
1152 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1167 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1153 listNew.append( (*it) ); 1168 listNew.append( (*it) );
1154 else 1169 else
1155 listExisting.append( (*it) ); 1170 listExisting.append( (*it) );
1156 } 1171 }
1157 if ( listExisting.count() > 0 ) 1172 if ( listExisting.count() > 0 )
1158 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1173 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1159 if ( listNew.count() > 0 ) { 1174 if ( listNew.count() > 0 ) {
1160 pasteWithNewUid = false; 1175 pasteWithNewUid = false;
1161 pasteContacts( listNew ); 1176 pasteContacts( listNew );
1162 pasteWithNewUid = true; 1177 pasteWithNewUid = true;
1163 } 1178 }
1164 } 1179 }
1165 delete idgl; 1180 delete idgl;
1166#endif 1181#endif
1167} 1182}
1168 1183
1169void KABCore::importVCard( const QString &vCard, bool showPreview ) 1184void KABCore::importVCard( const QString &vCard, bool showPreview )
1170{ 1185{
1171 mXXPortManager->importVCard( vCard, showPreview ); 1186 mXXPortManager->importVCard( vCard, showPreview );
1172} 1187}
1173 1188
1174//US added a second method without defaultparameter 1189//US added a second method without defaultparameter
1175void KABCore::editContact2() { 1190void KABCore::editContact2() {
1176 editContact( QString::null ); 1191 editContact( QString::null );
1177} 1192}
1178 1193
1179void KABCore::editContact( const QString &uid ) 1194void KABCore::editContact( const QString &uid )
1180{ 1195{
1181 1196
1182 if ( mExtensionManager->isQuickEditVisible() ) 1197 if ( mExtensionManager->isQuickEditVisible() )
1183 return; 1198 return;
1184 1199
1185 // First, locate the contact entry 1200 // First, locate the contact entry
1186 QString localUID = uid; 1201 QString localUID = uid;
1187 if ( localUID.isNull() ) { 1202 if ( localUID.isNull() ) {
1188 QStringList uidList = mViewManager->selectedUids(); 1203 QStringList uidList = mViewManager->selectedUids();
1189 if ( uidList.count() > 0 ) 1204 if ( uidList.count() > 0 )
1190 localUID = *( uidList.at( 0 ) ); 1205 localUID = *( uidList.at( 0 ) );
1191 } 1206 }
1192 1207
1193 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1208 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1194 if ( !addr.isEmpty() ) { 1209 if ( !addr.isEmpty() ) {
1195 mEditorDialog->setAddressee( addr ); 1210 mEditorDialog->setAddressee( addr );
1196 KApplication::execDialog ( mEditorDialog ); 1211 KApplication::execDialog ( mEditorDialog );
1197 } 1212 }
1198} 1213}
1199 1214
1200/** 1215/**
1201 Shows or edits the detail view for the given uid. If the uid is QString::null, 1216 Shows or edits the detail view for the given uid. If the uid is QString::null,
1202 the method will try to find a selected addressee in the view. 1217 the method will try to find a selected addressee in the view.
1203 */ 1218 */
1204void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1219void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1205{ 1220{
1206 if ( mMultipleViewsAtOnce ) 1221 if ( mMultipleViewsAtOnce )
1207 { 1222 {
1208 editContact( uid ); 1223 editContact( uid );
1209 } 1224 }
1210 else 1225 else
1211 { 1226 {
1212 setDetailsVisible( true ); 1227 setDetailsVisible( true );
1213 mActionDetails->setChecked(true); 1228 mActionDetails->setChecked(true);
1214 } 1229 }
1215 1230
1216} 1231}
1217 1232
1218void KABCore::save() 1233void KABCore::save()
1219{ 1234{
1220 if (syncManager->blockSave()) 1235 if (syncManager->blockSave())
1221 return; 1236 return;
1222 if ( !mModified ) 1237 if ( !mModified )
1223 return; 1238 return;
1224 1239
1225 syncManager->setBlockSave(true); 1240 syncManager->setBlockSave(true);
1226 QString text = i18n( "There was an error while attempting to save\n the " 1241 QString text = i18n( "There was an error while attempting to save\n the "
1227 "address book. Please check that some \nother application is " 1242 "address book. Please check that some \nother application is "
1228 "not using it. " ); 1243 "not using it. " );
1229 statusMessage(i18n("Saving addressbook ... ")); 1244 statusMessage(i18n("Saving addressbook ... "));
1230#ifndef KAB_EMBEDDED 1245#ifndef KAB_EMBEDDED
1231 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1246 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1232 if ( !b || !b->save() ) { 1247 if ( !b || !b->save() ) {
1233 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1248 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1234 } 1249 }