summaryrefslogtreecommitdiffabout
path: root/kabc/addressee.cpp
authorzautrix <zautrix>2004-09-18 13:13:58 (UTC)
committer zautrix <zautrix>2004-09-18 13:13:58 (UTC)
commitbb16660f29fc709791aa0ee4cb63a40710a994a8 (patch) (unidiff)
tree5d7387987848039bb3594a624b819d136a38b0cd /kabc/addressee.cpp
parent4ec7c78ebd2c5a79ff224e9b07d9a3164f7fe602 (diff)
downloadkdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.zip
kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.gz
kdepimpi-bb16660f29fc709791aa0ee4cb63a40710a994a8.tar.bz2
more AB syncing
Diffstat (limited to 'kabc/addressee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 4cdd5e5..fb32f6e 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -19,34 +19,36 @@
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//US 36//US
36#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <libkcal/syncdefines.h>
37 39
38//US #include "resource.h" 40//US #include "resource.h"
39#include "addressee.h" 41#include "addressee.h"
40 42
41using namespace KABC; 43using namespace KABC;
42 44
43static bool matchBinaryPattern( int value, int pattern ); 45static bool matchBinaryPattern( int value, int pattern );
44 46
45struct Addressee::AddresseeData : public KShared 47struct Addressee::AddresseeData : public KShared
46{ 48{
47 QString uid; 49 QString uid;
48 QString name; 50 QString name;
49 QString formattedName; 51 QString formattedName;
50 QString familyName; 52 QString familyName;
51 QString givenName; 53 QString givenName;
52 QString additionalName; 54 QString additionalName;
@@ -57,61 +59,64 @@ struct Addressee::AddresseeData : public KShared
57 QString mailer; 59 QString mailer;
58 TimeZone timeZone; 60 TimeZone timeZone;
59 Geo geo; 61 Geo geo;
60 QString title; 62 QString title;
61 QString role; 63 QString role;
62 QString organization; 64 QString organization;
63 QString note; 65 QString note;
64 QString productId; 66 QString productId;
65 QDateTime revision; 67 QDateTime revision;
66 QString sortString; 68 QString sortString;
67 KURL url; 69 KURL url;
68 Secrecy secrecy; 70 Secrecy secrecy;
69 Picture logo; 71 Picture logo;
70 Picture photo; 72 Picture photo;
71 Sound sound; 73 Sound sound;
72 Agent agent; 74 Agent agent;
73 75 QString mExternalId;
74 PhoneNumber::List phoneNumbers; 76 PhoneNumber::List phoneNumbers;
75 Address::List addresses; 77 Address::List addresses;
76 Key::List keys; 78 Key::List keys;
77 QStringList emails; 79 QStringList emails;
78 QStringList categories; 80 QStringList categories;
79 QStringList custom; 81 QStringList custom;
80 82
81 Resource *resource; 83 Resource *resource;
82 84
83 bool empty :1; 85 bool empty :1;
84 bool changed :1; 86 bool changed :1;
85}; 87};
86 88
87Addressee::Addressee() 89Addressee::Addressee()
88{ 90{
89 mData = new AddresseeData; 91 mData = new AddresseeData;
90 mData->empty = true; 92 mData->empty = true;
91 mData->changed = false; 93 mData->changed = false;
92 mData->resource = 0; 94 mData->resource = 0;
95 mData->mExternalId = ":";
96 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
93} 97}
94 98
95Addressee::~Addressee() 99Addressee::~Addressee()
96{ 100{
97} 101}
98 102
99Addressee::Addressee( const Addressee &a ) 103Addressee::Addressee( const Addressee &a )
100{ 104{
101 mData = a.mData; 105 mData = a.mData;
106 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
102} 107}
103 108
104Addressee &Addressee::operator=( const Addressee &a ) 109Addressee &Addressee::operator=( const Addressee &a )
105{ 110{
106 mData = a.mData; 111 mData = a.mData;
107 return (*this); 112 return (*this);
108} 113}
109 114
110Addressee Addressee::copy() 115Addressee Addressee::copy()
111{ 116{
112 Addressee a; 117 Addressee a;
113 *(a.mData) = *mData; 118 *(a.mData) = *mData;
114 return a; 119 return a;
115} 120}
116 121
117void Addressee::detach() 122void Addressee::detach()
@@ -155,32 +160,79 @@ bool Addressee::operator==( const Addressee &a ) const
155 if ( mData->emails != a.mData->emails ) return false; 160 if ( mData->emails != a.mData->emails ) return false;
156 if ( mData->categories != a.mData->categories ) return false; 161 if ( mData->categories != a.mData->categories ) return false;
157 if ( mData->custom != a.mData->custom ) return false; 162 if ( mData->custom != a.mData->custom ) return false;
158 163
159 return true; 164 return true;
160} 165}
161 166
162bool Addressee::operator!=( const Addressee &a ) const 167bool Addressee::operator!=( const Addressee &a ) const
163{ 168{
164 return !( a == *this ); 169 return !( a == *this );
165} 170}
166 171
167bool Addressee::isEmpty() const 172bool Addressee::isEmpty() const
168{ 173{
169 return mData->empty; 174 return mData->empty;
170} 175}
176void Addressee::removeID(const QString &prof)
177{
178 detach();
179 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
180
181}
182void Addressee::setID( const QString & prof , const QString & id )
183{
184 detach();
185 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
186}
187void Addressee::setTempSyncStat( int id )
188{
189 mTempSyncStat = id;
190}
191int Addressee::tempSyncStat() const
192{
193 return mTempSyncStat;
194}
195
196QString Addressee::getID( const QString & prof)
197{
198 return KIdManager::getId ( mData->mExternalId, prof );
199}
200
201void Addressee::setCsum( const QString & prof , const QString & id )
202{
203 detach();
204 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
205}
206
207QString Addressee::getCsum( const QString & prof)
208{
209 return KIdManager::getCsum ( mData->mExternalId, prof );
210}
211
212void Addressee::setIDStr( const QString & s )
213{
214 detach();
215 mData->mExternalId = s;
216}
217
218QString Addressee::IDStr() const
219{
220 return mData->mExternalId;
221}
222
171 223
172void Addressee::setUid( const QString &id ) 224void Addressee::setUid( const QString &id )
173{ 225{
174 if ( id == mData->uid ) return; 226 if ( id == mData->uid ) return;
175 detach(); 227 detach();
176 mData->empty = false; 228 mData->empty = false;
177 mData->uid = id; 229 mData->uid = id;
178} 230}
179 231
180QString Addressee::uid() const 232QString Addressee::uid() const
181{ 233{
182 if ( mData->uid.isEmpty() ) 234 if ( mData->uid.isEmpty() )
183 mData->uid = KApplication::randomString( 10 ); 235 mData->uid = KApplication::randomString( 10 );
184 236
185 return mData->uid; 237 return mData->uid;
186} 238}