author | zautrix <zautrix> | 2004-09-21 11:17:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-21 11:17:18 (UTC) |
commit | ba89a5d20eb054054d9cfae3723a4d62b9f62efd (patch) (unidiff) | |
tree | ee1a42079e3204dbab6f45762f83cb4c1712579e | |
parent | 19f445f0b6e7d4591db46b89e877ed9f4332ecd4 (diff) | |
download | kdepimpi-ba89a5d20eb054054d9cfae3723a4d62b9f62efd.zip kdepimpi-ba89a5d20eb054054d9cfae3723a4d62b9f62efd.tar.gz kdepimpi-ba89a5d20eb054054d9cfae3723a4d62b9f62efd.tar.bz2 |
DTM fix
-rw-r--r-- | kabc/addressee.cpp | 1 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 1 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 2 |
3 files changed, 3 insertions, 1 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 31ce1d6..25c77f6 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1082 +1,1083 @@ | |||
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 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (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 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct 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 | ||
93 | Addressee::Addressee() | 93 | Addressee::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 | ||
104 | Addressee::~Addressee() | 104 | Addressee::~Addressee() |
105 | { | 105 | { |
106 | } | 106 | } |
107 | 107 | ||
108 | Addressee::Addressee( const Addressee &a ) | 108 | Addressee::Addressee( const Addressee &a ) |
109 | { | 109 | { |
110 | mData = a.mData; | 110 | mData = a.mData; |
111 | } | 111 | } |
112 | 112 | ||
113 | Addressee &Addressee::operator=( const Addressee &a ) | 113 | Addressee &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 | ||
119 | Addressee Addressee::copy() | 119 | Addressee 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 | ||
126 | void Addressee::detach() | 126 | void 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 | ||
132 | bool Addressee::operator==( const Addressee &a ) const | 132 | bool 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 | ||
171 | bool Addressee::operator!=( const Addressee &a ) const | 171 | bool Addressee::operator!=( const Addressee &a ) const |
172 | { | 172 | { |
173 | return !( a == *this ); | 173 | return !( a == *this ); |
174 | } | 174 | } |
175 | 175 | ||
176 | bool Addressee::isEmpty() const | 176 | bool Addressee::isEmpty() const |
177 | { | 177 | { |
178 | return mData->empty; | 178 | return mData->empty; |
179 | } | 179 | } |
180 | ulong Addressee::getCsum4List( const QStringList & attList) | 180 | ulong 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 | } |
208 | void Addressee::computeCsum(const QString &dev) | 208 | void 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 | ||
279 | void Addressee::mergeContact( const Addressee& ad ) | 279 | void 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 | } | 316 | } |
316 | 317 | ||
317 | void Addressee::removeID(const QString &prof) | 318 | void Addressee::removeID(const QString &prof) |
318 | { | 319 | { |
319 | detach(); | 320 | detach(); |
320 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 321 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
321 | 322 | ||
322 | } | 323 | } |
323 | void Addressee::setID( const QString & prof , const QString & id ) | 324 | void Addressee::setID( const QString & prof , const QString & id ) |
324 | { | 325 | { |
325 | detach(); | 326 | detach(); |
326 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 327 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
327 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 328 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
328 | } | 329 | } |
329 | void Addressee::setTempSyncStat( int id ) | 330 | void Addressee::setTempSyncStat( int id ) |
330 | { | 331 | { |
331 | if ( mData->mTempSyncStat == id ) return; | 332 | if ( mData->mTempSyncStat == id ) return; |
332 | detach(); | 333 | detach(); |
333 | mData->mTempSyncStat = id; | 334 | mData->mTempSyncStat = id; |
334 | } | 335 | } |
335 | int Addressee::tempSyncStat() const | 336 | int Addressee::tempSyncStat() const |
336 | { | 337 | { |
337 | return mData->mTempSyncStat; | 338 | return mData->mTempSyncStat; |
338 | } | 339 | } |
339 | 340 | ||
340 | QString Addressee::getID( const QString & prof) | 341 | QString Addressee::getID( const QString & prof) |
341 | { | 342 | { |
342 | return KIdManager::getId ( mData->mExternalId, prof ); | 343 | return KIdManager::getId ( mData->mExternalId, prof ); |
343 | } | 344 | } |
344 | 345 | ||
345 | void Addressee::setCsum( const QString & prof , const QString & id ) | 346 | void Addressee::setCsum( const QString & prof , const QString & id ) |
346 | { | 347 | { |
347 | detach(); | 348 | detach(); |
348 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 349 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
349 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 350 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
350 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 351 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
351 | } | 352 | } |
352 | 353 | ||
353 | QString Addressee::getCsum( const QString & prof) | 354 | QString Addressee::getCsum( const QString & prof) |
354 | { | 355 | { |
355 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 356 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
356 | } | 357 | } |
357 | 358 | ||
358 | void Addressee::setIDStr( const QString & s ) | 359 | void Addressee::setIDStr( const QString & s ) |
359 | { | 360 | { |
360 | detach(); | 361 | detach(); |
361 | mData->mExternalId = s; | 362 | mData->mExternalId = s; |
362 | } | 363 | } |
363 | 364 | ||
364 | QString Addressee::IDStr() const | 365 | QString Addressee::IDStr() const |
365 | { | 366 | { |
366 | return mData->mExternalId; | 367 | return mData->mExternalId; |
367 | } | 368 | } |
368 | 369 | ||
369 | void Addressee::setExternalUID( const QString &id ) | 370 | void Addressee::setExternalUID( const QString &id ) |
370 | { | 371 | { |
371 | if ( id == mData->externalUID ) return; | 372 | if ( id == mData->externalUID ) return; |
372 | detach(); | 373 | detach(); |
373 | mData->empty = false; | 374 | mData->empty = false; |
374 | mData->externalUID = id; | 375 | mData->externalUID = id; |
375 | } | 376 | } |
376 | 377 | ||
377 | QString Addressee::externalUID() const | 378 | QString Addressee::externalUID() const |
378 | { | 379 | { |
379 | return mData->externalUID; | 380 | return mData->externalUID; |
380 | } | 381 | } |
381 | void Addressee::setOriginalExternalUID( const QString &id ) | 382 | void Addressee::setOriginalExternalUID( const QString &id ) |
382 | { | 383 | { |
383 | if ( id == mData->originalExternalUID ) return; | 384 | if ( id == mData->originalExternalUID ) return; |
384 | detach(); | 385 | detach(); |
385 | mData->empty = false; | 386 | mData->empty = false; |
386 | //qDebug("*******Set orig uid %s ", id.latin1()); | 387 | //qDebug("*******Set orig uid %s ", id.latin1()); |
387 | mData->originalExternalUID = id; | 388 | mData->originalExternalUID = id; |
388 | } | 389 | } |
389 | 390 | ||
390 | QString Addressee::originalExternalUID() const | 391 | QString Addressee::originalExternalUID() const |
391 | { | 392 | { |
392 | return mData->originalExternalUID; | 393 | return mData->originalExternalUID; |
393 | } | 394 | } |
394 | 395 | ||
395 | void Addressee::setUid( const QString &id ) | 396 | void Addressee::setUid( const QString &id ) |
396 | { | 397 | { |
397 | if ( id == mData->uid ) return; | 398 | if ( id == mData->uid ) return; |
398 | detach(); | 399 | detach(); |
399 | //qDebug("****setuid %s ", id.latin1()); | 400 | //qDebug("****setuid %s ", id.latin1()); |
400 | mData->empty = false; | 401 | mData->empty = false; |
401 | mData->uid = id; | 402 | mData->uid = id; |
402 | } | 403 | } |
403 | 404 | ||
404 | QString Addressee::uid() const | 405 | QString Addressee::uid() const |
405 | { | 406 | { |
406 | if ( mData->uid.isEmpty() ) | 407 | if ( mData->uid.isEmpty() ) |
407 | mData->uid = KApplication::randomString( 10 ); | 408 | mData->uid = KApplication::randomString( 10 ); |
408 | 409 | ||
409 | return mData->uid; | 410 | return mData->uid; |
410 | } | 411 | } |
411 | 412 | ||
412 | QString Addressee::uidLabel() | 413 | QString Addressee::uidLabel() |
413 | { | 414 | { |
414 | return i18n("Unique Identifier"); | 415 | return i18n("Unique Identifier"); |
415 | } | 416 | } |
416 | 417 | ||
417 | void Addressee::setName( const QString &name ) | 418 | void Addressee::setName( const QString &name ) |
418 | { | 419 | { |
419 | if ( name == mData->name ) return; | 420 | if ( name == mData->name ) return; |
420 | detach(); | 421 | detach(); |
421 | mData->empty = false; | 422 | mData->empty = false; |
422 | mData->name = name; | 423 | mData->name = name; |
423 | } | 424 | } |
424 | 425 | ||
425 | QString Addressee::name() const | 426 | QString Addressee::name() const |
426 | { | 427 | { |
427 | return mData->name; | 428 | return mData->name; |
428 | } | 429 | } |
429 | 430 | ||
430 | QString Addressee::nameLabel() | 431 | QString Addressee::nameLabel() |
431 | { | 432 | { |
432 | return i18n("Name"); | 433 | return i18n("Name"); |
433 | } | 434 | } |
434 | 435 | ||
435 | 436 | ||
436 | void Addressee::setFormattedName( const QString &formattedName ) | 437 | void Addressee::setFormattedName( const QString &formattedName ) |
437 | { | 438 | { |
438 | if ( formattedName == mData->formattedName ) return; | 439 | if ( formattedName == mData->formattedName ) return; |
439 | detach(); | 440 | detach(); |
440 | mData->empty = false; | 441 | mData->empty = false; |
441 | mData->formattedName = formattedName; | 442 | mData->formattedName = formattedName; |
442 | } | 443 | } |
443 | 444 | ||
444 | QString Addressee::formattedName() const | 445 | QString Addressee::formattedName() const |
445 | { | 446 | { |
446 | return mData->formattedName; | 447 | return mData->formattedName; |
447 | } | 448 | } |
448 | 449 | ||
449 | QString Addressee::formattedNameLabel() | 450 | QString Addressee::formattedNameLabel() |
450 | { | 451 | { |
451 | return i18n("Formatted Name"); | 452 | return i18n("Formatted Name"); |
452 | } | 453 | } |
453 | 454 | ||
454 | 455 | ||
455 | void Addressee::setFamilyName( const QString &familyName ) | 456 | void Addressee::setFamilyName( const QString &familyName ) |
456 | { | 457 | { |
457 | if ( familyName == mData->familyName ) return; | 458 | if ( familyName == mData->familyName ) return; |
458 | detach(); | 459 | detach(); |
459 | mData->empty = false; | 460 | mData->empty = false; |
460 | mData->familyName = familyName; | 461 | mData->familyName = familyName; |
461 | } | 462 | } |
462 | 463 | ||
463 | QString Addressee::familyName() const | 464 | QString Addressee::familyName() const |
464 | { | 465 | { |
465 | return mData->familyName; | 466 | return mData->familyName; |
466 | } | 467 | } |
467 | 468 | ||
468 | QString Addressee::familyNameLabel() | 469 | QString Addressee::familyNameLabel() |
469 | { | 470 | { |
470 | return i18n("Family Name"); | 471 | return i18n("Family Name"); |
471 | } | 472 | } |
472 | 473 | ||
473 | 474 | ||
474 | void Addressee::setGivenName( const QString &givenName ) | 475 | void Addressee::setGivenName( const QString &givenName ) |
475 | { | 476 | { |
476 | if ( givenName == mData->givenName ) return; | 477 | if ( givenName == mData->givenName ) return; |
477 | detach(); | 478 | detach(); |
478 | mData->empty = false; | 479 | mData->empty = false; |
479 | mData->givenName = givenName; | 480 | mData->givenName = givenName; |
480 | } | 481 | } |
481 | 482 | ||
482 | QString Addressee::givenName() const | 483 | QString Addressee::givenName() const |
483 | { | 484 | { |
484 | return mData->givenName; | 485 | return mData->givenName; |
485 | } | 486 | } |
486 | 487 | ||
487 | QString Addressee::givenNameLabel() | 488 | QString Addressee::givenNameLabel() |
488 | { | 489 | { |
489 | return i18n("Given Name"); | 490 | return i18n("Given Name"); |
490 | } | 491 | } |
491 | 492 | ||
492 | 493 | ||
493 | void Addressee::setAdditionalName( const QString &additionalName ) | 494 | void Addressee::setAdditionalName( const QString &additionalName ) |
494 | { | 495 | { |
495 | if ( additionalName == mData->additionalName ) return; | 496 | if ( additionalName == mData->additionalName ) return; |
496 | detach(); | 497 | detach(); |
497 | mData->empty = false; | 498 | mData->empty = false; |
498 | mData->additionalName = additionalName; | 499 | mData->additionalName = additionalName; |
499 | } | 500 | } |
500 | 501 | ||
501 | QString Addressee::additionalName() const | 502 | QString Addressee::additionalName() const |
502 | { | 503 | { |
503 | return mData->additionalName; | 504 | return mData->additionalName; |
504 | } | 505 | } |
505 | 506 | ||
506 | QString Addressee::additionalNameLabel() | 507 | QString Addressee::additionalNameLabel() |
507 | { | 508 | { |
508 | return i18n("Additional Names"); | 509 | return i18n("Additional Names"); |
509 | } | 510 | } |
510 | 511 | ||
511 | 512 | ||
512 | void Addressee::setPrefix( const QString &prefix ) | 513 | void Addressee::setPrefix( const QString &prefix ) |
513 | { | 514 | { |
514 | if ( prefix == mData->prefix ) return; | 515 | if ( prefix == mData->prefix ) return; |
515 | detach(); | 516 | detach(); |
516 | mData->empty = false; | 517 | mData->empty = false; |
517 | mData->prefix = prefix; | 518 | mData->prefix = prefix; |
518 | } | 519 | } |
519 | 520 | ||
520 | QString Addressee::prefix() const | 521 | QString Addressee::prefix() const |
521 | { | 522 | { |
522 | return mData->prefix; | 523 | return mData->prefix; |
523 | } | 524 | } |
524 | 525 | ||
525 | QString Addressee::prefixLabel() | 526 | QString Addressee::prefixLabel() |
526 | { | 527 | { |
527 | return i18n("Honorific Prefixes"); | 528 | return i18n("Honorific Prefixes"); |
528 | } | 529 | } |
529 | 530 | ||
530 | 531 | ||
531 | void Addressee::setSuffix( const QString &suffix ) | 532 | void Addressee::setSuffix( const QString &suffix ) |
532 | { | 533 | { |
533 | if ( suffix == mData->suffix ) return; | 534 | if ( suffix == mData->suffix ) return; |
534 | detach(); | 535 | detach(); |
535 | mData->empty = false; | 536 | mData->empty = false; |
536 | mData->suffix = suffix; | 537 | mData->suffix = suffix; |
537 | } | 538 | } |
538 | 539 | ||
539 | QString Addressee::suffix() const | 540 | QString Addressee::suffix() const |
540 | { | 541 | { |
541 | return mData->suffix; | 542 | return mData->suffix; |
542 | } | 543 | } |
543 | 544 | ||
544 | QString Addressee::suffixLabel() | 545 | QString Addressee::suffixLabel() |
545 | { | 546 | { |
546 | return i18n("Honorific Suffixes"); | 547 | return i18n("Honorific Suffixes"); |
547 | } | 548 | } |
548 | 549 | ||
549 | 550 | ||
550 | void Addressee::setNickName( const QString &nickName ) | 551 | void Addressee::setNickName( const QString &nickName ) |
551 | { | 552 | { |
552 | if ( nickName == mData->nickName ) return; | 553 | if ( nickName == mData->nickName ) return; |
553 | detach(); | 554 | detach(); |
554 | mData->empty = false; | 555 | mData->empty = false; |
555 | mData->nickName = nickName; | 556 | mData->nickName = nickName; |
556 | } | 557 | } |
557 | 558 | ||
558 | QString Addressee::nickName() const | 559 | QString Addressee::nickName() const |
559 | { | 560 | { |
560 | return mData->nickName; | 561 | return mData->nickName; |
561 | } | 562 | } |
562 | 563 | ||
563 | QString Addressee::nickNameLabel() | 564 | QString Addressee::nickNameLabel() |
564 | { | 565 | { |
565 | return i18n("Nick Name"); | 566 | return i18n("Nick Name"); |
566 | } | 567 | } |
567 | 568 | ||
568 | 569 | ||
569 | void Addressee::setBirthday( const QDateTime &birthday ) | 570 | void Addressee::setBirthday( const QDateTime &birthday ) |
570 | { | 571 | { |
571 | if ( birthday == mData->birthday ) return; | 572 | if ( birthday == mData->birthday ) return; |
572 | detach(); | 573 | detach(); |
573 | mData->empty = false; | 574 | mData->empty = false; |
574 | mData->birthday = birthday; | 575 | mData->birthday = birthday; |
575 | } | 576 | } |
576 | 577 | ||
577 | QDateTime Addressee::birthday() const | 578 | QDateTime Addressee::birthday() const |
578 | { | 579 | { |
579 | return mData->birthday; | 580 | return mData->birthday; |
580 | } | 581 | } |
581 | 582 | ||
582 | QString Addressee::birthdayLabel() | 583 | QString Addressee::birthdayLabel() |
583 | { | 584 | { |
584 | return i18n("Birthday"); | 585 | return i18n("Birthday"); |
585 | } | 586 | } |
586 | 587 | ||
587 | 588 | ||
588 | QString Addressee::homeAddressStreetLabel() | 589 | QString Addressee::homeAddressStreetLabel() |
589 | { | 590 | { |
590 | return i18n("Home Address Street"); | 591 | return i18n("Home Address Street"); |
591 | } | 592 | } |
592 | 593 | ||
593 | 594 | ||
594 | QString Addressee::homeAddressLocalityLabel() | 595 | QString Addressee::homeAddressLocalityLabel() |
595 | { | 596 | { |
596 | return i18n("Home Address Locality"); | 597 | return i18n("Home Address Locality"); |
597 | } | 598 | } |
598 | 599 | ||
599 | 600 | ||
600 | QString Addressee::homeAddressRegionLabel() | 601 | QString Addressee::homeAddressRegionLabel() |
601 | { | 602 | { |
602 | return i18n("Home Address Region"); | 603 | return i18n("Home Address Region"); |
603 | } | 604 | } |
604 | 605 | ||
605 | 606 | ||
606 | QString Addressee::homeAddressPostalCodeLabel() | 607 | QString Addressee::homeAddressPostalCodeLabel() |
607 | { | 608 | { |
608 | return i18n("Home Address Postal Code"); | 609 | return i18n("Home Address Postal Code"); |
609 | } | 610 | } |
610 | 611 | ||
611 | 612 | ||
612 | QString Addressee::homeAddressCountryLabel() | 613 | QString Addressee::homeAddressCountryLabel() |
613 | { | 614 | { |
614 | return i18n("Home Address Country"); | 615 | return i18n("Home Address Country"); |
615 | } | 616 | } |
616 | 617 | ||
617 | 618 | ||
618 | QString Addressee::homeAddressLabelLabel() | 619 | QString Addressee::homeAddressLabelLabel() |
619 | { | 620 | { |
620 | return i18n("Home Address Label"); | 621 | return i18n("Home Address Label"); |
621 | } | 622 | } |
622 | 623 | ||
623 | 624 | ||
624 | QString Addressee::businessAddressStreetLabel() | 625 | QString Addressee::businessAddressStreetLabel() |
625 | { | 626 | { |
626 | return i18n("Business Address Street"); | 627 | return i18n("Business Address Street"); |
627 | } | 628 | } |
628 | 629 | ||
629 | 630 | ||
630 | QString Addressee::businessAddressLocalityLabel() | 631 | QString Addressee::businessAddressLocalityLabel() |
631 | { | 632 | { |
632 | return i18n("Business Address Locality"); | 633 | return i18n("Business Address Locality"); |
633 | } | 634 | } |
634 | 635 | ||
635 | 636 | ||
636 | QString Addressee::businessAddressRegionLabel() | 637 | QString Addressee::businessAddressRegionLabel() |
637 | { | 638 | { |
638 | return i18n("Business Address Region"); | 639 | return i18n("Business Address Region"); |
639 | } | 640 | } |
640 | 641 | ||
641 | 642 | ||
642 | QString Addressee::businessAddressPostalCodeLabel() | 643 | QString Addressee::businessAddressPostalCodeLabel() |
643 | { | 644 | { |
644 | return i18n("Business Address Postal Code"); | 645 | return i18n("Business Address Postal Code"); |
645 | } | 646 | } |
646 | 647 | ||
647 | 648 | ||
648 | QString Addressee::businessAddressCountryLabel() | 649 | QString Addressee::businessAddressCountryLabel() |
649 | { | 650 | { |
650 | return i18n("Business Address Country"); | 651 | return i18n("Business Address Country"); |
651 | } | 652 | } |
652 | 653 | ||
653 | 654 | ||
654 | QString Addressee::businessAddressLabelLabel() | 655 | QString Addressee::businessAddressLabelLabel() |
655 | { | 656 | { |
656 | return i18n("Business Address Label"); | 657 | return i18n("Business Address Label"); |
657 | } | 658 | } |
658 | 659 | ||
659 | 660 | ||
660 | QString Addressee::homePhoneLabel() | 661 | QString Addressee::homePhoneLabel() |
661 | { | 662 | { |
662 | return i18n("Home Phone"); | 663 | return i18n("Home Phone"); |
663 | } | 664 | } |
664 | 665 | ||
665 | 666 | ||
666 | QString Addressee::businessPhoneLabel() | 667 | QString Addressee::businessPhoneLabel() |
667 | { | 668 | { |
668 | return i18n("Business Phone"); | 669 | return i18n("Business Phone"); |
669 | } | 670 | } |
670 | 671 | ||
671 | 672 | ||
672 | QString Addressee::mobilePhoneLabel() | 673 | QString Addressee::mobilePhoneLabel() |
673 | { | 674 | { |
674 | return i18n("Mobile Phone"); | 675 | return i18n("Mobile Phone"); |
675 | } | 676 | } |
676 | 677 | ||
677 | 678 | ||
678 | QString Addressee::homeFaxLabel() | 679 | QString Addressee::homeFaxLabel() |
679 | { | 680 | { |
680 | return i18n("Home Fax"); | 681 | return i18n("Home Fax"); |
681 | } | 682 | } |
682 | 683 | ||
683 | 684 | ||
684 | QString Addressee::businessFaxLabel() | 685 | QString Addressee::businessFaxLabel() |
685 | { | 686 | { |
686 | return i18n("Business Fax"); | 687 | return i18n("Business Fax"); |
687 | } | 688 | } |
688 | 689 | ||
689 | 690 | ||
690 | QString Addressee::carPhoneLabel() | 691 | QString Addressee::carPhoneLabel() |
691 | { | 692 | { |
692 | return i18n("Car Phone"); | 693 | return i18n("Car Phone"); |
693 | } | 694 | } |
694 | 695 | ||
695 | 696 | ||
696 | QString Addressee::isdnLabel() | 697 | QString Addressee::isdnLabel() |
697 | { | 698 | { |
698 | return i18n("ISDN"); | 699 | return i18n("ISDN"); |
699 | } | 700 | } |
700 | 701 | ||
701 | 702 | ||
702 | QString Addressee::pagerLabel() | 703 | QString Addressee::pagerLabel() |
703 | { | 704 | { |
704 | return i18n("Pager"); | 705 | return i18n("Pager"); |
705 | } | 706 | } |
706 | 707 | ||
707 | QString Addressee::sipLabel() | 708 | QString Addressee::sipLabel() |
708 | { | 709 | { |
709 | return i18n("SIP"); | 710 | return i18n("SIP"); |
710 | } | 711 | } |
711 | 712 | ||
712 | QString Addressee::emailLabel() | 713 | QString Addressee::emailLabel() |
713 | { | 714 | { |
714 | return i18n("Email Address"); | 715 | return i18n("Email Address"); |
715 | } | 716 | } |
716 | 717 | ||
717 | 718 | ||
718 | void Addressee::setMailer( const QString &mailer ) | 719 | void Addressee::setMailer( const QString &mailer ) |
719 | { | 720 | { |
720 | if ( mailer == mData->mailer ) return; | 721 | if ( mailer == mData->mailer ) return; |
721 | detach(); | 722 | detach(); |
722 | mData->empty = false; | 723 | mData->empty = false; |
723 | mData->mailer = mailer; | 724 | mData->mailer = mailer; |
724 | } | 725 | } |
725 | 726 | ||
726 | QString Addressee::mailer() const | 727 | QString Addressee::mailer() const |
727 | { | 728 | { |
728 | return mData->mailer; | 729 | return mData->mailer; |
729 | } | 730 | } |
730 | 731 | ||
731 | QString Addressee::mailerLabel() | 732 | QString Addressee::mailerLabel() |
732 | { | 733 | { |
733 | return i18n("Mail Client"); | 734 | return i18n("Mail Client"); |
734 | } | 735 | } |
735 | 736 | ||
736 | 737 | ||
737 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 738 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
738 | { | 739 | { |
739 | if ( timeZone == mData->timeZone ) return; | 740 | if ( timeZone == mData->timeZone ) return; |
740 | detach(); | 741 | detach(); |
741 | mData->empty = false; | 742 | mData->empty = false; |
742 | mData->timeZone = timeZone; | 743 | mData->timeZone = timeZone; |
743 | } | 744 | } |
744 | 745 | ||
745 | TimeZone Addressee::timeZone() const | 746 | TimeZone Addressee::timeZone() const |
746 | { | 747 | { |
747 | return mData->timeZone; | 748 | return mData->timeZone; |
748 | } | 749 | } |
749 | 750 | ||
750 | QString Addressee::timeZoneLabel() | 751 | QString Addressee::timeZoneLabel() |
751 | { | 752 | { |
752 | return i18n("Time Zone"); | 753 | return i18n("Time Zone"); |
753 | } | 754 | } |
754 | 755 | ||
755 | 756 | ||
756 | void Addressee::setGeo( const Geo &geo ) | 757 | void Addressee::setGeo( const Geo &geo ) |
757 | { | 758 | { |
758 | if ( geo == mData->geo ) return; | 759 | if ( geo == mData->geo ) return; |
759 | detach(); | 760 | detach(); |
760 | mData->empty = false; | 761 | mData->empty = false; |
761 | mData->geo = geo; | 762 | mData->geo = geo; |
762 | } | 763 | } |
763 | 764 | ||
764 | Geo Addressee::geo() const | 765 | Geo Addressee::geo() const |
765 | { | 766 | { |
766 | return mData->geo; | 767 | return mData->geo; |
767 | } | 768 | } |
768 | 769 | ||
769 | QString Addressee::geoLabel() | 770 | QString Addressee::geoLabel() |
770 | { | 771 | { |
771 | return i18n("Geographic Position"); | 772 | return i18n("Geographic Position"); |
772 | } | 773 | } |
773 | 774 | ||
774 | 775 | ||
775 | void Addressee::setTitle( const QString &title ) | 776 | void Addressee::setTitle( const QString &title ) |
776 | { | 777 | { |
777 | if ( title == mData->title ) return; | 778 | if ( title == mData->title ) return; |
778 | detach(); | 779 | detach(); |
779 | mData->empty = false; | 780 | mData->empty = false; |
780 | mData->title = title; | 781 | mData->title = title; |
781 | } | 782 | } |
782 | 783 | ||
783 | QString Addressee::title() const | 784 | QString Addressee::title() const |
784 | { | 785 | { |
785 | return mData->title; | 786 | return mData->title; |
786 | } | 787 | } |
787 | 788 | ||
788 | QString Addressee::titleLabel() | 789 | QString Addressee::titleLabel() |
789 | { | 790 | { |
790 | return i18n("Title"); | 791 | return i18n("Title"); |
791 | } | 792 | } |
792 | 793 | ||
793 | 794 | ||
794 | void Addressee::setRole( const QString &role ) | 795 | void Addressee::setRole( const QString &role ) |
795 | { | 796 | { |
796 | if ( role == mData->role ) return; | 797 | if ( role == mData->role ) return; |
797 | detach(); | 798 | detach(); |
798 | mData->empty = false; | 799 | mData->empty = false; |
799 | mData->role = role; | 800 | mData->role = role; |
800 | } | 801 | } |
801 | 802 | ||
802 | QString Addressee::role() const | 803 | QString Addressee::role() const |
803 | { | 804 | { |
804 | return mData->role; | 805 | return mData->role; |
805 | } | 806 | } |
806 | 807 | ||
807 | QString Addressee::roleLabel() | 808 | QString Addressee::roleLabel() |
808 | { | 809 | { |
809 | return i18n("Role"); | 810 | return i18n("Role"); |
810 | } | 811 | } |
811 | 812 | ||
812 | 813 | ||
813 | void Addressee::setOrganization( const QString &organization ) | 814 | void Addressee::setOrganization( const QString &organization ) |
814 | { | 815 | { |
815 | if ( organization == mData->organization ) return; | 816 | if ( organization == mData->organization ) return; |
816 | detach(); | 817 | detach(); |
817 | mData->empty = false; | 818 | mData->empty = false; |
818 | mData->organization = organization; | 819 | mData->organization = organization; |
819 | } | 820 | } |
820 | 821 | ||
821 | QString Addressee::organization() const | 822 | QString Addressee::organization() const |
822 | { | 823 | { |
823 | return mData->organization; | 824 | return mData->organization; |
824 | } | 825 | } |
825 | 826 | ||
826 | QString Addressee::organizationLabel() | 827 | QString Addressee::organizationLabel() |
827 | { | 828 | { |
828 | return i18n("Organization"); | 829 | return i18n("Organization"); |
829 | } | 830 | } |
830 | 831 | ||
831 | 832 | ||
832 | void Addressee::setNote( const QString ¬e ) | 833 | void Addressee::setNote( const QString ¬e ) |
833 | { | 834 | { |
834 | if ( note == mData->note ) return; | 835 | if ( note == mData->note ) return; |
835 | detach(); | 836 | detach(); |
836 | mData->empty = false; | 837 | mData->empty = false; |
837 | mData->note = note; | 838 | mData->note = note; |
838 | } | 839 | } |
839 | 840 | ||
840 | QString Addressee::note() const | 841 | QString Addressee::note() const |
841 | { | 842 | { |
842 | return mData->note; | 843 | return mData->note; |
843 | } | 844 | } |
844 | 845 | ||
845 | QString Addressee::noteLabel() | 846 | QString Addressee::noteLabel() |
846 | { | 847 | { |
847 | return i18n("Note"); | 848 | return i18n("Note"); |
848 | } | 849 | } |
849 | 850 | ||
850 | 851 | ||
851 | void Addressee::setProductId( const QString &productId ) | 852 | void Addressee::setProductId( const QString &productId ) |
852 | { | 853 | { |
853 | if ( productId == mData->productId ) return; | 854 | if ( productId == mData->productId ) return; |
854 | detach(); | 855 | detach(); |
855 | mData->empty = false; | 856 | mData->empty = false; |
856 | mData->productId = productId; | 857 | mData->productId = productId; |
857 | } | 858 | } |
858 | 859 | ||
859 | QString Addressee::productId() const | 860 | QString Addressee::productId() const |
860 | { | 861 | { |
861 | return mData->productId; | 862 | return mData->productId; |
862 | } | 863 | } |
863 | 864 | ||
864 | QString Addressee::productIdLabel() | 865 | QString Addressee::productIdLabel() |
865 | { | 866 | { |
866 | return i18n("Product Identifier"); | 867 | return i18n("Product Identifier"); |
867 | } | 868 | } |
868 | 869 | ||
869 | 870 | ||
870 | void Addressee::setRevision( const QDateTime &revision ) | 871 | void Addressee::setRevision( const QDateTime &revision ) |
871 | { | 872 | { |
872 | if ( revision == mData->revision ) return; | 873 | if ( revision == mData->revision ) return; |
873 | detach(); | 874 | detach(); |
874 | mData->empty = false; | 875 | mData->empty = false; |
875 | mData->revision = revision; | 876 | mData->revision = revision; |
876 | } | 877 | } |
877 | 878 | ||
878 | QDateTime Addressee::revision() const | 879 | QDateTime Addressee::revision() const |
879 | { | 880 | { |
880 | return mData->revision; | 881 | return mData->revision; |
881 | } | 882 | } |
882 | 883 | ||
883 | QString Addressee::revisionLabel() | 884 | QString Addressee::revisionLabel() |
884 | { | 885 | { |
885 | return i18n("Revision Date"); | 886 | return i18n("Revision Date"); |
886 | } | 887 | } |
887 | 888 | ||
888 | 889 | ||
889 | void Addressee::setSortString( const QString &sortString ) | 890 | void Addressee::setSortString( const QString &sortString ) |
890 | { | 891 | { |
891 | if ( sortString == mData->sortString ) return; | 892 | if ( sortString == mData->sortString ) return; |
892 | detach(); | 893 | detach(); |
893 | mData->empty = false; | 894 | mData->empty = false; |
894 | mData->sortString = sortString; | 895 | mData->sortString = sortString; |
895 | } | 896 | } |
896 | 897 | ||
897 | QString Addressee::sortString() const | 898 | QString Addressee::sortString() const |
898 | { | 899 | { |
899 | return mData->sortString; | 900 | return mData->sortString; |
900 | } | 901 | } |
901 | 902 | ||
902 | QString Addressee::sortStringLabel() | 903 | QString Addressee::sortStringLabel() |
903 | { | 904 | { |
904 | return i18n("Sort String"); | 905 | return i18n("Sort String"); |
905 | } | 906 | } |
906 | 907 | ||
907 | 908 | ||
908 | void Addressee::setUrl( const KURL &url ) | 909 | void Addressee::setUrl( const KURL &url ) |
909 | { | 910 | { |
910 | if ( url == mData->url ) return; | 911 | if ( url == mData->url ) return; |
911 | detach(); | 912 | detach(); |
912 | mData->empty = false; | 913 | mData->empty = false; |
913 | mData->url = url; | 914 | mData->url = url; |
914 | } | 915 | } |
915 | 916 | ||
916 | KURL Addressee::url() const | 917 | KURL Addressee::url() const |
917 | { | 918 | { |
918 | return mData->url; | 919 | return mData->url; |
919 | } | 920 | } |
920 | 921 | ||
921 | QString Addressee::urlLabel() | 922 | QString Addressee::urlLabel() |
922 | { | 923 | { |
923 | return i18n("URL"); | 924 | return i18n("URL"); |
924 | } | 925 | } |
925 | 926 | ||
926 | 927 | ||
927 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 928 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
928 | { | 929 | { |
929 | if ( secrecy == mData->secrecy ) return; | 930 | if ( secrecy == mData->secrecy ) return; |
930 | detach(); | 931 | detach(); |
931 | mData->empty = false; | 932 | mData->empty = false; |
932 | mData->secrecy = secrecy; | 933 | mData->secrecy = secrecy; |
933 | } | 934 | } |
934 | 935 | ||
935 | Secrecy Addressee::secrecy() const | 936 | Secrecy Addressee::secrecy() const |
936 | { | 937 | { |
937 | return mData->secrecy; | 938 | return mData->secrecy; |
938 | } | 939 | } |
939 | 940 | ||
940 | QString Addressee::secrecyLabel() | 941 | QString Addressee::secrecyLabel() |
941 | { | 942 | { |
942 | return i18n("Security Class"); | 943 | return i18n("Security Class"); |
943 | } | 944 | } |
944 | 945 | ||
945 | 946 | ||
946 | void Addressee::setLogo( const Picture &logo ) | 947 | void Addressee::setLogo( const Picture &logo ) |
947 | { | 948 | { |
948 | if ( logo == mData->logo ) return; | 949 | if ( logo == mData->logo ) return; |
949 | detach(); | 950 | detach(); |
950 | mData->empty = false; | 951 | mData->empty = false; |
951 | mData->logo = logo; | 952 | mData->logo = logo; |
952 | } | 953 | } |
953 | 954 | ||
954 | Picture Addressee::logo() const | 955 | Picture Addressee::logo() const |
955 | { | 956 | { |
956 | return mData->logo; | 957 | return mData->logo; |
957 | } | 958 | } |
958 | 959 | ||
959 | QString Addressee::logoLabel() | 960 | QString Addressee::logoLabel() |
960 | { | 961 | { |
961 | return i18n("Logo"); | 962 | return i18n("Logo"); |
962 | } | 963 | } |
963 | 964 | ||
964 | 965 | ||
965 | void Addressee::setPhoto( const Picture &photo ) | 966 | void Addressee::setPhoto( const Picture &photo ) |
966 | { | 967 | { |
967 | if ( photo == mData->photo ) return; | 968 | if ( photo == mData->photo ) return; |
968 | detach(); | 969 | detach(); |
969 | mData->empty = false; | 970 | mData->empty = false; |
970 | mData->photo = photo; | 971 | mData->photo = photo; |
971 | } | 972 | } |
972 | 973 | ||
973 | Picture Addressee::photo() const | 974 | Picture Addressee::photo() const |
974 | { | 975 | { |
975 | return mData->photo; | 976 | return mData->photo; |
976 | } | 977 | } |
977 | 978 | ||
978 | QString Addressee::photoLabel() | 979 | QString Addressee::photoLabel() |
979 | { | 980 | { |
980 | return i18n("Photo"); | 981 | return i18n("Photo"); |
981 | } | 982 | } |
982 | 983 | ||
983 | 984 | ||
984 | void Addressee::setSound( const Sound &sound ) | 985 | void Addressee::setSound( const Sound &sound ) |
985 | { | 986 | { |
986 | if ( sound == mData->sound ) return; | 987 | if ( sound == mData->sound ) return; |
987 | detach(); | 988 | detach(); |
988 | mData->empty = false; | 989 | mData->empty = false; |
989 | mData->sound = sound; | 990 | mData->sound = sound; |
990 | } | 991 | } |
991 | 992 | ||
992 | Sound Addressee::sound() const | 993 | Sound Addressee::sound() const |
993 | { | 994 | { |
994 | return mData->sound; | 995 | return mData->sound; |
995 | } | 996 | } |
996 | 997 | ||
997 | QString Addressee::soundLabel() | 998 | QString Addressee::soundLabel() |
998 | { | 999 | { |
999 | return i18n("Sound"); | 1000 | return i18n("Sound"); |
1000 | } | 1001 | } |
1001 | 1002 | ||
1002 | 1003 | ||
1003 | void Addressee::setAgent( const Agent &agent ) | 1004 | void Addressee::setAgent( const Agent &agent ) |
1004 | { | 1005 | { |
1005 | if ( agent == mData->agent ) return; | 1006 | if ( agent == mData->agent ) return; |
1006 | detach(); | 1007 | detach(); |
1007 | mData->empty = false; | 1008 | mData->empty = false; |
1008 | mData->agent = agent; | 1009 | mData->agent = agent; |
1009 | } | 1010 | } |
1010 | 1011 | ||
1011 | Agent Addressee::agent() const | 1012 | Agent Addressee::agent() const |
1012 | { | 1013 | { |
1013 | return mData->agent; | 1014 | return mData->agent; |
1014 | } | 1015 | } |
1015 | 1016 | ||
1016 | QString Addressee::agentLabel() | 1017 | QString Addressee::agentLabel() |
1017 | { | 1018 | { |
1018 | return i18n("Agent"); | 1019 | return i18n("Agent"); |
1019 | } | 1020 | } |
1020 | 1021 | ||
1021 | 1022 | ||
1022 | 1023 | ||
1023 | void Addressee::setNameFromString( const QString &str ) | 1024 | void Addressee::setNameFromString( const QString &str ) |
1024 | { | 1025 | { |
1025 | setFormattedName( str ); | 1026 | setFormattedName( str ); |
1026 | setName( str ); | 1027 | setName( str ); |
1027 | 1028 | ||
1028 | static bool first = true; | 1029 | static bool first = true; |
1029 | static QStringList titles; | 1030 | static QStringList titles; |
1030 | static QStringList suffixes; | 1031 | static QStringList suffixes; |
1031 | static QStringList prefixes; | 1032 | static QStringList prefixes; |
1032 | 1033 | ||
1033 | if ( first ) { | 1034 | if ( first ) { |
1034 | first = false; | 1035 | first = false; |
1035 | titles += i18n( "Dr." ); | 1036 | titles += i18n( "Dr." ); |
1036 | titles += i18n( "Miss" ); | 1037 | titles += i18n( "Miss" ); |
1037 | titles += i18n( "Mr." ); | 1038 | titles += i18n( "Mr." ); |
1038 | titles += i18n( "Mrs." ); | 1039 | titles += i18n( "Mrs." ); |
1039 | titles += i18n( "Ms." ); | 1040 | titles += i18n( "Ms." ); |
1040 | titles += i18n( "Prof." ); | 1041 | titles += i18n( "Prof." ); |
1041 | 1042 | ||
1042 | suffixes += i18n( "I" ); | 1043 | suffixes += i18n( "I" ); |
1043 | suffixes += i18n( "II" ); | 1044 | suffixes += i18n( "II" ); |
1044 | suffixes += i18n( "III" ); | 1045 | suffixes += i18n( "III" ); |
1045 | suffixes += i18n( "Jr." ); | 1046 | suffixes += i18n( "Jr." ); |
1046 | suffixes += i18n( "Sr." ); | 1047 | suffixes += i18n( "Sr." ); |
1047 | 1048 | ||
1048 | prefixes += "van"; | 1049 | prefixes += "van"; |
1049 | prefixes += "von"; | 1050 | prefixes += "von"; |
1050 | prefixes += "de"; | 1051 | prefixes += "de"; |
1051 | 1052 | ||
1052 | KConfig config( locateLocal( "config", "kabcrc") ); | 1053 | KConfig config( locateLocal( "config", "kabcrc") ); |
1053 | config.setGroup( "General" ); | 1054 | config.setGroup( "General" ); |
1054 | titles += config.readListEntry( "Prefixes" ); | 1055 | titles += config.readListEntry( "Prefixes" ); |
1055 | titles.remove( "" ); | 1056 | titles.remove( "" ); |
1056 | prefixes += config.readListEntry( "Inclusions" ); | 1057 | prefixes += config.readListEntry( "Inclusions" ); |
1057 | prefixes.remove( "" ); | 1058 | prefixes.remove( "" ); |
1058 | suffixes += config.readListEntry( "Suffixes" ); | 1059 | suffixes += config.readListEntry( "Suffixes" ); |
1059 | suffixes.remove( "" ); | 1060 | suffixes.remove( "" ); |
1060 | } | 1061 | } |
1061 | 1062 | ||
1062 | // clear all name parts | 1063 | // clear all name parts |
1063 | setPrefix( "" ); | 1064 | setPrefix( "" ); |
1064 | setGivenName( "" ); | 1065 | setGivenName( "" ); |
1065 | setAdditionalName( "" ); | 1066 | setAdditionalName( "" ); |
1066 | setFamilyName( "" ); | 1067 | setFamilyName( "" ); |
1067 | setSuffix( "" ); | 1068 | setSuffix( "" ); |
1068 | 1069 | ||
1069 | if ( str.isEmpty() ) | 1070 | if ( str.isEmpty() ) |
1070 | return; | 1071 | return; |
1071 | 1072 | ||
1072 | int i = str.find(','); | 1073 | int i = str.find(','); |
1073 | if( i < 0 ) { | 1074 | if( i < 0 ) { |
1074 | QStringList parts = QStringList::split( " ", str ); | 1075 | QStringList parts = QStringList::split( " ", str ); |
1075 | int leftOffset = 0; | 1076 | int leftOffset = 0; |
1076 | int rightOffset = parts.count() - 1; | 1077 | int rightOffset = parts.count() - 1; |
1077 | 1078 | ||
1078 | QString suffix; | 1079 | QString suffix; |
1079 | while ( rightOffset >= 0 ) { | 1080 | while ( rightOffset >= 0 ) { |
1080 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1081 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1081 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1082 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1082 | rightOffset--; | 1083 | rightOffset--; |
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index 437bda8..adc7256 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -1,442 +1,441 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <unistd.h> | 30 | #include <unistd.h> |
31 | 31 | ||
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qfileinfo.h> | 34 | #include <qfileinfo.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | //US #include <qtimer.h> | 36 | //US #include <qtimer.h> |
37 | 37 | ||
38 | #include <kapplication.h> | 38 | #include <kapplication.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kdebug.h> | 40 | #include <kdebug.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | //US #include <ksavefile.h> | 42 | //US #include <ksavefile.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | 45 | ||
46 | #include <sl/slzdb.h> | 46 | #include <sl/slzdb.h> |
47 | 47 | ||
48 | #include <libkdepim/ksyncprofile.h> | 48 | #include <libkdepim/ksyncprofile.h> |
49 | 49 | ||
50 | #include "resourcesharpdtmconfig.h" | 50 | #include "resourcesharpdtmconfig.h" |
51 | #include "resourcesharpdtm.h" | 51 | #include "resourcesharpdtm.h" |
52 | 52 | ||
53 | #include "syncprefwidget.h" | 53 | #include "syncprefwidget.h" |
54 | 54 | ||
55 | #include "stdaddressbook.h" | 55 | #include "stdaddressbook.h" |
56 | 56 | ||
57 | #include "sharpdtmconverter.h" | 57 | #include "sharpdtmconverter.h" |
58 | //#define ALLOW_LOCKING | 58 | //#define ALLOW_LOCKING |
59 | using namespace KABC; | 59 | using namespace KABC; |
60 | extern "C" | 60 | extern "C" |
61 | { | 61 | { |
62 | void *init_microkabc_sharpdtm() | 62 | void *init_microkabc_sharpdtm() |
63 | { | 63 | { |
64 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>(); | 64 | return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig,SyncPrefWidgetContainer>(); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable ) | 68 | ResourceSharpDTM::ResourceSharpDTM( const KConfig *config, bool syncable ) |
69 | : Resource( config, syncable ), mConverter (0) | 69 | : Resource( config, syncable ), mConverter (0) |
70 | { | 70 | { |
71 | // we can not choose the filename. Therefore use the default to display | 71 | // we can not choose the filename. Therefore use the default to display |
72 | 72 | ||
73 | QString fileName = SlZDataBase::addressbookFileName(); | 73 | QString fileName = SlZDataBase::addressbookFileName(); |
74 | init( fileName ); | 74 | init( fileName ); |
75 | } | 75 | } |
76 | 76 | ||
77 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable ) | 77 | ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable ) |
78 | : Resource( 0, syncable ) | 78 | : Resource( 0, syncable ) |
79 | { | 79 | { |
80 | init( fileName ); | 80 | init( fileName ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void ResourceSharpDTM::init( const QString &fileName ) | 83 | void ResourceSharpDTM::init( const QString &fileName ) |
84 | { | 84 | { |
85 | 85 | ||
86 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 86 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
87 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 87 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
88 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 88 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
89 | 89 | ||
90 | setFileName( fileName ); | 90 | setFileName( fileName ); |
91 | } | 91 | } |
92 | 92 | ||
93 | ResourceSharpDTM::~ResourceSharpDTM() | 93 | ResourceSharpDTM::~ResourceSharpDTM() |
94 | { | 94 | { |
95 | if (mConverter != 0) | 95 | if (mConverter != 0) |
96 | delete mConverter; | 96 | delete mConverter; |
97 | 97 | ||
98 | if(mAccess != 0) | 98 | if(mAccess != 0) |
99 | delete mAccess; | 99 | delete mAccess; |
100 | } | 100 | } |
101 | 101 | ||
102 | void ResourceSharpDTM::writeConfig( KConfig *config ) | 102 | void ResourceSharpDTM::writeConfig( KConfig *config ) |
103 | { | 103 | { |
104 | Resource::writeConfig( config ); | 104 | Resource::writeConfig( config ); |
105 | } | 105 | } |
106 | 106 | ||
107 | Ticket *ResourceSharpDTM::requestSaveTicket() | 107 | Ticket *ResourceSharpDTM::requestSaveTicket() |
108 | { | 108 | { |
109 | 109 | ||
110 | 110 | ||
111 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); | 111 | qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); |
112 | 112 | ||
113 | if ( !addressBook() ) return 0; | 113 | if ( !addressBook() ) return 0; |
114 | 114 | ||
115 | #ifdef ALLOW_LOCKING | 115 | #ifdef ALLOW_LOCKING |
116 | if ( !lock( fileName() ) ) { | 116 | if ( !lock( fileName() ) ) { |
117 | qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); | 117 | qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); |
118 | return 0; | 118 | return 0; |
119 | } | 119 | } |
120 | #endif | 120 | #endif |
121 | return createTicket( this ); | 121 | return createTicket( this ); |
122 | } | 122 | } |
123 | 123 | ||
124 | 124 | ||
125 | bool ResourceSharpDTM::doOpen() | 125 | bool ResourceSharpDTM::doOpen() |
126 | { | 126 | { |
127 | qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1()); | 127 | qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1()); |
128 | 128 | ||
129 | // the last parameter in the SlZDataBase constructor means "readonly" | 129 | // the last parameter in the SlZDataBase constructor means "readonly" |
130 | mAccess = new SlZDataBase(fileName(), | 130 | mAccess = new SlZDataBase(fileName(), |
131 | SlZDataBase::addressbookItems(), | 131 | SlZDataBase::addressbookItems(), |
132 | NULL, false); | 132 | NULL, false); |
133 | 133 | ||
134 | if ( !mAccess ) { | 134 | if ( !mAccess ) { |
135 | qDebug("Unable to load file() %s", fileName().latin1()); | 135 | qDebug("Unable to load file() %s", fileName().latin1()); |
136 | return false; | 136 | return false; |
137 | } | 137 | } |
138 | 138 | ||
139 | if (mConverter == 0) | 139 | if (mConverter == 0) |
140 | { | 140 | { |
141 | mConverter = new SharpDTMConverter(); | 141 | mConverter = new SharpDTMConverter(); |
142 | bool res = mConverter->init(); | 142 | bool res = mConverter->init(); |
143 | if ( !res ) | 143 | if ( !res ) |
144 | { | 144 | { |
145 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); | 145 | QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); |
146 | 146 | ||
147 | qDebug(msg); | 147 | qDebug(msg); |
148 | delete mAccess; | 148 | delete mAccess; |
149 | mAccess = 0; | 149 | mAccess = 0; |
150 | return false; | 150 | return false; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | return true; | 154 | return true; |
155 | } | 155 | } |
156 | 156 | ||
157 | void ResourceSharpDTM::doClose() | 157 | void ResourceSharpDTM::doClose() |
158 | { | 158 | { |
159 | qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1()); | 159 | qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1()); |
160 | 160 | ||
161 | if(mAccess) | 161 | if(mAccess) |
162 | { | 162 | { |
163 | delete mAccess; | 163 | delete mAccess; |
164 | mAccess = 0; | 164 | mAccess = 0; |
165 | } | 165 | } |
166 | // it seems so, that deletion of access deletes backend as well | 166 | // it seems so, that deletion of access deletes backend as well |
167 | //delete backend; | 167 | //delete backend; |
168 | 168 | ||
169 | return; | 169 | return; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool ResourceSharpDTM::load() | 172 | bool ResourceSharpDTM::load() |
173 | { | 173 | { |
174 | qDebug("ResourceSharpDTM::load: %s", fileName().latin1()); | 174 | qDebug("ResourceSharpDTM::load: %s", fileName().latin1()); |
175 | 175 | ||
176 | bool res = false; | 176 | bool res = false; |
177 | 177 | ||
178 | CardId id; | 178 | CardId id; |
179 | 179 | ||
180 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) | 180 | for (bool res=mAccess->first(); res == true; res=mAccess->next()) |
181 | { | 181 | { |
182 | id = mAccess->cardId(); | 182 | id = mAccess->cardId(); |
183 | 183 | ||
184 | KABC::Addressee addressee; | 184 | KABC::Addressee addressee; |
185 | 185 | ||
186 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 186 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
187 | 187 | ||
188 | if ( !addressee.isEmpty() && res ) | 188 | if ( !addressee.isEmpty() && res ) |
189 | { | 189 | { |
190 | addressee.setResource( this ); | 190 | addressee.setResource( this ); |
191 | addressBook()->insertAddressee( addressee ); | 191 | addressBook()->insertAddressee( addressee ); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | return true; | 195 | return true; |
196 | } | 196 | } |
197 | 197 | ||
198 | bool ResourceSharpDTM::save( Ticket *ticket ) | 198 | bool ResourceSharpDTM::save( Ticket *ticket ) |
199 | { | 199 | { |
200 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); | 200 | qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); |
201 | 201 | ||
202 | mDirWatch.stopScan(); | 202 | mDirWatch.stopScan(); |
203 | 203 | ||
204 | KABC::AddressBook::Iterator it; | 204 | KABC::AddressBook::Iterator it; |
205 | bool res; | 205 | bool res; |
206 | KABC::Addressee::List changedAddressees; | 206 | KABC::Addressee::List changedAddressees; |
207 | typedef QMap<int,QString> AddresseeMap; | 207 | typedef QMap<int,QString> AddresseeMap; |
208 | AddresseeMap map; | 208 | AddresseeMap map; |
209 | CardId id ; | 209 | CardId id ; |
210 | 210 | ||
211 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { | 211 | for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { |
212 | 212 | ||
213 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 213 | if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
214 | QString uid = (*it).originalExternalUID(); | 214 | QString uid = (*it).originalExternalUID(); |
215 | bool res; | 215 | bool res; |
216 | if ( uid.isEmpty() ) | 216 | if ( uid.isEmpty() ) |
217 | id = 0; | 217 | id = 0; |
218 | else | 218 | else |
219 | id = uid.toUInt(); | 219 | id = uid.toUInt(); |
220 | KABC::Addressee addressee = (*it); | 220 | KABC::Addressee addressee = (*it); |
221 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { | 221 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { |
222 | res = mAccess->startEditCard(id); | 222 | res = mAccess->startEditCard(id); |
223 | if (res == true) | 223 | if (res == true) |
224 | { | 224 | { |
225 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 225 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
226 | if (res == true) | 226 | if (res == true) |
227 | { | 227 | { |
228 | res = mAccess->finishEditCard(&id); | 228 | res = mAccess->finishEditCard(&id); |
229 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 229 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
230 | //(*it).setExternalUID( QString::number( id ) ); | 230 | //(*it).setExternalUID( QString::number( id ) ); |
231 | //(*it).setOriginalExternalUID( QString::number( id ) ); | 231 | //(*it).setOriginalExternalUID( QString::number( id ) ); |
232 | map.insert(id,(*it).uid()); | 232 | map.insert(id,(*it).uid()); |
233 | 233 | ||
234 | #if 0 | 234 | #if 0 |
235 | KABC::Addressee addressee; | 235 | KABC::Addressee addressee; |
236 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 236 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
237 | addressee.setUid((*it).uid() ); | 237 | addressee.setUid((*it).uid() ); |
238 | (it*).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 238 | (it*).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
239 | res = mAccess->finishEditCard(&id); | 239 | res = mAccess->finishEditCard(&id); |
240 | //qDebug("2NEW id is %d", id); | 240 | //qDebug("2NEW id is %d", id); |
241 | addressee.setExternalUID( QString::number( id ) ); | 241 | addressee.setExternalUID( QString::number( id ) ); |
242 | addressee.setOriginalExternalUID( QString::number( id ) ); | 242 | addressee.setOriginalExternalUID( QString::number( id ) ); |
243 | changedAddressees.append( addressee ); | 243 | changedAddressees.append( addressee ); |
244 | #endif | 244 | #endif |
245 | 245 | ||
246 | if (res == false) | 246 | if (res == false) |
247 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 247 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
248 | 248 | ||
249 | } | 249 | } |
250 | else | 250 | else |
251 | { | 251 | { |
252 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 252 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
253 | mAccess->cancelEditCard(); | 253 | mAccess->cancelEditCard(); |
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
257 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 257 | } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
258 | res = mAccess->deleteCard(&id); | 258 | res = mAccess->deleteCard(&id); |
259 | if ( res ) | 259 | if ( res ) |
260 | qDebug("delete success "); | 260 | qDebug("delete success "); |
261 | else | 261 | else |
262 | qDebug("delete error "); | 262 | qDebug("delete error "); |
263 | 263 | ||
264 | 264 | ||
265 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 265 | } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
266 | //changed | 266 | //changed |
267 | qDebug("changed ****"); | 267 | qDebug("changed ****"); |
268 | res = mAccess->startEditCard(id); | 268 | res = mAccess->startEditCard(id); |
269 | if (res == true) | 269 | if (res == true) |
270 | { | 270 | { |
271 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); | 271 | res = mConverter->addresseeToSharp( (*it), mAccess, id ); |
272 | if (res == true) | 272 | if (res == true) |
273 | { | 273 | { |
274 | res = mAccess->finishEditCard(&id); | 274 | res = mAccess->finishEditCard(&id); |
275 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | 275 | //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); |
276 | map.insert(id,(*it).uid()); | 276 | map.insert(id,(*it).uid()); |
277 | 277 | ||
278 | #if 0 | 278 | #if 0 |
279 | KABC::Addressee addressee; | 279 | KABC::Addressee addressee; |
280 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 280 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
281 | addressee.setUid((*it).uid() ); | 281 | addressee.setUid((*it).uid() ); |
282 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | 282 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); |
283 | changedAddressees.append( addressee ); | 283 | changedAddressees.append( addressee ); |
284 | res = mAccess->finishEditCard(&id); | 284 | res = mAccess->finishEditCard(&id); |
285 | #endif | 285 | #endif |
286 | if (res == false) | 286 | if (res == false) |
287 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 287 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
288 | 288 | ||
289 | } | 289 | } |
290 | else | 290 | else |
291 | { | 291 | { |
292 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | 292 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); |
293 | mAccess->cancelEditCard(); | 293 | mAccess->cancelEditCard(); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | } | 296 | } |
297 | } | 297 | } |
298 | 298 | ||
299 | } | 299 | } |
300 | AddresseeMap::Iterator itam; | 300 | AddresseeMap::Iterator itam; |
301 | res; | ||
302 | for ( res=mAccess->first(); res == true; res=mAccess->next()) | 301 | for ( res=mAccess->first(); res == true; res=mAccess->next()) |
303 | { | 302 | { |
304 | id = mAccess->cardId(); | 303 | id = mAccess->cardId(); |
305 | int idint = id; | 304 | int idint = id; |
306 | itam = map.find( idint ); | 305 | itam = map.find( idint ); |
307 | if ( itam != map.end() ) { | 306 | if ( itam != map.end() ) { |
308 | KABC::Addressee addressee; | 307 | KABC::Addressee addressee; |
309 | qDebug("found change %d %s ", idint, itam.data().latin1()); | 308 | qDebug("found change %d %s ", idint, itam.data().latin1()); |
310 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 309 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
311 | 310 | ||
312 | if ( !addressee.isEmpty() && res ) | 311 | if ( !addressee.isEmpty() && res ) |
313 | { | 312 | { |
314 | addressee.setResource( this ); | 313 | addressee.setResource( this ); |
315 | addressee.setUid( itam.data() ); | 314 | addressee.setUid( itam.data() ); |
316 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 315 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
317 | addressBook()->insertAddressee( addressee , false ); | 316 | addressBook()->insertAddressee( addressee , false ); |
318 | } | 317 | } |
319 | } | 318 | } |
320 | } | 319 | } |
321 | #if 0 | 320 | #if 0 |
322 | KABC::Addressee::List::Iterator it2; | 321 | KABC::Addressee::List::Iterator it2; |
323 | for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) { | 322 | for ( it2 = changedAddressees.begin(); it2 != changedAddressees.end(); ++it2 ) { |
324 | (*it2).computeCsum( "Sharp_DTM" ); | 323 | (*it2).computeCsum( "Sharp_DTM" ); |
325 | qDebug("CSUM: %s ",(*it2).getCsum( "Sharp_DTM" ).latin1() ); | 324 | qDebug("CSUM: %s ",(*it2).getCsum( "Sharp_DTM" ).latin1() ); |
326 | addressBook()->insertAddressee((*it2)); | 325 | addressBook()->insertAddressee((*it2)); |
327 | } | 326 | } |
328 | #endif | 327 | #endif |
329 | //US mAccess->save(); | 328 | //US mAccess->save(); |
330 | 329 | ||
331 | mDirWatch.startScan(); | 330 | mDirWatch.startScan(); |
332 | delete ticket; | 331 | delete ticket; |
333 | unlock( fileName() ); | 332 | unlock( fileName() ); |
334 | 333 | ||
335 | return true; | 334 | return true; |
336 | } | 335 | } |
337 | 336 | ||
338 | bool ResourceSharpDTM::lock( const QString &lockfileName ) | 337 | bool ResourceSharpDTM::lock( const QString &lockfileName ) |
339 | { | 338 | { |
340 | #ifdef ALLOW_LOCKING | 339 | #ifdef ALLOW_LOCKING |
341 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); | 340 | qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); |
342 | 341 | ||
343 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; | 342 | kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; |
344 | 343 | ||
345 | QString fn = lockfileName; | 344 | QString fn = lockfileName; |
346 | 345 | ||
347 | KURL url(fn); | 346 | KURL url(fn); |
348 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 347 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
349 | 348 | ||
350 | kdDebug(5700) << "-- lock name: " << lockName << endl; | 349 | kdDebug(5700) << "-- lock name: " << lockName << endl; |
351 | 350 | ||
352 | if (QFile::exists( lockName )) | 351 | if (QFile::exists( lockName )) |
353 | { | 352 | { |
354 | qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName()); | 353 | qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName()); |
355 | return false; | 354 | return false; |
356 | } | 355 | } |
357 | 356 | ||
358 | 357 | ||
359 | QString lockUniqueName; | 358 | QString lockUniqueName; |
360 | lockUniqueName = fn + KApplication::randomString( 8 ); | 359 | lockUniqueName = fn + KApplication::randomString( 8 ); |
361 | 360 | ||
362 | url = lockUniqueName; | 361 | url = lockUniqueName; |
363 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); | 362 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); |
364 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); | 363 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); |
365 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; | 364 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; |
366 | 365 | ||
367 | // Create unique file | 366 | // Create unique file |
368 | QFile file( mLockUniqueName ); | 367 | QFile file( mLockUniqueName ); |
369 | file.open( IO_WriteOnly ); | 368 | file.open( IO_WriteOnly ); |
370 | file.close(); | 369 | file.close(); |
371 | 370 | ||
372 | // Create lock file | 371 | // Create lock file |
373 | int result = 0; | 372 | int result = 0; |
374 | #ifndef _WIN32_ | 373 | #ifndef _WIN32_ |
375 | result = ::link( QFile::encodeName( mLockUniqueName ), | 374 | result = ::link( QFile::encodeName( mLockUniqueName ), |
376 | QFile::encodeName( lockName ) ); | 375 | QFile::encodeName( lockName ) ); |
377 | #endif | 376 | #endif |
378 | if ( result == 0 ) { | 377 | if ( result == 0 ) { |
379 | addressBook()->emitAddressBookLocked(); | 378 | addressBook()->emitAddressBookLocked(); |
380 | return true; | 379 | return true; |
381 | } | 380 | } |
382 | 381 | ||
383 | // TODO: check stat | 382 | // TODO: check stat |
384 | 383 | ||
385 | return false; | 384 | return false; |
386 | #else | 385 | #else |
387 | return true; | 386 | return true; |
388 | #endif | 387 | #endif |
389 | } | 388 | } |
390 | 389 | ||
391 | void ResourceSharpDTM::unlock( const QString &fileName ) | 390 | void ResourceSharpDTM::unlock( const QString &fileName ) |
392 | { | 391 | { |
393 | #ifdef ALLOW_LOCKING | 392 | #ifdef ALLOW_LOCKING |
394 | qDebug("ResourceSharpDTM::unlock() %s", fileName.latin1()); | 393 | qDebug("ResourceSharpDTM::unlock() %s", fileName.latin1()); |
395 | 394 | ||
396 | QString fn = fileName; | 395 | QString fn = fileName; |
397 | KURL url(fn); | 396 | KURL url(fn); |
398 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 397 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
399 | 398 | ||
400 | QFile::remove( lockName ); | 399 | QFile::remove( lockName ); |
401 | QFile::remove( mLockUniqueName ); | 400 | QFile::remove( mLockUniqueName ); |
402 | addressBook()->emitAddressBookUnlocked(); | 401 | addressBook()->emitAddressBookUnlocked(); |
403 | #endif | 402 | #endif |
404 | } | 403 | } |
405 | 404 | ||
406 | void ResourceSharpDTM::setFileName( const QString &newFileName ) | 405 | void ResourceSharpDTM::setFileName( const QString &newFileName ) |
407 | { | 406 | { |
408 | mDirWatch.stopScan(); | 407 | mDirWatch.stopScan(); |
409 | mDirWatch.removeFile( fileName() ); | 408 | mDirWatch.removeFile( fileName() ); |
410 | 409 | ||
411 | Resource::setFileName( newFileName ); | 410 | Resource::setFileName( newFileName ); |
412 | 411 | ||
413 | mDirWatch.addFile( fileName() ); | 412 | mDirWatch.addFile( fileName() ); |
414 | mDirWatch.startScan(); | 413 | mDirWatch.startScan(); |
415 | 414 | ||
416 | } | 415 | } |
417 | 416 | ||
418 | void ResourceSharpDTM::fileChanged() | 417 | void ResourceSharpDTM::fileChanged() |
419 | { | 418 | { |
420 | // There is a small theoretical chance that KDirWatch calls us before | 419 | // There is a small theoretical chance that KDirWatch calls us before |
421 | // we are fully constructed | 420 | // we are fully constructed |
422 | if (!addressBook()) | 421 | if (!addressBook()) |
423 | return; | 422 | return; |
424 | 423 | ||
425 | QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); | 424 | QString text( i18n( "Sharp DTM resource '%1'<br> has been changed by third party.<br>Do you want to reload?").arg( fileName() ) ); |
426 | if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { | 425 | if ( readOnly() || KMessageBox::questionYesNo( 0, text ) == KMessageBox::Yes ) { |
427 | load(); | 426 | load(); |
428 | addressBook()->emitAddressBookChanged(); | 427 | addressBook()->emitAddressBookChanged(); |
429 | } | 428 | } |
430 | } | 429 | } |
431 | 430 | ||
432 | void ResourceSharpDTM::removeAddressee( const Addressee &addr ) | 431 | void ResourceSharpDTM::removeAddressee( const Addressee &addr ) |
433 | { | 432 | { |
434 | } | 433 | } |
435 | 434 | ||
436 | void ResourceSharpDTM::cleanUp() | 435 | void ResourceSharpDTM::cleanUp() |
437 | { | 436 | { |
438 | unlock( fileName() ); | 437 | unlock( fileName() ); |
439 | } | 438 | } |
440 | 439 | ||
441 | 440 | ||
442 | 441 | ||
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index fccf625..d36df20 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp | |||
@@ -1,442 +1,444 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "kglobal.h" | 28 | #include "kglobal.h" |
29 | #include <qregexp.h> | 29 | #include <qregexp.h> |
30 | 30 | ||
31 | 31 | ||
32 | #include "sharpdtmconverter.h" | 32 | #include "sharpdtmconverter.h" |
33 | 33 | ||
34 | #include <sl/slcategories.h> | 34 | #include <sl/slcategories.h> |
35 | #include <libkdepim/ksyncprofile.h> | 35 | #include <libkdepim/ksyncprofile.h> |
36 | //US #include <qpe/categoryselect.h> | 36 | //US #include <qpe/categoryselect.h> |
37 | 37 | ||
38 | 38 | ||
39 | using namespace KABC; | 39 | using namespace KABC; |
40 | using namespace SlCategory; | 40 | using namespace SlCategory; |
41 | 41 | ||
42 | SharpDTMConverter::SharpDTMConverter() : catDB(0) | 42 | SharpDTMConverter::SharpDTMConverter() : catDB(0) |
43 | { | 43 | { |
44 | } | 44 | } |
45 | 45 | ||
46 | SharpDTMConverter::~SharpDTMConverter() | 46 | SharpDTMConverter::~SharpDTMConverter() |
47 | { | 47 | { |
48 | deinit(); | 48 | deinit(); |
49 | } | 49 | } |
50 | 50 | ||
51 | bool SharpDTMConverter::init() | 51 | bool SharpDTMConverter::init() |
52 | { | 52 | { |
53 | catDB = new SlCategory::SlCategories(); | 53 | catDB = new SlCategory::SlCategories(); |
54 | 54 | ||
55 | if (!catDB) | 55 | if (!catDB) |
56 | return false; | 56 | return false; |
57 | 57 | ||
58 | // catDB->load( categoryFileName() ); | 58 | // catDB->load( categoryFileName() ); |
59 | return true; | 59 | return true; |
60 | } | 60 | } |
61 | 61 | ||
62 | void SharpDTMConverter::deinit() | 62 | void SharpDTMConverter::deinit() |
63 | { | 63 | { |
64 | if (catDB) | 64 | if (catDB) |
65 | { | 65 | { |
66 | delete catDB; | 66 | delete catDB; |
67 | catDB = 0; | 67 | catDB = 0; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) | 71 | bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBase* database, Addressee &addr ) |
72 | { | 72 | { |
73 | SlZDataBase* db = (SlZDataBase*)database; | 73 | SlZDataBase* db = (SlZDataBase*)database; |
74 | 74 | ||
75 | // for syncing: we need setting of the two fields | 75 | // for syncing: we need setting of the two fields |
76 | addr.setExternalUID( QString::number( contact ) ); | 76 | addr.setExternalUID( QString::number( contact ) ); |
77 | addr.setOriginalExternalUID( QString::number( contact ) ); | 77 | addr.setOriginalExternalUID( QString::number( contact ) ); |
78 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 78 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
79 | 79 | ||
80 | 80 | ||
81 | // name | 81 | // name |
82 | //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); | 82 | //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); |
83 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); // needs fix | 83 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); // needs fix |
84 | 84 | ||
85 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); | 85 | addr.setFamilyName( db->readField(ZdbAdrs::LastName) ); |
86 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); | 86 | addr.setGivenName( db->readField(ZdbAdrs::FirstName) ); |
87 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); | 87 | addr.setAdditionalName( db->readField(ZdbAdrs::MiddleName) ); |
88 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); | 88 | addr.setPrefix( db->readField(ZdbAdrs::Title) ); |
89 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); | 89 | addr.setSuffix( db->readField(ZdbAdrs::Suffix) ); |
90 | 90 | ||
91 | 91 | ||
92 | QString emailstr = db->readField(ZdbAdrs::Emails); | 92 | QString emailstr = db->readField(ZdbAdrs::Emails); |
93 | emailstr.replace( QRegExp(","), " " ); | 93 | emailstr.replace( QRegExp(","), " " ); |
94 | emailstr.replace( QRegExp(";"), " " ); | 94 | emailstr.replace( QRegExp(";"), " " ); |
95 | emailstr.replace( QRegExp(":"), " " ); | 95 | emailstr.replace( QRegExp(":"), " " ); |
96 | //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); | 96 | //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); |
97 | QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); | 97 | QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); |
98 | bool defE = false; | 98 | bool defE = false; |
99 | bool found = false; | 99 | bool found = false; |
100 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 100 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
101 | if (found ) | 101 | if (found ) |
102 | defE = false; | 102 | defE = false; |
103 | else | 103 | else |
104 | found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); | 104 | found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); |
105 | addr.insertEmail( *it, defE ); | 105 | addr.insertEmail( *it, defE ); |
106 | } | 106 | } |
107 | if ( ! found ) | 107 | if ( ! found ) |
108 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) | 108 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) |
109 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); | 109 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); |
110 | 110 | ||
111 | // home | 111 | // home |
112 | if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || | 112 | if ((!db->readField(ZdbAdrs::HomeStreet).isEmpty()) || |
113 | (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || | 113 | (!db->readField(ZdbAdrs::HomeCity).isEmpty()) || |
114 | (!db->readField(ZdbAdrs::HomeState).isEmpty()) || | 114 | (!db->readField(ZdbAdrs::HomeState).isEmpty()) || |
115 | (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || | 115 | (!db->readField(ZdbAdrs::HomeZip).isEmpty()) || |
116 | (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) | 116 | (!db->readField(ZdbAdrs::HomeCountry).isEmpty())) |
117 | { | 117 | { |
118 | Address homeaddress; | 118 | Address homeaddress; |
119 | homeaddress.setType(Address::Home); | 119 | homeaddress.setType(Address::Home); |
120 | //US homeaddress.setPostOfficeBox( "" ); | 120 | //US homeaddress.setPostOfficeBox( "" ); |
121 | //US homeaddress.setExtended( "" ); | 121 | //US homeaddress.setExtended( "" ); |
122 | homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet) ); | 122 | homeaddress.setStreet( db->readField(ZdbAdrs::HomeStreet) ); |
123 | homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); | 123 | homeaddress.setLocality( db->readField(ZdbAdrs::HomeCity) ); |
124 | homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); | 124 | homeaddress.setRegion( db->readField(ZdbAdrs::HomeState) ); |
125 | homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); | 125 | homeaddress.setPostalCode( db->readField(ZdbAdrs::HomeZip) ); |
126 | homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); | 126 | homeaddress.setCountry( db->readField(ZdbAdrs::HomeCountry) ); |
127 | 127 | ||
128 | addr.insertAddress( homeaddress ); | 128 | addr.insertAddress( homeaddress ); |
129 | } | 129 | } |
130 | 130 | ||
131 | if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) | 131 | if (!db->readField(ZdbAdrs::HomePhone).isEmpty()) |
132 | { | 132 | { |
133 | PhoneNumber homephone; | 133 | PhoneNumber homephone; |
134 | homephone.setType( PhoneNumber::Home ); | 134 | homephone.setType( PhoneNumber::Home ); |
135 | homephone.setNumber( db->readField(ZdbAdrs::HomePhone) ); | 135 | homephone.setNumber( db->readField(ZdbAdrs::HomePhone) ); |
136 | addr.insertPhoneNumber( homephone ); | 136 | addr.insertPhoneNumber( homephone ); |
137 | } | 137 | } |
138 | 138 | ||
139 | if (!db->readField(ZdbAdrs::HomeFax).isEmpty()) | 139 | if (!db->readField(ZdbAdrs::HomeFax).isEmpty()) |
140 | { | 140 | { |
141 | PhoneNumber homefax; | 141 | PhoneNumber homefax; |
142 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); | 142 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); |
143 | homefax.setNumber( db->readField(ZdbAdrs::HomeFax) ); | 143 | homefax.setNumber( db->readField(ZdbAdrs::HomeFax) ); |
144 | addr.insertPhoneNumber( homefax ); | 144 | addr.insertPhoneNumber( homefax ); |
145 | } | 145 | } |
146 | 146 | ||
147 | if (!db->readField(ZdbAdrs::HomeMobile).isEmpty()) | 147 | if (!db->readField(ZdbAdrs::HomeMobile).isEmpty()) |
148 | { | 148 | { |
149 | PhoneNumber homemobile; | 149 | PhoneNumber homemobile; |
150 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); | 150 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); |
151 | homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) ); | 151 | homemobile.setNumber( db->readField(ZdbAdrs::HomeMobile) ); |
152 | addr.insertPhoneNumber( homemobile ); | 152 | addr.insertPhoneNumber( homemobile ); |
153 | } | 153 | } |
154 | 154 | ||
155 | addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) ); | 155 | addr.setUrl( db->readField(ZdbAdrs::HomeWebPage) ); |
156 | 156 | ||
157 | 157 | ||
158 | // business | 158 | // business |
159 | if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) || | 159 | if ((!db->readField(ZdbAdrs::BusinessStreet).isEmpty()) || |
160 | (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) || | 160 | (!db->readField(ZdbAdrs::BusinessCity).isEmpty()) || |
161 | (!db->readField(ZdbAdrs::BusinessState).isEmpty()) || | 161 | (!db->readField(ZdbAdrs::BusinessState).isEmpty()) || |
162 | (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) || | 162 | (!db->readField(ZdbAdrs::BusinessZip).isEmpty()) || |
163 | (!db->readField(ZdbAdrs::BusinessCountry).isEmpty())) | 163 | (!db->readField(ZdbAdrs::BusinessCountry).isEmpty())) |
164 | { | 164 | { |
165 | Address businessaddress; | 165 | Address businessaddress; |
166 | businessaddress.setType(Address::Work); | 166 | businessaddress.setType(Address::Work); |
167 | //US businessaddress.setPostOfficeBox( "" ); | 167 | //US businessaddress.setPostOfficeBox( "" ); |
168 | //US businessaddress.setExtended( "" ); | 168 | //US businessaddress.setExtended( "" ); |
169 | businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet) ); | 169 | businessaddress.setStreet( db->readField(ZdbAdrs::BusinessStreet) ); |
170 | businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) ); | 170 | businessaddress.setLocality( db->readField(ZdbAdrs::BusinessCity) ); |
171 | businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) ); | 171 | businessaddress.setRegion( db->readField(ZdbAdrs::BusinessState) ); |
172 | businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) ); | 172 | businessaddress.setPostalCode( db->readField(ZdbAdrs::BusinessZip) ); |
173 | businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) ); | 173 | businessaddress.setCountry( db->readField(ZdbAdrs::BusinessCountry) ); |
174 | 174 | ||
175 | addr.insertAddress( businessaddress ); | 175 | addr.insertAddress( businessaddress ); |
176 | } | 176 | } |
177 | 177 | ||
178 | 178 | ||
179 | if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) | 179 | if (!db->readField(ZdbAdrs::BusinessPhone).isEmpty()) |
180 | { | 180 | { |
181 | PhoneNumber businessphone; | 181 | PhoneNumber businessphone; |
182 | businessphone.setType( PhoneNumber::Work ); | 182 | businessphone.setType( PhoneNumber::Work ); |
183 | businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); | 183 | businessphone.setNumber( db->readField(ZdbAdrs::BusinessPhone) ); |
184 | addr.insertPhoneNumber( businessphone ); | 184 | addr.insertPhoneNumber( businessphone ); |
185 | } | 185 | } |
186 | 186 | ||
187 | if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) | 187 | if (!db->readField(ZdbAdrs::BusinessFax).isEmpty()) |
188 | { | 188 | { |
189 | PhoneNumber businessfax; | 189 | PhoneNumber businessfax; |
190 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); | 190 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); |
191 | businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); | 191 | businessfax.setNumber( db->readField(ZdbAdrs::BusinessFax) ); |
192 | addr.insertPhoneNumber( businessfax ); | 192 | addr.insertPhoneNumber( businessfax ); |
193 | } | 193 | } |
194 | 194 | ||
195 | if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) | 195 | if (!db->readField(ZdbAdrs::BusinessMobile).isEmpty()) |
196 | { | 196 | { |
197 | PhoneNumber businessmobile; | 197 | PhoneNumber businessmobile; |
198 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); | 198 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); |
199 | businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); | 199 | businessmobile.setNumber( db->readField(ZdbAdrs::BusinessMobile) ); |
200 | addr.insertPhoneNumber( businessmobile ); | 200 | addr.insertPhoneNumber( businessmobile ); |
201 | } | 201 | } |
202 | 202 | ||
203 | if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) | 203 | if (!db->readField(ZdbAdrs::BusinessPager).isEmpty()) |
204 | { | 204 | { |
205 | PhoneNumber businesspager; | 205 | PhoneNumber businesspager; |
206 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); | 206 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); |
207 | businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); | 207 | businesspager.setNumber( db->readField(ZdbAdrs::BusinessPager) ); |
208 | addr.insertPhoneNumber( businesspager ); | 208 | addr.insertPhoneNumber( businesspager ); |
209 | } | 209 | } |
210 | 210 | ||
211 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); | 211 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); |
212 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); | 212 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); |
213 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); | 213 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", db->readField(ZdbAdrs::Profession) ); |
214 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); | 214 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", db->readField(ZdbAdrs::Assistant) ); |
215 | addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); | 215 | addr.insertCustom( "KADDRESSBOOK", "X-Department", db->readField(ZdbAdrs::Department) ); |
216 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); | 216 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", db->readField(ZdbAdrs::Manager) ); |
217 | addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); | 217 | addr.insertCustom( "KADDRESSBOOK", "X-Office", db->readField(ZdbAdrs::Office) ); |
218 | 218 | ||
219 | //personal | 219 | //personal |
220 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); | 220 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", db->readField(ZdbAdrs::Spouse) ); |
221 | 221 | ||
222 | QString gen = db->readField(ZdbAdrs::Gender); | 222 | QString gen = db->readField(ZdbAdrs::Gender); |
223 | //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); | 223 | //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); |
224 | //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); | 224 | //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); |
225 | 225 | ||
226 | if (gen == "male") | 226 | if (gen == "male") |
227 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); | 227 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); |
228 | else if (gen == "female") | 228 | else if (gen == "female") |
229 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | 229 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); |
230 | 230 | ||
231 | 231 | ||
232 | QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); | 232 | QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); |
233 | if (ann.isValid()) { | 233 | if (ann.isValid()) { |
234 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); | 234 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); |
235 | //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); | 235 | //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); |
236 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 236 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
237 | } | 237 | } |
238 | 238 | ||
239 | 239 | ||
240 | addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); | 240 | addr.insertCustom( "KADDRESSBOOK", "X-Children", db->readField(ZdbAdrs::Children) ); |
241 | 241 | ||
242 | 242 | ||
243 | QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); | 243 | QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); |
244 | //qDebug("birtd %s ", birthd.toString().latin1()); | 244 | //qDebug("birtd %s ", birthd.toString().latin1()); |
245 | if (birthd.isValid()) | 245 | if (birthd.isValid()) |
246 | addr.setBirthday( birthd ); | 246 | addr.setBirthday( birthd ); |
247 | 247 | ||
248 | addr.setNickName( db->readField(ZdbAdrs::Nickname) ); | 248 | addr.setNickName( db->readField(ZdbAdrs::Nickname) ); |
249 | 249 | ||
250 | // others | 250 | // others |
251 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. | 251 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. |
252 | QString notes = db->readField(ZdbAdrs::Notes); | 252 | QString notes = db->readField(ZdbAdrs::Notes); |
253 | //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; | 253 | //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; |
254 | if ( addr.url().isEmpty() ) | 254 | if ( addr.url().isEmpty() ) |
255 | addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); | 255 | addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); |
256 | addr.setNote( db->readField(ZdbAdrs::Notes) ); | 256 | addr.setNote( db->readField(ZdbAdrs::Notes) ); |
257 | 257 | ||
258 | 258 | ||
259 | 259 | ||
260 | //US QString groups() const { return find( Qtopia::Groups ); } | 260 | //US QString groups() const { return find( Qtopia::Groups ); } |
261 | //US QStringList groupList() const; | 261 | //US QStringList groupList() const; |
262 | 262 | ||
263 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); | 263 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); |
264 | QArray<int> catArray = db->readCategories(); | 264 | QArray<int> catArray = db->readCategories(); |
265 | QString cat; | 265 | QString cat; |
266 | 266 | ||
267 | for ( unsigned int i=0; i < catArray.size(); i++ ) { | 267 | for ( unsigned int i=0; i < catArray.size(); i++ ) { |
268 | cat = catDB->label(catArray[i]); | 268 | cat = catDB->label(catArray[i]); |
269 | if ( cat.isEmpty() ) | 269 | if ( cat.isEmpty() ) |
270 | addr.insertCategory(QString::number(catArray[i])); | 270 | addr.insertCategory(QString::number(catArray[i])); |
271 | else | 271 | else |
272 | addr.insertCategory( cat ); | 272 | addr.insertCategory( cat ); |
273 | } | 273 | } |
274 | 274 | ||
275 | return true; | 275 | return true; |
276 | } | 276 | } |
277 | 277 | ||
278 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) | 278 | bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* database , const CardId &contact ) |
279 | { | 279 | { |
280 | bool cellHome = false, cellWork = false; | 280 | bool cellHome = false, cellWork = false; |
281 | // name | 281 | // name |
282 | database->writeField(ZdbAdrs::LastName, addr.familyName()); | 282 | database->writeField(ZdbAdrs::LastName, addr.familyName()); |
283 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); | 283 | database->writeField(ZdbAdrs::FirstName, addr.givenName()); |
284 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); | 284 | database->writeField(ZdbAdrs::MiddleName, addr.additionalName()); |
285 | database->writeField(ZdbAdrs::Title, addr.prefix()); | 285 | database->writeField(ZdbAdrs::Title, addr.prefix()); |
286 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); | 286 | database->writeField(ZdbAdrs::Suffix, addr.suffix()); |
287 | 287 | ||
288 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); | 288 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); |
289 | QString formattedName = addr.formattedName(); | 289 | QString formattedName = addr.formattedName(); |
290 | if ( formattedName.isEmpty() ) { | 290 | if ( formattedName.isEmpty() ) { |
291 | if ( !addr.familyName().isEmpty() ) { | 291 | if ( !addr.familyName().isEmpty() ) { |
292 | formattedName = addr.familyName(); | 292 | formattedName = addr.familyName(); |
293 | if ( !addr.givenName().isEmpty() ) { | 293 | if ( !addr.givenName().isEmpty() ) { |
294 | formattedName += ", "; | 294 | formattedName += ", "; |
295 | formattedName += addr.givenName(); | 295 | formattedName += addr.givenName(); |
296 | } | 296 | } |
297 | } else | 297 | } else |
298 | formattedName = addr.givenName(); | 298 | formattedName = addr.givenName(); |
299 | } | 299 | } |
300 | database->writeField(ZdbAdrs::FileAs, formattedName); | 300 | database->writeField(ZdbAdrs::FileAs, formattedName); |
301 | database->writeField(ZdbAdrs::FullName, formattedName); | 301 | database->writeField(ZdbAdrs::FullName, formattedName); |
302 | 302 | ||
303 | 303 | ||
304 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); | 304 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); |
305 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); | 305 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); |
306 | QString emails = addr.emails().join(" "); | 306 | QString emails = addr.emails().join(" "); |
307 | database->writeField(ZdbAdrs::Emails, emails ); | 307 | database->writeField(ZdbAdrs::Emails, emails ); |
308 | 308 | ||
309 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); | 309 | database->writeField(ZdbAdrs::DefaultEmail, addr.preferredEmail() ); |
310 | 310 | ||
311 | 311 | ||
312 | // home | 312 | // home |
313 | const Address homeaddress = addr.address(Address::Home); | 313 | const Address homeaddress = addr.address(Address::Home); |
314 | if (!homeaddress.isEmpty()) { | 314 | if (!homeaddress.isEmpty()) { |
315 | qDebug("write home address "); | ||
315 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); | 316 | database->writeField(ZdbAdrs::HomeStreet, homeaddress.street()); |
316 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); | 317 | database->writeField(ZdbAdrs::HomeCity, homeaddress.locality()); |
317 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); | 318 | database->writeField(ZdbAdrs::HomeState, homeaddress.region()); |
318 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); | 319 | database->writeField(ZdbAdrs::HomeZip, homeaddress.postalCode()); |
319 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); | 320 | database->writeField(ZdbAdrs::HomeCountry, homeaddress.country()); |
320 | } | 321 | } |
321 | 322 | ||
322 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); | 323 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); |
323 | if (!homephone.number().isEmpty()) | 324 | if (!homephone.number().isEmpty()) |
324 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); | 325 | database->writeField(ZdbAdrs::HomePhone, homephone.number()); |
325 | 326 | ||
326 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | 327 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); |
327 | if (!homefax.number().isEmpty()) | 328 | if (!homefax.number().isEmpty()) |
328 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); | 329 | database->writeField(ZdbAdrs::HomeFax, homefax.number()); |
329 | 330 | ||
330 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | 331 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); |
331 | if (!homemobile.number().isEmpty()) { | 332 | if (!homemobile.number().isEmpty()) { |
332 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); | 333 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); |
333 | cellHome = true; | 334 | cellHome = true; |
334 | } | 335 | } |
335 | 336 | ||
336 | database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); | 337 | database->writeField(ZdbAdrs::HomeWebPage, addr.url().url()); |
337 | 338 | ||
338 | 339 | ||
339 | // business | 340 | // business |
340 | const Address businessaddress = addr.address(Address::Work); | 341 | const Address businessaddress = addr.address(Address::Work); |
341 | if (!businessaddress.isEmpty()) { | 342 | if (!businessaddress.isEmpty()) { |
343 | qDebug("write business address "); | ||
342 | database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); | 344 | database->writeField(ZdbAdrs::BusinessStreet, businessaddress.street()); |
343 | database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); | 345 | database->writeField(ZdbAdrs::BusinessCity, businessaddress.locality()); |
344 | database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); | 346 | database->writeField(ZdbAdrs::BusinessState, businessaddress.region()); |
345 | database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); | 347 | database->writeField(ZdbAdrs::BusinessZip, businessaddress.postalCode()); |
346 | database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); | 348 | database->writeField(ZdbAdrs::BusinessCountry, businessaddress.country()); |
347 | } | 349 | } |
348 | 350 | ||
349 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); | 351 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); |
350 | if (!businessphone.number().isEmpty()) | 352 | if (!businessphone.number().isEmpty()) |
351 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); | 353 | database->writeField(ZdbAdrs::BusinessPhone, businessphone.number()); |
352 | 354 | ||
353 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | 355 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); |
354 | if (!businessfax.number().isEmpty()) | 356 | if (!businessfax.number().isEmpty()) |
355 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); | 357 | database->writeField(ZdbAdrs::BusinessFax, businessfax.number()); |
356 | 358 | ||
357 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 359 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
358 | if (!businessmobile.number().isEmpty()) { | 360 | if (!businessmobile.number().isEmpty()) { |
359 | cellWork = true; | 361 | cellWork = true; |
360 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); | 362 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); |
361 | } | 363 | } |
362 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); | 364 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); |
363 | if (! mobile.number().isEmpty()) { | 365 | if (! mobile.number().isEmpty()) { |
364 | if ( ! cellHome ) | 366 | if ( ! cellHome ) |
365 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); | 367 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); |
366 | else if (! cellWork ) | 368 | else if (! cellWork ) |
367 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); | 369 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); |
368 | } | 370 | } |
369 | 371 | ||
370 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 372 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
371 | if (!businesspager.number().isEmpty()) | 373 | if (!businesspager.number().isEmpty()) |
372 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); | 374 | database->writeField(ZdbAdrs::BusinessPager, businesspager.number()); |
373 | 375 | ||
374 | database->writeField(ZdbAdrs::JobTitle, addr.role()); | 376 | database->writeField(ZdbAdrs::JobTitle, addr.role()); |
375 | database->writeField(ZdbAdrs::Company, addr.organization()); | 377 | database->writeField(ZdbAdrs::Company, addr.organization()); |
376 | 378 | ||
377 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); | 379 | database->writeField(ZdbAdrs::Profession, addr.custom( "KADDRESSBOOK", "X-Profession" )); |
378 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | 380 | database->writeField(ZdbAdrs::Assistant, addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); |
379 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); | 381 | database->writeField(ZdbAdrs::Department, addr.custom( "KADDRESSBOOK", "X-Department" )); |
380 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); | 382 | database->writeField(ZdbAdrs::Manager, addr.custom( "KADDRESSBOOK", "X-ManagersName" )); |
381 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); | 383 | database->writeField(ZdbAdrs::Office, addr.custom( "KADDRESSBOOK", "X-Office" )); |
382 | 384 | ||
383 | //personal | 385 | //personal |
384 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); | 386 | database->writeField(ZdbAdrs::Spouse, addr.custom( "KADDRESSBOOK", "X-Spouse" )); |
385 | 387 | ||
386 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); | 388 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); |
387 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); | 389 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); |
388 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); | 390 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); |
389 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); | 391 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); |
390 | if (gt == "male") | 392 | if (gt == "male") |
391 | database->writeField(ZdbAdrs::Gender, "male"); | 393 | database->writeField(ZdbAdrs::Gender, "male"); |
392 | else if (gt == "female") | 394 | else if (gt == "female") |
393 | database->writeField(ZdbAdrs::Gender, "female"); | 395 | database->writeField(ZdbAdrs::Gender, "female"); |
394 | else | 396 | else |
395 | database->writeField(ZdbAdrs::Gender, ""); | 397 | database->writeField(ZdbAdrs::Gender, ""); |
396 | 398 | ||
397 | 399 | ||
398 | QDate dt = KGlobal::locale()->readDate( | 400 | QDate dt = KGlobal::locale()->readDate( |
399 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | 401 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
400 | if ( dt.isValid() ) { | 402 | if ( dt.isValid() ) { |
401 | QString dateS = KGlobal::locale()->formatDate(dt, true ); | 403 | QString dateS = KGlobal::locale()->formatDate(dt, true ); |
402 | database->writeField(ZdbAdrs::Anniversary, dateS ); | 404 | database->writeField(ZdbAdrs::Anniversary, dateS ); |
403 | } | 405 | } |
404 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); | 406 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); |
405 | dt = addr.birthday().date(); | 407 | dt = addr.birthday().date(); |
406 | if ( dt.isValid() ) { | 408 | if ( dt.isValid() ) { |
407 | QString dateS = KGlobal::locale()->formatDate(dt, true ); | 409 | QString dateS = KGlobal::locale()->formatDate(dt, true ); |
408 | database->writeField(ZdbAdrs::Birthday, dateS); | 410 | database->writeField(ZdbAdrs::Birthday, dateS); |
409 | } | 411 | } |
410 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); | 412 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); |
411 | 413 | ||
412 | // other | 414 | // other |
413 | database->writeField(ZdbAdrs::Notes, addr.note()); | 415 | database->writeField(ZdbAdrs::Notes, addr.note()); |
414 | 416 | ||
415 | //US QString groups() const { return find( Qtopia::Groups ); } | 417 | //US QString groups() const { return find( Qtopia::Groups ); } |
416 | //US QStringList groupList() const; | 418 | //US QStringList groupList() const; |
417 | 419 | ||
418 | 420 | ||
419 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); | 421 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); |
420 | 422 | ||
421 | QStringList cats = addr.categories(); | 423 | QStringList cats = addr.categories(); |
422 | int ii; | 424 | int ii; |
423 | for ( ii = 0; ii < cats.count() ;++ii ) { | 425 | for ( ii = 0; ii < cats.count() ;++ii ) { |
424 | if ( !catDB->exists( cats[ii] )) | 426 | if ( !catDB->exists( cats[ii] )) |
425 | catDB->addCategory(cats[ii]); | 427 | catDB->addCategory(cats[ii]); |
426 | } | 428 | } |
427 | QArray<int> iar; | 429 | QArray<int> iar; |
428 | if ( !cats.isEmpty() ) { | 430 | if ( !cats.isEmpty() ) { |
429 | QArray<int> iar = catDB->ids(cats); | 431 | QArray<int> iar = catDB->ids(cats); |
430 | qDebug("***cat count is %d ", iar.count()); | 432 | qDebug("***cat count is %d ", iar.count()); |
431 | database->updateCategories(contact, iar); | 433 | database->updateCategories(contact, iar); |
432 | } | 434 | } |
433 | 435 | ||
434 | return true; | 436 | return true; |
435 | } | 437 | } |
436 | 438 | ||
437 | QDate SharpDTMConverter::convertDate( QString s) | 439 | QDate SharpDTMConverter::convertDate( QString s) |
438 | { | 440 | { |
439 | QDate dt = KGlobal::locale()->readDate( s ); | 441 | QDate dt = KGlobal::locale()->readDate( s ); |
440 | return dt; | 442 | return dt; |
441 | return QDate (); | 443 | return QDate (); |
442 | } | 444 | } |