-rw-r--r-- | kabc/addressee.cpp | 22 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 45 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 |
3 files changed, 41 insertions, 28 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 295ee4f..2564894 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,968 +1,986 @@ | |||
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 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | if ( mData->url.isValid() ) | 235 | if ( mData->url.isValid() ) |
236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); | 236 | if ( ! mData->url.path().isEmpty()) l.append( mData->url.path() ); |
237 | KABC::PhoneNumber::List phoneNumbers; | 237 | KABC::PhoneNumber::List phoneNumbers; |
238 | KABC::PhoneNumber::List::Iterator phoneIter; | 238 | KABC::PhoneNumber::List::Iterator phoneIter; |
239 | 239 | ||
240 | QStringList t; | 240 | QStringList t; |
241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 241 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
242 | ++phoneIter ) | 242 | ++phoneIter ) |
243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 243 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
244 | t.sort(); | 244 | t.sort(); |
245 | uint iii; | 245 | uint iii; |
246 | for ( iii = 0; iii < t.count(); ++iii) | 246 | for ( iii = 0; iii < t.count(); ++iii) |
247 | l.append( t[iii] ); | 247 | l.append( t[iii] ); |
248 | t = mData->emails; | 248 | t = mData->emails; |
249 | t.sort(); | 249 | t.sort(); |
250 | for ( iii = 0; iii < t.count(); ++iii) | 250 | for ( iii = 0; iii < t.count(); ++iii) |
251 | l.append( t[iii] ); | 251 | l.append( t[iii] ); |
252 | t = mData->categories; | 252 | t = mData->categories; |
253 | t.sort(); | 253 | t.sort(); |
254 | for ( iii = 0; iii < t.count(); ++iii) | 254 | for ( iii = 0; iii < t.count(); ++iii) |
255 | l.append( t[iii] ); | 255 | l.append( t[iii] ); |
256 | t = mData->custom; | 256 | t = mData->custom; |
257 | t.sort(); | 257 | t.sort(); |
258 | for ( iii = 0; iii < t.count(); ++iii) | 258 | for ( iii = 0; iii < t.count(); ++iii) |
259 | l.append( t[iii] ); | 259 | l.append( t[iii] ); |
260 | KABC::Address::List::Iterator addressIter; | 260 | KABC::Address::List::Iterator addressIter; |
261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 261 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
262 | ++addressIter ) { | 262 | ++addressIter ) { |
263 | t = (*addressIter).asList(); | 263 | t = (*addressIter).asList(); |
264 | t.sort(); | 264 | t.sort(); |
265 | for ( iii = 0; iii < t.count(); ++iii) | 265 | for ( iii = 0; iii < t.count(); ++iii) |
266 | l.append( t[iii] ); | 266 | l.append( t[iii] ); |
267 | } | 267 | } |
268 | uint cs = getCsum4List(l); | 268 | uint cs = getCsum4List(l); |
269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 269 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
270 | setCsum( dev, QString::number (cs )); | 270 | setCsum( dev, QString::number (cs )); |
271 | } | 271 | } |
272 | 272 | ||
273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) | 273 | void Addressee::mergeContact( const Addressee& ad , bool isSubSet) // = false) |
274 | { | 274 | { |
275 | 275 | ||
276 | detach(); | 276 | detach(); |
277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 277 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 278 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 279 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 280 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 281 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 282 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 283 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 284 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
285 | if ( !mData->birthday.isValid() ) | 285 | if ( !mData->birthday.isValid() ) |
286 | if ( ad.mData->birthday.isValid()) | 286 | if ( ad.mData->birthday.isValid()) |
287 | mData->birthday = ad.mData->birthday; | 287 | mData->birthday = ad.mData->birthday; |
288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 288 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 289 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 290 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 291 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 292 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 293 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 294 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 295 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 296 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 297 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 298 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
299 | QStringList t; | 299 | QStringList t; |
300 | QStringList tAD; | 300 | QStringList tAD; |
301 | uint iii; | 301 | uint iii; |
302 | 302 | ||
303 | // ********** phone numbers | 303 | // ********** phone numbers |
304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); | 304 | PhoneNumber::List phoneAD = ad.phoneNumbers(); |
305 | PhoneNumber::List::Iterator phoneItAD; | 305 | PhoneNumber::List::Iterator phoneItAD; |
306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { | 306 | for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) { |
307 | bool found = false; | 307 | bool found = false; |
308 | PhoneNumber::List::Iterator it; | 308 | PhoneNumber::List::Iterator it; |
309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 309 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
310 | if ( ( *phoneItAD ).contains( (*it) ) ) { | 310 | if ( ( *phoneItAD ).contains( (*it) ) ) { |
311 | found = true; | 311 | found = true; |
312 | (*it).setType( ( *phoneItAD ).type() ); | 312 | (*it).setType( ( *phoneItAD ).type() ); |
313 | break; | 313 | break; |
314 | } | 314 | } |
315 | } | 315 | } |
316 | if ( isSubSet && ! found ) | 316 | if ( isSubSet && ! found ) |
317 | mData->phoneNumbers.append( *phoneItAD ); | 317 | mData->phoneNumbers.append( *phoneItAD ); |
318 | } | 318 | } |
319 | if ( isSubSet ) { | 319 | if ( isSubSet ) { |
320 | // ************* emails; | 320 | // ************* emails; |
321 | t = mData->emails; | 321 | t = mData->emails; |
322 | tAD = ad.mData->emails; | 322 | tAD = ad.mData->emails; |
323 | for ( iii = 0; iii < tAD.count(); ++iii) | 323 | for ( iii = 0; iii < tAD.count(); ++iii) |
324 | if ( !t.contains(tAD[iii] ) ) | 324 | if ( !t.contains(tAD[iii] ) ) |
325 | mData->emails.append( tAD[iii] ); | 325 | mData->emails.append( tAD[iii] ); |
326 | } | 326 | } |
327 | 327 | ||
328 | // ************* categories; | 328 | // ************* categories; |
329 | t = mData->categories; | 329 | t = mData->categories; |
330 | tAD = ad.mData->categories; | 330 | tAD = ad.mData->categories; |
331 | for ( iii = 0; iii < tAD.count(); ++iii) | 331 | for ( iii = 0; iii < tAD.count(); ++iii) |
332 | if ( !t.contains(tAD[iii] ) ) | 332 | if ( !t.contains(tAD[iii] ) ) |
333 | mData->categories.append( tAD[iii] ); | 333 | mData->categories.append( tAD[iii] ); |
334 | QStringList::ConstIterator it; | 334 | QStringList::ConstIterator it; |
335 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { | 335 | for( it = ad.mData->custom.begin(); it != ad.mData->custom.end(); ++it ) { |
336 | QString qualifiedName = (*it).left( (*it).find( ":" )); | 336 | QString qualifiedName = (*it).left( (*it).find( ":" )); |
337 | bool found = false; | 337 | bool found = false; |
338 | QStringList::ConstIterator itL; | 338 | QStringList::ConstIterator itL; |
339 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { | 339 | for( itL = mData->custom.begin(); itL != mData->custom.end(); ++itL ) { |
340 | if ( (*itL).startsWith( qualifiedName ) ) { | 340 | if ( (*itL).startsWith( qualifiedName ) ) { |
341 | found = true; | 341 | found = true; |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | if ( ! found ) { | 345 | if ( ! found ) { |
346 | mData->custom.append( *it ); | 346 | mData->custom.append( *it ); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; | 349 | if ( mData->logo.undefined() && !ad.mData->logo.undefined() ) mData->logo = ad.mData->logo; |
350 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; | 350 | if ( mData->photo.undefined() && !ad.mData->photo.undefined() ) mData->photo = ad.mData->photo; |
351 | if ( !mData->sound.isIntern() ) { | 351 | if ( !mData->sound.isIntern() ) { |
352 | if ( mData->sound.url().isEmpty() ) { | 352 | if ( mData->sound.url().isEmpty() ) { |
353 | mData->sound = ad.mData->sound; | 353 | mData->sound = ad.mData->sound; |
354 | } | 354 | } |
355 | } | 355 | } |
356 | if ( !mData->agent.isIntern() ) { | 356 | if ( !mData->agent.isIntern() ) { |
357 | if ( mData->agent.url().isEmpty() ) { | 357 | if ( mData->agent.url().isEmpty() ) { |
358 | mData->agent = ad.mData->agent; | 358 | mData->agent = ad.mData->agent; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | { | 361 | { |
362 | Key::List::Iterator itA; | 362 | Key::List::Iterator itA; |
363 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { | 363 | for( itA = ad.mData->keys.begin(); itA != ad.mData->keys.end(); ++itA ) { |
364 | bool found = false; | 364 | bool found = false; |
365 | Key::List::Iterator it; | 365 | Key::List::Iterator it; |
366 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 366 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
367 | if ( (*it) == (*itA)) { | 367 | if ( (*it) == (*itA)) { |
368 | found = true; | 368 | found = true; |
369 | break; | 369 | break; |
370 | 370 | ||
371 | } | 371 | } |
372 | } | 372 | } |
373 | if ( ! found ) { | 373 | if ( ! found ) { |
374 | mData->keys.append( *itA ); | 374 | mData->keys.append( *itA ); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | } | 377 | } |
378 | KABC::Address::List::Iterator addressIterA; | 378 | KABC::Address::List::Iterator addressIterA; |
379 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { | 379 | for ( addressIterA = ad.mData->addresses.begin(); addressIterA != ad.mData->addresses.end(); ++addressIterA ) { |
380 | bool found = false; | 380 | bool found = false; |
381 | KABC::Address::List::Iterator addressIter; | 381 | KABC::Address::List::Iterator addressIter; |
382 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 382 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
383 | ++addressIter ) { | 383 | ++addressIter ) { |
384 | if ( (*addressIter) == (*addressIterA)) { | 384 | if ( (*addressIter) == (*addressIterA)) { |
385 | found = true; | 385 | found = true; |
386 | (*addressIter).setType( (*addressIterA).type() ); | 386 | (*addressIter).setType( (*addressIterA).type() ); |
387 | break; | 387 | break; |
388 | } | 388 | } |
389 | 389 | ||
390 | } | 390 | } |
391 | if ( isSubSet && ! found ) { | 391 | if ( isSubSet && ! found ) { |
392 | mData->addresses.append( *addressIterA ); | 392 | mData->addresses.append( *addressIterA ); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | //qDebug("merge contact %s ", ad.uid().latin1()); | 395 | //qDebug("merge contact %s ", ad.uid().latin1()); |
396 | setUid( ad.uid() ); | 396 | setUid( ad.uid() ); |
397 | setRevision( ad.revision() ); | 397 | setRevision( ad.revision() ); |
398 | } | 398 | } |
399 | 399 | ||
400 | bool Addressee::removeVoice() | 400 | bool Addressee::removeVoice() |
401 | { | 401 | { |
402 | PhoneNumber::List phoneN = phoneNumbers(); | 402 | PhoneNumber::List phoneN = phoneNumbers(); |
403 | PhoneNumber::List::Iterator phoneIt; | 403 | PhoneNumber::List::Iterator phoneIt; |
404 | bool found = false; | 404 | bool found = false; |
405 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 405 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
406 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 406 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
407 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 407 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
408 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 408 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
409 | insertPhoneNumber( (*phoneIt) ); | 409 | insertPhoneNumber( (*phoneIt) ); |
410 | found = true; | 410 | found = true; |
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
414 | } | 414 | } |
415 | return found; | 415 | return found; |
416 | } | 416 | } |
417 | 417 | ||
418 | bool Addressee::containsAdr(const Addressee& ad ) | 418 | bool Addressee::containsAdr(const Addressee& ad ) |
419 | { | 419 | { |
420 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; | 420 | if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false; |
421 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; | 421 | if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false; |
422 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; | 422 | if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ; |
423 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; | 423 | if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ; |
424 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; | 424 | if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ; |
425 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; | 425 | if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ; |
426 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; | 426 | if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ; |
427 | 427 | ||
428 | // compare phone numbers | 428 | // compare phone numbers |
429 | PhoneNumber::List phoneN = ad.phoneNumbers(); | 429 | PhoneNumber::List phoneN = ad.phoneNumbers(); |
430 | PhoneNumber::List::Iterator phoneIt; | 430 | PhoneNumber::List::Iterator phoneIt; |
431 | bool found = false; | 431 | bool found = false; |
432 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 432 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
433 | bool found = false; | 433 | bool found = false; |
434 | PhoneNumber::List phoneL = ad.phoneNumbers(); | 434 | PhoneNumber::List phoneL = ad.phoneNumbers(); |
435 | PhoneNumber::List::Iterator phoneItL; | 435 | PhoneNumber::List::Iterator phoneItL; |
436 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { | 436 | for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) { |
437 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { | 437 | if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) { |
438 | found = true; | 438 | found = true; |
439 | break; | 439 | break; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | if ( ! found ) | 442 | if ( ! found ) |
443 | return false; | 443 | return false; |
444 | } | 444 | } |
445 | return true; | 445 | return true; |
446 | 446 | ||
447 | } | 447 | } |
448 | void Addressee::simplifyAddresses() | 448 | void Addressee::simplifyAddresses() |
449 | { | 449 | { |
450 | |||
451 | |||
452 | Address::List list; | ||
453 | Address::List::Iterator it; | ||
454 | Address::List::Iterator it2; | ||
455 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | ||
456 | it2 = it; | ||
457 | ++it2; | ||
458 | for( ; it2 != mData->addresses.end(); ++it2 ) { | ||
459 | if ( (*it) == (*it2) ) { | ||
460 | list.append( *it ); | ||
461 | break; | ||
462 | } | ||
463 | } | ||
464 | } | ||
465 | for( it = list.begin(); it != list.end(); ++it ) { | ||
466 | removeAddress( (*it) ); | ||
467 | } | ||
468 | |||
469 | list.clear(); | ||
450 | int max = 2; | 470 | int max = 2; |
451 | if ( mData->url.isValid() ) | 471 | if ( mData->url.isValid() ) |
452 | max = 1; | 472 | max = 1; |
453 | if ( mData->addresses.count() <= max ) return ; | 473 | if ( mData->addresses.count() <= max ) return ; |
454 | int count = 0; | 474 | int count = 0; |
455 | Address::List list; | ||
456 | Address::List::Iterator it; | ||
457 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 475 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
458 | if ( count >= max ) | 476 | if ( count >= max ) |
459 | list.append( *it ); | 477 | list.append( *it ); |
460 | ++count; | 478 | ++count; |
461 | } | 479 | } |
462 | for( it = list.begin(); it != list.end(); ++it ) { | 480 | for( it = list.begin(); it != list.end(); ++it ) { |
463 | removeAddress( (*it) ); | 481 | removeAddress( (*it) ); |
464 | } | 482 | } |
465 | } | 483 | } |
466 | 484 | ||
467 | // removes all emails but the first | 485 | // removes all emails but the first |
468 | // needed by phone sync | 486 | // needed by phone sync |
469 | void Addressee::simplifyEmails() | 487 | void Addressee::simplifyEmails() |
470 | { | 488 | { |
471 | if ( mData->emails.count() == 0 ) return ; | 489 | if ( mData->emails.count() == 0 ) return ; |
472 | QString email = mData->emails.first(); | 490 | QString email = mData->emails.first(); |
473 | detach(); | 491 | detach(); |
474 | mData->emails.clear(); | 492 | mData->emails.clear(); |
475 | mData->emails.append( email ); | 493 | mData->emails.append( email ); |
476 | } | 494 | } |
477 | 495 | ||
478 | void Addressee::simplifyPhoneNumbers() | 496 | void Addressee::simplifyPhoneNumbers() |
479 | { | 497 | { |
480 | int max = 4; | 498 | int max = 4; |
481 | int inList = mData->phoneNumbers.count(); | 499 | int inList = mData->phoneNumbers.count(); |
482 | KABC::PhoneNumber::List removeNumbers; | 500 | KABC::PhoneNumber::List removeNumbers; |
483 | KABC::PhoneNumber::List::Iterator phoneIter; | 501 | KABC::PhoneNumber::List::Iterator phoneIter; |
484 | if ( inList > max ) { | 502 | if ( inList > max ) { |
485 | // delete non-preferred numbers | 503 | // delete non-preferred numbers |
486 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 504 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
487 | ++phoneIter ) { | 505 | ++phoneIter ) { |
488 | if ( inList > max ) { | 506 | if ( inList > max ) { |
489 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { | 507 | if ( ! (( *phoneIter ).type() & PhoneNumber::Pref )) { |
490 | removeNumbers.append( ( *phoneIter ) ); | 508 | removeNumbers.append( ( *phoneIter ) ); |
491 | --inList; | 509 | --inList; |
492 | } | 510 | } |
493 | } else | 511 | } else |
494 | break; | 512 | break; |
495 | } | 513 | } |
496 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 514 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
497 | ++phoneIter ) { | 515 | ++phoneIter ) { |
498 | removePhoneNumber(( *phoneIter )); | 516 | removePhoneNumber(( *phoneIter )); |
499 | } | 517 | } |
500 | // delete preferred numbers | 518 | // delete preferred numbers |
501 | if ( inList > max ) { | 519 | if ( inList > max ) { |
502 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 520 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
503 | ++phoneIter ) { | 521 | ++phoneIter ) { |
504 | if ( inList > max ) { | 522 | if ( inList > max ) { |
505 | removeNumbers.append( ( *phoneIter ) ); | 523 | removeNumbers.append( ( *phoneIter ) ); |
506 | --inList; | 524 | --inList; |
507 | } else | 525 | } else |
508 | break; | 526 | break; |
509 | } | 527 | } |
510 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 528 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
511 | ++phoneIter ) { | 529 | ++phoneIter ) { |
512 | removePhoneNumber(( *phoneIter )); | 530 | removePhoneNumber(( *phoneIter )); |
513 | } | 531 | } |
514 | } | 532 | } |
515 | } | 533 | } |
516 | // remove non-numeric characters | 534 | // remove non-numeric characters |
517 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 535 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
518 | ++phoneIter ) { | 536 | ++phoneIter ) { |
519 | if ( ! ( *phoneIter ).simplifyNumber() ) | 537 | if ( ! ( *phoneIter ).simplifyNumber() ) |
520 | removeNumbers.append( ( *phoneIter ) ); | 538 | removeNumbers.append( ( *phoneIter ) ); |
521 | } | 539 | } |
522 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 540 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
523 | ++phoneIter ) { | 541 | ++phoneIter ) { |
524 | removePhoneNumber(( *phoneIter )); | 542 | removePhoneNumber(( *phoneIter )); |
525 | } | 543 | } |
526 | } | 544 | } |
527 | void Addressee::simplifyPhoneNumberTypes() | 545 | void Addressee::simplifyPhoneNumberTypes() |
528 | { | 546 | { |
529 | KABC::PhoneNumber::List::Iterator phoneIter; | 547 | KABC::PhoneNumber::List::Iterator phoneIter; |
530 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 548 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
531 | ++phoneIter ) | 549 | ++phoneIter ) |
532 | ( *phoneIter ).simplifyType(); | 550 | ( *phoneIter ).simplifyType(); |
533 | } | 551 | } |
534 | void Addressee::removeID(const QString &prof) | 552 | void Addressee::removeID(const QString &prof) |
535 | { | 553 | { |
536 | detach(); | 554 | detach(); |
537 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 555 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
538 | 556 | ||
539 | } | 557 | } |
540 | void Addressee::setID( const QString & prof , const QString & id ) | 558 | void Addressee::setID( const QString & prof , const QString & id ) |
541 | { | 559 | { |
542 | detach(); | 560 | detach(); |
543 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 561 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
544 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 562 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
545 | } | 563 | } |
546 | void Addressee::setTempSyncStat( int id ) | 564 | void Addressee::setTempSyncStat( int id ) |
547 | { | 565 | { |
548 | if ( mData->mTempSyncStat == id ) return; | 566 | if ( mData->mTempSyncStat == id ) return; |
549 | detach(); | 567 | detach(); |
550 | mData->mTempSyncStat = id; | 568 | mData->mTempSyncStat = id; |
551 | } | 569 | } |
552 | int Addressee::tempSyncStat() const | 570 | int Addressee::tempSyncStat() const |
553 | { | 571 | { |
554 | return mData->mTempSyncStat; | 572 | return mData->mTempSyncStat; |
555 | } | 573 | } |
556 | 574 | ||
557 | QString Addressee::getID( const QString & prof) | 575 | QString Addressee::getID( const QString & prof) |
558 | { | 576 | { |
559 | return KIdManager::getId ( mData->mExternalId, prof ); | 577 | return KIdManager::getId ( mData->mExternalId, prof ); |
560 | } | 578 | } |
561 | 579 | ||
562 | void Addressee::setCsum( const QString & prof , const QString & id ) | 580 | void Addressee::setCsum( const QString & prof , const QString & id ) |
563 | { | 581 | { |
564 | detach(); | 582 | detach(); |
565 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 583 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
566 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 584 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
567 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 585 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
568 | } | 586 | } |
569 | 587 | ||
570 | QString Addressee::getCsum( const QString & prof) | 588 | QString Addressee::getCsum( const QString & prof) |
571 | { | 589 | { |
572 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 590 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
573 | } | 591 | } |
574 | 592 | ||
575 | void Addressee::setIDStr( const QString & s ) | 593 | void Addressee::setIDStr( const QString & s ) |
576 | { | 594 | { |
577 | detach(); | 595 | detach(); |
578 | mData->mExternalId = s; | 596 | mData->mExternalId = s; |
579 | } | 597 | } |
580 | 598 | ||
581 | QString Addressee::IDStr() const | 599 | QString Addressee::IDStr() const |
582 | { | 600 | { |
583 | return mData->mExternalId; | 601 | return mData->mExternalId; |
584 | } | 602 | } |
585 | 603 | ||
586 | void Addressee::setExternalUID( const QString &id ) | 604 | void Addressee::setExternalUID( const QString &id ) |
587 | { | 605 | { |
588 | if ( id == mData->externalUID ) return; | 606 | if ( id == mData->externalUID ) return; |
589 | detach(); | 607 | detach(); |
590 | mData->empty = false; | 608 | mData->empty = false; |
591 | mData->externalUID = id; | 609 | mData->externalUID = id; |
592 | } | 610 | } |
593 | 611 | ||
594 | QString Addressee::externalUID() const | 612 | QString Addressee::externalUID() const |
595 | { | 613 | { |
596 | return mData->externalUID; | 614 | return mData->externalUID; |
597 | } | 615 | } |
598 | void Addressee::setOriginalExternalUID( const QString &id ) | 616 | void Addressee::setOriginalExternalUID( const QString &id ) |
599 | { | 617 | { |
600 | if ( id == mData->originalExternalUID ) return; | 618 | if ( id == mData->originalExternalUID ) return; |
601 | detach(); | 619 | detach(); |
602 | mData->empty = false; | 620 | mData->empty = false; |
603 | //qDebug("*******Set orig uid %s ", id.latin1()); | 621 | //qDebug("*******Set orig uid %s ", id.latin1()); |
604 | mData->originalExternalUID = id; | 622 | mData->originalExternalUID = id; |
605 | } | 623 | } |
606 | 624 | ||
607 | QString Addressee::originalExternalUID() const | 625 | QString Addressee::originalExternalUID() const |
608 | { | 626 | { |
609 | return mData->originalExternalUID; | 627 | return mData->originalExternalUID; |
610 | } | 628 | } |
611 | 629 | ||
612 | void Addressee::setUid( const QString &id ) | 630 | void Addressee::setUid( const QString &id ) |
613 | { | 631 | { |
614 | if ( id == mData->uid ) return; | 632 | if ( id == mData->uid ) return; |
615 | detach(); | 633 | detach(); |
616 | //qDebug("****setuid %s ", id.latin1()); | 634 | //qDebug("****setuid %s ", id.latin1()); |
617 | mData->empty = false; | 635 | mData->empty = false; |
618 | mData->uid = id; | 636 | mData->uid = id; |
619 | } | 637 | } |
620 | 638 | ||
621 | QString Addressee::uid() const | 639 | QString Addressee::uid() const |
622 | { | 640 | { |
623 | if ( mData->uid.isEmpty() ) | 641 | if ( mData->uid.isEmpty() ) |
624 | mData->uid = KApplication::randomString( 10 ); | 642 | mData->uid = KApplication::randomString( 10 ); |
625 | 643 | ||
626 | return mData->uid; | 644 | return mData->uid; |
627 | } | 645 | } |
628 | 646 | ||
629 | QString Addressee::uidLabel() | 647 | QString Addressee::uidLabel() |
630 | { | 648 | { |
631 | return i18n("Unique Identifier"); | 649 | return i18n("Unique Identifier"); |
632 | } | 650 | } |
633 | 651 | ||
634 | void Addressee::setName( const QString &name ) | 652 | void Addressee::setName( const QString &name ) |
635 | { | 653 | { |
636 | if ( name == mData->name ) return; | 654 | if ( name == mData->name ) return; |
637 | detach(); | 655 | detach(); |
638 | mData->empty = false; | 656 | mData->empty = false; |
639 | mData->name = name; | 657 | mData->name = name; |
640 | } | 658 | } |
641 | 659 | ||
642 | QString Addressee::name() const | 660 | QString Addressee::name() const |
643 | { | 661 | { |
644 | return mData->name; | 662 | return mData->name; |
645 | } | 663 | } |
646 | 664 | ||
647 | QString Addressee::nameLabel() | 665 | QString Addressee::nameLabel() |
648 | { | 666 | { |
649 | return i18n("Name"); | 667 | return i18n("Name"); |
650 | } | 668 | } |
651 | 669 | ||
652 | 670 | ||
653 | void Addressee::setFormattedName( const QString &formattedName ) | 671 | void Addressee::setFormattedName( const QString &formattedName ) |
654 | { | 672 | { |
655 | if ( formattedName == mData->formattedName ) return; | 673 | if ( formattedName == mData->formattedName ) return; |
656 | detach(); | 674 | detach(); |
657 | mData->empty = false; | 675 | mData->empty = false; |
658 | mData->formattedName = formattedName; | 676 | mData->formattedName = formattedName; |
659 | } | 677 | } |
660 | 678 | ||
661 | QString Addressee::formattedName() const | 679 | QString Addressee::formattedName() const |
662 | { | 680 | { |
663 | return mData->formattedName; | 681 | return mData->formattedName; |
664 | } | 682 | } |
665 | 683 | ||
666 | QString Addressee::formattedNameLabel() | 684 | QString Addressee::formattedNameLabel() |
667 | { | 685 | { |
668 | return i18n("Formatted Name"); | 686 | return i18n("Formatted Name"); |
669 | } | 687 | } |
670 | 688 | ||
671 | 689 | ||
672 | void Addressee::setFamilyName( const QString &familyName ) | 690 | void Addressee::setFamilyName( const QString &familyName ) |
673 | { | 691 | { |
674 | if ( familyName == mData->familyName ) return; | 692 | if ( familyName == mData->familyName ) return; |
675 | detach(); | 693 | detach(); |
676 | mData->empty = false; | 694 | mData->empty = false; |
677 | mData->familyName = familyName; | 695 | mData->familyName = familyName; |
678 | } | 696 | } |
679 | 697 | ||
680 | QString Addressee::familyName() const | 698 | QString Addressee::familyName() const |
681 | { | 699 | { |
682 | return mData->familyName; | 700 | return mData->familyName; |
683 | } | 701 | } |
684 | 702 | ||
685 | QString Addressee::familyNameLabel() | 703 | QString Addressee::familyNameLabel() |
686 | { | 704 | { |
687 | return i18n("Family Name"); | 705 | return i18n("Family Name"); |
688 | } | 706 | } |
689 | 707 | ||
690 | 708 | ||
691 | void Addressee::setGivenName( const QString &givenName ) | 709 | void Addressee::setGivenName( const QString &givenName ) |
692 | { | 710 | { |
693 | if ( givenName == mData->givenName ) return; | 711 | if ( givenName == mData->givenName ) return; |
694 | detach(); | 712 | detach(); |
695 | mData->empty = false; | 713 | mData->empty = false; |
696 | mData->givenName = givenName; | 714 | mData->givenName = givenName; |
697 | } | 715 | } |
698 | 716 | ||
699 | QString Addressee::givenName() const | 717 | QString Addressee::givenName() const |
700 | { | 718 | { |
701 | return mData->givenName; | 719 | return mData->givenName; |
702 | } | 720 | } |
703 | 721 | ||
704 | QString Addressee::givenNameLabel() | 722 | QString Addressee::givenNameLabel() |
705 | { | 723 | { |
706 | return i18n("Given Name"); | 724 | return i18n("Given Name"); |
707 | } | 725 | } |
708 | 726 | ||
709 | 727 | ||
710 | void Addressee::setAdditionalName( const QString &additionalName ) | 728 | void Addressee::setAdditionalName( const QString &additionalName ) |
711 | { | 729 | { |
712 | if ( additionalName == mData->additionalName ) return; | 730 | if ( additionalName == mData->additionalName ) return; |
713 | detach(); | 731 | detach(); |
714 | mData->empty = false; | 732 | mData->empty = false; |
715 | mData->additionalName = additionalName; | 733 | mData->additionalName = additionalName; |
716 | } | 734 | } |
717 | 735 | ||
718 | QString Addressee::additionalName() const | 736 | QString Addressee::additionalName() const |
719 | { | 737 | { |
720 | return mData->additionalName; | 738 | return mData->additionalName; |
721 | } | 739 | } |
722 | 740 | ||
723 | QString Addressee::additionalNameLabel() | 741 | QString Addressee::additionalNameLabel() |
724 | { | 742 | { |
725 | return i18n("Additional Names"); | 743 | return i18n("Additional Names"); |
726 | } | 744 | } |
727 | 745 | ||
728 | 746 | ||
729 | void Addressee::setPrefix( const QString &prefix ) | 747 | void Addressee::setPrefix( const QString &prefix ) |
730 | { | 748 | { |
731 | if ( prefix == mData->prefix ) return; | 749 | if ( prefix == mData->prefix ) return; |
732 | detach(); | 750 | detach(); |
733 | mData->empty = false; | 751 | mData->empty = false; |
734 | mData->prefix = prefix; | 752 | mData->prefix = prefix; |
735 | } | 753 | } |
736 | 754 | ||
737 | QString Addressee::prefix() const | 755 | QString Addressee::prefix() const |
738 | { | 756 | { |
739 | return mData->prefix; | 757 | return mData->prefix; |
740 | } | 758 | } |
741 | 759 | ||
742 | QString Addressee::prefixLabel() | 760 | QString Addressee::prefixLabel() |
743 | { | 761 | { |
744 | return i18n("Honorific Prefixes"); | 762 | return i18n("Honorific Prefixes"); |
745 | } | 763 | } |
746 | 764 | ||
747 | 765 | ||
748 | void Addressee::setSuffix( const QString &suffix ) | 766 | void Addressee::setSuffix( const QString &suffix ) |
749 | { | 767 | { |
750 | if ( suffix == mData->suffix ) return; | 768 | if ( suffix == mData->suffix ) return; |
751 | detach(); | 769 | detach(); |
752 | mData->empty = false; | 770 | mData->empty = false; |
753 | mData->suffix = suffix; | 771 | mData->suffix = suffix; |
754 | } | 772 | } |
755 | 773 | ||
756 | QString Addressee::suffix() const | 774 | QString Addressee::suffix() const |
757 | { | 775 | { |
758 | return mData->suffix; | 776 | return mData->suffix; |
759 | } | 777 | } |
760 | 778 | ||
761 | QString Addressee::suffixLabel() | 779 | QString Addressee::suffixLabel() |
762 | { | 780 | { |
763 | return i18n("Honorific Suffixes"); | 781 | return i18n("Honorific Suffixes"); |
764 | } | 782 | } |
765 | 783 | ||
766 | 784 | ||
767 | void Addressee::setNickName( const QString &nickName ) | 785 | void Addressee::setNickName( const QString &nickName ) |
768 | { | 786 | { |
769 | if ( nickName == mData->nickName ) return; | 787 | if ( nickName == mData->nickName ) return; |
770 | detach(); | 788 | detach(); |
771 | mData->empty = false; | 789 | mData->empty = false; |
772 | mData->nickName = nickName; | 790 | mData->nickName = nickName; |
773 | } | 791 | } |
774 | 792 | ||
775 | QString Addressee::nickName() const | 793 | QString Addressee::nickName() const |
776 | { | 794 | { |
777 | return mData->nickName; | 795 | return mData->nickName; |
778 | } | 796 | } |
779 | 797 | ||
780 | QString Addressee::nickNameLabel() | 798 | QString Addressee::nickNameLabel() |
781 | { | 799 | { |
782 | return i18n("Nick Name"); | 800 | return i18n("Nick Name"); |
783 | } | 801 | } |
784 | 802 | ||
785 | 803 | ||
786 | void Addressee::setBirthday( const QDateTime &birthday ) | 804 | void Addressee::setBirthday( const QDateTime &birthday ) |
787 | { | 805 | { |
788 | if ( birthday == mData->birthday ) return; | 806 | if ( birthday == mData->birthday ) return; |
789 | detach(); | 807 | detach(); |
790 | mData->empty = false; | 808 | mData->empty = false; |
791 | mData->birthday = birthday; | 809 | mData->birthday = birthday; |
792 | } | 810 | } |
793 | 811 | ||
794 | QDateTime Addressee::birthday() const | 812 | QDateTime Addressee::birthday() const |
795 | { | 813 | { |
796 | return mData->birthday; | 814 | return mData->birthday; |
797 | } | 815 | } |
798 | 816 | ||
799 | QString Addressee::birthdayLabel() | 817 | QString Addressee::birthdayLabel() |
800 | { | 818 | { |
801 | return i18n("Birthday"); | 819 | return i18n("Birthday"); |
802 | } | 820 | } |
803 | 821 | ||
804 | 822 | ||
805 | QString Addressee::homeAddressStreetLabel() | 823 | QString Addressee::homeAddressStreetLabel() |
806 | { | 824 | { |
807 | return i18n("Home Address Street"); | 825 | return i18n("Home Address Street"); |
808 | } | 826 | } |
809 | 827 | ||
810 | 828 | ||
811 | QString Addressee::homeAddressLocalityLabel() | 829 | QString Addressee::homeAddressLocalityLabel() |
812 | { | 830 | { |
813 | return i18n("Home Address Locality"); | 831 | return i18n("Home Address Locality"); |
814 | } | 832 | } |
815 | 833 | ||
816 | 834 | ||
817 | QString Addressee::homeAddressRegionLabel() | 835 | QString Addressee::homeAddressRegionLabel() |
818 | { | 836 | { |
819 | return i18n("Home Address Region"); | 837 | return i18n("Home Address Region"); |
820 | } | 838 | } |
821 | 839 | ||
822 | 840 | ||
823 | QString Addressee::homeAddressPostalCodeLabel() | 841 | QString Addressee::homeAddressPostalCodeLabel() |
824 | { | 842 | { |
825 | return i18n("Home Address Postal Code"); | 843 | return i18n("Home Address Postal Code"); |
826 | } | 844 | } |
827 | 845 | ||
828 | 846 | ||
829 | QString Addressee::homeAddressCountryLabel() | 847 | QString Addressee::homeAddressCountryLabel() |
830 | { | 848 | { |
831 | return i18n("Home Address Country"); | 849 | return i18n("Home Address Country"); |
832 | } | 850 | } |
833 | 851 | ||
834 | 852 | ||
835 | QString Addressee::homeAddressLabelLabel() | 853 | QString Addressee::homeAddressLabelLabel() |
836 | { | 854 | { |
837 | return i18n("Home Address Label"); | 855 | return i18n("Home Address Label"); |
838 | } | 856 | } |
839 | 857 | ||
840 | 858 | ||
841 | QString Addressee::businessAddressStreetLabel() | 859 | QString Addressee::businessAddressStreetLabel() |
842 | { | 860 | { |
843 | return i18n("Business Address Street"); | 861 | return i18n("Business Address Street"); |
844 | } | 862 | } |
845 | 863 | ||
846 | 864 | ||
847 | QString Addressee::businessAddressLocalityLabel() | 865 | QString Addressee::businessAddressLocalityLabel() |
848 | { | 866 | { |
849 | return i18n("Business Address Locality"); | 867 | return i18n("Business Address Locality"); |
850 | } | 868 | } |
851 | 869 | ||
852 | 870 | ||
853 | QString Addressee::businessAddressRegionLabel() | 871 | QString Addressee::businessAddressRegionLabel() |
854 | { | 872 | { |
855 | return i18n("Business Address Region"); | 873 | return i18n("Business Address Region"); |
856 | } | 874 | } |
857 | 875 | ||
858 | 876 | ||
859 | QString Addressee::businessAddressPostalCodeLabel() | 877 | QString Addressee::businessAddressPostalCodeLabel() |
860 | { | 878 | { |
861 | return i18n("Business Address Postal Code"); | 879 | return i18n("Business Address Postal Code"); |
862 | } | 880 | } |
863 | 881 | ||
864 | 882 | ||
865 | QString Addressee::businessAddressCountryLabel() | 883 | QString Addressee::businessAddressCountryLabel() |
866 | { | 884 | { |
867 | return i18n("Business Address Country"); | 885 | return i18n("Business Address Country"); |
868 | } | 886 | } |
869 | 887 | ||
870 | 888 | ||
871 | QString Addressee::businessAddressLabelLabel() | 889 | QString Addressee::businessAddressLabelLabel() |
872 | { | 890 | { |
873 | return i18n("Business Address Label"); | 891 | return i18n("Business Address Label"); |
874 | } | 892 | } |
875 | 893 | ||
876 | 894 | ||
877 | QString Addressee::homePhoneLabel() | 895 | QString Addressee::homePhoneLabel() |
878 | { | 896 | { |
879 | return i18n("Home Phone"); | 897 | return i18n("Home Phone"); |
880 | } | 898 | } |
881 | 899 | ||
882 | 900 | ||
883 | QString Addressee::businessPhoneLabel() | 901 | QString Addressee::businessPhoneLabel() |
884 | { | 902 | { |
885 | return i18n("Business Phone"); | 903 | return i18n("Business Phone"); |
886 | } | 904 | } |
887 | 905 | ||
888 | 906 | ||
889 | QString Addressee::mobilePhoneLabel() | 907 | QString Addressee::mobilePhoneLabel() |
890 | { | 908 | { |
891 | return i18n("Mobile Phone"); | 909 | return i18n("Mobile Phone"); |
892 | } | 910 | } |
893 | 911 | ||
894 | 912 | ||
895 | QString Addressee::homeFaxLabel() | 913 | QString Addressee::homeFaxLabel() |
896 | { | 914 | { |
897 | return i18n("Home Fax"); | 915 | return i18n("Home Fax"); |
898 | } | 916 | } |
899 | 917 | ||
900 | 918 | ||
901 | QString Addressee::businessFaxLabel() | 919 | QString Addressee::businessFaxLabel() |
902 | { | 920 | { |
903 | return i18n("Business Fax"); | 921 | return i18n("Business Fax"); |
904 | } | 922 | } |
905 | 923 | ||
906 | 924 | ||
907 | QString Addressee::carPhoneLabel() | 925 | QString Addressee::carPhoneLabel() |
908 | { | 926 | { |
909 | return i18n("Car Phone"); | 927 | return i18n("Car Phone"); |
910 | } | 928 | } |
911 | 929 | ||
912 | 930 | ||
913 | QString Addressee::isdnLabel() | 931 | QString Addressee::isdnLabel() |
914 | { | 932 | { |
915 | return i18n("ISDN"); | 933 | return i18n("ISDN"); |
916 | } | 934 | } |
917 | 935 | ||
918 | 936 | ||
919 | QString Addressee::pagerLabel() | 937 | QString Addressee::pagerLabel() |
920 | { | 938 | { |
921 | return i18n("Pager"); | 939 | return i18n("Pager"); |
922 | } | 940 | } |
923 | 941 | ||
924 | QString Addressee::sipLabel() | 942 | QString Addressee::sipLabel() |
925 | { | 943 | { |
926 | return i18n("SIP"); | 944 | return i18n("SIP"); |
927 | } | 945 | } |
928 | 946 | ||
929 | QString Addressee::emailLabel() | 947 | QString Addressee::emailLabel() |
930 | { | 948 | { |
931 | return i18n("Email Address"); | 949 | return i18n("Email Address"); |
932 | } | 950 | } |
933 | 951 | ||
934 | 952 | ||
935 | void Addressee::setMailer( const QString &mailer ) | 953 | void Addressee::setMailer( const QString &mailer ) |
936 | { | 954 | { |
937 | if ( mailer == mData->mailer ) return; | 955 | if ( mailer == mData->mailer ) return; |
938 | detach(); | 956 | detach(); |
939 | mData->empty = false; | 957 | mData->empty = false; |
940 | mData->mailer = mailer; | 958 | mData->mailer = mailer; |
941 | } | 959 | } |
942 | 960 | ||
943 | QString Addressee::mailer() const | 961 | QString Addressee::mailer() const |
944 | { | 962 | { |
945 | return mData->mailer; | 963 | return mData->mailer; |
946 | } | 964 | } |
947 | 965 | ||
948 | QString Addressee::mailerLabel() | 966 | QString Addressee::mailerLabel() |
949 | { | 967 | { |
950 | return i18n("Mail Client"); | 968 | return i18n("Mail Client"); |
951 | } | 969 | } |
952 | 970 | ||
953 | 971 | ||
954 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 972 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
955 | { | 973 | { |
956 | if ( timeZone == mData->timeZone ) return; | 974 | if ( timeZone == mData->timeZone ) return; |
957 | detach(); | 975 | detach(); |
958 | mData->empty = false; | 976 | mData->empty = false; |
959 | mData->timeZone = timeZone; | 977 | mData->timeZone = timeZone; |
960 | } | 978 | } |
961 | 979 | ||
962 | TimeZone Addressee::timeZone() const | 980 | TimeZone Addressee::timeZone() const |
963 | { | 981 | { |
964 | return mData->timeZone; | 982 | return mData->timeZone; |
965 | } | 983 | } |
966 | 984 | ||
967 | QString Addressee::timeZoneLabel() | 985 | QString Addressee::timeZoneLabel() |
968 | { | 986 | { |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index dae9cd2..087e9e3 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -184,1165 +184,1163 @@ class KAex2phonePrefs : public QDialog | |||
184 | temphb = new QHBox( this ); | 184 | temphb = new QHBox( this ); |
185 | new QLabel( i18n("Model(opt.): "), temphb ); | 185 | new QLabel( i18n("Model(opt.): "), temphb ); |
186 | mPhoneModel = new QLineEdit( temphb); | 186 | mPhoneModel = new QLineEdit( temphb); |
187 | lay->addWidget( temphb ); | 187 | lay->addWidget( temphb ); |
188 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 188 | // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
189 | // lay->addWidget( mWriteToSim ); | 189 | // lay->addWidget( mWriteToSim ); |
190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
191 | lab->setAlignment (AlignHCenter ); | 191 | lab->setAlignment (AlignHCenter ); |
192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
193 | lay->addWidget( ok ); | 193 | lay->addWidget( ok ); |
194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
195 | lay->addWidget( cancel ); | 195 | lay->addWidget( cancel ); |
196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
198 | resize( 220, 240 ); | 198 | resize( 220, 240 ); |
199 | 199 | ||
200 | } | 200 | } |
201 | 201 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | bool pasteWithNewUid = true; | 207 | bool pasteWithNewUid = true; |
208 | 208 | ||
209 | #ifdef KAB_EMBEDDED | 209 | #ifdef KAB_EMBEDDED |
210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
214 | #else //KAB_EMBEDDED | 214 | #else //KAB_EMBEDDED |
215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
218 | mReadWrite( readWrite ), mModified( false ) | 218 | mReadWrite( readWrite ), mModified( false ) |
219 | #endif //KAB_EMBEDDED | 219 | #endif //KAB_EMBEDDED |
220 | { | 220 | { |
221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
222 | // syncManager->setBlockSave(false); | 222 | // syncManager->setBlockSave(false); |
223 | mExtensionBarSplitter = 0; | 223 | mExtensionBarSplitter = 0; |
224 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 224 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
225 | 225 | ||
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | 323 | ||
324 | delete syncManager; | 324 | delete syncManager; |
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | void KABCore::recieve( QString fn ) | 328 | void KABCore::recieve( QString fn ) |
329 | { | 329 | { |
330 | //qDebug("KABCore::recieve "); | 330 | //qDebug("KABCore::recieve "); |
331 | mAddressBook->importFromFile( fn, true ); | 331 | mAddressBook->importFromFile( fn, true ); |
332 | mViewManager->refreshView(); | 332 | mViewManager->refreshView(); |
333 | topLevelWidget()->raise(); | 333 | topLevelWidget()->raise(); |
334 | } | 334 | } |
335 | void KABCore::restoreSettings() | 335 | void KABCore::restoreSettings() |
336 | { | 336 | { |
337 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 337 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
338 | 338 | ||
339 | bool state; | 339 | bool state; |
340 | 340 | ||
341 | if (mMultipleViewsAtOnce) | 341 | if (mMultipleViewsAtOnce) |
342 | state = KABPrefs::instance()->mDetailsPageVisible; | 342 | state = KABPrefs::instance()->mDetailsPageVisible; |
343 | else | 343 | else |
344 | state = false; | 344 | state = false; |
345 | 345 | ||
346 | mActionDetails->setChecked( state ); | 346 | mActionDetails->setChecked( state ); |
347 | setDetailsVisible( state ); | 347 | setDetailsVisible( state ); |
348 | 348 | ||
349 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 349 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
350 | 350 | ||
351 | mActionJumpBar->setChecked( state ); | 351 | mActionJumpBar->setChecked( state ); |
352 | setJumpButtonBarVisible( state ); | 352 | setJumpButtonBarVisible( state ); |
353 | /*US | 353 | /*US |
354 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 354 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
355 | if ( splitterSize.count() == 0 ) { | 355 | if ( splitterSize.count() == 0 ) { |
356 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
357 | splitterSize.append( width() / 2 ); | 357 | splitterSize.append( width() / 2 ); |
358 | } | 358 | } |
359 | mMiniSplitter->setSizes( splitterSize ); | 359 | mMiniSplitter->setSizes( splitterSize ); |
360 | if ( mExtensionBarSplitter ) { | 360 | if ( mExtensionBarSplitter ) { |
361 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 361 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
362 | if ( splitterSize.count() == 0 ) { | 362 | if ( splitterSize.count() == 0 ) { |
363 | splitterSize.append( width() / 2 ); | 363 | splitterSize.append( width() / 2 ); |
364 | splitterSize.append( width() / 2 ); | 364 | splitterSize.append( width() / 2 ); |
365 | } | 365 | } |
366 | mExtensionBarSplitter->setSizes( splitterSize ); | 366 | mExtensionBarSplitter->setSizes( splitterSize ); |
367 | 367 | ||
368 | } | 368 | } |
369 | */ | 369 | */ |
370 | mViewManager->restoreSettings(); | 370 | mViewManager->restoreSettings(); |
371 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 371 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
372 | mExtensionManager->restoreSettings(); | 372 | mExtensionManager->restoreSettings(); |
373 | #ifdef DESKTOP_VERSION | 373 | #ifdef DESKTOP_VERSION |
374 | int wid = width(); | 374 | int wid = width(); |
375 | if ( wid < 10 ) | 375 | if ( wid < 10 ) |
376 | wid = 400; | 376 | wid = 400; |
377 | #else | 377 | #else |
378 | int wid = QApplication::desktop()->width(); | 378 | int wid = QApplication::desktop()->width(); |
379 | if ( wid < 640 ) | 379 | if ( wid < 640 ) |
380 | wid = QApplication::desktop()->height(); | 380 | wid = QApplication::desktop()->height(); |
381 | #endif | 381 | #endif |
382 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 382 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
383 | if ( true /*splitterSize.count() == 0*/ ) { | 383 | if ( true /*splitterSize.count() == 0*/ ) { |
384 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
385 | splitterSize.append( wid / 2 ); | 385 | splitterSize.append( wid / 2 ); |
386 | } | 386 | } |
387 | mMiniSplitter->setSizes( splitterSize ); | 387 | mMiniSplitter->setSizes( splitterSize ); |
388 | if ( mExtensionBarSplitter ) { | 388 | if ( mExtensionBarSplitter ) { |
389 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 389 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
390 | if ( true /*splitterSize.count() == 0*/ ) { | 390 | if ( true /*splitterSize.count() == 0*/ ) { |
391 | splitterSize.append( wid / 2 ); | 391 | splitterSize.append( wid / 2 ); |
392 | splitterSize.append( wid / 2 ); | 392 | splitterSize.append( wid / 2 ); |
393 | } | 393 | } |
394 | mExtensionBarSplitter->setSizes( splitterSize ); | 394 | mExtensionBarSplitter->setSizes( splitterSize ); |
395 | 395 | ||
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | void KABCore::saveSettings() | 401 | void KABCore::saveSettings() |
402 | { | 402 | { |
403 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 403 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
404 | if ( mExtensionBarSplitter ) | 404 | if ( mExtensionBarSplitter ) |
405 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 405 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
406 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 406 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
407 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 407 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
408 | #ifndef KAB_EMBEDDED | 408 | #ifndef KAB_EMBEDDED |
409 | 409 | ||
410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
411 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 411 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
412 | #endif //KAB_EMBEDDED | 412 | #endif //KAB_EMBEDDED |
413 | mExtensionManager->saveSettings(); | 413 | mExtensionManager->saveSettings(); |
414 | mViewManager->saveSettings(); | 414 | mViewManager->saveSettings(); |
415 | 415 | ||
416 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 416 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
417 | } | 417 | } |
418 | 418 | ||
419 | KABC::AddressBook *KABCore::addressBook() const | 419 | KABC::AddressBook *KABCore::addressBook() const |
420 | { | 420 | { |
421 | return mAddressBook; | 421 | return mAddressBook; |
422 | } | 422 | } |
423 | 423 | ||
424 | KConfig *KABCore::config() | 424 | KConfig *KABCore::config() |
425 | { | 425 | { |
426 | #ifndef KAB_EMBEDDED | 426 | #ifndef KAB_EMBEDDED |
427 | return KABPrefs::instance()->config(); | 427 | return KABPrefs::instance()->config(); |
428 | #else //KAB_EMBEDDED | 428 | #else //KAB_EMBEDDED |
429 | return KABPrefs::instance()->getConfig(); | 429 | return KABPrefs::instance()->getConfig(); |
430 | #endif //KAB_EMBEDDED | 430 | #endif //KAB_EMBEDDED |
431 | } | 431 | } |
432 | 432 | ||
433 | KActionCollection *KABCore::actionCollection() const | 433 | KActionCollection *KABCore::actionCollection() const |
434 | { | 434 | { |
435 | return mGUIClient->actionCollection(); | 435 | return mGUIClient->actionCollection(); |
436 | } | 436 | } |
437 | 437 | ||
438 | KABC::Field *KABCore::currentSearchField() const | 438 | KABC::Field *KABCore::currentSearchField() const |
439 | { | 439 | { |
440 | if (mIncSearchWidget) | 440 | if (mIncSearchWidget) |
441 | return mIncSearchWidget->currentField(); | 441 | return mIncSearchWidget->currentField(); |
442 | else | 442 | else |
443 | return 0; | 443 | return 0; |
444 | } | 444 | } |
445 | 445 | ||
446 | QStringList KABCore::selectedUIDs() const | 446 | QStringList KABCore::selectedUIDs() const |
447 | { | 447 | { |
448 | return mViewManager->selectedUids(); | 448 | return mViewManager->selectedUids(); |
449 | } | 449 | } |
450 | 450 | ||
451 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 451 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
452 | { | 452 | { |
453 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 453 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
454 | 454 | ||
455 | QPtrList<KRES::Resource> kresResources; | 455 | QPtrList<KRES::Resource> kresResources; |
456 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 456 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
457 | KABC::Resource *resource; | 457 | KABC::Resource *resource; |
458 | while ( ( resource = resIt.current() ) != 0 ) { | 458 | while ( ( resource = resIt.current() ) != 0 ) { |
459 | ++resIt; | 459 | ++resIt; |
460 | if ( !resource->readOnly() ) { | 460 | if ( !resource->readOnly() ) { |
461 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 461 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
462 | if ( res ) | 462 | if ( res ) |
463 | kresResources.append( res ); | 463 | kresResources.append( res ); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 467 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
468 | return static_cast<KABC::Resource*>( res ); | 468 | return static_cast<KABC::Resource*>( res ); |
469 | } | 469 | } |
470 | 470 | ||
471 | #ifndef KAB_EMBEDDED | 471 | #ifndef KAB_EMBEDDED |
472 | KAboutData *KABCore::createAboutData() | 472 | KAboutData *KABCore::createAboutData() |
473 | #else //KAB_EMBEDDED | 473 | #else //KAB_EMBEDDED |
474 | void KABCore::createAboutData() | 474 | void KABCore::createAboutData() |
475 | #endif //KAB_EMBEDDED | 475 | #endif //KAB_EMBEDDED |
476 | { | 476 | { |
477 | #ifndef KAB_EMBEDDED | 477 | #ifndef KAB_EMBEDDED |
478 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 478 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
479 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 479 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
480 | KAboutData::License_GPL_V2, | 480 | KAboutData::License_GPL_V2, |
481 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 481 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
482 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 482 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
483 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 483 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
484 | about->addAuthor( "Cornelius Schumacher", | 484 | about->addAuthor( "Cornelius Schumacher", |
485 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 485 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
486 | "schumacher@kde.org" ); | 486 | "schumacher@kde.org" ); |
487 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 487 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
488 | "mpilone@slac.com" ); | 488 | "mpilone@slac.com" ); |
489 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 489 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
490 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 490 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
491 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 491 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
492 | "michel@klaralvdalens-datakonsult.se" ); | 492 | "michel@klaralvdalens-datakonsult.se" ); |
493 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 493 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
494 | "hansen@kde.org" ); | 494 | "hansen@kde.org" ); |
495 | 495 | ||
496 | return about; | 496 | return about; |
497 | #endif //KAB_EMBEDDED | 497 | #endif //KAB_EMBEDDED |
498 | 498 | ||
499 | QString version; | 499 | QString version; |
500 | #include <../version> | 500 | #include <../version> |
501 | QMessageBox::about( this, "About KAddressbook/Pi", | 501 | QMessageBox::about( this, "About KAddressbook/Pi", |
502 | "KAddressbook/Platform-independent\n" | 502 | "KAddressbook/Platform-independent\n" |
503 | "(KA/Pi) " +version + " - " + | 503 | "(KA/Pi) " +version + " - " + |
504 | #ifdef DESKTOP_VERSION | 504 | #ifdef DESKTOP_VERSION |
505 | "Desktop Edition\n" | 505 | "Desktop Edition\n" |
506 | #else | 506 | #else |
507 | "PDA-Edition\n" | 507 | "PDA-Edition\n" |
508 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 508 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
509 | #endif | 509 | #endif |
510 | 510 | ||
511 | "(c) 2004 Ulf Schenk\n" | 511 | "(c) 2004 Ulf Schenk\n" |
512 | "(c) 2004 Lutz Rogowski\n" | 512 | "(c) 2004 Lutz Rogowski\n" |
513 | "(c) 1997-2003, The KDE PIM Team\n" | 513 | "(c) 1997-2003, The KDE PIM Team\n" |
514 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 514 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
515 | "Don Sanders Original author\n" | 515 | "Don Sanders Original author\n" |
516 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 516 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
517 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 517 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
518 | "Greg Stern DCOP interface\n" | 518 | "Greg Stern DCOP interface\n" |
519 | "Mark Westcot Contact pinning\n" | 519 | "Mark Westcot Contact pinning\n" |
520 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 520 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
521 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 521 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
522 | #ifdef _WIN32_ | 522 | #ifdef _WIN32_ |
523 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 523 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
524 | #endif | 524 | #endif |
525 | ); | 525 | ); |
526 | } | 526 | } |
527 | 527 | ||
528 | void KABCore::setContactSelected( const QString &uid ) | 528 | void KABCore::setContactSelected( const QString &uid ) |
529 | { | 529 | { |
530 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 530 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
531 | if ( !mDetails->isHidden() ) | 531 | if ( !mDetails->isHidden() ) |
532 | mDetails->setAddressee( addr ); | 532 | mDetails->setAddressee( addr ); |
533 | 533 | ||
534 | if ( !addr.isEmpty() ) { | 534 | if ( !addr.isEmpty() ) { |
535 | emit contactSelected( addr.formattedName() ); | 535 | emit contactSelected( addr.formattedName() ); |
536 | KABC::Picture pic = addr.photo(); | 536 | KABC::Picture pic = addr.photo(); |
537 | if ( pic.isIntern() ) { | 537 | if ( pic.isIntern() ) { |
538 | //US emit contactSelected( pic.data() ); | 538 | //US emit contactSelected( pic.data() ); |
539 | //US instead use: | 539 | //US instead use: |
540 | QPixmap px; | 540 | QPixmap px; |
541 | if (pic.data().isNull() != true) | 541 | if (pic.data().isNull() != true) |
542 | { | 542 | { |
543 | px.convertFromImage(pic.data()); | 543 | px.convertFromImage(pic.data()); |
544 | } | 544 | } |
545 | 545 | ||
546 | emit contactSelected( px ); | 546 | emit contactSelected( px ); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | mExtensionManager->setSelectionChanged(); | 551 | mExtensionManager->setSelectionChanged(); |
552 | 552 | ||
553 | // update the actions | 553 | // update the actions |
554 | bool selected = !uid.isEmpty(); | 554 | bool selected = !uid.isEmpty(); |
555 | 555 | ||
556 | if ( mReadWrite ) { | 556 | if ( mReadWrite ) { |
557 | mActionCut->setEnabled( selected ); | 557 | mActionCut->setEnabled( selected ); |
558 | mActionPaste->setEnabled( selected ); | 558 | mActionPaste->setEnabled( selected ); |
559 | } | 559 | } |
560 | 560 | ||
561 | mActionCopy->setEnabled( selected ); | 561 | mActionCopy->setEnabled( selected ); |
562 | mActionDelete->setEnabled( selected ); | 562 | mActionDelete->setEnabled( selected ); |
563 | mActionEditAddressee->setEnabled( selected ); | 563 | mActionEditAddressee->setEnabled( selected ); |
564 | mActionMail->setEnabled( selected ); | 564 | mActionMail->setEnabled( selected ); |
565 | mActionMailVCard->setEnabled( selected ); | 565 | mActionMailVCard->setEnabled( selected ); |
566 | //if (mActionBeam) | 566 | //if (mActionBeam) |
567 | //mActionBeam->setEnabled( selected ); | 567 | //mActionBeam->setEnabled( selected ); |
568 | 568 | ||
569 | if (mActionBeamVCard) | 569 | if (mActionBeamVCard) |
570 | mActionBeamVCard->setEnabled( selected ); | 570 | mActionBeamVCard->setEnabled( selected ); |
571 | 571 | ||
572 | mActionExport2phone->setEnabled( selected ); | 572 | mActionExport2phone->setEnabled( selected ); |
573 | mActionWhoAmI->setEnabled( selected ); | 573 | mActionWhoAmI->setEnabled( selected ); |
574 | mActionCategories->setEnabled( selected ); | 574 | mActionCategories->setEnabled( selected ); |
575 | } | 575 | } |
576 | 576 | ||
577 | void KABCore::sendMail() | 577 | void KABCore::sendMail() |
578 | { | 578 | { |
579 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 579 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
580 | } | 580 | } |
581 | 581 | ||
582 | void KABCore::sendMail( const QString& emaillist ) | 582 | void KABCore::sendMail( const QString& emaillist ) |
583 | { | 583 | { |
584 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 584 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
585 | if (emaillist.contains(",") > 0) | 585 | if (emaillist.contains(",") > 0) |
586 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 586 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
587 | else | 587 | else |
588 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 588 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
589 | } | 589 | } |
590 | 590 | ||
591 | 591 | ||
592 | 592 | ||
593 | void KABCore::mailVCard() | 593 | void KABCore::mailVCard() |
594 | { | 594 | { |
595 | QStringList uids = mViewManager->selectedUids(); | 595 | QStringList uids = mViewManager->selectedUids(); |
596 | if ( !uids.isEmpty() ) | 596 | if ( !uids.isEmpty() ) |
597 | mailVCard( uids ); | 597 | mailVCard( uids ); |
598 | } | 598 | } |
599 | 599 | ||
600 | void KABCore::mailVCard( const QStringList& uids ) | 600 | void KABCore::mailVCard( const QStringList& uids ) |
601 | { | 601 | { |
602 | QStringList urls; | 602 | QStringList urls; |
603 | 603 | ||
604 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 604 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
605 | 605 | ||
606 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 606 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
607 | 607 | ||
608 | 608 | ||
609 | 609 | ||
610 | QDir().mkdir( dirName, true ); | 610 | QDir().mkdir( dirName, true ); |
611 | 611 | ||
612 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 612 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
613 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 613 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
614 | 614 | ||
615 | if ( a.isEmpty() ) | 615 | if ( a.isEmpty() ) |
616 | continue; | 616 | continue; |
617 | 617 | ||
618 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 618 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
619 | 619 | ||
620 | QString fileName = dirName + "/" + name; | 620 | QString fileName = dirName + "/" + name; |
621 | 621 | ||
622 | QFile outFile(fileName); | 622 | QFile outFile(fileName); |
623 | 623 | ||
624 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 624 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
625 | KABC::VCardConverter converter; | 625 | KABC::VCardConverter converter; |
626 | QString vcard; | 626 | QString vcard; |
627 | 627 | ||
628 | converter.addresseeToVCard( a, vcard ); | 628 | converter.addresseeToVCard( a, vcard ); |
629 | 629 | ||
630 | QTextStream t( &outFile ); // use a text stream | 630 | QTextStream t( &outFile ); // use a text stream |
631 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 631 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
632 | t << vcard; | 632 | t << vcard; |
633 | 633 | ||
634 | outFile.close(); | 634 | outFile.close(); |
635 | 635 | ||
636 | urls.append( fileName ); | 636 | urls.append( fileName ); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | 639 | ||
640 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 640 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
641 | 641 | ||
642 | 642 | ||
643 | /*US | 643 | /*US |
644 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 644 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
645 | QString::null, // subject | 645 | QString::null, // subject |
646 | QString::null, // body | 646 | QString::null, // body |
647 | QString::null, | 647 | QString::null, |
648 | urls ); // attachments | 648 | urls ); // attachments |
649 | */ | 649 | */ |
650 | 650 | ||
651 | } | 651 | } |
652 | 652 | ||
653 | /** | 653 | /** |
654 | Beams the "WhoAmI contact. | 654 | Beams the "WhoAmI contact. |
655 | */ | 655 | */ |
656 | void KABCore::beamMySelf() | 656 | void KABCore::beamMySelf() |
657 | { | 657 | { |
658 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 658 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
659 | if (!a.isEmpty()) | 659 | if (!a.isEmpty()) |
660 | { | 660 | { |
661 | QStringList uids; | 661 | QStringList uids; |
662 | uids << a.uid(); | 662 | uids << a.uid(); |
663 | 663 | ||
664 | beamVCard(uids); | 664 | beamVCard(uids); |
665 | } else { | 665 | } else { |
666 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 666 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
667 | 667 | ||
668 | 668 | ||
669 | } | 669 | } |
670 | } | 670 | } |
671 | 671 | ||
672 | void KABCore::export2phone() | 672 | void KABCore::export2phone() |
673 | { | 673 | { |
674 | 674 | ||
675 | KAex2phonePrefs ex2phone; | 675 | KAex2phonePrefs ex2phone; |
676 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 676 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
677 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 677 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
678 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 678 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
679 | 679 | ||
680 | if ( !ex2phone.exec() ) { | 680 | if ( !ex2phone.exec() ) { |
681 | return; | 681 | return; |
682 | } | 682 | } |
683 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 683 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
684 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 684 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
685 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 685 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
686 | 686 | ||
687 | 687 | ||
688 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 688 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
689 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 689 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
690 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 690 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
691 | 691 | ||
692 | QStringList uids = mViewManager->selectedUids(); | 692 | QStringList uids = mViewManager->selectedUids(); |
693 | if ( uids.isEmpty() ) | 693 | if ( uids.isEmpty() ) |
694 | return; | 694 | return; |
695 | 695 | ||
696 | QString fileName = getPhoneFile(); | ||
697 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | ||
698 | return; | ||
699 | |||
700 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | ||
701 | |||
702 | } | ||
703 | QString KABCore::getPhoneFile() | ||
704 | { | ||
696 | #ifdef _WIN32_ | 705 | #ifdef _WIN32_ |
697 | QString fileName = locateLocal("tmp", "phonefile.vcf"); | 706 | return locateLocal("tmp", "phonefile.vcf"); |
698 | #else | 707 | #else |
699 | QString fileName = "/tmp/phonefile.vcf"; | 708 | return "/tmp/phonefile.vcf"; |
700 | #endif | 709 | #endif |
701 | 710 | ||
702 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 711 | } |
703 | return; | 712 | void KABCore::writeToPhone( ) |
704 | 713 | { | |
705 | if ( PhoneAccess::writeToPhone( fileName ) ) | 714 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
706 | qDebug("Export okay "); | 715 | qDebug("Export okay "); |
707 | else | ||
708 | qDebug("Error export contacts "); | ||
709 | |||
710 | |||
711 | #if 0 | ||
712 | |||
713 | setCaption( i18n("Writing to phone...")); | ||
714 | if ( PhoneFormat::writeToPhone( cal ) ) | ||
715 | setCaption( i18n("Export to phone successful!")); | ||
716 | else | 716 | else |
717 | setCaption( i18n("Error exporting to phone!")); | 717 | qDebug("Error export contacts "); |
718 | #endif | ||
719 | |||
720 | |||
721 | } | 718 | } |
722 | void KABCore::beamVCard() | 719 | void KABCore::beamVCard() |
723 | { | 720 | { |
724 | QStringList uids = mViewManager->selectedUids(); | 721 | QStringList uids = mViewManager->selectedUids(); |
725 | if ( !uids.isEmpty() ) | 722 | if ( !uids.isEmpty() ) |
726 | beamVCard( uids ); | 723 | beamVCard( uids ); |
727 | } | 724 | } |
728 | 725 | ||
729 | 726 | ||
730 | void KABCore::beamVCard(const QStringList& uids) | 727 | void KABCore::beamVCard(const QStringList& uids) |
731 | { | 728 | { |
732 | /*US | 729 | /*US |
733 | QString beamFilename; | 730 | QString beamFilename; |
734 | Opie::OPimContact c; | 731 | Opie::OPimContact c; |
735 | if ( actionPersonal->isOn() ) { | 732 | if ( actionPersonal->isOn() ) { |
736 | beamFilename = addressbookPersonalVCardName(); | 733 | beamFilename = addressbookPersonalVCardName(); |
737 | if ( !QFile::exists( beamFilename ) ) | 734 | if ( !QFile::exists( beamFilename ) ) |
738 | return; // can't beam a non-existent file | 735 | return; // can't beam a non-existent file |
739 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 736 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
740 | beamFilename ); | 737 | beamFilename ); |
741 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 738 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
742 | Opie::OPimContactAccess::List allList = access->allRecords(); | 739 | Opie::OPimContactAccess::List allList = access->allRecords(); |
743 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 740 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
744 | c = *it; | 741 | c = *it; |
745 | 742 | ||
746 | delete access; | 743 | delete access; |
747 | } else { | 744 | } else { |
748 | unlink( beamfile ); // delete if exists | 745 | unlink( beamfile ); // delete if exists |
749 | mkdir("/tmp/obex/", 0755); | 746 | mkdir("/tmp/obex/", 0755); |
750 | c = m_abView -> currentEntry(); | 747 | c = m_abView -> currentEntry(); |
751 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 748 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
752 | beamfile ); | 749 | beamfile ); |
753 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 750 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
754 | access->add( c ); | 751 | access->add( c ); |
755 | access->save(); | 752 | access->save(); |
756 | delete access; | 753 | delete access; |
757 | 754 | ||
758 | beamFilename = beamfile; | 755 | beamFilename = beamfile; |
759 | } | 756 | } |
760 | 757 | ||
761 | owarn << "Beaming: " << beamFilename << oendl; | 758 | owarn << "Beaming: " << beamFilename << oendl; |
762 | */ | 759 | */ |
763 | 760 | ||
764 | #if 0 | 761 | #if 0 |
765 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 762 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
766 | 763 | ||
767 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 764 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
768 | 765 | ||
769 | QString name = "contact.vcf"; | 766 | QString name = "contact.vcf"; |
770 | 767 | ||
771 | QString fileName = dirName + "/" + name; | 768 | QString fileName = dirName + "/" + name; |
772 | #endif | 769 | #endif |
773 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 770 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
774 | // | 771 | // |
775 | QString fileName = "/tmp/kapibeamfile.vcf"; | 772 | QString fileName = "/tmp/kapibeamfile.vcf"; |
776 | 773 | ||
777 | 774 | ||
778 | //QDir().mkdir( dirName, true ); | 775 | //QDir().mkdir( dirName, true ); |
779 | 776 | ||
780 | 777 | ||
781 | KABC::VCardConverter converter; | 778 | KABC::VCardConverter converter; |
782 | QString description; | 779 | QString description; |
783 | QString datastream; | 780 | QString datastream; |
784 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 781 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
785 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 782 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
786 | 783 | ||
787 | if ( a.isEmpty() ) | 784 | if ( a.isEmpty() ) |
788 | continue; | 785 | continue; |
789 | 786 | ||
790 | if (description.isEmpty()) | 787 | if (description.isEmpty()) |
791 | description = a.formattedName(); | 788 | description = a.formattedName(); |
792 | 789 | ||
793 | QString vcard; | 790 | QString vcard; |
794 | converter.addresseeToVCard( a, vcard ); | 791 | converter.addresseeToVCard( a, vcard ); |
795 | int start = 0; | 792 | int start = 0; |
796 | int next; | 793 | int next; |
797 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 794 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
798 | int semi = vcard.find(";", next); | 795 | int semi = vcard.find(";", next); |
799 | int dopp = vcard.find(":", next); | 796 | int dopp = vcard.find(":", next); |
800 | int sep; | 797 | int sep; |
801 | if ( semi < dopp && semi >= 0 ) | 798 | if ( semi < dopp && semi >= 0 ) |
802 | sep = semi ; | 799 | sep = semi ; |
803 | else | 800 | else |
804 | sep = dopp; | 801 | sep = dopp; |
805 | datastream +=vcard.mid( start, next - start); | 802 | datastream +=vcard.mid( start, next - start); |
806 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 803 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
807 | start = sep; | 804 | start = sep; |
808 | } | 805 | } |
809 | datastream += vcard.mid( start,vcard.length() ); | 806 | datastream += vcard.mid( start,vcard.length() ); |
810 | } | 807 | } |
811 | #ifndef DESKTOP_VERSION | 808 | #ifndef DESKTOP_VERSION |
812 | QFile outFile(fileName); | 809 | QFile outFile(fileName); |
813 | if ( outFile.open(IO_WriteOnly) ) { | 810 | if ( outFile.open(IO_WriteOnly) ) { |
814 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 811 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
815 | QTextStream t( &outFile ); // use a text stream | 812 | QTextStream t( &outFile ); // use a text stream |
816 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 813 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
817 | t.setEncoding( QTextStream::Latin1 ); | 814 | t.setEncoding( QTextStream::Latin1 ); |
818 | t <<datastream.latin1(); | 815 | t <<datastream.latin1(); |
819 | outFile.close(); | 816 | outFile.close(); |
820 | Ir *ir = new Ir( this ); | 817 | Ir *ir = new Ir( this ); |
821 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 818 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
822 | ir->send( fileName, description, "text/x-vCard" ); | 819 | ir->send( fileName, description, "text/x-vCard" ); |
823 | } else { | 820 | } else { |
824 | qDebug("Error open temp beam file "); | 821 | qDebug("Error open temp beam file "); |
825 | return; | 822 | return; |
826 | } | 823 | } |
827 | #endif | 824 | #endif |
828 | 825 | ||
829 | } | 826 | } |
830 | 827 | ||
831 | void KABCore::beamDone( Ir *ir ) | 828 | void KABCore::beamDone( Ir *ir ) |
832 | { | 829 | { |
833 | #ifndef DESKTOP_VERSION | 830 | #ifndef DESKTOP_VERSION |
834 | delete ir; | 831 | delete ir; |
835 | #endif | 832 | #endif |
836 | topLevelWidget()->raise(); | 833 | topLevelWidget()->raise(); |
834 | message( i18n("Beaming successful!") ); | ||
837 | } | 835 | } |
838 | 836 | ||
839 | 837 | ||
840 | void KABCore::browse( const QString& url ) | 838 | void KABCore::browse( const QString& url ) |
841 | { | 839 | { |
842 | #ifndef KAB_EMBEDDED | 840 | #ifndef KAB_EMBEDDED |
843 | kapp->invokeBrowser( url ); | 841 | kapp->invokeBrowser( url ); |
844 | #else //KAB_EMBEDDED | 842 | #else //KAB_EMBEDDED |
845 | qDebug("KABCore::browse must be fixed"); | 843 | qDebug("KABCore::browse must be fixed"); |
846 | #endif //KAB_EMBEDDED | 844 | #endif //KAB_EMBEDDED |
847 | } | 845 | } |
848 | 846 | ||
849 | void KABCore::selectAllContacts() | 847 | void KABCore::selectAllContacts() |
850 | { | 848 | { |
851 | mViewManager->setSelected( QString::null, true ); | 849 | mViewManager->setSelected( QString::null, true ); |
852 | } | 850 | } |
853 | 851 | ||
854 | void KABCore::deleteContacts() | 852 | void KABCore::deleteContacts() |
855 | { | 853 | { |
856 | QStringList uidList = mViewManager->selectedUids(); | 854 | QStringList uidList = mViewManager->selectedUids(); |
857 | deleteContacts( uidList ); | 855 | deleteContacts( uidList ); |
858 | } | 856 | } |
859 | 857 | ||
860 | void KABCore::deleteContacts( const QStringList &uids ) | 858 | void KABCore::deleteContacts( const QStringList &uids ) |
861 | { | 859 | { |
862 | if ( uids.count() > 0 ) { | 860 | if ( uids.count() > 0 ) { |
863 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 861 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
864 | UndoStack::instance()->push( command ); | 862 | UndoStack::instance()->push( command ); |
865 | RedoStack::instance()->clear(); | 863 | RedoStack::instance()->clear(); |
866 | 864 | ||
867 | // now if we deleted anything, refresh | 865 | // now if we deleted anything, refresh |
868 | setContactSelected( QString::null ); | 866 | setContactSelected( QString::null ); |
869 | setModified( true ); | 867 | setModified( true ); |
870 | } | 868 | } |
871 | } | 869 | } |
872 | 870 | ||
873 | void KABCore::copyContacts() | 871 | void KABCore::copyContacts() |
874 | { | 872 | { |
875 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 873 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
876 | 874 | ||
877 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 875 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
878 | 876 | ||
879 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 877 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
880 | 878 | ||
881 | QClipboard *cb = QApplication::clipboard(); | 879 | QClipboard *cb = QApplication::clipboard(); |
882 | cb->setText( clipText ); | 880 | cb->setText( clipText ); |
883 | } | 881 | } |
884 | 882 | ||
885 | void KABCore::cutContacts() | 883 | void KABCore::cutContacts() |
886 | { | 884 | { |
887 | QStringList uidList = mViewManager->selectedUids(); | 885 | QStringList uidList = mViewManager->selectedUids(); |
888 | 886 | ||
889 | //US if ( uidList.size() > 0 ) { | 887 | //US if ( uidList.size() > 0 ) { |
890 | if ( uidList.count() > 0 ) { | 888 | if ( uidList.count() > 0 ) { |
891 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 889 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
892 | UndoStack::instance()->push( command ); | 890 | UndoStack::instance()->push( command ); |
893 | RedoStack::instance()->clear(); | 891 | RedoStack::instance()->clear(); |
894 | 892 | ||
895 | setModified( true ); | 893 | setModified( true ); |
896 | } | 894 | } |
897 | } | 895 | } |
898 | 896 | ||
899 | void KABCore::pasteContacts() | 897 | void KABCore::pasteContacts() |
900 | { | 898 | { |
901 | QClipboard *cb = QApplication::clipboard(); | 899 | QClipboard *cb = QApplication::clipboard(); |
902 | 900 | ||
903 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 901 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
904 | 902 | ||
905 | pasteContacts( list ); | 903 | pasteContacts( list ); |
906 | } | 904 | } |
907 | 905 | ||
908 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 906 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
909 | { | 907 | { |
910 | KABC::Resource *resource = requestResource( this ); | 908 | KABC::Resource *resource = requestResource( this ); |
911 | KABC::Addressee::List::Iterator it; | 909 | KABC::Addressee::List::Iterator it; |
912 | for ( it = list.begin(); it != list.end(); ++it ) | 910 | for ( it = list.begin(); it != list.end(); ++it ) |
913 | (*it).setResource( resource ); | 911 | (*it).setResource( resource ); |
914 | 912 | ||
915 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 913 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
916 | UndoStack::instance()->push( command ); | 914 | UndoStack::instance()->push( command ); |
917 | RedoStack::instance()->clear(); | 915 | RedoStack::instance()->clear(); |
918 | 916 | ||
919 | setModified( true ); | 917 | setModified( true ); |
920 | } | 918 | } |
921 | 919 | ||
922 | void KABCore::setWhoAmI() | 920 | void KABCore::setWhoAmI() |
923 | { | 921 | { |
924 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 922 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
925 | 923 | ||
926 | if ( addrList.count() > 1 ) { | 924 | if ( addrList.count() > 1 ) { |
927 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 925 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
928 | return; | 926 | return; |
929 | } | 927 | } |
930 | 928 | ||
931 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 929 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
932 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 930 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
933 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 931 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
934 | } | 932 | } |
935 | 933 | ||
936 | void KABCore::setCategories() | 934 | void KABCore::setCategories() |
937 | { | 935 | { |
938 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 936 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
939 | if ( !dlg.exec() ) | 937 | if ( !dlg.exec() ) |
940 | return; | 938 | return; |
941 | 939 | ||
942 | bool merge = false; | 940 | bool merge = false; |
943 | QString msg = i18n( "Merge with existing categories?" ); | 941 | QString msg = i18n( "Merge with existing categories?" ); |
944 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 942 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
945 | merge = true; | 943 | merge = true; |
946 | 944 | ||
947 | QStringList categories = dlg.selectedCategories(); | 945 | QStringList categories = dlg.selectedCategories(); |
948 | 946 | ||
949 | QStringList uids = mViewManager->selectedUids(); | 947 | QStringList uids = mViewManager->selectedUids(); |
950 | QStringList::Iterator it; | 948 | QStringList::Iterator it; |
951 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 949 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
952 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 950 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
953 | if ( !addr.isEmpty() ) { | 951 | if ( !addr.isEmpty() ) { |
954 | if ( !merge ) | 952 | if ( !merge ) |
955 | addr.setCategories( categories ); | 953 | addr.setCategories( categories ); |
956 | else { | 954 | else { |
957 | QStringList addrCategories = addr.categories(); | 955 | QStringList addrCategories = addr.categories(); |
958 | QStringList::Iterator catIt; | 956 | QStringList::Iterator catIt; |
959 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 957 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
960 | if ( !addrCategories.contains( *catIt ) ) | 958 | if ( !addrCategories.contains( *catIt ) ) |
961 | addrCategories.append( *catIt ); | 959 | addrCategories.append( *catIt ); |
962 | } | 960 | } |
963 | addr.setCategories( addrCategories ); | 961 | addr.setCategories( addrCategories ); |
964 | } | 962 | } |
965 | 963 | ||
966 | mAddressBook->insertAddressee( addr ); | 964 | mAddressBook->insertAddressee( addr ); |
967 | } | 965 | } |
968 | } | 966 | } |
969 | 967 | ||
970 | if ( uids.count() > 0 ) | 968 | if ( uids.count() > 0 ) |
971 | setModified( true ); | 969 | setModified( true ); |
972 | } | 970 | } |
973 | 971 | ||
974 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 972 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
975 | { | 973 | { |
976 | mIncSearchWidget->setFields( fields ); | 974 | mIncSearchWidget->setFields( fields ); |
977 | } | 975 | } |
978 | 976 | ||
979 | void KABCore::incrementalSearch( const QString& text ) | 977 | void KABCore::incrementalSearch( const QString& text ) |
980 | { | 978 | { |
981 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 979 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
982 | } | 980 | } |
983 | 981 | ||
984 | void KABCore::setModified() | 982 | void KABCore::setModified() |
985 | { | 983 | { |
986 | setModified( true ); | 984 | setModified( true ); |
987 | } | 985 | } |
988 | 986 | ||
989 | void KABCore::setModifiedWOrefresh() | 987 | void KABCore::setModifiedWOrefresh() |
990 | { | 988 | { |
991 | // qDebug("KABCore::setModifiedWOrefresh() "); | 989 | // qDebug("KABCore::setModifiedWOrefresh() "); |
992 | mModified = true; | 990 | mModified = true; |
993 | mActionSave->setEnabled( mModified ); | 991 | mActionSave->setEnabled( mModified ); |
994 | #ifdef DESKTOP_VERSION | 992 | #ifdef DESKTOP_VERSION |
995 | mDetails->refreshView(); | 993 | mDetails->refreshView(); |
996 | #endif | 994 | #endif |
997 | 995 | ||
998 | } | 996 | } |
999 | void KABCore::setModified( bool modified ) | 997 | void KABCore::setModified( bool modified ) |
1000 | { | 998 | { |
1001 | mModified = modified; | 999 | mModified = modified; |
1002 | mActionSave->setEnabled( mModified ); | 1000 | mActionSave->setEnabled( mModified ); |
1003 | 1001 | ||
1004 | if ( modified ) | 1002 | if ( modified ) |
1005 | mJumpButtonBar->recreateButtons(); | 1003 | mJumpButtonBar->recreateButtons(); |
1006 | 1004 | ||
1007 | mViewManager->refreshView(); | 1005 | mViewManager->refreshView(); |
1008 | mDetails->refreshView(); | 1006 | mDetails->refreshView(); |
1009 | 1007 | ||
1010 | } | 1008 | } |
1011 | 1009 | ||
1012 | bool KABCore::modified() const | 1010 | bool KABCore::modified() const |
1013 | { | 1011 | { |
1014 | return mModified; | 1012 | return mModified; |
1015 | } | 1013 | } |
1016 | 1014 | ||
1017 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1015 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1018 | { | 1016 | { |
1019 | 1017 | ||
1020 | Command *command = 0; | 1018 | Command *command = 0; |
1021 | QString uid; | 1019 | QString uid; |
1022 | 1020 | ||
1023 | // check if it exists already | 1021 | // check if it exists already |
1024 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1022 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1025 | if ( origAddr.isEmpty() ) | 1023 | if ( origAddr.isEmpty() ) |
1026 | command = new PwNewCommand( mAddressBook, addr ); | 1024 | command = new PwNewCommand( mAddressBook, addr ); |
1027 | else { | 1025 | else { |
1028 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1026 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1029 | uid = addr.uid(); | 1027 | uid = addr.uid(); |
1030 | } | 1028 | } |
1031 | 1029 | ||
1032 | UndoStack::instance()->push( command ); | 1030 | UndoStack::instance()->push( command ); |
1033 | RedoStack::instance()->clear(); | 1031 | RedoStack::instance()->clear(); |
1034 | 1032 | ||
1035 | setModified( true ); | 1033 | setModified( true ); |
1036 | } | 1034 | } |
1037 | 1035 | ||
1038 | void KABCore::newContact() | 1036 | void KABCore::newContact() |
1039 | { | 1037 | { |
1040 | 1038 | ||
1041 | 1039 | ||
1042 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1040 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1043 | 1041 | ||
1044 | QPtrList<KRES::Resource> kresResources; | 1042 | QPtrList<KRES::Resource> kresResources; |
1045 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1043 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1046 | KABC::Resource *resource; | 1044 | KABC::Resource *resource; |
1047 | while ( ( resource = it.current() ) != 0 ) { | 1045 | while ( ( resource = it.current() ) != 0 ) { |
1048 | ++it; | 1046 | ++it; |
1049 | if ( !resource->readOnly() ) { | 1047 | if ( !resource->readOnly() ) { |
1050 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1048 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1051 | if ( res ) | 1049 | if ( res ) |
1052 | kresResources.append( res ); | 1050 | kresResources.append( res ); |
1053 | } | 1051 | } |
1054 | } | 1052 | } |
1055 | 1053 | ||
1056 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1054 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1057 | resource = static_cast<KABC::Resource*>( res ); | 1055 | resource = static_cast<KABC::Resource*>( res ); |
1058 | 1056 | ||
1059 | if ( resource ) { | 1057 | if ( resource ) { |
1060 | KABC::Addressee addr; | 1058 | KABC::Addressee addr; |
1061 | addr.setResource( resource ); | 1059 | addr.setResource( resource ); |
1062 | mEditorDialog->setAddressee( addr ); | 1060 | mEditorDialog->setAddressee( addr ); |
1063 | KApplication::execDialog ( mEditorDialog ); | 1061 | KApplication::execDialog ( mEditorDialog ); |
1064 | 1062 | ||
1065 | } else | 1063 | } else |
1066 | return; | 1064 | return; |
1067 | 1065 | ||
1068 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1066 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1069 | 1067 | ||
1070 | 1068 | ||
1071 | } | 1069 | } |
1072 | 1070 | ||
1073 | void KABCore::addEmail( QString aStr ) | 1071 | void KABCore::addEmail( QString aStr ) |
1074 | { | 1072 | { |
1075 | #ifndef KAB_EMBEDDED | 1073 | #ifndef KAB_EMBEDDED |
1076 | QString fullName, email; | 1074 | QString fullName, email; |
1077 | 1075 | ||
1078 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1076 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1079 | 1077 | ||
1080 | // Try to lookup the addressee matching the email address | 1078 | // Try to lookup the addressee matching the email address |
1081 | bool found = false; | 1079 | bool found = false; |
1082 | QStringList emailList; | 1080 | QStringList emailList; |
1083 | KABC::AddressBook::Iterator it; | 1081 | KABC::AddressBook::Iterator it; |
1084 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1082 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1085 | emailList = (*it).emails(); | 1083 | emailList = (*it).emails(); |
1086 | if ( emailList.contains( email ) > 0 ) { | 1084 | if ( emailList.contains( email ) > 0 ) { |
1087 | found = true; | 1085 | found = true; |
1088 | (*it).setNameFromString( fullName ); | 1086 | (*it).setNameFromString( fullName ); |
1089 | editContact( (*it).uid() ); | 1087 | editContact( (*it).uid() ); |
1090 | } | 1088 | } |
1091 | } | 1089 | } |
1092 | 1090 | ||
1093 | if ( !found ) { | 1091 | if ( !found ) { |
1094 | KABC::Addressee addr; | 1092 | KABC::Addressee addr; |
1095 | addr.setNameFromString( fullName ); | 1093 | addr.setNameFromString( fullName ); |
1096 | addr.insertEmail( email, true ); | 1094 | addr.insertEmail( email, true ); |
1097 | 1095 | ||
1098 | mAddressBook->insertAddressee( addr ); | 1096 | mAddressBook->insertAddressee( addr ); |
1099 | mViewManager->refreshView( addr.uid() ); | 1097 | mViewManager->refreshView( addr.uid() ); |
1100 | editContact( addr.uid() ); | 1098 | editContact( addr.uid() ); |
1101 | } | 1099 | } |
1102 | #else //KAB_EMBEDDED | 1100 | #else //KAB_EMBEDDED |
1103 | qDebug("KABCore::addEmail finsih method"); | 1101 | qDebug("KABCore::addEmail finsih method"); |
1104 | #endif //KAB_EMBEDDED | 1102 | #endif //KAB_EMBEDDED |
1105 | } | 1103 | } |
1106 | 1104 | ||
1107 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1105 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1108 | { | 1106 | { |
1109 | mXXPortManager->importVCard( url, showPreview ); | 1107 | mXXPortManager->importVCard( url, showPreview ); |
1110 | } | 1108 | } |
1111 | void KABCore::importFromOL() | 1109 | void KABCore::importFromOL() |
1112 | { | 1110 | { |
1113 | #ifdef _WIN32_ | 1111 | #ifdef _WIN32_ |
1114 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1112 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1115 | idgl->exec(); | 1113 | idgl->exec(); |
1116 | KABC::Addressee::List list = idgl->getAddressList(); | 1114 | KABC::Addressee::List list = idgl->getAddressList(); |
1117 | if ( list.count() > 0 ) { | 1115 | if ( list.count() > 0 ) { |
1118 | KABC::Addressee::List listNew; | 1116 | KABC::Addressee::List listNew; |
1119 | KABC::Addressee::List listExisting; | 1117 | KABC::Addressee::List listExisting; |
1120 | KABC::Addressee::List::Iterator it; | 1118 | KABC::Addressee::List::Iterator it; |
1121 | KABC::AddressBook::Iterator iter; | 1119 | KABC::AddressBook::Iterator iter; |
1122 | for ( it = list.begin(); it != list.end(); ++it ) { | 1120 | for ( it = list.begin(); it != list.end(); ++it ) { |
1123 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1121 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1124 | listNew.append( (*it) ); | 1122 | listNew.append( (*it) ); |
1125 | else | 1123 | else |
1126 | listExisting.append( (*it) ); | 1124 | listExisting.append( (*it) ); |
1127 | } | 1125 | } |
1128 | if ( listExisting.count() > 0 ) | 1126 | if ( listExisting.count() > 0 ) |
1129 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1127 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1130 | if ( listNew.count() > 0 ) { | 1128 | if ( listNew.count() > 0 ) { |
1131 | pasteWithNewUid = false; | 1129 | pasteWithNewUid = false; |
1132 | pasteContacts( listNew ); | 1130 | pasteContacts( listNew ); |
1133 | pasteWithNewUid = true; | 1131 | pasteWithNewUid = true; |
1134 | } | 1132 | } |
1135 | } | 1133 | } |
1136 | delete idgl; | 1134 | delete idgl; |
1137 | #endif | 1135 | #endif |
1138 | } | 1136 | } |
1139 | 1137 | ||
1140 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1138 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1141 | { | 1139 | { |
1142 | mXXPortManager->importVCard( vCard, showPreview ); | 1140 | mXXPortManager->importVCard( vCard, showPreview ); |
1143 | } | 1141 | } |
1144 | 1142 | ||
1145 | //US added a second method without defaultparameter | 1143 | //US added a second method without defaultparameter |
1146 | void KABCore::editContact2() { | 1144 | void KABCore::editContact2() { |
1147 | editContact( QString::null ); | 1145 | editContact( QString::null ); |
1148 | } | 1146 | } |
1149 | 1147 | ||
1150 | void KABCore::editContact( const QString &uid ) | 1148 | void KABCore::editContact( const QString &uid ) |
1151 | { | 1149 | { |
1152 | 1150 | ||
1153 | if ( mExtensionManager->isQuickEditVisible() ) | 1151 | if ( mExtensionManager->isQuickEditVisible() ) |
1154 | return; | 1152 | return; |
1155 | 1153 | ||
1156 | // First, locate the contact entry | 1154 | // First, locate the contact entry |
1157 | QString localUID = uid; | 1155 | QString localUID = uid; |
1158 | if ( localUID.isNull() ) { | 1156 | if ( localUID.isNull() ) { |
1159 | QStringList uidList = mViewManager->selectedUids(); | 1157 | QStringList uidList = mViewManager->selectedUids(); |
1160 | if ( uidList.count() > 0 ) | 1158 | if ( uidList.count() > 0 ) |
1161 | localUID = *( uidList.at( 0 ) ); | 1159 | localUID = *( uidList.at( 0 ) ); |
1162 | } | 1160 | } |
1163 | 1161 | ||
1164 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1162 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1165 | if ( !addr.isEmpty() ) { | 1163 | if ( !addr.isEmpty() ) { |
1166 | mEditorDialog->setAddressee( addr ); | 1164 | mEditorDialog->setAddressee( addr ); |
1167 | KApplication::execDialog ( mEditorDialog ); | 1165 | KApplication::execDialog ( mEditorDialog ); |
1168 | } | 1166 | } |
1169 | } | 1167 | } |
1170 | 1168 | ||
1171 | /** | 1169 | /** |
1172 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1170 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1173 | the method will try to find a selected addressee in the view. | 1171 | the method will try to find a selected addressee in the view. |
1174 | */ | 1172 | */ |
1175 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1173 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1176 | { | 1174 | { |
1177 | if ( mMultipleViewsAtOnce ) | 1175 | if ( mMultipleViewsAtOnce ) |
1178 | { | 1176 | { |
1179 | editContact( uid ); | 1177 | editContact( uid ); |
1180 | } | 1178 | } |
1181 | else | 1179 | else |
1182 | { | 1180 | { |
1183 | setDetailsVisible( true ); | 1181 | setDetailsVisible( true ); |
1184 | mActionDetails->setChecked(true); | 1182 | mActionDetails->setChecked(true); |
1185 | } | 1183 | } |
1186 | 1184 | ||
1187 | } | 1185 | } |
1188 | 1186 | ||
1189 | void KABCore::save() | 1187 | void KABCore::save() |
1190 | { | 1188 | { |
1191 | if (syncManager->blockSave()) | 1189 | if (syncManager->blockSave()) |
1192 | return; | 1190 | return; |
1193 | if ( !mModified ) | 1191 | if ( !mModified ) |
1194 | return; | 1192 | return; |
1195 | 1193 | ||
1196 | syncManager->setBlockSave(true); | 1194 | syncManager->setBlockSave(true); |
1197 | QString text = i18n( "There was an error while attempting to save\n the " | 1195 | QString text = i18n( "There was an error while attempting to save\n the " |
1198 | "address book. Please check that some \nother application is " | 1196 | "address book. Please check that some \nother application is " |
1199 | "not using it. " ); | 1197 | "not using it. " ); |
1200 | statusMessage(i18n("Saving addressbook ... ")); | 1198 | statusMessage(i18n("Saving addressbook ... ")); |
1201 | #ifndef KAB_EMBEDDED | 1199 | #ifndef KAB_EMBEDDED |
1202 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1200 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1203 | if ( !b || !b->save() ) { | 1201 | if ( !b || !b->save() ) { |
1204 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1202 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1205 | } | 1203 | } |
1206 | #else //KAB_EMBEDDED | 1204 | #else //KAB_EMBEDDED |
1207 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1205 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1208 | if ( !b || !b->save() ) { | 1206 | if ( !b || !b->save() ) { |
1209 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1207 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1210 | } | 1208 | } |
1211 | #endif //KAB_EMBEDDED | 1209 | #endif //KAB_EMBEDDED |
1212 | 1210 | ||
1213 | statusMessage(i18n("Addressbook saved!")); | 1211 | statusMessage(i18n("Addressbook saved!")); |
1214 | setModified( false ); | 1212 | setModified( false ); |
1215 | syncManager->setBlockSave(false); | 1213 | syncManager->setBlockSave(false); |
1216 | } | 1214 | } |
1217 | 1215 | ||
1218 | void KABCore::statusMessage(QString mess , int time ) | 1216 | void KABCore::statusMessage(QString mess , int time ) |
1219 | { | 1217 | { |
1220 | //topLevelWidget()->setCaption( mess ); | 1218 | //topLevelWidget()->setCaption( mess ); |
1221 | // pending setting timer to revome message | 1219 | // pending setting timer to revome message |
1222 | } | 1220 | } |
1223 | void KABCore::undo() | 1221 | void KABCore::undo() |
1224 | { | 1222 | { |
1225 | UndoStack::instance()->undo(); | 1223 | UndoStack::instance()->undo(); |
1226 | 1224 | ||
1227 | // Refresh the view | 1225 | // Refresh the view |
1228 | mViewManager->refreshView(); | 1226 | mViewManager->refreshView(); |
1229 | } | 1227 | } |
1230 | 1228 | ||
1231 | void KABCore::redo() | 1229 | void KABCore::redo() |
1232 | { | 1230 | { |
1233 | RedoStack::instance()->redo(); | 1231 | RedoStack::instance()->redo(); |
1234 | 1232 | ||
1235 | // Refresh the view | 1233 | // Refresh the view |
1236 | mViewManager->refreshView(); | 1234 | mViewManager->refreshView(); |
1237 | } | 1235 | } |
1238 | 1236 | ||
1239 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1237 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1240 | { | 1238 | { |
1241 | if (mMultipleViewsAtOnce) | 1239 | if (mMultipleViewsAtOnce) |
1242 | { | 1240 | { |
1243 | if ( visible ) | 1241 | if ( visible ) |
1244 | mJumpButtonBar->show(); | 1242 | mJumpButtonBar->show(); |
1245 | else | 1243 | else |
1246 | mJumpButtonBar->hide(); | 1244 | mJumpButtonBar->hide(); |
1247 | } | 1245 | } |
1248 | else | 1246 | else |
1249 | { | 1247 | { |
1250 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1248 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1251 | if (mViewManager->isVisible()) | 1249 | if (mViewManager->isVisible()) |
1252 | { | 1250 | { |
1253 | if ( visible ) | 1251 | if ( visible ) |
1254 | mJumpButtonBar->show(); | 1252 | mJumpButtonBar->show(); |
1255 | else | 1253 | else |
1256 | mJumpButtonBar->hide(); | 1254 | mJumpButtonBar->hide(); |
1257 | } | 1255 | } |
1258 | else | 1256 | else |
1259 | { | 1257 | { |
1260 | mJumpButtonBar->hide(); | 1258 | mJumpButtonBar->hide(); |
1261 | } | 1259 | } |
1262 | } | 1260 | } |
1263 | } | 1261 | } |
1264 | 1262 | ||
1265 | 1263 | ||
1266 | void KABCore::setDetailsToState() | 1264 | void KABCore::setDetailsToState() |
1267 | { | 1265 | { |
1268 | setDetailsVisible( mActionDetails->isChecked() ); | 1266 | setDetailsVisible( mActionDetails->isChecked() ); |
1269 | } | 1267 | } |
1270 | 1268 | ||
1271 | 1269 | ||
1272 | 1270 | ||
1273 | void KABCore::setDetailsVisible( bool visible ) | 1271 | void KABCore::setDetailsVisible( bool visible ) |
1274 | { | 1272 | { |
1275 | if (visible && mDetails->isHidden()) | 1273 | if (visible && mDetails->isHidden()) |
1276 | { | 1274 | { |
1277 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1275 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1278 | if ( addrList.count() > 0 ) | 1276 | if ( addrList.count() > 0 ) |
1279 | mDetails->setAddressee( addrList[ 0 ] ); | 1277 | mDetails->setAddressee( addrList[ 0 ] ); |
1280 | } | 1278 | } |
1281 | 1279 | ||
1282 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1280 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1283 | // the listview and the detailview. We do that by changing the splitbar size. | 1281 | // the listview and the detailview. We do that by changing the splitbar size. |
1284 | if (mMultipleViewsAtOnce) | 1282 | if (mMultipleViewsAtOnce) |
1285 | { | 1283 | { |
1286 | if ( visible ) | 1284 | if ( visible ) |
1287 | mDetails->show(); | 1285 | mDetails->show(); |
1288 | else | 1286 | else |
1289 | mDetails->hide(); | 1287 | mDetails->hide(); |
1290 | } | 1288 | } |
1291 | else | 1289 | else |
1292 | { | 1290 | { |
1293 | if ( visible ) { | 1291 | if ( visible ) { |
1294 | mViewManager->hide(); | 1292 | mViewManager->hide(); |
1295 | mDetails->show(); | 1293 | mDetails->show(); |
1296 | } | 1294 | } |
1297 | else { | 1295 | else { |
1298 | mViewManager->show(); | 1296 | mViewManager->show(); |
1299 | mDetails->hide(); | 1297 | mDetails->hide(); |
1300 | } | 1298 | } |
1301 | setJumpButtonBarVisible( !visible ); | 1299 | setJumpButtonBarVisible( !visible ); |
1302 | } | 1300 | } |
1303 | 1301 | ||
1304 | } | 1302 | } |
1305 | 1303 | ||
1306 | void KABCore::extensionChanged( int id ) | 1304 | void KABCore::extensionChanged( int id ) |
1307 | { | 1305 | { |
1308 | //change the details view only for non desktop systems | 1306 | //change the details view only for non desktop systems |
1309 | #ifndef DESKTOP_VERSION | 1307 | #ifndef DESKTOP_VERSION |
1310 | 1308 | ||
1311 | if (id == 0) | 1309 | if (id == 0) |
1312 | { | 1310 | { |
1313 | //the user disabled the extension. | 1311 | //the user disabled the extension. |
1314 | 1312 | ||
1315 | if (mMultipleViewsAtOnce) | 1313 | if (mMultipleViewsAtOnce) |
1316 | { // enable detailsview again | 1314 | { // enable detailsview again |
1317 | setDetailsVisible( true ); | 1315 | setDetailsVisible( true ); |
1318 | mActionDetails->setChecked( true ); | 1316 | mActionDetails->setChecked( true ); |
1319 | } | 1317 | } |
1320 | else | 1318 | else |
1321 | { //go back to the listview | 1319 | { //go back to the listview |
1322 | setDetailsVisible( false ); | 1320 | setDetailsVisible( false ); |
1323 | mActionDetails->setChecked( false ); | 1321 | mActionDetails->setChecked( false ); |
1324 | mActionDetails->setEnabled(true); | 1322 | mActionDetails->setEnabled(true); |
1325 | } | 1323 | } |
1326 | 1324 | ||
1327 | } | 1325 | } |
1328 | else | 1326 | else |
1329 | { | 1327 | { |
1330 | //the user enabled the extension. | 1328 | //the user enabled the extension. |
1331 | setDetailsVisible( false ); | 1329 | setDetailsVisible( false ); |
1332 | mActionDetails->setChecked( false ); | 1330 | mActionDetails->setChecked( false ); |
1333 | 1331 | ||
1334 | if (!mMultipleViewsAtOnce) | 1332 | if (!mMultipleViewsAtOnce) |
1335 | { | 1333 | { |
1336 | mActionDetails->setEnabled(false); | 1334 | mActionDetails->setEnabled(false); |
1337 | } | 1335 | } |
1338 | 1336 | ||
1339 | mExtensionManager->setSelectionChanged(); | 1337 | mExtensionManager->setSelectionChanged(); |
1340 | 1338 | ||
1341 | } | 1339 | } |
1342 | 1340 | ||
1343 | #endif// DESKTOP_VERSION | 1341 | #endif// DESKTOP_VERSION |
1344 | 1342 | ||
1345 | } | 1343 | } |
1346 | 1344 | ||
1347 | 1345 | ||
1348 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1346 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
@@ -2309,573 +2307,568 @@ KABC::Addressee KABCore::getLastSyncAddressee() | |||
2309 | Addressee lse; | 2307 | Addressee lse; |
2310 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2308 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2311 | 2309 | ||
2312 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2310 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2313 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2311 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2314 | if (lse.isEmpty()) { | 2312 | if (lse.isEmpty()) { |
2315 | qDebug("Creating new last-syncAddressee "); | 2313 | qDebug("Creating new last-syncAddressee "); |
2316 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2314 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2317 | QString sum = ""; | 2315 | QString sum = ""; |
2318 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2316 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2319 | sum = "E: "; | 2317 | sum = "E: "; |
2320 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2318 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2321 | lse.setRevision( mLastAddressbookSync ); | 2319 | lse.setRevision( mLastAddressbookSync ); |
2322 | lse.setCategories( i18n("SyncEvent") ); | 2320 | lse.setCategories( i18n("SyncEvent") ); |
2323 | mAddressBook->insertAddressee( lse ); | 2321 | mAddressBook->insertAddressee( lse ); |
2324 | } | 2322 | } |
2325 | return lse; | 2323 | return lse; |
2326 | } | 2324 | } |
2327 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2325 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2328 | { | 2326 | { |
2329 | 2327 | ||
2330 | //void setZaurusId(int id); | 2328 | //void setZaurusId(int id); |
2331 | // int zaurusId() const; | 2329 | // int zaurusId() const; |
2332 | // void setZaurusUid(int id); | 2330 | // void setZaurusUid(int id); |
2333 | // int zaurusUid() const; | 2331 | // int zaurusUid() const; |
2334 | // void setZaurusStat(int id); | 2332 | // void setZaurusStat(int id); |
2335 | // int zaurusStat() const; | 2333 | // int zaurusStat() const; |
2336 | // 0 equal | 2334 | // 0 equal |
2337 | // 1 take local | 2335 | // 1 take local |
2338 | // 2 take remote | 2336 | // 2 take remote |
2339 | // 3 cancel | 2337 | // 3 cancel |
2340 | QDateTime lastSync = mLastAddressbookSync; | 2338 | QDateTime lastSync = mLastAddressbookSync; |
2341 | QDateTime localMod = local->revision(); | 2339 | QDateTime localMod = local->revision(); |
2342 | QDateTime remoteMod = remote->revision(); | 2340 | QDateTime remoteMod = remote->revision(); |
2343 | 2341 | ||
2344 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2342 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2345 | 2343 | ||
2346 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2344 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2347 | bool remCh, locCh; | 2345 | bool remCh, locCh; |
2348 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2346 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2349 | 2347 | ||
2350 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2348 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2351 | locCh = ( localMod > mLastAddressbookSync ); | 2349 | locCh = ( localMod > mLastAddressbookSync ); |
2352 | if ( !remCh && ! locCh ) { | 2350 | if ( !remCh && ! locCh ) { |
2353 | //qDebug("both not changed "); | 2351 | //qDebug("both not changed "); |
2354 | lastSync = localMod.addDays(1); | 2352 | lastSync = localMod.addDays(1); |
2355 | if ( mode <= SYNC_PREF_ASK ) | 2353 | if ( mode <= SYNC_PREF_ASK ) |
2356 | return 0; | 2354 | return 0; |
2357 | } else { | 2355 | } else { |
2358 | if ( locCh ) { | 2356 | if ( locCh ) { |
2359 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2357 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2360 | lastSync = localMod.addDays( -1 ); | 2358 | lastSync = localMod.addDays( -1 ); |
2361 | if ( !remCh ) | 2359 | if ( !remCh ) |
2362 | remoteMod =( lastSync.addDays( -1 ) ); | 2360 | remoteMod =( lastSync.addDays( -1 ) ); |
2363 | } else { | 2361 | } else { |
2364 | //qDebug(" not loc changed "); | 2362 | //qDebug(" not loc changed "); |
2365 | lastSync = localMod.addDays( 1 ); | 2363 | lastSync = localMod.addDays( 1 ); |
2366 | if ( remCh ) | 2364 | if ( remCh ) |
2367 | remoteMod =( lastSync.addDays( 1 ) ); | 2365 | remoteMod =( lastSync.addDays( 1 ) ); |
2368 | 2366 | ||
2369 | } | 2367 | } |
2370 | } | 2368 | } |
2371 | full = true; | 2369 | full = true; |
2372 | if ( mode < SYNC_PREF_ASK ) | 2370 | if ( mode < SYNC_PREF_ASK ) |
2373 | mode = SYNC_PREF_ASK; | 2371 | mode = SYNC_PREF_ASK; |
2374 | } else { | 2372 | } else { |
2375 | if ( localMod == remoteMod ) | 2373 | if ( localMod == remoteMod ) |
2376 | return 0; | 2374 | return 0; |
2377 | 2375 | ||
2378 | } | 2376 | } |
2379 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2377 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2380 | 2378 | ||
2381 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2379 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2382 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2380 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2383 | //full = true; //debug only | 2381 | //full = true; //debug only |
2384 | if ( full ) { | 2382 | if ( full ) { |
2385 | bool equ = ( (*local) == (*remote) ); | 2383 | bool equ = ( (*local) == (*remote) ); |
2386 | if ( equ ) { | 2384 | if ( equ ) { |
2387 | //qDebug("equal "); | 2385 | //qDebug("equal "); |
2388 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2386 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2389 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2387 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2390 | } | 2388 | } |
2391 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2389 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2392 | return 0; | 2390 | return 0; |
2393 | 2391 | ||
2394 | }//else //debug only | 2392 | }//else //debug only |
2395 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2393 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2396 | } | 2394 | } |
2397 | int result; | 2395 | int result; |
2398 | bool localIsNew; | 2396 | bool localIsNew; |
2399 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2397 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2400 | 2398 | ||
2401 | if ( full && mode < SYNC_PREF_NEWEST ) | 2399 | if ( full && mode < SYNC_PREF_NEWEST ) |
2402 | mode = SYNC_PREF_ASK; | 2400 | mode = SYNC_PREF_ASK; |
2403 | 2401 | ||
2404 | switch( mode ) { | 2402 | switch( mode ) { |
2405 | case SYNC_PREF_LOCAL: | 2403 | case SYNC_PREF_LOCAL: |
2406 | if ( lastSync > remoteMod ) | 2404 | if ( lastSync > remoteMod ) |
2407 | return 1; | 2405 | return 1; |
2408 | if ( lastSync > localMod ) | 2406 | if ( lastSync > localMod ) |
2409 | return 2; | 2407 | return 2; |
2410 | return 1; | 2408 | return 1; |
2411 | break; | 2409 | break; |
2412 | case SYNC_PREF_REMOTE: | 2410 | case SYNC_PREF_REMOTE: |
2413 | if ( lastSync > remoteMod ) | 2411 | if ( lastSync > remoteMod ) |
2414 | return 1; | 2412 | return 1; |
2415 | if ( lastSync > localMod ) | 2413 | if ( lastSync > localMod ) |
2416 | return 2; | 2414 | return 2; |
2417 | return 2; | 2415 | return 2; |
2418 | break; | 2416 | break; |
2419 | case SYNC_PREF_NEWEST: | 2417 | case SYNC_PREF_NEWEST: |
2420 | if ( localMod > remoteMod ) | 2418 | if ( localMod > remoteMod ) |
2421 | return 1; | 2419 | return 1; |
2422 | else | 2420 | else |
2423 | return 2; | 2421 | return 2; |
2424 | break; | 2422 | break; |
2425 | case SYNC_PREF_ASK: | 2423 | case SYNC_PREF_ASK: |
2426 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2424 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2427 | if ( lastSync > remoteMod ) | 2425 | if ( lastSync > remoteMod ) |
2428 | return 1; | 2426 | return 1; |
2429 | if ( lastSync > localMod ) | 2427 | if ( lastSync > localMod ) |
2430 | return 2; | 2428 | return 2; |
2431 | localIsNew = localMod >= remoteMod; | 2429 | localIsNew = localMod >= remoteMod; |
2432 | //qDebug("conflict! ************************************** "); | 2430 | //qDebug("conflict! ************************************** "); |
2433 | { | 2431 | { |
2434 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2432 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2435 | result = acd.executeD(localIsNew); | 2433 | result = acd.executeD(localIsNew); |
2436 | return result; | 2434 | return result; |
2437 | } | 2435 | } |
2438 | break; | 2436 | break; |
2439 | case SYNC_PREF_FORCE_LOCAL: | 2437 | case SYNC_PREF_FORCE_LOCAL: |
2440 | return 1; | 2438 | return 1; |
2441 | break; | 2439 | break; |
2442 | case SYNC_PREF_FORCE_REMOTE: | 2440 | case SYNC_PREF_FORCE_REMOTE: |
2443 | return 2; | 2441 | return 2; |
2444 | break; | 2442 | break; |
2445 | 2443 | ||
2446 | default: | 2444 | default: |
2447 | // SYNC_PREF_TAKE_BOTH not implemented | 2445 | // SYNC_PREF_TAKE_BOTH not implemented |
2448 | break; | 2446 | break; |
2449 | } | 2447 | } |
2450 | return 0; | 2448 | return 0; |
2451 | } | 2449 | } |
2452 | 2450 | ||
2453 | 2451 | ||
2454 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2452 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2455 | { | 2453 | { |
2456 | bool syncOK = true; | 2454 | bool syncOK = true; |
2457 | int addedAddressee = 0; | 2455 | int addedAddressee = 0; |
2458 | int addedAddresseeR = 0; | 2456 | int addedAddresseeR = 0; |
2459 | int deletedAddresseeR = 0; | 2457 | int deletedAddresseeR = 0; |
2460 | int deletedAddresseeL = 0; | 2458 | int deletedAddresseeL = 0; |
2461 | int changedLocal = 0; | 2459 | int changedLocal = 0; |
2462 | int changedRemote = 0; | 2460 | int changedRemote = 0; |
2463 | 2461 | ||
2464 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2462 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2465 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2463 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2466 | 2464 | ||
2467 | //QPtrList<Addressee> el = local->rawAddressees(); | 2465 | //QPtrList<Addressee> el = local->rawAddressees(); |
2468 | Addressee addresseeR; | 2466 | Addressee addresseeR; |
2469 | QString uid; | 2467 | QString uid; |
2470 | int take; | 2468 | int take; |
2471 | Addressee addresseeL; | 2469 | Addressee addresseeL; |
2472 | Addressee addresseeRSync; | 2470 | Addressee addresseeRSync; |
2473 | Addressee addresseeLSync; | 2471 | Addressee addresseeLSync; |
2474 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2472 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2475 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2473 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2476 | bool fullDateRange = false; | 2474 | bool fullDateRange = false; |
2477 | local->resetTempSyncStat(); | 2475 | local->resetTempSyncStat(); |
2478 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2476 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2479 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2477 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2480 | addresseeLSync = getLastSyncAddressee(); | 2478 | addresseeLSync = getLastSyncAddressee(); |
2481 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2479 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2482 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2480 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2483 | if ( !addresseeR.isEmpty() ) { | 2481 | if ( !addresseeR.isEmpty() ) { |
2484 | addresseeRSync = addresseeR; | 2482 | addresseeRSync = addresseeR; |
2485 | remote->removeAddressee(addresseeR ); | 2483 | remote->removeAddressee(addresseeR ); |
2486 | 2484 | ||
2487 | } else { | 2485 | } else { |
2488 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2486 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2489 | addresseeRSync = addresseeLSync ; | 2487 | addresseeRSync = addresseeLSync ; |
2490 | } else { | 2488 | } else { |
2491 | qDebug("FULLDATE 1"); | 2489 | qDebug("FULLDATE 1"); |
2492 | fullDateRange = true; | 2490 | fullDateRange = true; |
2493 | Addressee newAdd; | 2491 | Addressee newAdd; |
2494 | addresseeRSync = newAdd; | 2492 | addresseeRSync = newAdd; |
2495 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2493 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2496 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2494 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2497 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2495 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2498 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2496 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2499 | } | 2497 | } |
2500 | } | 2498 | } |
2501 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2499 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2502 | qDebug("FULLDATE 2"); | 2500 | qDebug("FULLDATE 2"); |
2503 | fullDateRange = true; | 2501 | fullDateRange = true; |
2504 | } | 2502 | } |
2505 | if ( ! fullDateRange ) { | 2503 | if ( ! fullDateRange ) { |
2506 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2504 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2507 | 2505 | ||
2508 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2506 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2509 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2507 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2510 | fullDateRange = true; | 2508 | fullDateRange = true; |
2511 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2509 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2512 | } | 2510 | } |
2513 | } | 2511 | } |
2514 | // fullDateRange = true; // debug only! | 2512 | // fullDateRange = true; // debug only! |
2515 | if ( fullDateRange ) | 2513 | if ( fullDateRange ) |
2516 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2514 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2517 | else | 2515 | else |
2518 | mLastAddressbookSync = addresseeLSync.revision(); | 2516 | mLastAddressbookSync = addresseeLSync.revision(); |
2519 | // for resyncing if own file has changed | 2517 | // for resyncing if own file has changed |
2520 | // PENDING fixme later when implemented | 2518 | // PENDING fixme later when implemented |
2521 | #if 0 | 2519 | #if 0 |
2522 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2520 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2523 | mLastAddressbookSync = loadedFileVersion; | 2521 | mLastAddressbookSync = loadedFileVersion; |
2524 | qDebug("setting mLastAddressbookSync "); | 2522 | qDebug("setting mLastAddressbookSync "); |
2525 | } | 2523 | } |
2526 | #endif | 2524 | #endif |
2527 | 2525 | ||
2528 | //qDebug("*************************** "); | 2526 | //qDebug("*************************** "); |
2529 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2527 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2530 | QStringList er = remote->uidList(); | 2528 | QStringList er = remote->uidList(); |
2531 | Addressee inR ;//= er.first(); | 2529 | Addressee inR ;//= er.first(); |
2532 | Addressee inL; | 2530 | Addressee inL; |
2533 | 2531 | ||
2534 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2532 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2535 | 2533 | ||
2536 | int modulo = (er.count()/10)+1; | 2534 | int modulo = (er.count()/10)+1; |
2537 | int incCounter = 0; | 2535 | int incCounter = 0; |
2538 | while ( incCounter < er.count()) { | 2536 | while ( incCounter < er.count()) { |
2539 | if (syncManager->isProgressBarCanceled()) | 2537 | if (syncManager->isProgressBarCanceled()) |
2540 | return false; | 2538 | return false; |
2541 | if ( incCounter % modulo == 0 ) | 2539 | if ( incCounter % modulo == 0 ) |
2542 | syncManager->showProgressBar(incCounter); | 2540 | syncManager->showProgressBar(incCounter); |
2543 | 2541 | ||
2544 | uid = er[ incCounter ]; | 2542 | uid = er[ incCounter ]; |
2545 | bool skipIncidence = false; | 2543 | bool skipIncidence = false; |
2546 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2544 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2547 | skipIncidence = true; | 2545 | skipIncidence = true; |
2548 | QString idS,OidS; | 2546 | QString idS,OidS; |
2549 | qApp->processEvents(); | 2547 | qApp->processEvents(); |
2550 | if ( !skipIncidence ) { | 2548 | if ( !skipIncidence ) { |
2551 | inL = local->findByUid( uid ); | 2549 | inL = local->findByUid( uid ); |
2552 | inR = remote->findByUid( uid ); | 2550 | inR = remote->findByUid( uid ); |
2553 | //inL.setResource( 0 ); | 2551 | //inL.setResource( 0 ); |
2554 | //inR.setResource( 0 ); | 2552 | //inR.setResource( 0 ); |
2555 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2553 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2556 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2554 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2557 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2555 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2558 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2556 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2559 | if ( take == 3 ) | 2557 | if ( take == 3 ) |
2560 | return false; | 2558 | return false; |
2561 | if ( take == 1 ) {// take local | 2559 | if ( take == 1 ) {// take local |
2562 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2560 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2563 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2561 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2564 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2562 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2565 | local->insertAddressee( inL, false ); | 2563 | local->insertAddressee( inL, false ); |
2566 | idS = inR.externalUID(); | 2564 | idS = inR.externalUID(); |
2567 | OidS = inR.originalExternalUID(); | 2565 | OidS = inR.originalExternalUID(); |
2568 | } | 2566 | } |
2569 | else | 2567 | else |
2570 | idS = inR.IDStr(); | 2568 | idS = inR.IDStr(); |
2571 | remote->removeAddressee( inR ); | 2569 | remote->removeAddressee( inR ); |
2572 | inR = inL; | 2570 | inR = inL; |
2573 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2571 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2574 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2572 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2575 | inR.setOriginalExternalUID( OidS ); | 2573 | inR.setOriginalExternalUID( OidS ); |
2576 | inR.setExternalUID( idS ); | 2574 | inR.setExternalUID( idS ); |
2577 | } else { | 2575 | } else { |
2578 | inR.setIDStr( idS ); | 2576 | inR.setIDStr( idS ); |
2579 | } | 2577 | } |
2580 | inR.setResource( 0 ); | 2578 | inR.setResource( 0 ); |
2581 | remote->insertAddressee( inR , false); | 2579 | remote->insertAddressee( inR , false); |
2582 | ++changedRemote; | 2580 | ++changedRemote; |
2583 | } else { // take == 2 take remote | 2581 | } else { // take == 2 take remote |
2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2582 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2585 | if ( inR.revision().date().year() < 2004 ) | 2583 | if ( inR.revision().date().year() < 2004 ) |
2586 | inR.setRevision( modifiedCalendar ); | 2584 | inR.setRevision( modifiedCalendar ); |
2587 | } | 2585 | } |
2588 | idS = inL.IDStr(); | 2586 | idS = inL.IDStr(); |
2589 | local->removeAddressee( inL ); | 2587 | local->removeAddressee( inL ); |
2590 | inL = inR; | 2588 | inL = inR; |
2591 | inL.setIDStr( idS ); | 2589 | inL.setIDStr( idS ); |
2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2590 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2593 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2591 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2594 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2592 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2595 | } | 2593 | } |
2596 | inL.setResource( 0 ); | 2594 | inL.setResource( 0 ); |
2597 | local->insertAddressee( inL , false ); | 2595 | local->insertAddressee( inL , false ); |
2598 | ++changedLocal; | 2596 | ++changedLocal; |
2599 | } | 2597 | } |
2600 | } | 2598 | } |
2601 | } | 2599 | } |
2602 | } else { // no conflict | 2600 | } else { // no conflict |
2603 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2601 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2604 | QString des = addresseeLSync.note(); | 2602 | QString des = addresseeLSync.note(); |
2605 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2603 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2606 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2604 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2607 | remote->insertAddressee( inR, false ); | 2605 | remote->insertAddressee( inR, false ); |
2608 | ++deletedAddresseeR; | 2606 | ++deletedAddresseeR; |
2609 | } else { | 2607 | } else { |
2610 | inR.setRevision( modifiedCalendar ); | 2608 | inR.setRevision( modifiedCalendar ); |
2611 | remote->insertAddressee( inR, false ); | 2609 | remote->insertAddressee( inR, false ); |
2612 | inL = inR; | 2610 | inL = inR; |
2613 | inL.setResource( 0 ); | 2611 | inL.setResource( 0 ); |
2614 | local->insertAddressee( inL , false); | 2612 | local->insertAddressee( inL , false); |
2615 | ++addedAddressee; | 2613 | ++addedAddressee; |
2616 | } | 2614 | } |
2617 | } else { | 2615 | } else { |
2618 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2616 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2619 | inR.setRevision( modifiedCalendar ); | 2617 | inR.setRevision( modifiedCalendar ); |
2620 | remote->insertAddressee( inR, false ); | 2618 | remote->insertAddressee( inR, false ); |
2621 | inR.setResource( 0 ); | 2619 | inR.setResource( 0 ); |
2622 | local->insertAddressee( inR, false ); | 2620 | local->insertAddressee( inR, false ); |
2623 | ++addedAddressee; | 2621 | ++addedAddressee; |
2624 | } else { | 2622 | } else { |
2625 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2623 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2626 | remote->removeAddressee( inR ); | 2624 | remote->removeAddressee( inR ); |
2627 | ++deletedAddresseeR; | 2625 | ++deletedAddresseeR; |
2628 | } | 2626 | } |
2629 | } | 2627 | } |
2630 | } | 2628 | } |
2631 | } | 2629 | } |
2632 | ++incCounter; | 2630 | ++incCounter; |
2633 | } | 2631 | } |
2634 | er.clear(); | 2632 | er.clear(); |
2635 | QStringList el = local->uidList(); | 2633 | QStringList el = local->uidList(); |
2636 | modulo = (el.count()/10)+1; | 2634 | modulo = (el.count()/10)+1; |
2637 | 2635 | ||
2638 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2636 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2639 | incCounter = 0; | 2637 | incCounter = 0; |
2640 | while ( incCounter < el.count()) { | 2638 | while ( incCounter < el.count()) { |
2641 | qApp->processEvents(); | 2639 | qApp->processEvents(); |
2642 | if (syncManager->isProgressBarCanceled()) | 2640 | if (syncManager->isProgressBarCanceled()) |
2643 | return false; | 2641 | return false; |
2644 | if ( incCounter % modulo == 0 ) | 2642 | if ( incCounter % modulo == 0 ) |
2645 | syncManager->showProgressBar(incCounter); | 2643 | syncManager->showProgressBar(incCounter); |
2646 | uid = el[ incCounter ]; | 2644 | uid = el[ incCounter ]; |
2647 | bool skipIncidence = false; | 2645 | bool skipIncidence = false; |
2648 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2646 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2649 | skipIncidence = true; | 2647 | skipIncidence = true; |
2650 | if ( !skipIncidence ) { | 2648 | if ( !skipIncidence ) { |
2651 | inL = local->findByUid( uid ); | 2649 | inL = local->findByUid( uid ); |
2652 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2650 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2653 | inR = remote->findByUid( uid ); | 2651 | inR = remote->findByUid( uid ); |
2654 | if ( inR.isEmpty() ) { | 2652 | if ( inR.isEmpty() ) { |
2655 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2653 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2656 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2654 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2657 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2655 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2658 | local->removeAddressee( inL ); | 2656 | local->removeAddressee( inL ); |
2659 | ++deletedAddresseeL; | 2657 | ++deletedAddresseeL; |
2660 | } else { | 2658 | } else { |
2661 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2659 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2662 | inL.removeID(mCurrentSyncDevice ); | 2660 | inL.removeID(mCurrentSyncDevice ); |
2663 | ++addedAddresseeR; | 2661 | ++addedAddresseeR; |
2664 | inL.setRevision( modifiedCalendar ); | 2662 | inL.setRevision( modifiedCalendar ); |
2665 | local->insertAddressee( inL, false ); | 2663 | local->insertAddressee( inL, false ); |
2666 | inR = inL; | 2664 | inR = inL; |
2667 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2665 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2668 | inR.setResource( 0 ); | 2666 | inR.setResource( 0 ); |
2669 | remote->insertAddressee( inR, false ); | 2667 | remote->insertAddressee( inR, false ); |
2670 | } | 2668 | } |
2671 | } | 2669 | } |
2672 | } else { | 2670 | } else { |
2673 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2671 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2674 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2672 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2675 | local->removeAddressee( inL ); | 2673 | local->removeAddressee( inL ); |
2676 | ++deletedAddresseeL; | 2674 | ++deletedAddresseeL; |
2677 | } else { | 2675 | } else { |
2678 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2676 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2679 | ++addedAddresseeR; | 2677 | ++addedAddresseeR; |
2680 | inL.setRevision( modifiedCalendar ); | 2678 | inL.setRevision( modifiedCalendar ); |
2681 | local->insertAddressee( inL, false ); | 2679 | local->insertAddressee( inL, false ); |
2682 | inR = inL; | 2680 | inR = inL; |
2683 | inR.setResource( 0 ); | 2681 | inR.setResource( 0 ); |
2684 | remote->insertAddressee( inR, false ); | 2682 | remote->insertAddressee( inR, false ); |
2685 | } | 2683 | } |
2686 | } | 2684 | } |
2687 | } | 2685 | } |
2688 | } | 2686 | } |
2689 | } | 2687 | } |
2690 | } | 2688 | } |
2691 | ++incCounter; | 2689 | ++incCounter; |
2692 | } | 2690 | } |
2693 | el.clear(); | 2691 | el.clear(); |
2694 | syncManager->hideProgressBar(); | 2692 | syncManager->hideProgressBar(); |
2695 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2693 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2696 | // get rid of micro seconds | 2694 | // get rid of micro seconds |
2697 | QTime t = mLastAddressbookSync.time(); | 2695 | QTime t = mLastAddressbookSync.time(); |
2698 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2696 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2699 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2697 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2700 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2698 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2701 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2699 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2702 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2700 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2703 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2701 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2704 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2702 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2705 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2703 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2706 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2704 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2707 | addresseeRSync.setNote( "" ) ; | 2705 | addresseeRSync.setNote( "" ) ; |
2708 | addresseeLSync.setNote( "" ); | 2706 | addresseeLSync.setNote( "" ); |
2709 | 2707 | ||
2710 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2708 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2711 | remote->insertAddressee( addresseeRSync, false ); | 2709 | remote->insertAddressee( addresseeRSync, false ); |
2712 | local->insertAddressee( addresseeLSync, false ); | 2710 | local->insertAddressee( addresseeLSync, false ); |
2713 | QString mes; | 2711 | QString mes; |
2714 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2712 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2715 | if ( syncManager->mShowSyncSummary ) { | 2713 | if ( syncManager->mShowSyncSummary ) { |
2716 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2714 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2717 | } | 2715 | } |
2718 | qDebug( mes ); | 2716 | qDebug( mes ); |
2719 | return syncOK; | 2717 | return syncOK; |
2720 | } | 2718 | } |
2721 | 2719 | ||
2722 | 2720 | ||
2723 | //this is a overwritten callbackmethods from the syncinterface | 2721 | //this is a overwritten callbackmethods from the syncinterface |
2724 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2722 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2725 | { | 2723 | { |
2726 | 2724 | ||
2727 | //pending prepare addresseeview for output | 2725 | //pending prepare addresseeview for output |
2728 | //pending detect, if remote file has REV field. if not switch to external sync | 2726 | //pending detect, if remote file has REV field. if not switch to external sync |
2729 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2727 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2730 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2728 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2731 | 2729 | ||
2732 | AddressBook abLocal(filename,"syncContact"); | 2730 | AddressBook abLocal(filename,"syncContact"); |
2733 | bool syncOK = false; | 2731 | bool syncOK = false; |
2734 | if ( abLocal.load() ) { | 2732 | if ( abLocal.load() ) { |
2735 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2733 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2736 | bool external = false; | 2734 | bool external = false; |
2737 | bool isXML = false; | 2735 | bool isXML = false; |
2738 | if ( filename.right(4) == ".xml") { | 2736 | if ( filename.right(4) == ".xml") { |
2739 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2737 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2740 | isXML = true; | 2738 | isXML = true; |
2741 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2739 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2742 | } else { | 2740 | } else { |
2743 | external = !manager->mIsKapiFile; | 2741 | external = !manager->mIsKapiFile; |
2744 | if ( external ) { | 2742 | if ( external ) { |
2745 | qDebug("Setting vcf mode to external "); | 2743 | qDebug("Setting vcf mode to external "); |
2746 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2744 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2747 | AddressBook::Iterator it; | 2745 | AddressBook::Iterator it; |
2748 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2746 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2749 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2747 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2750 | (*it).computeCsum( mCurrentSyncDevice ); | 2748 | (*it).computeCsum( mCurrentSyncDevice ); |
2751 | } | 2749 | } |
2752 | } | 2750 | } |
2753 | } | 2751 | } |
2754 | //AddressBook::Iterator it; | 2752 | //AddressBook::Iterator it; |
2755 | //QStringList vcards; | 2753 | //QStringList vcards; |
2756 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2754 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2757 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2755 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2758 | //} | 2756 | //} |
2759 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2757 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2760 | if ( syncOK ) { | 2758 | if ( syncOK ) { |
2761 | if ( syncManager->mWriteBackFile ) | 2759 | if ( syncManager->mWriteBackFile ) |
2762 | { | 2760 | { |
2763 | if ( external ) | 2761 | if ( external ) |
2764 | abLocal.removeSyncAddressees( !isXML); | 2762 | abLocal.removeSyncAddressees( !isXML); |
2765 | qDebug("Saving remote AB "); | 2763 | qDebug("Saving remote AB "); |
2766 | if ( ! abLocal.saveAB()) | 2764 | if ( ! abLocal.saveAB()) |
2767 | qDebug("Error writing back AB to file "); | 2765 | qDebug("Error writing back AB to file "); |
2768 | if ( isXML ) { | 2766 | if ( isXML ) { |
2769 | // afterwrite processing | 2767 | // afterwrite processing |
2770 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2768 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2771 | } | 2769 | } |
2772 | } | 2770 | } |
2773 | } | 2771 | } |
2774 | setModified(); | 2772 | setModified(); |
2775 | 2773 | ||
2776 | } | 2774 | } |
2777 | if ( syncOK ) | 2775 | if ( syncOK ) |
2778 | mViewManager->refreshView(); | 2776 | mViewManager->refreshView(); |
2779 | return syncOK; | 2777 | return syncOK; |
2780 | 2778 | ||
2781 | } | 2779 | } |
2782 | 2780 | ||
2783 | 2781 | ||
2784 | //this is a overwritten callbackmethods from the syncinterface | 2782 | //this is a overwritten callbackmethods from the syncinterface |
2785 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2783 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2786 | { | 2784 | { |
2787 | if ( resource == "phone" ) | 2785 | if ( resource == "phone" ) |
2788 | return syncPhone(); | 2786 | return syncPhone(); |
2789 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2787 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2790 | 2788 | ||
2791 | AddressBook abLocal( resource,"syncContact"); | 2789 | AddressBook abLocal( resource,"syncContact"); |
2792 | bool syncOK = false; | 2790 | bool syncOK = false; |
2793 | if ( abLocal.load() ) { | 2791 | if ( abLocal.load() ) { |
2794 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2792 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2795 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2793 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2796 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2794 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2797 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2795 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2798 | if ( syncOK ) { | 2796 | if ( syncOK ) { |
2799 | if ( syncManager->mWriteBackFile ) { | 2797 | if ( syncManager->mWriteBackFile ) { |
2800 | abLocal.removeSyncAddressees( false ); | 2798 | abLocal.removeSyncAddressees( false ); |
2801 | abLocal.saveAB(); | 2799 | abLocal.saveAB(); |
2802 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2800 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2803 | } | 2801 | } |
2804 | } | 2802 | } |
2805 | setModified(); | 2803 | setModified(); |
2806 | } | 2804 | } |
2807 | if ( syncOK ) | 2805 | if ( syncOK ) |
2808 | mViewManager->refreshView(); | 2806 | mViewManager->refreshView(); |
2809 | return syncOK; | 2807 | return syncOK; |
2810 | 2808 | ||
2811 | } | 2809 | } |
2812 | void KABCore::message( QString m ) | 2810 | void KABCore::message( QString m ) |
2813 | { | 2811 | { |
2814 | 2812 | ||
2815 | topLevelWidget()->setCaption( m ); | 2813 | topLevelWidget()->setCaption( m ); |
2816 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); | 2814 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); |
2817 | } | 2815 | } |
2818 | bool KABCore::syncPhone() | 2816 | bool KABCore::syncPhone() |
2819 | { | 2817 | { |
2820 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2818 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2821 | QString fileName; | 2819 | QString fileName = getPhoneFile(); |
2822 | #ifdef _WIN32_ | ||
2823 | fileName = locateLocal("tmp", "phonefile.vcf"); | ||
2824 | #else | ||
2825 | fileName = "/tmp/phonefile.vcf"; | ||
2826 | #endif | ||
2827 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2820 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2828 | message(i18n("Phone access failed!")); | 2821 | message(i18n("Phone access failed!")); |
2829 | return false; | 2822 | return false; |
2830 | } | 2823 | } |
2831 | AddressBook abLocal( fileName,"syncContact"); | 2824 | AddressBook abLocal( fileName,"syncContact"); |
2832 | bool syncOK = false; | 2825 | bool syncOK = false; |
2833 | { | 2826 | { |
2834 | abLocal.importFromFile( fileName ); | 2827 | abLocal.importFromFile( fileName ); |
2835 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2828 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2836 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2829 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2837 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2830 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2838 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2831 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2839 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2832 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2840 | if ( syncOK ) { | 2833 | if ( syncOK ) { |
2841 | if ( syncManager->mWriteBackFile ) { | 2834 | if ( syncManager->mWriteBackFile ) { |
2842 | abLocal.removeSyncAddressees( true ); | 2835 | abLocal.removeSyncAddressees( true ); |
2843 | abLocal.saveABphone( fileName ); | 2836 | abLocal.saveABphone( fileName ); |
2844 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2837 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2845 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2838 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2846 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2839 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2847 | } | 2840 | } |
2848 | } | 2841 | } |
2849 | setModified(); | 2842 | setModified(); |
2850 | } | 2843 | } |
2851 | if ( syncOK ) | 2844 | if ( syncOK ) |
2852 | mViewManager->refreshView(); | 2845 | mViewManager->refreshView(); |
2853 | return syncOK; | 2846 | return syncOK; |
2854 | } | 2847 | } |
2855 | void KABCore::getFile( bool success ) | 2848 | void KABCore::getFile( bool success ) |
2856 | { | 2849 | { |
2857 | if ( ! success ) { | 2850 | if ( ! success ) { |
2858 | message( i18n("Error receiving file. Nothing changed!") ); | 2851 | message( i18n("Error receiving file. Nothing changed!") ); |
2859 | return; | 2852 | return; |
2860 | } | 2853 | } |
2861 | mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2854 | mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2862 | message( i18n("Pi-Sync successful!") ); | 2855 | message( i18n("Pi-Sync successful!") ); |
2863 | mViewManager->refreshView(); | 2856 | mViewManager->refreshView(); |
2864 | } | 2857 | } |
2865 | void KABCore::syncFileRequest() | 2858 | void KABCore::syncFileRequest() |
2866 | { | 2859 | { |
2867 | mAddressBook->export2File( sentSyncFile() ); | 2860 | mAddressBook->export2File( sentSyncFile() ); |
2868 | } | 2861 | } |
2869 | QString KABCore::sentSyncFile() | 2862 | QString KABCore::sentSyncFile() |
2870 | { | 2863 | { |
2871 | #ifdef _WIN32_ | 2864 | #ifdef _WIN32_ |
2872 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2865 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2873 | #else | 2866 | #else |
2874 | return QString( "/tmp/copysyncab.vcf" ); | 2867 | return QString( "/tmp/copysyncab.vcf" ); |
2875 | #endif | 2868 | #endif |
2876 | } | 2869 | } |
2877 | 2870 | ||
2878 | void KABCore::setCaptionBack() | 2871 | void KABCore::setCaptionBack() |
2879 | { | 2872 | { |
2880 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2873 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2881 | } | 2874 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 3c33923..5871d39 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,488 +1,490 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <ksyncmanager.h> | 35 | #include <ksyncmanager.h> |
36 | 36 | ||
37 | namespace KABC { | 37 | namespace KABC { |
38 | class AddressBook; | 38 | class AddressBook; |
39 | } | 39 | } |
40 | 40 | ||
41 | #ifndef KAB_EMBEDDED | 41 | #ifndef KAB_EMBEDDED |
42 | class KAboutData; | 42 | class KAboutData; |
43 | class KConfig; | 43 | class KConfig; |
44 | 44 | ||
45 | class KAddressBookService; | 45 | class KAddressBookService; |
46 | class LDAPSearchDialog; | 46 | class LDAPSearchDialog; |
47 | #else //KAB_EMBEDDED | 47 | #else //KAB_EMBEDDED |
48 | class KAddressBookMain; | 48 | class KAddressBookMain; |
49 | //US class QAction; | 49 | //US class QAction; |
50 | #endif //KAB_EMBEDDED | 50 | #endif //KAB_EMBEDDED |
51 | class KCMultiDialog; | 51 | class KCMultiDialog; |
52 | class KXMLGUIClient; | 52 | class KXMLGUIClient; |
53 | class ExtensionManager; | 53 | class ExtensionManager; |
54 | class XXPortManager; | 54 | class XXPortManager; |
55 | class JumpButtonBar; | 55 | class JumpButtonBar; |
56 | class IncSearchWidget; | 56 | class IncSearchWidget; |
57 | class KDGanttMinimizeSplitter; | 57 | class KDGanttMinimizeSplitter; |
58 | class KAction; | 58 | class KAction; |
59 | class KActionCollection; | 59 | class KActionCollection; |
60 | class KToggleAction; | 60 | class KToggleAction; |
61 | class KSyncProfile; | 61 | class KSyncProfile; |
62 | 62 | ||
63 | class QAction; | 63 | class QAction; |
64 | class QMenuBar; | 64 | class QMenuBar; |
65 | class QSplitter; | 65 | class QSplitter; |
66 | class ViewContainer; | 66 | class ViewContainer; |
67 | class ViewManager; | 67 | class ViewManager; |
68 | class AddresseeEditorDialog; | 68 | class AddresseeEditorDialog; |
69 | class Ir; | 69 | class Ir; |
70 | 70 | ||
71 | class KABCore : public QWidget, public KSyncInterface | 71 | class KABCore : public QWidget, public KSyncInterface |
72 | { | 72 | { |
73 | Q_OBJECT | 73 | Q_OBJECT |
74 | 74 | ||
75 | public: | 75 | public: |
76 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 76 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
77 | 77 | ||
78 | 78 | ||
79 | ~KABCore(); | 79 | ~KABCore(); |
80 | 80 | ||
81 | 81 | ||
82 | #ifdef KAB_EMBEDDED | 82 | #ifdef KAB_EMBEDDED |
83 | //US added functionality | 83 | //US added functionality |
84 | QPopupMenu* getViewMenu() {return viewMenu;} | 84 | QPopupMenu* getViewMenu() {return viewMenu;} |
85 | QPopupMenu* getFilterMenu() {return filterMenu;} | 85 | QPopupMenu* getFilterMenu() {return filterMenu;} |
86 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 86 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
87 | void addActionsManually(); | 87 | void addActionsManually(); |
88 | #endif //KAB_EMBEDDED | 88 | #endif //KAB_EMBEDDED |
89 | /** | 89 | /** |
90 | Restores the global settings. | 90 | Restores the global settings. |
91 | */ | 91 | */ |
92 | void restoreSettings(); | 92 | void restoreSettings(); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | Saves the global settings. | 95 | Saves the global settings. |
96 | */ | 96 | */ |
97 | void saveSettings(); | 97 | void saveSettings(); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | Returns a pointer to the StdAddressBook of the application. | 100 | Returns a pointer to the StdAddressBook of the application. |
101 | */ | 101 | */ |
102 | KABC::AddressBook *addressBook() const; | 102 | KABC::AddressBook *addressBook() const; |
103 | 103 | ||
104 | /** | 104 | /** |
105 | Returns a pointer to the KConfig object of the application. | 105 | Returns a pointer to the KConfig object of the application. |
106 | */ | 106 | */ |
107 | static KConfig *config(); | 107 | static KConfig *config(); |
108 | 108 | ||
109 | /** | 109 | /** |
110 | Returns a pointer to the global KActionCollection object. So | 110 | Returns a pointer to the global KActionCollection object. So |
111 | other classes can register their actions easily. | 111 | other classes can register their actions easily. |
112 | */ | 112 | */ |
113 | KActionCollection *actionCollection() const; | 113 | KActionCollection *actionCollection() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | Returns the current search field of the Incremental Search Widget. | 116 | Returns the current search field of the Incremental Search Widget. |
117 | */ | 117 | */ |
118 | KABC::Field *currentSearchField() const; | 118 | KABC::Field *currentSearchField() const; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | Returns the uid list of the currently selected contacts. | 121 | Returns the uid list of the currently selected contacts. |
122 | */ | 122 | */ |
123 | QStringList selectedUIDs() const; | 123 | QStringList selectedUIDs() const; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | Displays the ResourceSelectDialog and returns the selected | 126 | Displays the ResourceSelectDialog and returns the selected |
127 | resource or a null pointer if no resource was selected by | 127 | resource or a null pointer if no resource was selected by |
128 | the user. | 128 | the user. |
129 | */ | 129 | */ |
130 | KABC::Resource *requestResource( QWidget *parent ); | 130 | KABC::Resource *requestResource( QWidget *parent ); |
131 | 131 | ||
132 | #ifndef KAB_EMBEDDED | 132 | #ifndef KAB_EMBEDDED |
133 | static KAboutData *createAboutData(); | 133 | static KAboutData *createAboutData(); |
134 | #endif //KAB_EMBEDDED | 134 | #endif //KAB_EMBEDDED |
135 | 135 | ||
136 | #ifdef KAB_EMBEDDED | 136 | #ifdef KAB_EMBEDDED |
137 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 137 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
138 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 138 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
139 | #endif //KAB_EMBEDDED | 139 | #endif //KAB_EMBEDDED |
140 | 140 | ||
141 | public slots: | 141 | public slots: |
142 | #ifdef KAB_EMBEDDED | 142 | #ifdef KAB_EMBEDDED |
143 | void createAboutData(); | 143 | void createAboutData(); |
144 | #endif //KAB_EMBEDDED | 144 | #endif //KAB_EMBEDDED |
145 | 145 | ||
146 | void statusMessage(QString, int time = 0 ); | 146 | void statusMessage(QString, int time = 0 ); |
147 | void showLicence(); | 147 | void showLicence(); |
148 | void faq(); | 148 | void faq(); |
149 | void whatsnew() ; | 149 | void whatsnew() ; |
150 | void synchowto() ; | 150 | void synchowto() ; |
151 | void writeToPhone(); | ||
151 | 152 | ||
152 | /** | 153 | /** |
153 | Is called whenever a contact is selected in the view. | 154 | Is called whenever a contact is selected in the view. |
154 | */ | 155 | */ |
155 | void setContactSelected( const QString &uid ); | 156 | void setContactSelected( const QString &uid ); |
156 | 157 | ||
157 | /** | 158 | /** |
158 | Opens the preferred mail composer with all selected contacts as | 159 | Opens the preferred mail composer with all selected contacts as |
159 | arguments. | 160 | arguments. |
160 | */ | 161 | */ |
161 | void sendMail(); | 162 | void sendMail(); |
162 | 163 | ||
163 | /** | 164 | /** |
164 | Opens the preferred mail composer with the given contacts as | 165 | Opens the preferred mail composer with the given contacts as |
165 | arguments. | 166 | arguments. |
166 | */ | 167 | */ |
167 | void sendMail( const QString& email ); | 168 | void sendMail( const QString& email ); |
168 | 169 | ||
169 | 170 | ||
170 | void mailVCard(); | 171 | void mailVCard(); |
171 | void mailVCard(const QStringList& uids); | 172 | void mailVCard(const QStringList& uids); |
172 | 173 | ||
173 | /** | 174 | /** |
174 | Beams the "WhoAmI contact. | 175 | Beams the "WhoAmI contact. |
175 | */ | 176 | */ |
176 | void beamMySelf(); | 177 | void beamMySelf(); |
177 | 178 | ||
178 | void beamVCard(); | 179 | void beamVCard(); |
179 | void export2phone(); | 180 | void export2phone(); |
180 | void beamVCard(const QStringList& uids); | 181 | void beamVCard(const QStringList& uids); |
181 | void beamDone( Ir *ir ); | 182 | void beamDone( Ir *ir ); |
182 | 183 | ||
183 | 184 | ||
184 | /** | 185 | /** |
185 | Starts the preferred web browser with the given URL as argument. | 186 | Starts the preferred web browser with the given URL as argument. |
186 | */ | 187 | */ |
187 | void browse( const QString& url ); | 188 | void browse( const QString& url ); |
188 | 189 | ||
189 | /** | 190 | /** |
190 | Select all contacts in the view. | 191 | Select all contacts in the view. |
191 | */ | 192 | */ |
192 | void selectAllContacts(); | 193 | void selectAllContacts(); |
193 | 194 | ||
194 | /** | 195 | /** |
195 | Deletes all selected contacts from the address book. | 196 | Deletes all selected contacts from the address book. |
196 | */ | 197 | */ |
197 | void deleteContacts(); | 198 | void deleteContacts(); |
198 | 199 | ||
199 | /** | 200 | /** |
200 | Deletes given contacts from the address book. | 201 | Deletes given contacts from the address book. |
201 | 202 | ||
202 | @param uids The uids of the contacts, which shall be deleted. | 203 | @param uids The uids of the contacts, which shall be deleted. |
203 | */ | 204 | */ |
204 | void deleteContacts( const QStringList &uids ); | 205 | void deleteContacts( const QStringList &uids ); |
205 | 206 | ||
206 | /** | 207 | /** |
207 | Copys the selected contacts into clipboard for later pasting. | 208 | Copys the selected contacts into clipboard for later pasting. |
208 | */ | 209 | */ |
209 | void copyContacts(); | 210 | void copyContacts(); |
210 | 211 | ||
211 | /** | 212 | /** |
212 | Cuts the selected contacts and stores them for later pasting. | 213 | Cuts the selected contacts and stores them for later pasting. |
213 | */ | 214 | */ |
214 | void cutContacts(); | 215 | void cutContacts(); |
215 | 216 | ||
216 | /** | 217 | /** |
217 | Paste contacts from clipboard into the address book. | 218 | Paste contacts from clipboard into the address book. |
218 | */ | 219 | */ |
219 | void pasteContacts(); | 220 | void pasteContacts(); |
220 | 221 | ||
221 | /** | 222 | /** |
222 | Paste given contacts into the address book. | 223 | Paste given contacts into the address book. |
223 | 224 | ||
224 | @param list The list of addressee, which shall be pasted. | 225 | @param list The list of addressee, which shall be pasted. |
225 | */ | 226 | */ |
226 | void pasteContacts( KABC::Addressee::List &list ); | 227 | void pasteContacts( KABC::Addressee::List &list ); |
227 | 228 | ||
228 | /** | 229 | /** |
229 | Sets the whoAmI contact, that is used by many other programs to | 230 | Sets the whoAmI contact, that is used by many other programs to |
230 | get personal information about the current user. | 231 | get personal information about the current user. |
231 | */ | 232 | */ |
232 | void setWhoAmI(); | 233 | void setWhoAmI(); |
233 | 234 | ||
234 | /** | 235 | /** |
235 | Displays the category dialog and applies the result to all | 236 | Displays the category dialog and applies the result to all |
236 | selected contacts. | 237 | selected contacts. |
237 | */ | 238 | */ |
238 | void setCategories(); | 239 | void setCategories(); |
239 | 240 | ||
240 | /** | 241 | /** |
241 | Sets the field list of the Incremental Search Widget. | 242 | Sets the field list of the Incremental Search Widget. |
242 | */ | 243 | */ |
243 | void setSearchFields( const KABC::Field::List &fields ); | 244 | void setSearchFields( const KABC::Field::List &fields ); |
244 | 245 | ||
245 | /** | 246 | /** |
246 | Search with the current search field for a contact, that matches | 247 | Search with the current search field for a contact, that matches |
247 | the given text, and selects it in the view. | 248 | the given text, and selects it in the view. |
248 | */ | 249 | */ |
249 | void incrementalSearch( const QString& text ); | 250 | void incrementalSearch( const QString& text ); |
250 | 251 | ||
251 | /** | 252 | /** |
252 | Marks the address book as modified. | 253 | Marks the address book as modified. |
253 | */ | 254 | */ |
254 | void setModified(); | 255 | void setModified(); |
255 | /** | 256 | /** |
256 | Marks the address book as modified without refreshing the view. | 257 | Marks the address book as modified without refreshing the view. |
257 | */ | 258 | */ |
258 | void setModifiedWOrefresh(); | 259 | void setModifiedWOrefresh(); |
259 | 260 | ||
260 | /** | 261 | /** |
261 | Marks the address book as modified concerning the argument. | 262 | Marks the address book as modified concerning the argument. |
262 | */ | 263 | */ |
263 | void setModified( bool modified ); | 264 | void setModified( bool modified ); |
264 | 265 | ||
265 | /** | 266 | /** |
266 | Returns whether the address book is modified. | 267 | Returns whether the address book is modified. |
267 | */ | 268 | */ |
268 | bool modified() const; | 269 | bool modified() const; |
269 | 270 | ||
270 | /** | 271 | /** |
271 | Called whenever an contact is modified in the contact editor | 272 | Called whenever an contact is modified in the contact editor |
272 | dialog or the quick edit. | 273 | dialog or the quick edit. |
273 | */ | 274 | */ |
274 | void contactModified( const KABC::Addressee &addr ); | 275 | void contactModified( const KABC::Addressee &addr ); |
275 | 276 | ||
276 | /** | 277 | /** |
277 | DCOP METHODS. | 278 | DCOP METHODS. |
278 | */ | 279 | */ |
279 | void addEmail( QString addr ); | 280 | void addEmail( QString addr ); |
280 | void importVCard( const KURL& url, bool showPreview ); | 281 | void importVCard( const KURL& url, bool showPreview ); |
281 | void importVCard( const QString& vCard, bool showPreview ); | 282 | void importVCard( const QString& vCard, bool showPreview ); |
282 | void newContact(); | 283 | void newContact(); |
283 | QString getNameByPhone( const QString& phone ); | 284 | QString getNameByPhone( const QString& phone ); |
284 | /** | 285 | /** |
285 | END DCOP METHODS | 286 | END DCOP METHODS |
286 | */ | 287 | */ |
287 | 288 | ||
288 | /** | 289 | /** |
289 | Saves the contents of the AddressBook back to disk. | 290 | Saves the contents of the AddressBook back to disk. |
290 | */ | 291 | */ |
291 | void save(); | 292 | void save(); |
292 | 293 | ||
293 | /** | 294 | /** |
294 | Undos the last command using the undo stack. | 295 | Undos the last command using the undo stack. |
295 | */ | 296 | */ |
296 | void undo(); | 297 | void undo(); |
297 | 298 | ||
298 | /** | 299 | /** |
299 | Redos the last command that was undone, using the redo stack. | 300 | Redos the last command that was undone, using the redo stack. |
300 | */ | 301 | */ |
301 | void redo(); | 302 | void redo(); |
302 | 303 | ||
303 | /** | 304 | /** |
304 | Shows the edit dialog for the given uid. If the uid is QString::null, | 305 | Shows the edit dialog for the given uid. If the uid is QString::null, |
305 | the method will try to find a selected addressee in the view. | 306 | the method will try to find a selected addressee in the view. |
306 | */ | 307 | */ |
307 | void editContact( const QString &uid /*US = QString::null*/ ); | 308 | void editContact( const QString &uid /*US = QString::null*/ ); |
308 | //US added a second method without defaultparameter | 309 | //US added a second method without defaultparameter |
309 | void editContact2(); | 310 | void editContact2(); |
310 | 311 | ||
311 | /** | 312 | /** |
312 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 313 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
313 | the method will try to find a selected addressee in the view. | 314 | the method will try to find a selected addressee in the view. |
314 | */ | 315 | */ |
315 | void executeContact( const QString &uid /*US = QString::null*/ ); | 316 | void executeContact( const QString &uid /*US = QString::null*/ ); |
316 | 317 | ||
317 | /** | 318 | /** |
318 | Launches the configuration dialog. | 319 | Launches the configuration dialog. |
319 | */ | 320 | */ |
320 | void openConfigDialog(); | 321 | void openConfigDialog(); |
321 | 322 | ||
322 | /** | 323 | /** |
323 | Launches the ldap search dialog. | 324 | Launches the ldap search dialog. |
324 | */ | 325 | */ |
325 | void openLDAPDialog(); | 326 | void openLDAPDialog(); |
326 | 327 | ||
327 | /** | 328 | /** |
328 | Creates a KAddressBookPrinter, which will display the print | 329 | Creates a KAddressBookPrinter, which will display the print |
329 | dialog and do the printing. | 330 | dialog and do the printing. |
330 | */ | 331 | */ |
331 | void print(); | 332 | void print(); |
332 | 333 | ||
333 | /** | 334 | /** |
334 | Registers a new GUI client, so plugins can register its actions. | 335 | Registers a new GUI client, so plugins can register its actions. |
335 | */ | 336 | */ |
336 | void addGUIClient( KXMLGUIClient *client ); | 337 | void addGUIClient( KXMLGUIClient *client ); |
337 | 338 | ||
338 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 339 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
339 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 340 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
340 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); | 341 | void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); |
341 | 342 | ||
342 | 343 | ||
343 | signals: | 344 | signals: |
344 | void contactSelected( const QString &name ); | 345 | void contactSelected( const QString &name ); |
345 | void contactSelected( const QPixmap &pixmap ); | 346 | void contactSelected( const QPixmap &pixmap ); |
346 | public slots: | 347 | public slots: |
347 | void recieve(QString cmsg ); | 348 | void recieve(QString cmsg ); |
348 | void getFile( bool success ); | 349 | void getFile( bool success ); |
349 | void syncFileRequest(); | 350 | void syncFileRequest(); |
350 | void setDetailsVisible( bool visible ); | 351 | void setDetailsVisible( bool visible ); |
351 | void setDetailsToState(); | 352 | void setDetailsToState(); |
352 | // void slotSyncMenu( int ); | 353 | // void slotSyncMenu( int ); |
353 | private slots: | 354 | private slots: |
354 | void setJumpButtonBarVisible( bool visible ); | 355 | void setJumpButtonBarVisible( bool visible ); |
355 | void setCaptionBack(); | 356 | void setCaptionBack(); |
356 | void importFromOL(); | 357 | void importFromOL(); |
357 | void extensionModified( const KABC::Addressee::List &list ); | 358 | void extensionModified( const KABC::Addressee::List &list ); |
358 | void extensionChanged( int id ); | 359 | void extensionChanged( int id ); |
359 | void clipboardDataChanged(); | 360 | void clipboardDataChanged(); |
360 | void updateActionMenu(); | 361 | void updateActionMenu(); |
361 | void configureKeyBindings(); | 362 | void configureKeyBindings(); |
362 | void removeVoice(); | 363 | void removeVoice(); |
363 | #ifdef KAB_EMBEDDED | 364 | #ifdef KAB_EMBEDDED |
364 | void configureResources(); | 365 | void configureResources(); |
365 | #endif //KAB_EMBEDDED | 366 | #endif //KAB_EMBEDDED |
366 | 367 | ||
367 | void slotEditorDestroyed( const QString &uid ); | 368 | void slotEditorDestroyed( const QString &uid ); |
368 | void configurationChanged(); | 369 | void configurationChanged(); |
369 | void addressBookChanged(); | 370 | void addressBookChanged(); |
370 | 371 | ||
371 | private: | 372 | private: |
372 | void initGUI(); | 373 | void initGUI(); |
373 | void initActions(); | 374 | void initActions(); |
375 | QString getPhoneFile(); | ||
374 | 376 | ||
375 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 377 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
376 | const char *name = 0 ); | 378 | const char *name = 0 ); |
377 | 379 | ||
378 | KXMLGUIClient *mGUIClient; | 380 | KXMLGUIClient *mGUIClient; |
379 | 381 | ||
380 | KABC::AddressBook *mAddressBook; | 382 | KABC::AddressBook *mAddressBook; |
381 | 383 | ||
382 | ViewManager *mViewManager; | 384 | ViewManager *mViewManager; |
383 | // QSplitter *mDetailsSplitter; | 385 | // QSplitter *mDetailsSplitter; |
384 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 386 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
385 | ViewContainer *mDetails; | 387 | ViewContainer *mDetails; |
386 | KDGanttMinimizeSplitter* mMiniSplitter; | 388 | KDGanttMinimizeSplitter* mMiniSplitter; |
387 | XXPortManager *mXXPortManager; | 389 | XXPortManager *mXXPortManager; |
388 | JumpButtonBar *mJumpButtonBar; | 390 | JumpButtonBar *mJumpButtonBar; |
389 | IncSearchWidget *mIncSearchWidget; | 391 | IncSearchWidget *mIncSearchWidget; |
390 | ExtensionManager *mExtensionManager; | 392 | ExtensionManager *mExtensionManager; |
391 | 393 | ||
392 | KCMultiDialog *mConfigureDialog; | 394 | KCMultiDialog *mConfigureDialog; |
393 | 395 | ||
394 | #ifndef KAB_EMBEDDED | 396 | #ifndef KAB_EMBEDDED |
395 | LDAPSearchDialog *mLdapSearchDialog; | 397 | LDAPSearchDialog *mLdapSearchDialog; |
396 | #endif //KAB_EMBEDDED | 398 | #endif //KAB_EMBEDDED |
397 | // QDict<AddresseeEditorDialog> mEditorDict; | 399 | // QDict<AddresseeEditorDialog> mEditorDict; |
398 | AddresseeEditorDialog *mEditorDialog; | 400 | AddresseeEditorDialog *mEditorDialog; |
399 | bool mReadWrite; | 401 | bool mReadWrite; |
400 | bool mModified; | 402 | bool mModified; |
401 | bool mIsPart; | 403 | bool mIsPart; |
402 | bool mMultipleViewsAtOnce; | 404 | bool mMultipleViewsAtOnce; |
403 | 405 | ||
404 | 406 | ||
405 | //US file menu | 407 | //US file menu |
406 | KAction *mActionMail; | 408 | KAction *mActionMail; |
407 | KAction *mActionBeam; | 409 | KAction *mActionBeam; |
408 | KAction *mActionExport2phone; | 410 | KAction *mActionExport2phone; |
409 | KAction* mActionPrint; | 411 | KAction* mActionPrint; |
410 | KAction* mActionNewContact; | 412 | KAction* mActionNewContact; |
411 | KAction *mActionSave; | 413 | KAction *mActionSave; |
412 | KAction *mActionEditAddressee; | 414 | KAction *mActionEditAddressee; |
413 | KAction *mActionMailVCard; | 415 | KAction *mActionMailVCard; |
414 | KAction *mActionBeamVCard; | 416 | KAction *mActionBeamVCard; |
415 | 417 | ||
416 | KAction *mActionQuit; | 418 | KAction *mActionQuit; |
417 | 419 | ||
418 | //US edit menu | 420 | //US edit menu |
419 | KAction *mActionCopy; | 421 | KAction *mActionCopy; |
420 | KAction *mActionCut; | 422 | KAction *mActionCut; |
421 | KAction *mActionPaste; | 423 | KAction *mActionPaste; |
422 | KAction *mActionSelectAll; | 424 | KAction *mActionSelectAll; |
423 | KAction *mActionUndo; | 425 | KAction *mActionUndo; |
424 | KAction *mActionRedo; | 426 | KAction *mActionRedo; |
425 | KAction *mActionDelete; | 427 | KAction *mActionDelete; |
426 | 428 | ||
427 | //US settings menu | 429 | //US settings menu |
428 | KAction *mActionConfigResources; | 430 | KAction *mActionConfigResources; |
429 | KAction *mActionConfigKAddressbook; | 431 | KAction *mActionConfigKAddressbook; |
430 | KAction *mActionConfigShortcuts; | 432 | KAction *mActionConfigShortcuts; |
431 | KAction *mActionConfigureToolbars; | 433 | KAction *mActionConfigureToolbars; |
432 | KAction *mActionKeyBindings; | 434 | KAction *mActionKeyBindings; |
433 | KToggleAction *mActionJumpBar; | 435 | KToggleAction *mActionJumpBar; |
434 | KToggleAction *mActionDetails; | 436 | KToggleAction *mActionDetails; |
435 | KAction *mActionWhoAmI; | 437 | KAction *mActionWhoAmI; |
436 | KAction *mActionCategories; | 438 | KAction *mActionCategories; |
437 | KAction *mActionAboutKAddressbook; | 439 | KAction *mActionAboutKAddressbook; |
438 | KAction *mActionLicence; | 440 | KAction *mActionLicence; |
439 | KAction *mActionFaq; | 441 | KAction *mActionFaq; |
440 | KAction *mActionWN; | 442 | KAction *mActionWN; |
441 | KAction *mActionSyncHowto; | 443 | KAction *mActionSyncHowto; |
442 | 444 | ||
443 | KAction *mActionDeleteView; | 445 | KAction *mActionDeleteView; |
444 | 446 | ||
445 | QPopupMenu *viewMenu; | 447 | QPopupMenu *viewMenu; |
446 | QPopupMenu *filterMenu; | 448 | QPopupMenu *filterMenu; |
447 | QPopupMenu *settingsMenu; | 449 | QPopupMenu *settingsMenu; |
448 | QPopupMenu *changeMenu; | 450 | QPopupMenu *changeMenu; |
449 | //US QAction *mActionSave; | 451 | //US QAction *mActionSave; |
450 | QPopupMenu *ImportMenu; | 452 | QPopupMenu *ImportMenu; |
451 | QPopupMenu *ExportMenu; | 453 | QPopupMenu *ExportMenu; |
452 | //LR additional methods | 454 | //LR additional methods |
453 | KAction *mActionRemoveVoice; | 455 | KAction *mActionRemoveVoice; |
454 | KAction * mActionImportOL; | 456 | KAction * mActionImportOL; |
455 | 457 | ||
456 | #ifndef KAB_EMBEDDED | 458 | #ifndef KAB_EMBEDDED |
457 | KAddressBookService *mAddressBookService; | 459 | KAddressBookService *mAddressBookService; |
458 | #endif //KAB_EMBEDDED | 460 | #endif //KAB_EMBEDDED |
459 | 461 | ||
460 | class KABCorePrivate; | 462 | class KABCorePrivate; |
461 | KABCorePrivate *d; | 463 | KABCorePrivate *d; |
462 | //US bool mBlockSaveFlag; | 464 | //US bool mBlockSaveFlag; |
463 | 465 | ||
464 | #ifdef KAB_EMBEDDED | 466 | #ifdef KAB_EMBEDDED |
465 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 467 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
466 | #endif //KAB_EMBEDDED | 468 | #endif //KAB_EMBEDDED |
467 | 469 | ||
468 | //this are the overwritten callbackmethods from the syncinterface | 470 | //this are the overwritten callbackmethods from the syncinterface |
469 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 471 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
470 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 472 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
471 | bool syncPhone(); | 473 | bool syncPhone(); |
472 | void message( QString m ); | 474 | void message( QString m ); |
473 | 475 | ||
474 | // LR ******************************* | 476 | // LR ******************************* |
475 | // sync stuff! | 477 | // sync stuff! |
476 | QString sentSyncFile(); | 478 | QString sentSyncFile(); |
477 | QPopupMenu *syncMenu; | 479 | QPopupMenu *syncMenu; |
478 | KSyncManager* syncManager; | 480 | KSyncManager* syncManager; |
479 | int mGlobalSyncMode; | 481 | int mGlobalSyncMode; |
480 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 482 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
481 | KABC::Addressee getLastSyncAddressee(); | 483 | KABC::Addressee getLastSyncAddressee(); |
482 | QDateTime mLastAddressbookSync; | 484 | QDateTime mLastAddressbookSync; |
483 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); | 485 | int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); |
484 | // ********************* | 486 | // ********************* |
485 | 487 | ||
486 | }; | 488 | }; |
487 | 489 | ||
488 | #endif | 490 | #endif |