summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmmisc.c5
-rw-r--r--kabc/addressbook.cpp3
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kabc/plugins/sharpdtm/resourcesharpdtm.cpp4
-rw-r--r--kaddressbook/kabcore.cpp31
-rw-r--r--kaddressbook/kabcore.h3
6 files changed, 27 insertions, 21 deletions
diff --git a/gammu/emb/common/service/gsmmisc.c b/gammu/emb/common/service/gsmmisc.c
index 1c6ec8b..486d136 100644
--- a/gammu/emb/common/service/gsmmisc.c
+++ b/gammu/emb/common/service/gsmmisc.c
@@ -1,262 +1,265 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#include <string.h> 3#include <string.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#include <sys/stat.h> 5#include <sys/stat.h>
6#ifdef WIN32 6#ifdef WIN32
7# include <io.h> 7# include <io.h>
8# include <fcntl.h> 8# include <fcntl.h>
9#endif 9#endif
10 10
11#include "../misc/coding/coding.h" 11#include "../misc/coding/coding.h"
12#include "../gsmcomon.h" 12#include "../gsmcomon.h"
13#include "gsmmisc.h" 13#include "gsmmisc.h"
14 14
15struct keys_table_position { 15struct keys_table_position {
16 char whatchar; 16 char whatchar;
17 int whatcode; 17 int whatcode;
18}; 18};
19 19
20static struct keys_table_position Keys[] = { 20static struct keys_table_position Keys[] = {
21 {'m',GSM_KEY_MENU}, {'M',GSM_KEY_MENU}, 21 {'m',GSM_KEY_MENU}, {'M',GSM_KEY_MENU},
22 {'n',GSM_KEY_NAMES}, {'N',GSM_KEY_NAMES}, 22 {'n',GSM_KEY_NAMES}, {'N',GSM_KEY_NAMES},
23 {'p',GSM_KEY_POWER}, {'P',GSM_KEY_POWER}, 23 {'p',GSM_KEY_POWER}, {'P',GSM_KEY_POWER},
24 {'u',GSM_KEY_UP}, {'U',GSM_KEY_UP}, 24 {'u',GSM_KEY_UP}, {'U',GSM_KEY_UP},
25 {'d',GSM_KEY_DOWN}, {'D',GSM_KEY_DOWN}, 25 {'d',GSM_KEY_DOWN}, {'D',GSM_KEY_DOWN},
26 {'+',GSM_KEY_INCREASEVOLUME},{'-',GSM_KEY_DECREASEVOLUME}, 26 {'+',GSM_KEY_INCREASEVOLUME},{'-',GSM_KEY_DECREASEVOLUME},
27 {'1',GSM_KEY_1}, {'2',GSM_KEY_2},{'3',GSM_KEY_3}, 27 {'1',GSM_KEY_1}, {'2',GSM_KEY_2},{'3',GSM_KEY_3},
28 {'4',GSM_KEY_4}, {'5',GSM_KEY_5},{'6',GSM_KEY_6}, 28 {'4',GSM_KEY_4}, {'5',GSM_KEY_5},{'6',GSM_KEY_6},
29 {'7',GSM_KEY_7}, {'8',GSM_KEY_8},{'9',GSM_KEY_9}, 29 {'7',GSM_KEY_7}, {'8',GSM_KEY_8},{'9',GSM_KEY_9},
30 {'*',GSM_KEY_ASTERISK}, {'0',GSM_KEY_0},{'#',GSM_KEY_HASH}, 30 {'*',GSM_KEY_ASTERISK}, {'0',GSM_KEY_0},{'#',GSM_KEY_HASH},
31 {'g',GSM_KEY_GREEN}, {'G',GSM_KEY_GREEN}, 31 {'g',GSM_KEY_GREEN}, {'G',GSM_KEY_GREEN},
32 {'r',GSM_KEY_RED}, {'R',GSM_KEY_RED}, 32 {'r',GSM_KEY_RED}, {'R',GSM_KEY_RED},
33 {' ',0} 33 {' ',0}
34}; 34};
35 35
36GSM_Error MakeKeySequence(char *text, GSM_KeyCode *KeyCode, int *Length) 36GSM_Error MakeKeySequence(char *text, GSM_KeyCode *KeyCode, int *Length)
37{ 37{
38 int i,j; 38 int i,j;
39 unsigned char key; 39 unsigned char key;
40 40
41 for (i=0;i<(int)(strlen(text));i++) { 41 for (i=0;i<(int)(strlen(text));i++) {
42 key = text[i]; 42 key = text[i];
43 KeyCode[i] = GSM_KEY_NONE; 43 KeyCode[i] = GSM_KEY_NONE;
44 j = 0; 44 j = 0;
45 while (Keys[j].whatchar!=' ') { 45 while (Keys[j].whatchar!=' ') {
46 if (Keys[j].whatchar==key) { 46 if (Keys[j].whatchar==key) {
47 KeyCode[i]=Keys[j].whatcode; 47 KeyCode[i]=Keys[j].whatcode;
48 break; 48 break;
49 } 49 }
50 j++; 50 j++;
51 } 51 }
52 if (KeyCode[i] == GSM_KEY_NONE) { 52 if (KeyCode[i] == GSM_KEY_NONE) {
53 *Length = i; 53 *Length = i;
54 return ERR_NOTSUPPORTED; 54 return ERR_NOTSUPPORTED;
55 } 55 }
56 } 56 }
57 *Length = i; 57 *Length = i;
58 return ERR_NONE; 58 return ERR_NONE;
59} 59}
60 60
61GSM_Error GSM_ReadFile(char *FileName, GSM_File *File) 61GSM_Error GSM_ReadFile(char *FileName, GSM_File *File)
62{ 62{
63 int i = 1000; 63 int i = 1000;
64 FILE *file; 64 FILE *file;
65 struct statfileinfo; 65 struct statfileinfo;
66 66
67 if (FileName[0] == 0x00) return ERR_UNKNOWN; 67 if (FileName[0] == 0x00) return ERR_UNKNOWN;
68 file = fopen(FileName,"rb"); 68 file = fopen(FileName,"rb");
69 if (file == NULL) return ERR_CANTOPENFILE; 69 if (file == NULL) return ERR_CANTOPENFILE;
70 70
71 free(File->Buffer); 71 free(File->Buffer);
72 File->Buffer = NULL; 72 File->Buffer = NULL;
73 File->Used = 0; 73 File->Used = 0;
74 while (i == 1000) { 74 while (i == 1000) {
75 File->Buffer = realloc(File->Buffer,File->Used + 1000); 75 File->Buffer = realloc(File->Buffer,File->Used + 1000);
76 i = fread(File->Buffer+File->Used,1,1000,file); 76 i = fread(File->Buffer+File->Used,1,1000,file);
77 File->Used = File->Used + i; 77 File->Used = File->Used + i;
78 } 78 }
79 File->Buffer = realloc(File->Buffer,File->Used); 79 File->Buffer = realloc(File->Buffer,File->Used);
80 fclose(file); 80 fclose(file);
81 81
82 File->ModifiedEmpty = true; 82 File->ModifiedEmpty = true;
83 if (stat(FileName,&fileinfo) == 0) { 83 if (stat(FileName,&fileinfo) == 0) {
84 File->ModifiedEmpty = false; 84 File->ModifiedEmpty = false;
85 dbgprintf("File info read correctly\n"); 85 dbgprintf("File info read correctly\n");
86 //st_mtime is time of last modification of file 86 //st_mtime is time of last modification of file
87 Fill_GSM_DateTime(&File->Modified, fileinfo.st_mtime); 87 Fill_GSM_DateTime(&File->Modified, fileinfo.st_mtime);
88 File->Modified.Year = File->Modified.Year + 1900; 88 File->Modified.Year = File->Modified.Year + 1900;
89 dbgprintf("FileTime: %02i-%02i-%04i %02i:%02i:%02i\n", 89 dbgprintf("FileTime: %02i-%02i-%04i %02i:%02i:%02i\n",
90 File->Modified.Day,File->Modified.Month,File->Modified.Year, 90 File->Modified.Day,File->Modified.Month,File->Modified.Year,
91 File->Modified.Hour,File->Modified.Minute,File->Modified.Second); 91 File->Modified.Hour,File->Modified.Minute,File->Modified.Second);
92 } 92 }
93 93
94 return ERR_NONE; 94 return ERR_NONE;
95} 95}
96 96
97static void GSM_JADFindLine(GSM_File File, char *Name, char *Value) 97static void GSM_JADFindLine(GSM_File File, char *Name, char *Value)
98{ 98{
99 unsigned char Line[2000]; 99 unsigned char Line[2000];
100 int Pos = 0; 100 int Pos = 0;
101 101
102 Value[0] = 0; 102 Value[0] = 0;
103 103
104 while (1) { 104 while (1) {
105 MyGetLine(File.Buffer, &Pos, Line, File.Used); 105 MyGetLine(File.Buffer, &Pos, Line, File.Used);
106 if (strlen(Line) == 0) break; 106 if (strlen(Line) == 0) break;
107 if (!strncmp(Line,Name,strlen(Name))) { 107 if (!strncmp(Line,Name,strlen(Name))) {
108 Pos = strlen(Name); 108 Pos = strlen(Name);
109 while (Line[Pos] == 0x20) Pos++; 109 while (Line[Pos] == 0x20) Pos++;
110 strcpy(Value,Line+Pos); 110 strcpy(Value,Line+Pos);
111 return; 111 return;
112 } 112 }
113 } 113 }
114} 114}
115 115
116GSM_Error GSM_JADFindData(GSM_File File, char *Vendor, char *Name, char *JAR, char *Version, int *Size) 116GSM_Error GSM_JADFindData(GSM_File File, char *Vendor, char *Name, char *JAR, char *Version, int *Size)
117{ 117{
118 char Size2[200]; 118 char Size2[200];
119 119
120 GSM_JADFindLine(File, "MIDlet-Vendor:", Vendor); 120 GSM_JADFindLine(File, "MIDlet-Vendor:", Vendor);
121 if (Vendor[0] == 0x00) return ERR_FILENOTSUPPORTED; 121 if (Vendor[0] == 0x00) return ERR_FILENOTSUPPORTED;
122 dbgprintf("Vendor: \"%s\"\n",Vendor); 122 dbgprintf("Vendor: \"%s\"\n",Vendor);
123 123
124 GSM_JADFindLine(File, "MIDlet-Name:", Name); 124 GSM_JADFindLine(File, "MIDlet-Name:", Name);
125 if (Name[0] == 0x00) return ERR_FILENOTSUPPORTED; 125 if (Name[0] == 0x00) return ERR_FILENOTSUPPORTED;
126 dbgprintf("Name: \"%s\"\n",Name); 126 dbgprintf("Name: \"%s\"\n",Name);
127 127
128 GSM_JADFindLine(File, "MIDlet-Jar-URL:", JAR); 128 GSM_JADFindLine(File, "MIDlet-Jar-URL:", JAR);
129 if (JAR[0] == 0x00) return ERR_FILENOTSUPPORTED; 129 if (JAR[0] == 0x00) return ERR_FILENOTSUPPORTED;
130 dbgprintf("JAR file URL: \"%s\"\n",JAR); 130 dbgprintf("JAR file URL: \"%s\"\n",JAR);
131 131
132 GSM_JADFindLine(File, "MIDlet-Jar-Size:", Size2); 132 GSM_JADFindLine(File, "MIDlet-Jar-Size:", Size2);
133 *Size = -1; 133 *Size = -1;
134 if (Size2[0] == 0x00) return ERR_FILENOTSUPPORTED; 134 if (Size2[0] == 0x00) return ERR_FILENOTSUPPORTED;
135 dbgprintf("JAR size: \"%s\"\n",Size2); 135 dbgprintf("JAR size: \"%s\"\n",Size2);
136 (*Size) = atoi(Size2); 136 (*Size) = atoi(Size2);
137 137
138 GSM_JADFindLine(File, "MIDlet-Version:", Version); 138 GSM_JADFindLine(File, "MIDlet-Version:", Version);
139 dbgprintf("Version: \"%s\"\n",Version); 139 dbgprintf("Version: \"%s\"\n",Version);
140 140
141 return ERR_NONE; 141 return ERR_NONE;
142} 142}
143 143
144void GSM_IdentifyFileFormat(GSM_File *File) 144void GSM_IdentifyFileFormat(GSM_File *File)
145{ 145{
146 File->Type = GSM_File_Other; 146 File->Type = GSM_File_Other;
147 if (File->Used > 2) { 147 if (File->Used > 2) {
148 if (memcmp(File->Buffer, "BM",2)==0) { 148 if (memcmp(File->Buffer, "BM",2)==0) {
149 File->Type = GSM_File_Image_BMP; 149 File->Type = GSM_File_Image_BMP;
150 } else if (memcmp(File->Buffer, "GIF",3)==0) { 150 } else if (memcmp(File->Buffer, "GIF",3)==0) {
151 File->Type = GSM_File_Image_GIF; 151 File->Type = GSM_File_Image_GIF;
152 } else if (File->Buffer[0] == 0x00 && File->Buffer[1] == 0x00) { 152 } else if (File->Buffer[0] == 0x00 && File->Buffer[1] == 0x00) {
153 File->Type = GSM_File_Image_WBMP; 153 File->Type = GSM_File_Image_WBMP;
154 } else if (memcmp(File->Buffer+1, "PNG",3)==0) { 154 } else if (memcmp(File->Buffer+1, "PNG",3)==0) {
155 File->Type = GSM_File_Image_PNG; 155 File->Type = GSM_File_Image_PNG;
156 } else if (File->Buffer[0] == 0xFF && File->Buffer[1] == 0xD8) { 156 } else if (File->Buffer[0] == 0xFF && File->Buffer[1] == 0xD8) {
157 File->Type = GSM_File_Image_JPG; 157 File->Type = GSM_File_Image_JPG;
158 } else if (memcmp(File->Buffer, "MThd",4)==0) { 158 } else if (memcmp(File->Buffer, "MThd",4)==0) {
159 File->Type = GSM_File_Sound_MIDI; 159 File->Type = GSM_File_Sound_MIDI;
160 } else if (File->Buffer[0] == 0x00 && File->Buffer[1] == 0x02) { 160 } else if (File->Buffer[0] == 0x00 && File->Buffer[1] == 0x02) {
161 File->Type = GSM_File_Sound_NRT; 161 File->Type = GSM_File_Sound_NRT;
162 } 162 }
163 } 163 }
164} 164}
165 165
166void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start) 166void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start)
167{ 167{
168 if (Start != NULL) { 168 if (Start != NULL) {
169 *Length+=sprintf(Buffer+(*Length), "%s:",Start); 169 *Length+=sprintf(Buffer+(*Length), "%s:",Start);
170 } 170 }
171 *Length+=sprintf(Buffer+(*Length), "%04d%02d%02dT%02d%02d%02d%c%c", 171 *Length+=sprintf(Buffer+(*Length), "%04d%02d%02dT%02d%02d%02d%c%c",
172 Date->Year, Date->Month, Date->Day, 172 Date->Year, Date->Month, Date->Day,
173 Date->Hour, Date->Minute, Date->Second,13,10); 173 Date->Hour, Date->Minute, Date->Second,13,10);
174} 174}
175 175
176void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt) 176void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt)
177{ 177{
178 char year[5]="", month[3]="", day[3]="", hour[3]="", minute[3]="", second[3]=""; 178 char year[5]="", month[3]="", day[3]="", hour[3]="", minute[3]="", second[3]="";
179 179
180 memset(dt,0,sizeof(dt)); 180 memset(dt,0,sizeof(dt));
181 181
182 strncpy(year, Buffer, 4); 182 strncpy(year, Buffer, 4);
183 strncpy(month, Buffer+4, 2); 183 strncpy(month, Buffer+4, 2);
184 strncpy(day, Buffer+6, 2); 184 strncpy(day, Buffer+6, 2);
185 strncpy(hour, Buffer+9,2); 185 strncpy(hour, Buffer+9,2);
186 strncpy(minute, Buffer+11,2); 186 strncpy(minute, Buffer+11,2);
187 strncpy(second, Buffer+13,2); 187 strncpy(second, Buffer+13,2);
188 188
189 /* FIXME: Should check ranges... */ 189 /* FIXME: Should check ranges... */
190 dt->Year= atoi(year); 190 dt->Year= atoi(year);
191 dt->Month= atoi(month); 191 dt->Month= atoi(month);
192 dt->Day = atoi(day); 192 dt->Day = atoi(day);
193 dt->Hour= atoi(hour); 193 dt->Hour= atoi(hour);
194 dt->Minute= atoi(minute); 194 dt->Minute= atoi(minute);
195 dt->Second= atoi(second); 195 dt->Second= atoi(second);
196 /* FIXME */ 196 /* FIXME */
197 dt->Timezone= 0; 197 dt->Timezone= 0;
198} 198}
199 199
200void SaveVCALText(char *Buffer, int *Length, char *Text, char *Start) 200void SaveVCALText(char *Buffer, int *Length, char *Text, char *Start)
201{ 201{
202 char buffer[1000]; 202 char buffer[1000];
203 203
204 if (UnicodeLength(Text) != 0) { 204 if (UnicodeLength(Text) != 0) {
205 EncodeUTF8(buffer,Text); 205 EncodeUTF8(buffer,Text);
206 if (UnicodeLength(Text)==strlen(buffer)) { 206 if (UnicodeLength(Text)==strlen(buffer)) {
207 *Length+=sprintf(Buffer+(*Length), "%s:%s%c%c",Start,DecodeUnicodeString(Text),13,10); 207 *Length+=sprintf(Buffer+(*Length), "%s:%s%c%c",Start,DecodeUnicodeString(Text),13,10);
208 } else { 208 } else {
209 *Length+=sprintf(Buffer+(*Length), "%s:%s%c%c",Start,buffer,13,10); 209 *Length+=sprintf(Buffer+(*Length), "%s:%s%c%c",Start,buffer,13,10);
210 } 210 }
211 } 211 }
212} 212}
213 213
214bool ReadVCALText(char *Buffer, char *Start, char *Value) 214bool ReadVCALText(char *Buffer, char *Start, char *Value)
215{ 215{
216 unsigned char buff[200]; 216 unsigned char buff[200];
217 217
218 Value[0] = 0x00; 218 Value[0] = 0x00;
219 Value[1] = 0x00; 219 Value[1] = 0x00;
220 220
221 strcpy(buff,Start); 221 strcpy(buff,Start);
222 strcat(buff,":"); 222 strcat(buff,":");
223 if (!strncmp(Buffer,buff,strlen(buff))) { 223 if (!strncmp(Buffer,buff,strlen(buff))) {
224 EncodeUnicode(Value,Buffer+strlen(Start)+1,strlen(Buffer)-(strlen(Start)+1)); 224
225 // LR original :EncodeUnicode(Value,Buffer+strlen(Start)+1,strlen(Buffer)-(strlen(Start)+1));
226 // LR we have utf8 as default
227 DecodeUTF8(Value,Buffer+strlen(Start)+1,strlen(Buffer)-(strlen(Start)+1));
225 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 228 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
226 return true; 229 return true;
227 } 230 }
228 /* SE T68i */ 231 /* SE T68i */
229 strcpy(buff,Start); 232 strcpy(buff,Start);
230 strcat(buff,";ENCODING=QUOTED-PRINTABLE:"); 233 strcat(buff,";ENCODING=QUOTED-PRINTABLE:");
231 if (!strncmp(Buffer,buff,strlen(buff))) { 234 if (!strncmp(Buffer,buff,strlen(buff))) {
232 DecodeUTF8QuotedPrintable(Value,Buffer+strlen(Start)+27,strlen(Buffer)-(strlen(Start)+27)); 235 DecodeUTF8QuotedPrintable(Value,Buffer+strlen(Start)+27,strlen(Buffer)-(strlen(Start)+27));
233 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 236 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
234 return true; 237 return true;
235 } 238 }
236 strcpy(buff,Start); 239 strcpy(buff,Start);
237 strcat(buff,";CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:"); 240 strcat(buff,";CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:");
238 if (!strncmp(Buffer,buff,strlen(buff))) { 241 if (!strncmp(Buffer,buff,strlen(buff))) {
239 DecodeUTF8QuotedPrintable(Value,Buffer+strlen(Start)+41,strlen(Buffer)-(strlen(Start)+41)); 242 DecodeUTF8QuotedPrintable(Value,Buffer+strlen(Start)+41,strlen(Buffer)-(strlen(Start)+41));
240 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 243 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
241 return true; 244 return true;
242 } 245 }
243 strcpy(buff,Start); 246 strcpy(buff,Start);
244 strcat(buff,";CHARSET=UTF-8:"); 247 strcat(buff,";CHARSET=UTF-8:");
245 if (!strncmp(Buffer,buff,strlen(buff))) { 248 if (!strncmp(Buffer,buff,strlen(buff))) {
246 DecodeUTF8(Value,Buffer+strlen(Start)+15,strlen(Buffer)-(strlen(Start)+15)); 249 DecodeUTF8(Value,Buffer+strlen(Start)+15,strlen(Buffer)-(strlen(Start)+15));
247 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 250 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
248 return true; 251 return true;
249 } 252 }
250 strcpy(buff,Start); 253 strcpy(buff,Start);
251 strcat(buff,";CHARSET=UTF-7:"); 254 strcat(buff,";CHARSET=UTF-7:");
252 if (!strncmp(Buffer,buff,strlen(buff))) { 255 if (!strncmp(Buffer,buff,strlen(buff))) {
253 DecodeUTF7(Value,Buffer+strlen(Start)+15,strlen(Buffer)-(strlen(Start)+15)); 256 DecodeUTF7(Value,Buffer+strlen(Start)+15,strlen(Buffer)-(strlen(Start)+15));
254 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 257 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
255 return true; 258 return true;
256 } 259 }
257 return false; 260 return false;
258} 261}
259 262
260/* How should editor hadle tabs in this file? Add editor commands here. 263/* How should editor hadle tabs in this file? Add editor commands here.
261 * vim: noexpandtab sw=8 ts=8 sts=8: 264 * vim: noexpandtab sw=8 ts=8 sts=8:
262 */ 265 */
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index c584c35..3641c0c 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -224,545 +224,546 @@ bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
224 224
225AddressBook::AddressBook() 225AddressBook::AddressBook()
226{ 226{
227 init(0, "contact"); 227 init(0, "contact");
228} 228}
229 229
230AddressBook::AddressBook( const QString &config ) 230AddressBook::AddressBook( const QString &config )
231{ 231{
232 init(config, "contact"); 232 init(config, "contact");
233} 233}
234 234
235AddressBook::AddressBook( const QString &config, const QString &family ) 235AddressBook::AddressBook( const QString &config, const QString &family )
236{ 236{
237 init(config, family); 237 init(config, family);
238 238
239} 239}
240 240
241// the default family is "contact" 241// the default family is "contact"
242void AddressBook::init(const QString &config, const QString &family ) 242void AddressBook::init(const QString &config, const QString &family )
243{ 243{
244 blockLSEchange = false; 244 blockLSEchange = false;
245 d = new AddressBookData; 245 d = new AddressBookData;
246 QString fami = family; 246 QString fami = family;
247 if (config != 0) { 247 if (config != 0) {
248 if ( family == "syncContact" ) { 248 if ( family == "syncContact" ) {
249 qDebug("creating sync config "); 249 qDebug("creating sync config ");
250 fami = "contact"; 250 fami = "contact";
251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 251 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
252 con->setGroup( "General" ); 252 con->setGroup( "General" );
253 con->writeEntry( "ResourceKeys", QString("sync") ); 253 con->writeEntry( "ResourceKeys", QString("sync") );
254 con->writeEntry( "Standard", QString("sync") ); 254 con->writeEntry( "Standard", QString("sync") );
255 con->setGroup( "Resource_sync" ); 255 con->setGroup( "Resource_sync" );
256 con->writeEntry( "FileName", config ); 256 con->writeEntry( "FileName", config );
257 con->writeEntry( "FileFormat", QString("vcard") ); 257 con->writeEntry( "FileFormat", QString("vcard") );
258 con->writeEntry( "ResourceIdentifier", QString("sync") ); 258 con->writeEntry( "ResourceIdentifier", QString("sync") );
259 con->writeEntry( "ResourceName", QString("sync_res") ); 259 con->writeEntry( "ResourceName", QString("sync_res") );
260 if ( config.right(4) == ".xml" ) 260 if ( config.right(4) == ".xml" )
261 con->writeEntry( "ResourceType", QString("qtopia") ); 261 con->writeEntry( "ResourceType", QString("qtopia") );
262 else if ( config == "sharp" ) { 262 else if ( config == "sharp" ) {
263 con->writeEntry( "ResourceType", QString("sharp") ); 263 con->writeEntry( "ResourceType", QString("sharp") );
264 } else { 264 } else {
265 con->writeEntry( "ResourceType", QString("file") ); 265 con->writeEntry( "ResourceType", QString("file") );
266 } 266 }
267 //con->sync(); 267 //con->sync();
268 d->mConfig = con; 268 d->mConfig = con;
269 } 269 }
270 else 270 else
271 d->mConfig = new KConfig( locateLocal("config", config) ); 271 d->mConfig = new KConfig( locateLocal("config", config) );
272// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 272// qDebug("AddressBook::init 1 config=%s",config.latin1() );
273 } 273 }
274 else { 274 else {
275 d->mConfig = 0; 275 d->mConfig = 0;
276// qDebug("AddressBook::init 1 config=0"); 276// qDebug("AddressBook::init 1 config=0");
277 } 277 }
278 278
279//US d->mErrorHandler = 0; 279//US d->mErrorHandler = 0;
280 d->mManager = new KRES::Manager<Resource>( fami ); 280 d->mManager = new KRES::Manager<Resource>( fami );
281 d->mManager->readConfig( d->mConfig ); 281 d->mManager->readConfig( d->mConfig );
282 if ( family == "syncContact" ) { 282 if ( family == "syncContact" ) {
283 KRES::Manager<Resource> *manager = d->mManager; 283 KRES::Manager<Resource> *manager = d->mManager;
284 KRES::Manager<Resource>::ActiveIterator it; 284 KRES::Manager<Resource>::ActiveIterator it;
285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 285 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
286 (*it)->setAddressBook( this ); 286 (*it)->setAddressBook( this );
287 if ( !(*it)->open() ) 287 if ( !(*it)->open() )
288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 288 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
289 } 289 }
290 Resource *res = standardResource(); 290 Resource *res = standardResource();
291 if ( !res ) { 291 if ( !res ) {
292 qDebug("ERROR: no standard resource"); 292 qDebug("ERROR: no standard resource");
293 res = manager->createResource( "file" ); 293 res = manager->createResource( "file" );
294 if ( res ) 294 if ( res )
295 { 295 {
296 addResource( res ); 296 addResource( res );
297 } 297 }
298 else 298 else
299 qDebug(" No resource available!!!"); 299 qDebug(" No resource available!!!");
300 } 300 }
301 setStandardResource( res ); 301 setStandardResource( res );
302 manager->writeConfig(); 302 manager->writeConfig();
303 } 303 }
304 addCustomField( i18n( "Department" ), KABC::Field::Organization, 304 addCustomField( i18n( "Department" ), KABC::Field::Organization,
305 "X-Department", "KADDRESSBOOK" ); 305 "X-Department", "KADDRESSBOOK" );
306 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 306 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
307 "X-Profession", "KADDRESSBOOK" ); 307 "X-Profession", "KADDRESSBOOK" );
308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
309 "X-AssistantsName", "KADDRESSBOOK" ); 309 "X-AssistantsName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 310 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
311 "X-ManagersName", "KADDRESSBOOK" ); 311 "X-ManagersName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 312 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
313 "X-SpousesName", "KADDRESSBOOK" ); 313 "X-SpousesName", "KADDRESSBOOK" );
314 addCustomField( i18n( "Office" ), KABC::Field::Personal, 314 addCustomField( i18n( "Office" ), KABC::Field::Personal,
315 "X-Office", "KADDRESSBOOK" ); 315 "X-Office", "KADDRESSBOOK" );
316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 316 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
317 "X-IMAddress", "KADDRESSBOOK" ); 317 "X-IMAddress", "KADDRESSBOOK" );
318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 318 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
319 "X-Anniversary", "KADDRESSBOOK" ); 319 "X-Anniversary", "KADDRESSBOOK" );
320 320
321 //US added this field to become compatible with Opie/qtopia addressbook 321 //US added this field to become compatible with Opie/qtopia addressbook
322 // values can be "female" or "male" or "". An empty field represents undefined. 322 // values can be "female" or "male" or "". An empty field represents undefined.
323 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 323 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
324 "X-Gender", "KADDRESSBOOK" ); 324 "X-Gender", "KADDRESSBOOK" );
325 addCustomField( i18n( "Children" ), KABC::Field::Personal, 325 addCustomField( i18n( "Children" ), KABC::Field::Personal,
326 "X-Children", "KADDRESSBOOK" ); 326 "X-Children", "KADDRESSBOOK" );
327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 327 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
328 "X-FreeBusyUrl", "KADDRESSBOOK" ); 328 "X-FreeBusyUrl", "KADDRESSBOOK" );
329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 329 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
330 "X-ExternalID", "KADDRESSBOOK" ); 330 "X-ExternalID", "KADDRESSBOOK" );
331} 331}
332 332
333AddressBook::~AddressBook() 333AddressBook::~AddressBook()
334{ 334{
335 delete d->mConfig; d->mConfig = 0; 335 delete d->mConfig; d->mConfig = 0;
336 delete d->mManager; d->mManager = 0; 336 delete d->mManager; d->mManager = 0;
337//US delete d->mErrorHandler; d->mErrorHandler = 0; 337//US delete d->mErrorHandler; d->mErrorHandler = 0;
338 delete d; d = 0; 338 delete d; d = 0;
339} 339}
340 340
341bool AddressBook::load() 341bool AddressBook::load()
342{ 342{
343 343
344 clear(); 344 clear();
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } else { 351 } else {
352 qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) ); 352 qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) );
353 } 353 }
354 // mark all addressees as unchanged 354 // mark all addressees as unchanged
355 Addressee::List::Iterator addrIt; 355 Addressee::List::Iterator addrIt;
356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
357 (*addrIt).setChanged( false ); 357 (*addrIt).setChanged( false );
358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
359 if ( !id.isEmpty() ) { 359 if ( !id.isEmpty() ) {
360 //qDebug("setId aa %s ", id.latin1()); 360 //qDebug("setId aa %s ", id.latin1());
361 (*addrIt).setIDStr(id ); 361 (*addrIt).setIDStr(id );
362 } 362 }
363 } 363 }
364 blockLSEchange = true; 364 blockLSEchange = true;
365 return ok; 365 return ok;
366} 366}
367 367
368bool AddressBook::save( Ticket *ticket ) 368bool AddressBook::save( Ticket *ticket )
369{ 369{
370 kdDebug(5700) << "AddressBook::save()"<< endl; 370 kdDebug(5700) << "AddressBook::save()"<< endl;
371 371
372 if ( ticket->resource() ) { 372 if ( ticket->resource() ) {
373 deleteRemovedAddressees(); 373 deleteRemovedAddressees();
374 return ticket->resource()->save( ticket ); 374 return ticket->resource()->save( ticket );
375 } 375 }
376 376
377 return false; 377 return false;
378} 378}
379// exports all Addressees, which are syncable 379// exports all Addressees, which are syncable
380void AddressBook::export2File( QString fileName ) 380void AddressBook::export2File( QString fileName )
381{ 381{
382 382
383 QFile outFile( fileName ); 383 QFile outFile( fileName );
384 if ( !outFile.open( IO_WriteOnly ) ) { 384 if ( !outFile.open( IO_WriteOnly ) ) {
385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
386 KMessageBox::error( 0, text.arg( fileName ) ); 386 KMessageBox::error( 0, text.arg( fileName ) );
387 return ; 387 return ;
388 } 388 }
389 QTextStream t( &outFile ); 389 QTextStream t( &outFile );
390 t.setEncoding( QTextStream::UnicodeUTF8 ); 390 t.setEncoding( QTextStream::UnicodeUTF8 );
391 Iterator it; 391 Iterator it;
392 KABC::VCardConverter::Version version; 392 KABC::VCardConverter::Version version;
393 version = KABC::VCardConverter::v3_0; 393 version = KABC::VCardConverter::v3_0;
394 for ( it = begin(); it != end(); ++it ) { 394 for ( it = begin(); it != end(); ++it ) {
395 if ( (*it).resource() && (*it).resource()->includeInSync() ) { 395 if ( (*it).resource() && (*it).resource()->includeInSync() ) {
396 if ( !(*it).IDStr().isEmpty() ) { 396 if ( !(*it).IDStr().isEmpty() ) {
397 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 397 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
398 } 398 }
399 KABC::VCardConverter converter; 399 KABC::VCardConverter converter;
400 QString vcard; 400 QString vcard;
401 //Resource *resource() const; 401 //Resource *resource() const;
402 converter.addresseeToVCard( *it, vcard, version ); 402 converter.addresseeToVCard( *it, vcard, version );
403 t << vcard << "\r\n"; 403 t << vcard << "\r\n";
404 } 404 }
405 } 405 }
406 t << "\r\n\r\n"; 406 t << "\r\n\r\n";
407 outFile.close(); 407 outFile.close();
408} 408}
409// if QStringList uids is empty, all are exported 409// if QStringList uids is empty, all are exported
410bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName ) 410bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
411{ 411{
412 KABC::VCardConverter converter; 412 KABC::VCardConverter converter;
413 QString datastream; 413 QString datastream;
414 Iterator it; 414 Iterator it;
415 bool all = uids.isEmpty(); 415 bool all = uids.isEmpty();
416 for ( it = begin(); it != end(); ++it ) { 416 for ( it = begin(); it != end(); ++it ) {
417 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 417 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
418 if ( ! all ) { 418 if ( ! all ) {
419 if ( ! ( uids.contains((*it).uid() ) )) 419 if ( ! ( uids.contains((*it).uid() ) ))
420 continue; 420 continue;
421 } 421 }
422 KABC::Addressee a = ( *it ); 422 KABC::Addressee a = ( *it );
423 if ( a.isEmpty() ) 423 if ( a.isEmpty() )
424 continue; 424 continue;
425 if ( all && a.resource() && !a.resource()->includeInSync() ) 425 if ( all && a.resource() && !a.resource()->includeInSync() )
426 continue; 426 continue;
427 a.simplifyEmails(); 427 a.simplifyEmails();
428 a.simplifyPhoneNumbers(); 428 a.simplifyPhoneNumbers();
429 a.simplifyPhoneNumberTypes(); 429 a.simplifyPhoneNumberTypes();
430 a.simplifyAddresses(); 430 a.simplifyAddresses();
431 431
432 QString vcard; 432 QString vcard;
433 QString vcardnew; 433 QString vcardnew;
434 converter.addresseeToVCard( a, vcard ); 434 converter.addresseeToVCard( a, vcard );
435 int start = 0; 435 int start = 0;
436 int next; 436 int next;
437 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 437 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
438 int semi = vcard.find(";", next); 438 int semi = vcard.find(";", next);
439 int dopp = vcard.find(":", next); 439 int dopp = vcard.find(":", next);
440 int sep; 440 int sep;
441 if ( semi < dopp && semi >= 0 ) 441 if ( semi < dopp && semi >= 0 )
442 sep = semi ; 442 sep = semi ;
443 else 443 else
444 sep = dopp; 444 sep = dopp;
445 vcardnew +=vcard.mid( start, next - start); 445 vcardnew +=vcard.mid( start, next - start);
446 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 446 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
447 start = sep; 447 start = sep;
448 } 448 }
449 vcardnew += vcard.mid( start,vcard.length() ); 449 vcardnew += vcard.mid( start,vcard.length() );
450 vcard = ""; 450 vcard = "";
451 start = 0; 451 start = 0;
452 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 452 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
453 int sep = vcardnew.find(":", next); 453 int sep = vcardnew.find(":", next);
454 vcard +=vcardnew.mid( start, next - start+3); 454 vcard +=vcardnew.mid( start, next - start+3);
455 start = sep; 455 start = sep;
456 } 456 }
457 vcard += vcardnew.mid( start,vcardnew.length() ); 457 vcard += vcardnew.mid( start,vcardnew.length() );
458 vcard.replace ( QRegExp(";;;") , "" ); 458 vcard.replace ( QRegExp(";;;") , "" );
459 vcard.replace ( QRegExp(";;") , "" ); 459 vcard.replace ( QRegExp(";;") , "" );
460 datastream += vcard; 460 datastream += vcard;
461 461
462 } 462 }
463 463
464 QFile outFile(fileName); 464 QFile outFile(fileName);
465 if ( outFile.open(IO_WriteOnly) ) { 465 if ( outFile.open(IO_WriteOnly) ) {
466 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 466 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
467 QTextStream t( &outFile ); // use a text stream 467 QTextStream t( &outFile ); // use a text stream
468 t.setEncoding( QTextStream::UnicodeUTF8 ); 468 t.setEncoding( QTextStream::UnicodeUTF8 );
469 t <<datastream; 469 t <<datastream;
470 t << "\r\n\r\n"; 470 t << "\r\n\r\n";
471 outFile.close(); 471 outFile.close();
472 472
473 } else { 473 } else {
474 qDebug("Error open temp file "); 474 qDebug("Error open temp file ");
475 return false; 475 return false;
476 } 476 }
477 return true; 477 return true;
478 478
479} 479}
480void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 480int AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
481{ 481{
482 482
483 if ( removeOld ) 483 if ( removeOld )
484 setUntagged( true ); 484 setUntagged( true );
485 KABC::Addressee::List list; 485 KABC::Addressee::List list;
486 QFile file( fileName ); 486 QFile file( fileName );
487 file.open( IO_ReadOnly ); 487 file.open( IO_ReadOnly );
488 QByteArray rawData = file.readAll(); 488 QByteArray rawData = file.readAll();
489 file.close(); 489 file.close();
490 QString data; 490 QString data;
491 if ( replaceLabel ) { 491 if ( replaceLabel ) {
492 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 492 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
493 data.replace ( QRegExp("LABEL") , "ADR" ); 493 data.replace ( QRegExp("LABEL") , "ADR" );
494 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 494 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
495 } else 495 } else
496 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 496 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
497 KABC::VCardTool tool; 497 KABC::VCardTool tool;
498 list = tool.parseVCards( data ); 498 list = tool.parseVCards( data );
499 KABC::Addressee::List::Iterator it; 499 KABC::Addressee::List::Iterator it;
500 for ( it = list.begin(); it != list.end(); ++it ) { 500 for ( it = list.begin(); it != list.end(); ++it ) {
501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 501 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
502 if ( !id.isEmpty() ) 502 if ( !id.isEmpty() )
503 (*it).setIDStr(id ); 503 (*it).setIDStr(id );
504 (*it).setResource( 0 ); 504 (*it).setResource( 0 );
505 if ( replaceLabel ) 505 if ( replaceLabel )
506 (*it).removeVoice(); 506 (*it).removeVoice();
507 if ( removeOld ) 507 if ( removeOld )
508 (*it).setTagged( true ); 508 (*it).setTagged( true );
509 insertAddressee( (*it), false, true ); 509 insertAddressee( (*it), false, true );
510 } 510 }
511 if ( removeOld ) 511 if ( removeOld )
512 removeUntagged(); 512 removeUntagged();
513 return list.count();
513} 514}
514void AddressBook::setUntagged(bool setNonSyncTagged) // = false) 515void AddressBook::setUntagged(bool setNonSyncTagged) // = false)
515{ 516{
516 Iterator ait; 517 Iterator ait;
517 for ( ait = begin(); ait != end(); ++ait ) { 518 for ( ait = begin(); ait != end(); ++ait ) {
518 if ( setNonSyncTagged ) { 519 if ( setNonSyncTagged ) {
519 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) { 520 if ( (*ait).resource() && ! (*ait).resource()->includeInSync() ) {
520 (*ait).setTagged( true ); 521 (*ait).setTagged( true );
521 } else 522 } else
522 (*ait).setTagged( false ); 523 (*ait).setTagged( false );
523 } else 524 } else
524 (*ait).setTagged( false ); 525 (*ait).setTagged( false );
525 } 526 }
526} 527}
527void AddressBook::removeUntagged() 528void AddressBook::removeUntagged()
528{ 529{
529 Iterator ait; 530 Iterator ait;
530 bool todelete = false; 531 bool todelete = false;
531 Iterator todel; 532 Iterator todel;
532 for ( ait = begin(); ait != end(); ++ait ) { 533 for ( ait = begin(); ait != end(); ++ait ) {
533 if ( todelete ) 534 if ( todelete )
534 removeAddressee( todel ); 535 removeAddressee( todel );
535 if (!(*ait).tagged()) { 536 if (!(*ait).tagged()) {
536 todelete = true; 537 todelete = true;
537 todel = ait; 538 todel = ait;
538 } else 539 } else
539 todelete = false; 540 todelete = false;
540 } 541 }
541 if ( todelete ) 542 if ( todelete )
542 removeAddressee( todel ); 543 removeAddressee( todel );
543 deleteRemovedAddressees(); 544 deleteRemovedAddressees();
544} 545}
545void AddressBook::smplifyAddressees() 546void AddressBook::smplifyAddressees()
546{ 547{
547 Iterator ait; 548 Iterator ait;
548 for ( ait = begin(); ait != end(); ++ait ) { 549 for ( ait = begin(); ait != end(); ++ait ) {
549 (*ait).simplifyEmails(); 550 (*ait).simplifyEmails();
550 (*ait).simplifyPhoneNumbers(); 551 (*ait).simplifyPhoneNumbers();
551 (*ait).simplifyPhoneNumberTypes(); 552 (*ait).simplifyPhoneNumberTypes();
552 (*ait).simplifyAddresses(); 553 (*ait).simplifyAddresses();
553 } 554 }
554} 555}
555void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 556void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
556{ 557{
557 Iterator ait; 558 Iterator ait;
558 for ( ait = begin(); ait != end(); ++ait ) { 559 for ( ait = begin(); ait != end(); ++ait ) {
559 QString id = (*ait).IDStr(); 560 QString id = (*ait).IDStr();
560 (*ait).setIDStr( ":"); 561 (*ait).setIDStr( ":");
561 (*ait).setExternalUID( id ); 562 (*ait).setExternalUID( id );
562 (*ait).setOriginalExternalUID( id ); 563 (*ait).setOriginalExternalUID( id );
563 if ( isPreSync ) 564 if ( isPreSync )
564 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 565 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
565 else { 566 else {
566 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 567 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
567 (*ait).setID( currentSyncDevice,id ); 568 (*ait).setID( currentSyncDevice,id );
568 569
569 } 570 }
570 } 571 }
571} 572}
572void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice ) 573void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
573{ 574{
574 575
575 setUntagged(); 576 setUntagged();
576 KABC::Addressee::List list; 577 KABC::Addressee::List list;
577 QFile file( fileName ); 578 QFile file( fileName );
578 file.open( IO_ReadOnly ); 579 file.open( IO_ReadOnly );
579 QByteArray rawData = file.readAll(); 580 QByteArray rawData = file.readAll();
580 file.close(); 581 file.close();
581 QString data; 582 QString data;
582 583
583 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 584 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
584 KABC::VCardTool tool; 585 KABC::VCardTool tool;
585 list = tool.parseVCards( data ); 586 list = tool.parseVCards( data );
586 KABC::Addressee::List::Iterator it; 587 KABC::Addressee::List::Iterator it;
587 for ( it = list.begin(); it != list.end(); ++it ) { 588 for ( it = list.begin(); it != list.end(); ++it ) {
588 Iterator ait; 589 Iterator ait;
589 for ( ait = begin(); ait != end(); ++ait ) { 590 for ( ait = begin(); ait != end(); ++ait ) {
590 if ( !(*ait).tagged() ) { 591 if ( !(*ait).tagged() ) {
591 if ( (*ait).containsAdr(*it)) { 592 if ( (*ait).containsAdr(*it)) {
592 (*ait).setTagged(true); 593 (*ait).setTagged(true);
593 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" ); 594 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
594 (*it).setIDStr( ":"); 595 (*it).setIDStr( ":");
595 (*it).setID( currentSyncDevice,id ); 596 (*it).setID( currentSyncDevice,id );
596 (*it).setExternalUID( id ); 597 (*it).setExternalUID( id );
597 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 598 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
598 (*it).setUid( ( (*ait).uid() )); 599 (*it).setUid( ( (*ait).uid() ));
599 break; 600 break;
600 } 601 }
601 } 602 }
602 603
603 } 604 }
604 if ( ait == end() ) 605 if ( ait == end() )
605 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1()); 606 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1());
606 } 607 }
607 clear(); 608 clear();
608 for ( it = list.begin(); it != list.end(); ++it ) { 609 for ( it = list.begin(); it != list.end(); ++it ) {
609 insertAddressee( (*it) ); 610 insertAddressee( (*it) );
610 } 611 }
611} 612}
612 613
613bool AddressBook::saveABphone( QString fileName ) 614bool AddressBook::saveABphone( QString fileName )
614{ 615{
615 //smplifyAddressees(); 616 //smplifyAddressees();
616 qDebug("saveABphone:: saving AB... "); 617 qDebug("saveABphone:: saving AB... ");
617 if ( ! export2PhoneFormat( QStringList() ,fileName ) ) 618 if ( ! export2PhoneFormat( QStringList() ,fileName ) )
618 return false; 619 return false;
619 qDebug("saveABphone:: writing to phone... "); 620 qDebug("saveABphone:: writing to phone... ");
620 if ( !PhoneAccess::writeToPhone( fileName) ) { 621 if ( !PhoneAccess::writeToPhone( fileName) ) {
621 return false; 622 return false;
622 } 623 }
623 qDebug("saveABphone:: re-reading from phone... "); 624 qDebug("saveABphone:: re-reading from phone... ");
624 if ( !PhoneAccess::readFromPhone( fileName) ) { 625 if ( !PhoneAccess::readFromPhone( fileName) ) {
625 return false; 626 return false;
626 } 627 }
627 return true; 628 return true;
628} 629}
629bool AddressBook::saveAB() 630bool AddressBook::saveAB()
630{ 631{
631 bool ok = true; 632 bool ok = true;
632 633
633 deleteRemovedAddressees(); 634 deleteRemovedAddressees();
634 Iterator ait; 635 Iterator ait;
635 for ( ait = begin(); ait != end(); ++ait ) { 636 for ( ait = begin(); ait != end(); ++ait ) {
636 if ( !(*ait).IDStr().isEmpty() ) { 637 if ( !(*ait).IDStr().isEmpty() ) {
637 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 638 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
638 } 639 }
639 } 640 }
640 KRES::Manager<Resource>::ActiveIterator it; 641 KRES::Manager<Resource>::ActiveIterator it;
641 KRES::Manager<Resource> *manager = d->mManager; 642 KRES::Manager<Resource> *manager = d->mManager;
642 qDebug("SaveAB::saving..." ); 643 qDebug("SaveAB::saving..." );
643 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 644 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
644 qDebug("SaveAB::checking resource..." ); 645 qDebug("SaveAB::checking resource..." );
645 if ( (*it)->readOnly() ) 646 if ( (*it)->readOnly() )
646 qDebug("resource is readonly." ); 647 qDebug("resource is readonly." );
647 if ( (*it)->isOpen() ) 648 if ( (*it)->isOpen() )
648 qDebug("resource is open" ); 649 qDebug("resource is open" );
649 650
650 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 651 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
651 Ticket *ticket = requestSaveTicket( *it ); 652 Ticket *ticket = requestSaveTicket( *it );
652 qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 653 qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
653 if ( !ticket ) { 654 if ( !ticket ) {
654 qDebug( i18n( "Unable to save to resource '%1'. It is locked." ) 655 qDebug( i18n( "Unable to save to resource '%1'. It is locked." )
655 .arg( (*it)->resourceName() ) ); 656 .arg( (*it)->resourceName() ) );
656 return false; 657 return false;
657 } 658 }
658 659
659 //if ( !save( ticket ) ) 660 //if ( !save( ticket ) )
660 if ( ticket->resource() ) { 661 if ( ticket->resource() ) {
661 QString name = ticket->resource()->resourceName(); 662 QString name = ticket->resource()->resourceName();
662 if ( ! ticket->resource()->save( ticket ) ) 663 if ( ! ticket->resource()->save( ticket ) )
663 ok = false; 664 ok = false;
664 else 665 else
665 qDebug("StdAddressBook::resource saved '%s'", name.latin1() ); 666 qDebug("StdAddressBook::resource saved '%s'", name.latin1() );
666 667
667 } else 668 } else
668 ok = false; 669 ok = false;
669 670
670 } 671 }
671 } 672 }
672 return ok; 673 return ok;
673} 674}
674 675
675AddressBook::Iterator AddressBook::begin() 676AddressBook::Iterator AddressBook::begin()
676{ 677{
677 Iterator it = Iterator(); 678 Iterator it = Iterator();
678 it.d->mIt = d->mAddressees.begin(); 679 it.d->mIt = d->mAddressees.begin();
679 return it; 680 return it;
680} 681}
681 682
682AddressBook::ConstIterator AddressBook::begin() const 683AddressBook::ConstIterator AddressBook::begin() const
683{ 684{
684 ConstIterator it = ConstIterator(); 685 ConstIterator it = ConstIterator();
685 it.d->mIt = d->mAddressees.begin(); 686 it.d->mIt = d->mAddressees.begin();
686 return it; 687 return it;
687} 688}
688 689
689AddressBook::Iterator AddressBook::end() 690AddressBook::Iterator AddressBook::end()
690{ 691{
691 Iterator it = Iterator(); 692 Iterator it = Iterator();
692 it.d->mIt = d->mAddressees.end(); 693 it.d->mIt = d->mAddressees.end();
693 return it; 694 return it;
694} 695}
695 696
696AddressBook::ConstIterator AddressBook::end() const 697AddressBook::ConstIterator AddressBook::end() const
697{ 698{
698 ConstIterator it = ConstIterator(); 699 ConstIterator it = ConstIterator();
699 it.d->mIt = d->mAddressees.end(); 700 it.d->mIt = d->mAddressees.end();
700 return it; 701 return it;
701} 702}
702 703
703void AddressBook::clear() 704void AddressBook::clear()
704{ 705{
705 d->mAddressees.clear(); 706 d->mAddressees.clear();
706} 707}
707 708
708Ticket *AddressBook::requestSaveTicket( Resource *resource ) 709Ticket *AddressBook::requestSaveTicket( Resource *resource )
709{ 710{
710 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 711 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
711 712
712 if ( !resource ) 713 if ( !resource )
713 { 714 {
714 qDebug("AddressBook::requestSaveTicket no resource" ); 715 qDebug("AddressBook::requestSaveTicket no resource" );
715 resource = standardResource(); 716 resource = standardResource();
716 } 717 }
717 718
718 KRES::Manager<Resource>::ActiveIterator it; 719 KRES::Manager<Resource>::ActiveIterator it;
719 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 720 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
720 if ( (*it) == resource ) { 721 if ( (*it) == resource ) {
721 if ( (*it)->readOnly() || !(*it)->isOpen() ) 722 if ( (*it)->readOnly() || !(*it)->isOpen() )
722 return 0; 723 return 0;
723 else 724 else
724 return (*it)->requestSaveTicket(); 725 return (*it)->requestSaveTicket();
725 } 726 }
726 } 727 }
727 728
728 return 0; 729 return 0;
729} 730}
730//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 731//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
731void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 732void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
732{ 733{
733 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 734 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
734 //qDebug("block insert "); 735 //qDebug("block insert ");
735 return; 736 return;
736 } 737 }
737 //qDebug("inserting.... %s ",a.uid().latin1() ); 738 //qDebug("inserting.... %s ",a.uid().latin1() );
738 bool found = false; 739 bool found = false;
739 Addressee::List::Iterator it; 740 Addressee::List::Iterator it;
740 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 741 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
741 if ( a.uid() == (*it).uid() ) { 742 if ( a.uid() == (*it).uid() ) {
742 743
743 bool changed = false; 744 bool changed = false;
744 Addressee addr = a; 745 Addressee addr = a;
745 if ( addr != (*it) ) 746 if ( addr != (*it) )
746 changed = true; 747 changed = true;
747 748
748 if ( takeResource ) { 749 if ( takeResource ) {
749 Resource * res = (*it).resource(); 750 Resource * res = (*it).resource();
750 (*it) = a; 751 (*it) = a;
751 (*it).setResource( res ); 752 (*it).setResource( res );
752 } else { 753 } else {
753 (*it) = a; 754 (*it) = a;
754 if ( (*it).resource() == 0 ) 755 if ( (*it).resource() == 0 )
755 (*it).setResource( standardResource() ); 756 (*it).setResource( standardResource() );
756 } 757 }
757 if ( changed ) { 758 if ( changed ) {
758 if ( setRev ) { 759 if ( setRev ) {
759 760
760 // get rid of micro seconds 761 // get rid of micro seconds
761 QDateTime dt = QDateTime::currentDateTime(); 762 QDateTime dt = QDateTime::currentDateTime();
762 QTime t = dt.time(); 763 QTime t = dt.time();
763 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 764 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
764 (*it).setRevision( dt ); 765 (*it).setRevision( dt );
765 } 766 }
766 (*it).setChanged( true ); 767 (*it).setChanged( true );
767 } 768 }
768 769
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index 23bba02..5edca06 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -1,348 +1,348 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_ADDRESSBOOK_H 28#ifndef KABC_ADDRESSBOOK_H
29#define KABC_ADDRESSBOOK_H 29#define KABC_ADDRESSBOOK_H
30 30
31#include <qobject.h> 31#include <qobject.h>
32 32
33#include <kresources/manager.h> 33#include <kresources/manager.h>
34#include <qptrlist.h> 34#include <qptrlist.h>
35 35
36#include "addressee.h" 36#include "addressee.h"
37#include "field.h" 37#include "field.h"
38 38
39namespace KABC { 39namespace KABC {
40 40
41class ErrorHandler; 41class ErrorHandler;
42class Resource; 42class Resource;
43class Ticket; 43class Ticket;
44 44
45/** 45/**
46 @short Address Book 46 @short Address Book
47 47
48 This class provides access to a collection of address book entries. 48 This class provides access to a collection of address book entries.
49*/ 49*/
50class AddressBook : public QObject 50class AddressBook : public QObject
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54 friend QDataStream &operator<<( QDataStream &, const AddressBook & ); 54 friend QDataStream &operator<<( QDataStream &, const AddressBook & );
55 friend QDataStream &operator>>( QDataStream &, AddressBook & ); 55 friend QDataStream &operator>>( QDataStream &, AddressBook & );
56 friend class StdAddressBook; 56 friend class StdAddressBook;
57 57
58 public: 58 public:
59 /** 59 /**
60 @short Address Book Iterator 60 @short Address Book Iterator
61 61
62 This class provides an iterator for address book entries. 62 This class provides an iterator for address book entries.
63 */ 63 */
64 class Iterator 64 class Iterator
65 { 65 {
66 public: 66 public:
67 Iterator(); 67 Iterator();
68 Iterator( const Iterator & ); 68 Iterator( const Iterator & );
69 ~Iterator(); 69 ~Iterator();
70 70
71 Iterator &operator=( const Iterator & ); 71 Iterator &operator=( const Iterator & );
72 const Addressee &operator*() const; 72 const Addressee &operator*() const;
73 Addressee &operator*(); 73 Addressee &operator*();
74 Addressee* operator->(); 74 Addressee* operator->();
75 Iterator &operator++(); 75 Iterator &operator++();
76 Iterator &operator++(int); 76 Iterator &operator++(int);
77 Iterator &operator--(); 77 Iterator &operator--();
78 Iterator &operator--(int); 78 Iterator &operator--(int);
79 bool operator==( const Iterator &it ); 79 bool operator==( const Iterator &it );
80 bool operator!=( const Iterator &it ); 80 bool operator!=( const Iterator &it );
81 81
82 struct IteratorData; 82 struct IteratorData;
83 IteratorData *d; 83 IteratorData *d;
84 }; 84 };
85 85
86 /** 86 /**
87 @short Address Book Const Iterator 87 @short Address Book Const Iterator
88 88
89 This class provides a const iterator for address book entries. 89 This class provides a const iterator for address book entries.
90 */ 90 */
91 class ConstIterator 91 class ConstIterator
92 { 92 {
93 public: 93 public:
94 ConstIterator(); 94 ConstIterator();
95 ConstIterator( const ConstIterator & ); 95 ConstIterator( const ConstIterator & );
96 ~ConstIterator(); 96 ~ConstIterator();
97 97
98 ConstIterator &operator=( const ConstIterator & ); 98 ConstIterator &operator=( const ConstIterator & );
99 const Addressee &operator*() const; 99 const Addressee &operator*() const;
100 const Addressee* operator->() const; 100 const Addressee* operator->() const;
101 ConstIterator &operator++(); 101 ConstIterator &operator++();
102 ConstIterator &operator++(int); 102 ConstIterator &operator++(int);
103 ConstIterator &operator--(); 103 ConstIterator &operator--();
104 ConstIterator &operator--(int); 104 ConstIterator &operator--(int);
105 bool operator==( const ConstIterator &it ); 105 bool operator==( const ConstIterator &it );
106 bool operator!=( const ConstIterator &it ); 106 bool operator!=( const ConstIterator &it );
107 107
108 struct ConstIteratorData; 108 struct ConstIteratorData;
109 ConstIteratorData *d; 109 ConstIteratorData *d;
110 }; 110 };
111 111
112 /** 112 /**
113 Constructs a address book object. 113 Constructs a address book object.
114 114
115 @param format File format class. 115 @param format File format class.
116 */ 116 */
117 AddressBook(); 117 AddressBook();
118 AddressBook( const QString &config ); 118 AddressBook( const QString &config );
119 AddressBook( const QString &config, const QString &family ); 119 AddressBook( const QString &config, const QString &family );
120 virtual ~AddressBook(); 120 virtual ~AddressBook();
121 121
122 /** 122 /**
123 Requests a ticket for saving the addressbook. Calling this function locks 123 Requests a ticket for saving the addressbook. Calling this function locks
124 the addressbook for all other processes. If the address book is already 124 the addressbook for all other processes. If the address book is already
125 locked the function returns 0. You need the returned @ref Ticket object 125 locked the function returns 0. You need the returned @ref Ticket object
126 for calling the @ref save() function. 126 for calling the @ref save() function.
127 127
128 @see save() 128 @see save()
129 */ 129 */
130 Ticket *requestSaveTicket( Resource *resource=0 ); 130 Ticket *requestSaveTicket( Resource *resource=0 );
131 131
132 /** 132 /**
133 Load address book from file. 133 Load address book from file.
134 */ 134 */
135 bool load(); 135 bool load();
136 136
137 /** 137 /**
138 Save address book. The address book is saved to the file, the Ticket 138 Save address book. The address book is saved to the file, the Ticket
139 object has been requested for by @ref requestSaveTicket(). 139 object has been requested for by @ref requestSaveTicket().
140 140
141 @param ticket a ticket object returned by @ref requestSaveTicket() 141 @param ticket a ticket object returned by @ref requestSaveTicket()
142 */ 142 */
143 bool save( Ticket *ticket ); 143 bool save( Ticket *ticket );
144 bool saveAB( ); 144 bool saveAB( );
145 bool saveABphone( QString fileName ); 145 bool saveABphone( QString fileName );
146 void smplifyAddressees(); 146 void smplifyAddressees();
147 void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); 147 void preparePhoneSync( QString currentSyncDevice, bool isPreSync );
148 void export2File( QString fileName ); 148 void export2File( QString fileName );
149 bool export2PhoneFormat( QStringList uids ,QString fileName ); 149 bool export2PhoneFormat( QStringList uids ,QString fileName );
150 void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); 150 int importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
151 void setUntagged( bool setNonSyncTagged = false ); 151 void setUntagged( bool setNonSyncTagged = false );
152 void removeUntagged(); 152 void removeUntagged();
153 void findNewExtIds( QString fileName, QString currentSyncDevice ); 153 void findNewExtIds( QString fileName, QString currentSyncDevice );
154 /** 154 /**
155 Returns a iterator for first entry of address book. 155 Returns a iterator for first entry of address book.
156 */ 156 */
157 Iterator begin(); 157 Iterator begin();
158 158
159 /** 159 /**
160 Returns a const iterator for first entry of address book. 160 Returns a const iterator for first entry of address book.
161 */ 161 */
162 ConstIterator begin() const; 162 ConstIterator begin() const;
163 163
164 /** 164 /**
165 Returns a iterator for first entry of address book. 165 Returns a iterator for first entry of address book.
166 */ 166 */
167 Iterator end(); 167 Iterator end();
168 168
169 /** 169 /**
170 Returns a const iterator for first entry of address book. 170 Returns a const iterator for first entry of address book.
171 */ 171 */
172 ConstIterator end() const; 172 ConstIterator end() const;
173 173
174 /** 174 /**
175 Removes all entries from address book. 175 Removes all entries from address book.
176 */ 176 */
177 void clear(); 177 void clear();
178 178
179 /** 179 /**
180 Insert an Addressee object into address book. If an object with the same 180 Insert an Addressee object into address book. If an object with the same
181 unique id already exists in the address book it it replaced by the new 181 unique id already exists in the address book it it replaced by the new
182 one. If not the new object is appended to the address book. 182 one. If not the new object is appended to the address book.
183 */ 183 */
184 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 184 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
185 185
186 /** 186 /**
187 Removes entry from the address book. 187 Removes entry from the address book.
188 */ 188 */
189 void removeAddressee( const Addressee & ); 189 void removeAddressee( const Addressee & );
190 190
191 /** 191 /**
192 This is like @ref removeAddressee() just above, with the difference that 192 This is like @ref removeAddressee() just above, with the difference that
193 the first element is a iterator, returned by @ref begin(). 193 the first element is a iterator, returned by @ref begin().
194 */ 194 */
195 void removeAddressee( const Iterator & ); 195 void removeAddressee( const Iterator & );
196 196
197 /** 197 /**
198 Find the specified entry in address book. Returns end(), if the entry 198 Find the specified entry in address book. Returns end(), if the entry
199 couldn't be found. 199 couldn't be found.
200 */ 200 */
201 Iterator find( const Addressee & ); 201 Iterator find( const Addressee & );
202 202
203 /** 203 /**
204 Find the entry specified by an unique id. Returns an empty Addressee 204 Find the entry specified by an unique id. Returns an empty Addressee
205 object, if the address book does not contain an entry with this id. 205 object, if the address book does not contain an entry with this id.
206 */ 206 */
207 Addressee findByUid( const QString & ); 207 Addressee findByUid( const QString & );
208 208
209 209
210 /** 210 /**
211 Returns a list of all addressees in the address book. This list can 211 Returns a list of all addressees in the address book. This list can
212 be sorted with @ref KABC::AddresseeList for example. 212 be sorted with @ref KABC::AddresseeList for example.
213 */ 213 */
214 Addressee::List allAddressees(); 214 Addressee::List allAddressees();
215 215
216 /** 216 /**
217 Find all entries with the specified name in the address book. Returns 217 Find all entries with the specified name in the address book. Returns
218 an empty list, if no entries could be found. 218 an empty list, if no entries could be found.
219 */ 219 */
220 Addressee::List findByName( const QString & ); 220 Addressee::List findByName( const QString & );
221 221
222 /** 222 /**
223 Find all entries with the specified email address in the address book. 223 Find all entries with the specified email address in the address book.
224 Returns an empty list, if no entries could be found. 224 Returns an empty list, if no entries could be found.
225 */ 225 */
226 Addressee::List findByEmail( const QString & ); 226 Addressee::List findByEmail( const QString & );
227 227
228 /** 228 /**
229 Find all entries wich have the specified category in the address book. 229 Find all entries wich have the specified category in the address book.
230 Returns an empty list, if no entries could be found. 230 Returns an empty list, if no entries could be found.
231 */ 231 */
232 Addressee::List findByCategory( const QString & ); 232 Addressee::List findByCategory( const QString & );
233 233
234 /** 234 /**
235 Return a string identifying this addressbook. 235 Return a string identifying this addressbook.
236 */ 236 */
237 virtual QString identifier(); 237 virtual QString identifier();
238 238
239 /** 239 /**
240 Used for debug output. 240 Used for debug output.
241 */ 241 */
242 void dump() const; 242 void dump() const;
243 243
244 void emitAddressBookLocked() { emit addressBookLocked( this ); } 244 void emitAddressBookLocked() { emit addressBookLocked( this ); }
245 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 245 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
246 void emitAddressBookChanged() { emit addressBookChanged( this ); } 246 void emitAddressBookChanged() { emit addressBookChanged( this ); }
247 247
248 /** 248 /**
249 Return list of all Fields known to the address book which are associated 249 Return list of all Fields known to the address book which are associated
250 with the given field category. 250 with the given field category.
251 */ 251 */
252 Field::List fields( int category = Field::All ); 252 Field::List fields( int category = Field::All );
253 253
254 /** 254 /**
255 Add custom field to address book. 255 Add custom field to address book.
256 256
257 @param label User visible label of the field. 257 @param label User visible label of the field.
258 @param category Ored list of field categories. 258 @param category Ored list of field categories.
259 @param key Identifier used as key for reading and writing the field. 259 @param key Identifier used as key for reading and writing the field.
260 @param app String used as application key for reading and writing 260 @param app String used as application key for reading and writing
261 the field. 261 the field.
262 */ 262 */
263 bool addCustomField( const QString &label, int category = Field::All, 263 bool addCustomField( const QString &label, int category = Field::All,
264 const QString &key = QString::null, 264 const QString &key = QString::null,
265 const QString &app = QString::null ); 265 const QString &app = QString::null );
266 266
267 267
268 /** 268 /**
269 Add address book resource. 269 Add address book resource.
270 */ 270 */
271 bool addResource( Resource * ); 271 bool addResource( Resource * );
272 272
273 /** 273 /**
274 Remove address book resource. 274 Remove address book resource.
275 */ 275 */
276 bool removeResource( Resource * ); 276 bool removeResource( Resource * );
277 277
278 /** 278 /**
279 Return pointer list of all resources. 279 Return pointer list of all resources.
280 */ 280 */
281 QPtrList<Resource> resources(); 281 QPtrList<Resource> resources();
282 282
283 /** 283 /**
284 Set the @p ErrorHandler, that is used by @ref error() to 284 Set the @p ErrorHandler, that is used by @ref error() to
285 provide gui-independend error messages. 285 provide gui-independend error messages.
286 */ 286 */
287 void setErrorHandler( ErrorHandler * ); 287 void setErrorHandler( ErrorHandler * );
288 288
289 /** 289 /**
290 Shows gui independend error messages. 290 Shows gui independend error messages.
291 */ 291 */
292 void error( const QString& ); 292 void error( const QString& );
293 293
294 /** 294 /**
295 Query all resources to clean up their lock files 295 Query all resources to clean up their lock files
296 */ 296 */
297 void cleanUp(); 297 void cleanUp();
298 298
299 // sync stuff 299 // sync stuff
300 //Addressee::List getExternLastSyncAddressees(); 300 //Addressee::List getExternLastSyncAddressees();
301 void resetTempSyncStat(); 301 void resetTempSyncStat();
302 QStringList uidList(); 302 QStringList uidList();
303 void removeSyncAddressees( bool removeDeleted = false ); 303 void removeSyncAddressees( bool removeDeleted = false );
304 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset ); 304 void mergeAB( AddressBook *aBook, const QString& profile, bool isSubset );
305 Addressee findByExternUid( const QString& uid , const QString& profile ); 305 Addressee findByExternUid( const QString& uid , const QString& profile );
306 bool containsExternalUid( const QString& uid ); 306 bool containsExternalUid( const QString& uid );
307 307
308 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset ); 308 void preExternSync( AddressBook* aBook, const QString& csd, bool isSubset );
309 void postExternSync( AddressBook* aBook, const QString& csd ); 309 void postExternSync( AddressBook* aBook, const QString& csd );
310 signals: 310 signals:
311 /** 311 /**
312 Emitted, when the address book has changed on disk. 312 Emitted, when the address book has changed on disk.
313 */ 313 */
314 void addressBookChanged( AddressBook * ); 314 void addressBookChanged( AddressBook * );
315 315
316 /** 316 /**
317 Emitted, when the address book has been locked for writing. 317 Emitted, when the address book has been locked for writing.
318 */ 318 */
319 void addressBookLocked( AddressBook * ); 319 void addressBookLocked( AddressBook * );
320 320
321 /** 321 /**
322 Emitted, when the address book has been unlocked. 322 Emitted, when the address book has been unlocked.
323 */ 323 */
324 void addressBookUnlocked( AddressBook * ); 324 void addressBookUnlocked( AddressBook * );
325 325
326 protected: 326 protected:
327 void deleteRemovedAddressees(); 327 void deleteRemovedAddressees();
328 void setStandardResource( Resource * ); 328 void setStandardResource( Resource * );
329 Resource *standardResource(); 329 Resource *standardResource();
330 KRES::Manager<Resource> *resourceManager(); 330 KRES::Manager<Resource> *resourceManager();
331 331
332 void init(const QString &config, const QString &family); 332 void init(const QString &config, const QString &family);
333 333
334 private: 334 private:
335//US QPtrList<Resource> mDummy; // Remove in KDE 4 335//US QPtrList<Resource> mDummy; // Remove in KDE 4
336 336
337 337
338 struct AddressBookData; 338 struct AddressBookData;
339 AddressBookData *d; 339 AddressBookData *d;
340 bool blockLSEchange; 340 bool blockLSEchange;
341}; 341};
342 342
343QDataStream &operator<<( QDataStream &, const AddressBook & ); 343QDataStream &operator<<( QDataStream &, const AddressBook & );
344QDataStream &operator>>( QDataStream &, AddressBook & ); 344QDataStream &operator>>( QDataStream &, AddressBook & );
345 345
346} 346}
347 347
348#endif 348#endif
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
index 2cdf4bf..ba17c50 100644
--- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
+++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp
@@ -1,332 +1,332 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <sys/types.h> 28#include <sys/types.h>
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <unistd.h> 30#include <unistd.h>
31 31
32#include <qdir.h> 32#include <qdir.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qfileinfo.h> 34#include <qfileinfo.h>
35#include <qregexp.h> 35#include <qregexp.h>
36//US #include <qtimer.h> 36//US #include <qtimer.h>
37 37
38#include <kapplication.h> 38#include <kapplication.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kdebug.h> 40#include <kdebug.h>
41#include <klocale.h> 41#include <klocale.h>
42//US #include <ksavefile.h> 42//US #include <ksavefile.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kmessagebox.h> 44#include <kmessagebox.h>
45 45
46#include <sl/slzdb.h> 46#include <sl/slzdb.h>
47 47
48#include <libkdepim/ksyncprofile.h> 48#include <libkdepim/ksyncprofile.h>
49 49
50#include "resourcesharpdtmconfig.h" 50#include "resourcesharpdtmconfig.h"
51#include "resourcesharpdtm.h" 51#include "resourcesharpdtm.h"
52 52
53#include "stdaddressbook.h" 53#include "stdaddressbook.h"
54 54
55#include "sharpdtmconverter.h" 55#include "sharpdtmconverter.h"
56//#define ALLOW_LOCKING 56//#define ALLOW_LOCKING
57using namespace KABC; 57using namespace KABC;
58extern "C" 58extern "C"
59{ 59{
60 void *init_microkabc_sharpdtm() 60 void *init_microkabc_sharpdtm()
61 { 61 {
62 return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>(); 62 return new KRES::PluginFactory<ResourceSharpDTM,ResourceSharpDTMConfig>();
63 } 63 }
64} 64}
65 65
66ResourceSharpDTM::ResourceSharpDTM( const KConfig *config ) 66ResourceSharpDTM::ResourceSharpDTM( const KConfig *config )
67 : Resource( config ), mConverter (0) 67 : Resource( config ), mConverter (0)
68{ 68{
69 // we can not choose the filename. Therefore use the default to display 69 // we can not choose the filename. Therefore use the default to display
70 70
71 QString fileName = SlZDataBase::addressbookFileName(); 71 QString fileName = SlZDataBase::addressbookFileName();
72 init( fileName ); 72 init( fileName );
73} 73}
74 74
75ResourceSharpDTM::ResourceSharpDTM( const QString &fileName, bool syncable ) 75ResourceSharpDTM::ResourceSharpDTM( const QString &fileName )
76 : Resource( 0, syncable ) 76 : Resource( 0 )
77{ 77{
78 init( fileName ); 78 init( fileName );
79} 79}
80 80
81void ResourceSharpDTM::init( const QString &fileName ) 81void ResourceSharpDTM::init( const QString &fileName )
82{ 82{
83 83
84 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); 84 connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) );
85 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); 85 connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) );
86 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); 86 connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) );
87 87
88 setFileName( fileName ); 88 setFileName( fileName );
89} 89}
90 90
91ResourceSharpDTM::~ResourceSharpDTM() 91ResourceSharpDTM::~ResourceSharpDTM()
92{ 92{
93 if (mConverter != 0) 93 if (mConverter != 0)
94 delete mConverter; 94 delete mConverter;
95 95
96 if(mAccess != 0) 96 if(mAccess != 0)
97 delete mAccess; 97 delete mAccess;
98} 98}
99 99
100void ResourceSharpDTM::writeConfig( KConfig *config ) 100void ResourceSharpDTM::writeConfig( KConfig *config )
101{ 101{
102 Resource::writeConfig( config ); 102 Resource::writeConfig( config );
103} 103}
104 104
105Ticket *ResourceSharpDTM::requestSaveTicket() 105Ticket *ResourceSharpDTM::requestSaveTicket()
106{ 106{
107 107
108 108
109 qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1()); 109 qDebug("ResourceSharpDTM::requestSaveTicket: %s", fileName().latin1());
110 110
111 if ( !addressBook() ) return 0; 111 if ( !addressBook() ) return 0;
112 112
113#ifdef ALLOW_LOCKING 113#ifdef ALLOW_LOCKING
114 if ( !lock( fileName() ) ) { 114 if ( !lock( fileName() ) ) {
115 qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file "); 115 qDebug("ResourceSharpDTM::requestSaveTicket(): Unable to lock file ");
116 return 0; 116 return 0;
117 } 117 }
118#endif 118#endif
119 return createTicket( this ); 119 return createTicket( this );
120} 120}
121 121
122 122
123bool ResourceSharpDTM::doOpen() 123bool ResourceSharpDTM::doOpen()
124{ 124{
125 qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1()); 125 qDebug("ResourceSharpDTM::doOpen: %s", fileName().latin1());
126 126
127 // the last parameter in the SlZDataBase constructor means "readonly" 127 // the last parameter in the SlZDataBase constructor means "readonly"
128 mAccess = new SlZDataBase(fileName(), 128 mAccess = new SlZDataBase(fileName(),
129 SlZDataBase::addressbookItems(), 129 SlZDataBase::addressbookItems(),
130 NULL, false); 130 NULL, false);
131 131
132 if ( !mAccess ) { 132 if ( !mAccess ) {
133 qDebug("Unable to load file() %s", fileName().latin1()); 133 qDebug("Unable to load file() %s", fileName().latin1());
134 return false; 134 return false;
135 } 135 }
136 136
137 if (mConverter == 0) 137 if (mConverter == 0)
138 { 138 {
139 mConverter = new SharpDTMConverter(); 139 mConverter = new SharpDTMConverter();
140 bool res = mConverter->init(); 140 bool res = mConverter->init();
141 if ( !res ) 141 if ( !res )
142 { 142 {
143 QString msg("Unable to initialize sharp converter. Most likely a problem with the category file"); 143 QString msg("Unable to initialize sharp converter. Most likely a problem with the category file");
144 144
145 qDebug(msg); 145 qDebug(msg);
146 delete mAccess; 146 delete mAccess;
147 mAccess = 0; 147 mAccess = 0;
148 return false; 148 return false;
149 } 149 }
150 } 150 }
151 151
152 return true; 152 return true;
153} 153}
154 154
155void ResourceSharpDTM::doClose() 155void ResourceSharpDTM::doClose()
156{ 156{
157 qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1()); 157 qDebug("ResourceSharpDTM::doClose: %s", fileName().latin1());
158 158
159 if(mAccess) 159 if(mAccess)
160 { 160 {
161 delete mAccess; 161 delete mAccess;
162 mAccess = 0; 162 mAccess = 0;
163 } 163 }
164 // it seems so, that deletion of access deletes backend as well 164 // it seems so, that deletion of access deletes backend as well
165 //delete backend; 165 //delete backend;
166 166
167 return; 167 return;
168} 168}
169 169
170bool ResourceSharpDTM::load() 170bool ResourceSharpDTM::load()
171{ 171{
172 qDebug("ResourceSharpDTM::load: %s", fileName().latin1()); 172 qDebug("ResourceSharpDTM::load: %s", fileName().latin1());
173 173
174 bool res = false; 174 bool res = false;
175 175
176 CardId id; 176 CardId id;
177 177
178 for (bool res=mAccess->first(); res == true; res=mAccess->next()) 178 for (bool res=mAccess->first(); res == true; res=mAccess->next())
179 { 179 {
180 id = mAccess->cardId(); 180 id = mAccess->cardId();
181 181
182 KABC::Addressee addressee; 182 KABC::Addressee addressee;
183 183
184 res = mConverter->sharpToAddressee( id, mAccess, addressee ); 184 res = mConverter->sharpToAddressee( id, mAccess, addressee );
185 185
186 if ( !addressee.isEmpty() && res ) 186 if ( !addressee.isEmpty() && res )
187 { 187 {
188 addressee.setResource( this ); 188 addressee.setResource( this );
189 addressBook()->insertAddressee( addressee ); 189 addressBook()->insertAddressee( addressee );
190 } 190 }
191 } 191 }
192 192
193 return true; 193 return true;
194} 194}
195 195
196bool ResourceSharpDTM::save( Ticket *ticket ) 196bool ResourceSharpDTM::save( Ticket *ticket )
197{ 197{
198 qDebug("ResourceSharpDTM::save: %s", fileName().latin1()); 198 qDebug("ResourceSharpDTM::save: %s", fileName().latin1());
199 199
200 mDirWatch.stopScan(); 200 mDirWatch.stopScan();
201 201
202 KABC::AddressBook::Iterator it; 202 KABC::AddressBook::Iterator it;
203 bool res; 203 bool res;
204 KABC::Addressee::List changedAddressees; 204 KABC::Addressee::List changedAddressees;
205 typedef QMap<int,QString> AddresseeMap; 205 typedef QMap<int,QString> AddresseeMap;
206 AddresseeMap map; 206 AddresseeMap map;
207 CardId id ; 207 CardId id ;
208 208
209 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) { 209 for ( it = addressBook()->begin(); it != addressBook()->end(); ++it ) {
210 210
211 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 211 if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
212 QString uid = (*it).originalExternalUID(); 212 QString uid = (*it).originalExternalUID();
213 bool res; 213 bool res;
214 if ( uid.isEmpty() ) 214 if ( uid.isEmpty() )
215 id = 0; 215 id = 0;
216 else 216 else
217 id = uid.toUInt(); 217 id = uid.toUInt();
218 KABC::Addressee addressee = (*it); 218 KABC::Addressee addressee = (*it);
219 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) { 219 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_ADDED_EXTERNAL ) {
220 res = mAccess->startEditCard(id); 220 res = mAccess->startEditCard(id);
221 if (res == true) 221 if (res == true)
222 { 222 {
223 res = mConverter->addresseeToSharp( (*it), mAccess, id ); 223 res = mConverter->addresseeToSharp( (*it), mAccess, id );
224 if (res == true) 224 if (res == true)
225 { 225 {
226 res = mAccess->finishEditCard(&id); 226 res = mAccess->finishEditCard(&id);
227 //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 227 //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
228 //(*it).setExternalUID( QString::number( id ) ); 228 //(*it).setExternalUID( QString::number( id ) );
229 //(*it).setOriginalExternalUID( QString::number( id ) ); 229 //(*it).setOriginalExternalUID( QString::number( id ) );
230 map.insert(id,(*it).uid()); 230 map.insert(id,(*it).uid());
231 if (res == false) 231 if (res == false)
232 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); 232 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
233 233
234 } 234 }
235 else 235 else
236 { 236 {
237 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); 237 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1());
238 mAccess->cancelEditCard(); 238 mAccess->cancelEditCard();
239 } 239 }
240 } 240 }
241 241
242 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 242 } else if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
243 res = mAccess->deleteCard(&id); 243 res = mAccess->deleteCard(&id);
244 if ( !res ) 244 if ( !res )
245 qDebug("delete error "); 245 qDebug("delete error ");
246 246
247 247
248 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 248 } else if ( (*it).tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
249 //changed 249 //changed
250 res = mAccess->startEditCard(id); 250 res = mAccess->startEditCard(id);
251 if (res == true) 251 if (res == true)
252 { 252 {
253 res = mConverter->addresseeToSharp( (*it), mAccess, id ); 253 res = mConverter->addresseeToSharp( (*it), mAccess, id );
254 if (res == true) 254 if (res == true)
255 { 255 {
256 res = mAccess->finishEditCard(&id); 256 res = mAccess->finishEditCard(&id);
257 //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); 257 //(*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM );
258 map.insert(id,(*it).uid()); 258 map.insert(id,(*it).uid());
259 if (res == false) 259 if (res == false)
260 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); 260 qDebug("Unable to append Contact: %s", addressee.formattedName().latin1());
261 261
262 } 262 }
263 else 263 else
264 { 264 {
265 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); 265 qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1());
266 mAccess->cancelEditCard(); 266 mAccess->cancelEditCard();
267 } 267 }
268 } 268 }
269 } 269 }
270 } 270 }
271 271
272 } 272 }
273 AddresseeMap::Iterator itam; 273 AddresseeMap::Iterator itam;
274 for ( res=mAccess->first(); res == true; res=mAccess->next()) 274 for ( res=mAccess->first(); res == true; res=mAccess->next())
275 { 275 {
276 id = mAccess->cardId(); 276 id = mAccess->cardId();
277 int idint = id; 277 int idint = id;
278 itam = map.find( idint ); 278 itam = map.find( idint );
279 if ( itam != map.end() ) { 279 if ( itam != map.end() ) {
280 KABC::Addressee addressee; 280 KABC::Addressee addressee;
281 res = mConverter->sharpToAddressee( id, mAccess, addressee ); 281 res = mConverter->sharpToAddressee( id, mAccess, addressee );
282 282
283 if ( !addressee.isEmpty() && res ) 283 if ( !addressee.isEmpty() && res )
284 { 284 {
285 addressee.setResource( this ); 285 addressee.setResource( this );
286 addressee.setUid( itam.data() ); 286 addressee.setUid( itam.data() );
287 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 287 addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
288 addressBook()->insertAddressee( addressee , false ); 288 addressBook()->insertAddressee( addressee , false );
289 } 289 }
290 } 290 }
291 } 291 }
292 292
293 //US mAccess->save(); 293 //US mAccess->save();
294 294
295 mDirWatch.startScan(); 295 mDirWatch.startScan();
296 delete ticket; 296 delete ticket;
297 unlock( fileName() ); 297 unlock( fileName() );
298 298
299 return true; 299 return true;
300} 300}
301 301
302bool ResourceSharpDTM::lock( const QString &lockfileName ) 302bool ResourceSharpDTM::lock( const QString &lockfileName )
303{ 303{
304#ifdef ALLOW_LOCKING 304#ifdef ALLOW_LOCKING
305 qDebug("ResourceSharpDTM::lock: %s", fileName().latin1()); 305 qDebug("ResourceSharpDTM::lock: %s", fileName().latin1());
306 306
307 kdDebug(5700) << "ResourceSharpDTM::lock()" << endl; 307 kdDebug(5700) << "ResourceSharpDTM::lock()" << endl;
308 308
309 QString fn = lockfileName; 309 QString fn = lockfileName;
310 310
311 KURL url(fn); 311 KURL url(fn);
312 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); 312 QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" );
313 313
314 kdDebug(5700) << "-- lock name: " << lockName << endl; 314 kdDebug(5700) << "-- lock name: " << lockName << endl;
315 315
316 if (QFile::exists( lockName )) 316 if (QFile::exists( lockName ))
317 { 317 {
318 qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName()); 318 qDebug("ResourceSharpDTM::lock: lockfile %s already exists. (Delete it before continuing if nobody else is accessing the resourcefile %s)", lockName.latin1(), fileName());
319 return false; 319 return false;
320 } 320 }
321 321
322 322
323 QString lockUniqueName; 323 QString lockUniqueName;
324 lockUniqueName = fn + KApplication::randomString( 8 ); 324 lockUniqueName = fn + KApplication::randomString( 8 );
325 325
326 url = lockUniqueName; 326 url = lockUniqueName;
327//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); 327//US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName );
328 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); 328 mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() );
329 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; 329 kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl;
330 330
331 // Create unique file 331 // Create unique file
332 QFile file( mLockUniqueName ); 332 QFile file( mLockUniqueName );
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 087e9e3..3ab06c4 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1476 +1,1477 @@
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/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
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
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207
207bool pasteWithNewUid = true; 208bool pasteWithNewUid = true;
208 209
209#ifdef KAB_EMBEDDED 210#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 215#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 219 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 220#endif //KAB_EMBEDDED
220{ 221{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 223 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 224 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 225 mIsPart = !parent->inherits( "KAddressBookMain" );
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
311 mMessageTimer = new QTimer( this );
312 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
310 mEditorDialog = 0; 313 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 314 createAddresseeEditorDialog( this );
312 setModified( false ); 315 setModified( false );
313} 316}
314 317
315KABCore::~KABCore() 318KABCore::~KABCore()
316{ 319{
317 // save(); 320 // save();
318 //saveSettings(); 321 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 322 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 323 delete AddresseeConfig::instance();
321 mAddressBook = 0; 324 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 325 KABC::StdAddressBook::close();
323 326
324 delete syncManager; 327 delete syncManager;
325 328
326} 329}
327 330
328void KABCore::recieve( QString fn ) 331void KABCore::recieve( QString fn )
329{ 332{
330 //qDebug("KABCore::recieve "); 333 //qDebug("KABCore::recieve ");
331 mAddressBook->importFromFile( fn, true ); 334 int count = mAddressBook->importFromFile( fn, true );
332 mViewManager->refreshView(); 335 mViewManager->refreshView();
336 message(i18n("%1 contact(s) received!").arg( count ));
333 topLevelWidget()->raise(); 337 topLevelWidget()->raise();
334} 338}
335void KABCore::restoreSettings() 339void KABCore::restoreSettings()
336{ 340{
337 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 341 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
338 342
339 bool state; 343 bool state;
340 344
341 if (mMultipleViewsAtOnce) 345 if (mMultipleViewsAtOnce)
342 state = KABPrefs::instance()->mDetailsPageVisible; 346 state = KABPrefs::instance()->mDetailsPageVisible;
343 else 347 else
344 state = false; 348 state = false;
345 349
346 mActionDetails->setChecked( state ); 350 mActionDetails->setChecked( state );
347 setDetailsVisible( state ); 351 setDetailsVisible( state );
348 352
349 state = KABPrefs::instance()->mJumpButtonBarVisible; 353 state = KABPrefs::instance()->mJumpButtonBarVisible;
350 354
351 mActionJumpBar->setChecked( state ); 355 mActionJumpBar->setChecked( state );
352 setJumpButtonBarVisible( state ); 356 setJumpButtonBarVisible( state );
353/*US 357/*US
354 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 358 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
355 if ( splitterSize.count() == 0 ) { 359 if ( splitterSize.count() == 0 ) {
356 splitterSize.append( width() / 2 ); 360 splitterSize.append( width() / 2 );
357 splitterSize.append( width() / 2 ); 361 splitterSize.append( width() / 2 );
358 } 362 }
359 mMiniSplitter->setSizes( splitterSize ); 363 mMiniSplitter->setSizes( splitterSize );
360 if ( mExtensionBarSplitter ) { 364 if ( mExtensionBarSplitter ) {
361 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 365 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
362 if ( splitterSize.count() == 0 ) { 366 if ( splitterSize.count() == 0 ) {
363 splitterSize.append( width() / 2 ); 367 splitterSize.append( width() / 2 );
364 splitterSize.append( width() / 2 ); 368 splitterSize.append( width() / 2 );
365 } 369 }
366 mExtensionBarSplitter->setSizes( splitterSize ); 370 mExtensionBarSplitter->setSizes( splitterSize );
367 371
368 } 372 }
369*/ 373*/
370 mViewManager->restoreSettings(); 374 mViewManager->restoreSettings();
371 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 375 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
372 mExtensionManager->restoreSettings(); 376 mExtensionManager->restoreSettings();
373#ifdef DESKTOP_VERSION 377#ifdef DESKTOP_VERSION
374 int wid = width(); 378 int wid = width();
375 if ( wid < 10 ) 379 if ( wid < 10 )
376 wid = 400; 380 wid = 400;
377#else 381#else
378 int wid = QApplication::desktop()->width(); 382 int wid = QApplication::desktop()->width();
379 if ( wid < 640 ) 383 if ( wid < 640 )
380 wid = QApplication::desktop()->height(); 384 wid = QApplication::desktop()->height();
381#endif 385#endif
382 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 386 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
383 if ( true /*splitterSize.count() == 0*/ ) { 387 if ( true /*splitterSize.count() == 0*/ ) {
384 splitterSize.append( wid / 2 ); 388 splitterSize.append( wid / 2 );
385 splitterSize.append( wid / 2 ); 389 splitterSize.append( wid / 2 );
386 } 390 }
387 mMiniSplitter->setSizes( splitterSize ); 391 mMiniSplitter->setSizes( splitterSize );
388 if ( mExtensionBarSplitter ) { 392 if ( mExtensionBarSplitter ) {
389 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 393 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
390 if ( true /*splitterSize.count() == 0*/ ) { 394 if ( true /*splitterSize.count() == 0*/ ) {
391 splitterSize.append( wid / 2 ); 395 splitterSize.append( wid / 2 );
392 splitterSize.append( wid / 2 ); 396 splitterSize.append( wid / 2 );
393 } 397 }
394 mExtensionBarSplitter->setSizes( splitterSize ); 398 mExtensionBarSplitter->setSizes( splitterSize );
395 399
396 } 400 }
397 401
398 402
399} 403}
400 404
401void KABCore::saveSettings() 405void KABCore::saveSettings()
402{ 406{
403 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 407 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
404 if ( mExtensionBarSplitter ) 408 if ( mExtensionBarSplitter )
405 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 409 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
406 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 410 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
407 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 411 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
408#ifndef KAB_EMBEDDED 412#ifndef KAB_EMBEDDED
409 413
410 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 414 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
411 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 415 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
412#endif //KAB_EMBEDDED 416#endif //KAB_EMBEDDED
413 mExtensionManager->saveSettings(); 417 mExtensionManager->saveSettings();
414 mViewManager->saveSettings(); 418 mViewManager->saveSettings();
415 419
416 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 420 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
417} 421}
418 422
419KABC::AddressBook *KABCore::addressBook() const 423KABC::AddressBook *KABCore::addressBook() const
420{ 424{
421 return mAddressBook; 425 return mAddressBook;
422} 426}
423 427
424KConfig *KABCore::config() 428KConfig *KABCore::config()
425{ 429{
426#ifndef KAB_EMBEDDED 430#ifndef KAB_EMBEDDED
427 return KABPrefs::instance()->config(); 431 return KABPrefs::instance()->config();
428#else //KAB_EMBEDDED 432#else //KAB_EMBEDDED
429 return KABPrefs::instance()->getConfig(); 433 return KABPrefs::instance()->getConfig();
430#endif //KAB_EMBEDDED 434#endif //KAB_EMBEDDED
431} 435}
432 436
433KActionCollection *KABCore::actionCollection() const 437KActionCollection *KABCore::actionCollection() const
434{ 438{
435 return mGUIClient->actionCollection(); 439 return mGUIClient->actionCollection();
436} 440}
437 441
438KABC::Field *KABCore::currentSearchField() const 442KABC::Field *KABCore::currentSearchField() const
439{ 443{
440 if (mIncSearchWidget) 444 if (mIncSearchWidget)
441 return mIncSearchWidget->currentField(); 445 return mIncSearchWidget->currentField();
442 else 446 else
443 return 0; 447 return 0;
444} 448}
445 449
446QStringList KABCore::selectedUIDs() const 450QStringList KABCore::selectedUIDs() const
447{ 451{
448 return mViewManager->selectedUids(); 452 return mViewManager->selectedUids();
449} 453}
450 454
451KABC::Resource *KABCore::requestResource( QWidget *parent ) 455KABC::Resource *KABCore::requestResource( QWidget *parent )
452{ 456{
453 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 457 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
454 458
455 QPtrList<KRES::Resource> kresResources; 459 QPtrList<KRES::Resource> kresResources;
456 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 460 QPtrListIterator<KABC::Resource> resIt( kabcResources );
457 KABC::Resource *resource; 461 KABC::Resource *resource;
458 while ( ( resource = resIt.current() ) != 0 ) { 462 while ( ( resource = resIt.current() ) != 0 ) {
459 ++resIt; 463 ++resIt;
460 if ( !resource->readOnly() ) { 464 if ( !resource->readOnly() ) {
461 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 465 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
462 if ( res ) 466 if ( res )
463 kresResources.append( res ); 467 kresResources.append( res );
464 } 468 }
465 } 469 }
466 470
467 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 471 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
468 return static_cast<KABC::Resource*>( res ); 472 return static_cast<KABC::Resource*>( res );
469} 473}
470 474
471#ifndef KAB_EMBEDDED 475#ifndef KAB_EMBEDDED
472KAboutData *KABCore::createAboutData() 476KAboutData *KABCore::createAboutData()
473#else //KAB_EMBEDDED 477#else //KAB_EMBEDDED
474void KABCore::createAboutData() 478void KABCore::createAboutData()
475#endif //KAB_EMBEDDED 479#endif //KAB_EMBEDDED
476{ 480{
477#ifndef KAB_EMBEDDED 481#ifndef KAB_EMBEDDED
478 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 482 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
479 "3.1", I18N_NOOP( "The KDE Address Book" ), 483 "3.1", I18N_NOOP( "The KDE Address Book" ),
480 KAboutData::License_GPL_V2, 484 KAboutData::License_GPL_V2,
481 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 485 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
482 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 486 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
483 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 487 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
484 about->addAuthor( "Cornelius Schumacher", 488 about->addAuthor( "Cornelius Schumacher",
485 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 489 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
486 "schumacher@kde.org" ); 490 "schumacher@kde.org" );
487 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 491 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
488 "mpilone@slac.com" ); 492 "mpilone@slac.com" );
489 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 493 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
490 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 494 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
491 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 495 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
492 "michel@klaralvdalens-datakonsult.se" ); 496 "michel@klaralvdalens-datakonsult.se" );
493 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 497 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
494 "hansen@kde.org" ); 498 "hansen@kde.org" );
495 499
496 return about; 500 return about;
497#endif //KAB_EMBEDDED 501#endif //KAB_EMBEDDED
498 502
499 QString version; 503 QString version;
500#include <../version> 504#include <../version>
501 QMessageBox::about( this, "About KAddressbook/Pi", 505 QMessageBox::about( this, "About KAddressbook/Pi",
502 "KAddressbook/Platform-independent\n" 506 "KAddressbook/Platform-independent\n"
503 "(KA/Pi) " +version + " - " + 507 "(KA/Pi) " +version + " - " +
504#ifdef DESKTOP_VERSION 508#ifdef DESKTOP_VERSION
505 "Desktop Edition\n" 509 "Desktop Edition\n"
506#else 510#else
507 "PDA-Edition\n" 511 "PDA-Edition\n"
508 "for: Zaurus 5500 / 7x0 / 8x0\n" 512 "for: Zaurus 5500 / 7x0 / 8x0\n"
509#endif 513#endif
510 514
511 "(c) 2004 Ulf Schenk\n" 515 "(c) 2004 Ulf Schenk\n"
512 "(c) 2004 Lutz Rogowski\n" 516 "(c) 2004 Lutz Rogowski\n"
513 "(c) 1997-2003, The KDE PIM Team\n" 517 "(c) 1997-2003, The KDE PIM Team\n"
514 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 518 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
515 "Don Sanders Original author\n" 519 "Don Sanders Original author\n"
516 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 520 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
517 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 521 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
518 "Greg Stern DCOP interface\n" 522 "Greg Stern DCOP interface\n"
519 "Mark Westcot Contact pinning\n" 523 "Mark Westcot Contact pinning\n"
520 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 524 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
521 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 525 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
522#ifdef _WIN32_ 526#ifdef _WIN32_
523 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 527 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
524#endif 528#endif
525 ); 529 );
526} 530}
527 531
528void KABCore::setContactSelected( const QString &uid ) 532void KABCore::setContactSelected( const QString &uid )
529{ 533{
530 KABC::Addressee addr = mAddressBook->findByUid( uid ); 534 KABC::Addressee addr = mAddressBook->findByUid( uid );
531 if ( !mDetails->isHidden() ) 535 if ( !mDetails->isHidden() )
532 mDetails->setAddressee( addr ); 536 mDetails->setAddressee( addr );
533 537
534 if ( !addr.isEmpty() ) { 538 if ( !addr.isEmpty() ) {
535 emit contactSelected( addr.formattedName() ); 539 emit contactSelected( addr.formattedName() );
536 KABC::Picture pic = addr.photo(); 540 KABC::Picture pic = addr.photo();
537 if ( pic.isIntern() ) { 541 if ( pic.isIntern() ) {
538//US emit contactSelected( pic.data() ); 542//US emit contactSelected( pic.data() );
539//US instead use: 543//US instead use:
540 QPixmap px; 544 QPixmap px;
541 if (pic.data().isNull() != true) 545 if (pic.data().isNull() != true)
542 { 546 {
543 px.convertFromImage(pic.data()); 547 px.convertFromImage(pic.data());
544 } 548 }
545 549
546 emit contactSelected( px ); 550 emit contactSelected( px );
547 } 551 }
548 } 552 }
549 553
550 554
551 mExtensionManager->setSelectionChanged(); 555 mExtensionManager->setSelectionChanged();
552 556
553 // update the actions 557 // update the actions
554 bool selected = !uid.isEmpty(); 558 bool selected = !uid.isEmpty();
555 559
556 if ( mReadWrite ) { 560 if ( mReadWrite ) {
557 mActionCut->setEnabled( selected ); 561 mActionCut->setEnabled( selected );
558 mActionPaste->setEnabled( selected ); 562 mActionPaste->setEnabled( selected );
559 } 563 }
560 564
561 mActionCopy->setEnabled( selected ); 565 mActionCopy->setEnabled( selected );
562 mActionDelete->setEnabled( selected ); 566 mActionDelete->setEnabled( selected );
563 mActionEditAddressee->setEnabled( selected ); 567 mActionEditAddressee->setEnabled( selected );
564 mActionMail->setEnabled( selected ); 568 mActionMail->setEnabled( selected );
565 mActionMailVCard->setEnabled( selected ); 569 mActionMailVCard->setEnabled( selected );
566 //if (mActionBeam) 570 //if (mActionBeam)
567 //mActionBeam->setEnabled( selected ); 571 //mActionBeam->setEnabled( selected );
568 572
569 if (mActionBeamVCard) 573 if (mActionBeamVCard)
570 mActionBeamVCard->setEnabled( selected ); 574 mActionBeamVCard->setEnabled( selected );
571 575
572 mActionExport2phone->setEnabled( selected ); 576 mActionExport2phone->setEnabled( selected );
573 mActionWhoAmI->setEnabled( selected ); 577 mActionWhoAmI->setEnabled( selected );
574 mActionCategories->setEnabled( selected ); 578 mActionCategories->setEnabled( selected );
575} 579}
576 580
577void KABCore::sendMail() 581void KABCore::sendMail()
578{ 582{
579 sendMail( mViewManager->selectedEmails().join( ", " ) ); 583 sendMail( mViewManager->selectedEmails().join( ", " ) );
580} 584}
581 585
582void KABCore::sendMail( const QString& emaillist ) 586void KABCore::sendMail( const QString& emaillist )
583{ 587{
584 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 588 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
585 if (emaillist.contains(",") > 0) 589 if (emaillist.contains(",") > 0)
586 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 590 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
587 else 591 else
588 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 592 ExternalAppHandler::instance()->mailToOneContact( emaillist );
589} 593}
590 594
591 595
592 596
593void KABCore::mailVCard() 597void KABCore::mailVCard()
594{ 598{
595 QStringList uids = mViewManager->selectedUids(); 599 QStringList uids = mViewManager->selectedUids();
596 if ( !uids.isEmpty() ) 600 if ( !uids.isEmpty() )
597 mailVCard( uids ); 601 mailVCard( uids );
598} 602}
599 603
600void KABCore::mailVCard( const QStringList& uids ) 604void KABCore::mailVCard( const QStringList& uids )
601{ 605{
602 QStringList urls; 606 QStringList urls;
603 607
604// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 608// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
605 609
606 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 610 QString dirName = "/tmp/" + KApplication::randomString( 8 );
607 611
608 612
609 613
610 QDir().mkdir( dirName, true ); 614 QDir().mkdir( dirName, true );
611 615
612 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 616 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
613 KABC::Addressee a = mAddressBook->findByUid( *it ); 617 KABC::Addressee a = mAddressBook->findByUid( *it );
614 618
615 if ( a.isEmpty() ) 619 if ( a.isEmpty() )
616 continue; 620 continue;
617 621
618 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 622 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
619 623
620 QString fileName = dirName + "/" + name; 624 QString fileName = dirName + "/" + name;
621 625
622 QFile outFile(fileName); 626 QFile outFile(fileName);
623 627
624 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 628 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
625 KABC::VCardConverter converter; 629 KABC::VCardConverter converter;
626 QString vcard; 630 QString vcard;
627 631
628 converter.addresseeToVCard( a, vcard ); 632 converter.addresseeToVCard( a, vcard );
629 633
630 QTextStream t( &outFile ); // use a text stream 634 QTextStream t( &outFile ); // use a text stream
631 t.setEncoding( QTextStream::UnicodeUTF8 ); 635 t.setEncoding( QTextStream::UnicodeUTF8 );
632 t << vcard; 636 t << vcard;
633 637
634 outFile.close(); 638 outFile.close();
635 639
636 urls.append( fileName ); 640 urls.append( fileName );
637 } 641 }
638 } 642 }
639 643
640 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 644 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
641 645
642 646
643/*US 647/*US
644 kapp->invokeMailer( QString::null, QString::null, QString::null, 648 kapp->invokeMailer( QString::null, QString::null, QString::null,
645 QString::null, // subject 649 QString::null, // subject
646 QString::null, // body 650 QString::null, // body
647 QString::null, 651 QString::null,
648 urls ); // attachments 652 urls ); // attachments
649*/ 653*/
650 654
651} 655}
652 656
653/** 657/**
654 Beams the "WhoAmI contact. 658 Beams the "WhoAmI contact.
655*/ 659*/
656void KABCore::beamMySelf() 660void KABCore::beamMySelf()
657{ 661{
658 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 662 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
659 if (!a.isEmpty()) 663 if (!a.isEmpty())
660 { 664 {
661 QStringList uids; 665 QStringList uids;
662 uids << a.uid(); 666 uids << a.uid();
663 667
664 beamVCard(uids); 668 beamVCard(uids);
665 } else { 669 } 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" ) ); 670 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 671
668 672
669 } 673 }
670} 674}
671 675
672void KABCore::export2phone() 676void KABCore::export2phone()
673{ 677{
674 678
675 KAex2phonePrefs ex2phone; 679 KAex2phonePrefs ex2phone;
676 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 680 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
677 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 681 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
678 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 682 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
679 683
680 if ( !ex2phone.exec() ) { 684 if ( !ex2phone.exec() ) {
681 return; 685 return;
682 } 686 }
683 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 687 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
684 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 688 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
685 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 689 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
686 690
687 691
688 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 692 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
689 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 693 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
690 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 694 KPimGlobalPrefs::instance()->mEx2PhoneModel );
691 695
692 QStringList uids = mViewManager->selectedUids(); 696 QStringList uids = mViewManager->selectedUids();
693 if ( uids.isEmpty() ) 697 if ( uids.isEmpty() )
694 return; 698 return;
695 699
696 QString fileName = getPhoneFile(); 700 QString fileName = getPhoneFile();
697 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 701 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
698 return; 702 return;
699 703
704 message(i18n("Exporting to phone..."));
700 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 705 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
701 706
702} 707}
703QString KABCore::getPhoneFile() 708QString KABCore::getPhoneFile()
704{ 709{
705#ifdef _WIN32_ 710#ifdef _WIN32_
706 return locateLocal("tmp", "phonefile.vcf"); 711 return locateLocal("tmp", "phonefile.vcf");
707#else 712#else
708 return "/tmp/phonefile.vcf"; 713 return "/tmp/phonefile.vcf";
709#endif 714#endif
710 715
711} 716}
712void KABCore::writeToPhone( ) 717void KABCore::writeToPhone( )
713{ 718{
714 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 719 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
715 qDebug("Export okay "); 720 message(i18n("Export to phone finished!"));
716 else 721 else
717 qDebug("Error export contacts "); 722 qDebug(i18n("Error exporting to phone"));
718} 723}
719void KABCore::beamVCard() 724void KABCore::beamVCard()
720{ 725{
721 QStringList uids = mViewManager->selectedUids(); 726 QStringList uids = mViewManager->selectedUids();
722 if ( !uids.isEmpty() ) 727 if ( !uids.isEmpty() )
723 beamVCard( uids ); 728 beamVCard( uids );
724} 729}
725 730
726 731
727void KABCore::beamVCard(const QStringList& uids) 732void KABCore::beamVCard(const QStringList& uids)
728{ 733{
729/*US 734/*US
730 QString beamFilename; 735 QString beamFilename;
731 Opie::OPimContact c; 736 Opie::OPimContact c;
732 if ( actionPersonal->isOn() ) { 737 if ( actionPersonal->isOn() ) {
733 beamFilename = addressbookPersonalVCardName(); 738 beamFilename = addressbookPersonalVCardName();
734 if ( !QFile::exists( beamFilename ) ) 739 if ( !QFile::exists( beamFilename ) )
735 return; // can't beam a non-existent file 740 return; // can't beam a non-existent file
736 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 741 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
737 beamFilename ); 742 beamFilename );
738 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 743 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
739 Opie::OPimContactAccess::List allList = access->allRecords(); 744 Opie::OPimContactAccess::List allList = access->allRecords();
740 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 745 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
741 c = *it; 746 c = *it;
742 747
743 delete access; 748 delete access;
744 } else { 749 } else {
745 unlink( beamfile ); // delete if exists 750 unlink( beamfile ); // delete if exists
746 mkdir("/tmp/obex/", 0755); 751 mkdir("/tmp/obex/", 0755);
747 c = m_abView -> currentEntry(); 752 c = m_abView -> currentEntry();
748 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 753 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
749 beamfile ); 754 beamfile );
750 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 755 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
751 access->add( c ); 756 access->add( c );
752 access->save(); 757 access->save();
753 delete access; 758 delete access;
754 759
755 beamFilename = beamfile; 760 beamFilename = beamfile;
756 } 761 }
757 762
758 owarn << "Beaming: " << beamFilename << oendl; 763 owarn << "Beaming: " << beamFilename << oendl;
759*/ 764*/
760 765
761#if 0 766#if 0
762 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 767 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
763 768
764 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 769 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
765 770
766 QString name = "contact.vcf"; 771 QString name = "contact.vcf";
767 772
768 QString fileName = dirName + "/" + name; 773 QString fileName = dirName + "/" + name;
769#endif 774#endif
770 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 775 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
771 // 776 //
772 QString fileName = "/tmp/kapibeamfile.vcf"; 777 QString fileName = "/tmp/kapibeamfile.vcf";
773 778
774 779
775 //QDir().mkdir( dirName, true ); 780 //QDir().mkdir( dirName, true );
776 781
777 782
778 KABC::VCardConverter converter; 783 KABC::VCardConverter converter;
779 QString description; 784 QString description;
780 QString datastream; 785 QString datastream;
781 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 786 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
782 KABC::Addressee a = mAddressBook->findByUid( *it ); 787 KABC::Addressee a = mAddressBook->findByUid( *it );
783 788
784 if ( a.isEmpty() ) 789 if ( a.isEmpty() )
785 continue; 790 continue;
786 791
787 if (description.isEmpty()) 792 if (description.isEmpty())
788 description = a.formattedName(); 793 description = a.formattedName();
789 794
790 QString vcard; 795 QString vcard;
791 converter.addresseeToVCard( a, vcard ); 796 converter.addresseeToVCard( a, vcard );
792 int start = 0; 797 int start = 0;
793 int next; 798 int next;
794 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 799 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
795 int semi = vcard.find(";", next); 800 int semi = vcard.find(";", next);
796 int dopp = vcard.find(":", next); 801 int dopp = vcard.find(":", next);
797 int sep; 802 int sep;
798 if ( semi < dopp && semi >= 0 ) 803 if ( semi < dopp && semi >= 0 )
799 sep = semi ; 804 sep = semi ;
800 else 805 else
801 sep = dopp; 806 sep = dopp;
802 datastream +=vcard.mid( start, next - start); 807 datastream +=vcard.mid( start, next - start);
803 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 808 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
804 start = sep; 809 start = sep;
805 } 810 }
806 datastream += vcard.mid( start,vcard.length() ); 811 datastream += vcard.mid( start,vcard.length() );
807 } 812 }
808#ifndef DESKTOP_VERSION 813#ifndef DESKTOP_VERSION
809 QFile outFile(fileName); 814 QFile outFile(fileName);
810 if ( outFile.open(IO_WriteOnly) ) { 815 if ( outFile.open(IO_WriteOnly) ) {
811 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 816 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
812 QTextStream t( &outFile ); // use a text stream 817 QTextStream t( &outFile ); // use a text stream
813 //t.setEncoding( QTextStream::UnicodeUTF8 ); 818 //t.setEncoding( QTextStream::UnicodeUTF8 );
814 t.setEncoding( QTextStream::Latin1 ); 819 t.setEncoding( QTextStream::Latin1 );
815 t <<datastream.latin1(); 820 t <<datastream.latin1();
816 outFile.close(); 821 outFile.close();
817 Ir *ir = new Ir( this ); 822 Ir *ir = new Ir( this );
818 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 823 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
819 ir->send( fileName, description, "text/x-vCard" ); 824 ir->send( fileName, description, "text/x-vCard" );
820 } else { 825 } else {
821 qDebug("Error open temp beam file "); 826 qDebug("Error open temp beam file ");
822 return; 827 return;
823 } 828 }
824#endif 829#endif
825 830
826} 831}
827 832
828void KABCore::beamDone( Ir *ir ) 833void KABCore::beamDone( Ir *ir )
829{ 834{
830#ifndef DESKTOP_VERSION 835#ifndef DESKTOP_VERSION
831 delete ir; 836 delete ir;
832#endif 837#endif
833 topLevelWidget()->raise(); 838 topLevelWidget()->raise();
834 message( i18n("Beaming successful!") ); 839 message( i18n("Beaming finished!") );
835} 840}
836 841
837 842
838void KABCore::browse( const QString& url ) 843void KABCore::browse( const QString& url )
839{ 844{
840#ifndef KAB_EMBEDDED 845#ifndef KAB_EMBEDDED
841 kapp->invokeBrowser( url ); 846 kapp->invokeBrowser( url );
842#else //KAB_EMBEDDED 847#else //KAB_EMBEDDED
843 qDebug("KABCore::browse must be fixed"); 848 qDebug("KABCore::browse must be fixed");
844#endif //KAB_EMBEDDED 849#endif //KAB_EMBEDDED
845} 850}
846 851
847void KABCore::selectAllContacts() 852void KABCore::selectAllContacts()
848{ 853{
849 mViewManager->setSelected( QString::null, true ); 854 mViewManager->setSelected( QString::null, true );
850} 855}
851 856
852void KABCore::deleteContacts() 857void KABCore::deleteContacts()
853{ 858{
854 QStringList uidList = mViewManager->selectedUids(); 859 QStringList uidList = mViewManager->selectedUids();
855 deleteContacts( uidList ); 860 deleteContacts( uidList );
856} 861}
857 862
858void KABCore::deleteContacts( const QStringList &uids ) 863void KABCore::deleteContacts( const QStringList &uids )
859{ 864{
860 if ( uids.count() > 0 ) { 865 if ( uids.count() > 0 ) {
861 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 866 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
862 UndoStack::instance()->push( command ); 867 UndoStack::instance()->push( command );
863 RedoStack::instance()->clear(); 868 RedoStack::instance()->clear();
864 869
865 // now if we deleted anything, refresh 870 // now if we deleted anything, refresh
866 setContactSelected( QString::null ); 871 setContactSelected( QString::null );
867 setModified( true ); 872 setModified( true );
868 } 873 }
869} 874}
870 875
871void KABCore::copyContacts() 876void KABCore::copyContacts()
872{ 877{
873 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 878 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
874 879
875 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 880 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
876 881
877 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 882 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
878 883
879 QClipboard *cb = QApplication::clipboard(); 884 QClipboard *cb = QApplication::clipboard();
880 cb->setText( clipText ); 885 cb->setText( clipText );
881} 886}
882 887
883void KABCore::cutContacts() 888void KABCore::cutContacts()
884{ 889{
885 QStringList uidList = mViewManager->selectedUids(); 890 QStringList uidList = mViewManager->selectedUids();
886 891
887//US if ( uidList.size() > 0 ) { 892//US if ( uidList.size() > 0 ) {
888 if ( uidList.count() > 0 ) { 893 if ( uidList.count() > 0 ) {
889 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 894 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
890 UndoStack::instance()->push( command ); 895 UndoStack::instance()->push( command );
891 RedoStack::instance()->clear(); 896 RedoStack::instance()->clear();
892 897
893 setModified( true ); 898 setModified( true );
894 } 899 }
895} 900}
896 901
897void KABCore::pasteContacts() 902void KABCore::pasteContacts()
898{ 903{
899 QClipboard *cb = QApplication::clipboard(); 904 QClipboard *cb = QApplication::clipboard();
900 905
901 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 906 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
902 907
903 pasteContacts( list ); 908 pasteContacts( list );
904} 909}
905 910
906void KABCore::pasteContacts( KABC::Addressee::List &list ) 911void KABCore::pasteContacts( KABC::Addressee::List &list )
907{ 912{
908 KABC::Resource *resource = requestResource( this ); 913 KABC::Resource *resource = requestResource( this );
909 KABC::Addressee::List::Iterator it; 914 KABC::Addressee::List::Iterator it;
910 for ( it = list.begin(); it != list.end(); ++it ) 915 for ( it = list.begin(); it != list.end(); ++it )
911 (*it).setResource( resource ); 916 (*it).setResource( resource );
912 917
913 PwPasteCommand *command = new PwPasteCommand( this, list ); 918 PwPasteCommand *command = new PwPasteCommand( this, list );
914 UndoStack::instance()->push( command ); 919 UndoStack::instance()->push( command );
915 RedoStack::instance()->clear(); 920 RedoStack::instance()->clear();
916 921
917 setModified( true ); 922 setModified( true );
918} 923}
919 924
920void KABCore::setWhoAmI() 925void KABCore::setWhoAmI()
921{ 926{
922 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 927 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
923 928
924 if ( addrList.count() > 1 ) { 929 if ( addrList.count() > 1 ) {
925 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 930 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
926 return; 931 return;
927 } 932 }
928 933
929 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 934 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
930 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 935 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
931 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 936 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
932} 937}
933 938
934void KABCore::setCategories() 939void KABCore::setCategories()
935{ 940{
936 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 941 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
937 if ( !dlg.exec() ) 942 if ( !dlg.exec() )
938 return; 943 return;
939 944
940 bool merge = false; 945 bool merge = false;
941 QString msg = i18n( "Merge with existing categories?" ); 946 QString msg = i18n( "Merge with existing categories?" );
942 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 947 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
943 merge = true; 948 merge = true;
944 949
945 QStringList categories = dlg.selectedCategories(); 950 QStringList categories = dlg.selectedCategories();
946 951
947 QStringList uids = mViewManager->selectedUids(); 952 QStringList uids = mViewManager->selectedUids();
948 QStringList::Iterator it; 953 QStringList::Iterator it;
949 for ( it = uids.begin(); it != uids.end(); ++it ) { 954 for ( it = uids.begin(); it != uids.end(); ++it ) {
950 KABC::Addressee addr = mAddressBook->findByUid( *it ); 955 KABC::Addressee addr = mAddressBook->findByUid( *it );
951 if ( !addr.isEmpty() ) { 956 if ( !addr.isEmpty() ) {
952 if ( !merge ) 957 if ( !merge )
953 addr.setCategories( categories ); 958 addr.setCategories( categories );
954 else { 959 else {
955 QStringList addrCategories = addr.categories(); 960 QStringList addrCategories = addr.categories();
956 QStringList::Iterator catIt; 961 QStringList::Iterator catIt;
957 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 962 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
958 if ( !addrCategories.contains( *catIt ) ) 963 if ( !addrCategories.contains( *catIt ) )
959 addrCategories.append( *catIt ); 964 addrCategories.append( *catIt );
960 } 965 }
961 addr.setCategories( addrCategories ); 966 addr.setCategories( addrCategories );
962 } 967 }
963 968
964 mAddressBook->insertAddressee( addr ); 969 mAddressBook->insertAddressee( addr );
965 } 970 }
966 } 971 }
967 972
968 if ( uids.count() > 0 ) 973 if ( uids.count() > 0 )
969 setModified( true ); 974 setModified( true );
970} 975}
971 976
972void KABCore::setSearchFields( const KABC::Field::List &fields ) 977void KABCore::setSearchFields( const KABC::Field::List &fields )
973{ 978{
974 mIncSearchWidget->setFields( fields ); 979 mIncSearchWidget->setFields( fields );
975} 980}
976 981
977void KABCore::incrementalSearch( const QString& text ) 982void KABCore::incrementalSearch( const QString& text )
978{ 983{
979 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 984 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
980} 985}
981 986
982void KABCore::setModified() 987void KABCore::setModified()
983{ 988{
984 setModified( true ); 989 setModified( true );
985} 990}
986 991
987void KABCore::setModifiedWOrefresh() 992void KABCore::setModifiedWOrefresh()
988{ 993{
989 // qDebug("KABCore::setModifiedWOrefresh() "); 994 // qDebug("KABCore::setModifiedWOrefresh() ");
990 mModified = true; 995 mModified = true;
991 mActionSave->setEnabled( mModified ); 996 mActionSave->setEnabled( mModified );
992#ifdef DESKTOP_VERSION 997#ifdef DESKTOP_VERSION
993 mDetails->refreshView(); 998 mDetails->refreshView();
994#endif 999#endif
995 1000
996} 1001}
997void KABCore::setModified( bool modified ) 1002void KABCore::setModified( bool modified )
998{ 1003{
999 mModified = modified; 1004 mModified = modified;
1000 mActionSave->setEnabled( mModified ); 1005 mActionSave->setEnabled( mModified );
1001 1006
1002 if ( modified ) 1007 if ( modified )
1003 mJumpButtonBar->recreateButtons(); 1008 mJumpButtonBar->recreateButtons();
1004 1009
1005 mViewManager->refreshView(); 1010 mViewManager->refreshView();
1006 mDetails->refreshView(); 1011 mDetails->refreshView();
1007 1012
1008} 1013}
1009 1014
1010bool KABCore::modified() const 1015bool KABCore::modified() const
1011{ 1016{
1012 return mModified; 1017 return mModified;
1013} 1018}
1014 1019
1015void KABCore::contactModified( const KABC::Addressee &addr ) 1020void KABCore::contactModified( const KABC::Addressee &addr )
1016{ 1021{
1017 1022
1018 Command *command = 0; 1023 Command *command = 0;
1019 QString uid; 1024 QString uid;
1020 1025
1021 // check if it exists already 1026 // check if it exists already
1022 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1027 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1023 if ( origAddr.isEmpty() ) 1028 if ( origAddr.isEmpty() )
1024 command = new PwNewCommand( mAddressBook, addr ); 1029 command = new PwNewCommand( mAddressBook, addr );
1025 else { 1030 else {
1026 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1031 command = new PwEditCommand( mAddressBook, origAddr, addr );
1027 uid = addr.uid(); 1032 uid = addr.uid();
1028 } 1033 }
1029 1034
1030 UndoStack::instance()->push( command ); 1035 UndoStack::instance()->push( command );
1031 RedoStack::instance()->clear(); 1036 RedoStack::instance()->clear();
1032 1037
1033 setModified( true ); 1038 setModified( true );
1034} 1039}
1035 1040
1036void KABCore::newContact() 1041void KABCore::newContact()
1037{ 1042{
1038 1043
1039 1044
1040 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1045 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1041 1046
1042 QPtrList<KRES::Resource> kresResources; 1047 QPtrList<KRES::Resource> kresResources;
1043 QPtrListIterator<KABC::Resource> it( kabcResources ); 1048 QPtrListIterator<KABC::Resource> it( kabcResources );
1044 KABC::Resource *resource; 1049 KABC::Resource *resource;
1045 while ( ( resource = it.current() ) != 0 ) { 1050 while ( ( resource = it.current() ) != 0 ) {
1046 ++it; 1051 ++it;
1047 if ( !resource->readOnly() ) { 1052 if ( !resource->readOnly() ) {
1048 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1053 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1049 if ( res ) 1054 if ( res )
1050 kresResources.append( res ); 1055 kresResources.append( res );
1051 } 1056 }
1052 } 1057 }
1053 1058
1054 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1059 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1055 resource = static_cast<KABC::Resource*>( res ); 1060 resource = static_cast<KABC::Resource*>( res );
1056 1061
1057 if ( resource ) { 1062 if ( resource ) {
1058 KABC::Addressee addr; 1063 KABC::Addressee addr;
1059 addr.setResource( resource ); 1064 addr.setResource( resource );
1060 mEditorDialog->setAddressee( addr ); 1065 mEditorDialog->setAddressee( addr );
1061 KApplication::execDialog ( mEditorDialog ); 1066 KApplication::execDialog ( mEditorDialog );
1062 1067
1063 } else 1068 } else
1064 return; 1069 return;
1065 1070
1066 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1071 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1067 1072
1068 1073
1069} 1074}
1070 1075
1071void KABCore::addEmail( QString aStr ) 1076void KABCore::addEmail( QString aStr )
1072{ 1077{
1073#ifndef KAB_EMBEDDED 1078#ifndef KAB_EMBEDDED
1074 QString fullName, email; 1079 QString fullName, email;
1075 1080
1076 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1081 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1077 1082
1078 // Try to lookup the addressee matching the email address 1083 // Try to lookup the addressee matching the email address
1079 bool found = false; 1084 bool found = false;
1080 QStringList emailList; 1085 QStringList emailList;
1081 KABC::AddressBook::Iterator it; 1086 KABC::AddressBook::Iterator it;
1082 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1087 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1083 emailList = (*it).emails(); 1088 emailList = (*it).emails();
1084 if ( emailList.contains( email ) > 0 ) { 1089 if ( emailList.contains( email ) > 0 ) {
1085 found = true; 1090 found = true;
1086 (*it).setNameFromString( fullName ); 1091 (*it).setNameFromString( fullName );
1087 editContact( (*it).uid() ); 1092 editContact( (*it).uid() );
1088 } 1093 }
1089 } 1094 }
1090 1095
1091 if ( !found ) { 1096 if ( !found ) {
1092 KABC::Addressee addr; 1097 KABC::Addressee addr;
1093 addr.setNameFromString( fullName ); 1098 addr.setNameFromString( fullName );
1094 addr.insertEmail( email, true ); 1099 addr.insertEmail( email, true );
1095 1100
1096 mAddressBook->insertAddressee( addr ); 1101 mAddressBook->insertAddressee( addr );
1097 mViewManager->refreshView( addr.uid() ); 1102 mViewManager->refreshView( addr.uid() );
1098 editContact( addr.uid() ); 1103 editContact( addr.uid() );
1099 } 1104 }
1100#else //KAB_EMBEDDED 1105#else //KAB_EMBEDDED
1101 qDebug("KABCore::addEmail finsih method"); 1106 qDebug("KABCore::addEmail finsih method");
1102#endif //KAB_EMBEDDED 1107#endif //KAB_EMBEDDED
1103} 1108}
1104 1109
1105void KABCore::importVCard( const KURL &url, bool showPreview ) 1110void KABCore::importVCard( const KURL &url, bool showPreview )
1106{ 1111{
1107 mXXPortManager->importVCard( url, showPreview ); 1112 mXXPortManager->importVCard( url, showPreview );
1108} 1113}
1109void KABCore::importFromOL() 1114void KABCore::importFromOL()
1110{ 1115{
1111#ifdef _WIN32_ 1116#ifdef _WIN32_
1112 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1117 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1113 idgl->exec(); 1118 idgl->exec();
1114 KABC::Addressee::List list = idgl->getAddressList(); 1119 KABC::Addressee::List list = idgl->getAddressList();
1115 if ( list.count() > 0 ) { 1120 if ( list.count() > 0 ) {
1116 KABC::Addressee::List listNew; 1121 KABC::Addressee::List listNew;
1117 KABC::Addressee::List listExisting; 1122 KABC::Addressee::List listExisting;
1118 KABC::Addressee::List::Iterator it; 1123 KABC::Addressee::List::Iterator it;
1119 KABC::AddressBook::Iterator iter; 1124 KABC::AddressBook::Iterator iter;
1120 for ( it = list.begin(); it != list.end(); ++it ) { 1125 for ( it = list.begin(); it != list.end(); ++it ) {
1121 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1126 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1122 listNew.append( (*it) ); 1127 listNew.append( (*it) );
1123 else 1128 else
1124 listExisting.append( (*it) ); 1129 listExisting.append( (*it) );
1125 } 1130 }
1126 if ( listExisting.count() > 0 ) 1131 if ( listExisting.count() > 0 )
1127 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1132 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1128 if ( listNew.count() > 0 ) { 1133 if ( listNew.count() > 0 ) {
1129 pasteWithNewUid = false; 1134 pasteWithNewUid = false;
1130 pasteContacts( listNew ); 1135 pasteContacts( listNew );
1131 pasteWithNewUid = true; 1136 pasteWithNewUid = true;
1132 } 1137 }
1133 } 1138 }
1134 delete idgl; 1139 delete idgl;
1135#endif 1140#endif
1136} 1141}
1137 1142
1138void KABCore::importVCard( const QString &vCard, bool showPreview ) 1143void KABCore::importVCard( const QString &vCard, bool showPreview )
1139{ 1144{
1140 mXXPortManager->importVCard( vCard, showPreview ); 1145 mXXPortManager->importVCard( vCard, showPreview );
1141} 1146}
1142 1147
1143//US added a second method without defaultparameter 1148//US added a second method without defaultparameter
1144void KABCore::editContact2() { 1149void KABCore::editContact2() {
1145 editContact( QString::null ); 1150 editContact( QString::null );
1146} 1151}
1147 1152
1148void KABCore::editContact( const QString &uid ) 1153void KABCore::editContact( const QString &uid )
1149{ 1154{
1150 1155
1151 if ( mExtensionManager->isQuickEditVisible() ) 1156 if ( mExtensionManager->isQuickEditVisible() )
1152 return; 1157 return;
1153 1158
1154 // First, locate the contact entry 1159 // First, locate the contact entry
1155 QString localUID = uid; 1160 QString localUID = uid;
1156 if ( localUID.isNull() ) { 1161 if ( localUID.isNull() ) {
1157 QStringList uidList = mViewManager->selectedUids(); 1162 QStringList uidList = mViewManager->selectedUids();
1158 if ( uidList.count() > 0 ) 1163 if ( uidList.count() > 0 )
1159 localUID = *( uidList.at( 0 ) ); 1164 localUID = *( uidList.at( 0 ) );
1160 } 1165 }
1161 1166
1162 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1167 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1163 if ( !addr.isEmpty() ) { 1168 if ( !addr.isEmpty() ) {
1164 mEditorDialog->setAddressee( addr ); 1169 mEditorDialog->setAddressee( addr );
1165 KApplication::execDialog ( mEditorDialog ); 1170 KApplication::execDialog ( mEditorDialog );
1166 } 1171 }
1167} 1172}
1168 1173
1169/** 1174/**
1170 Shows or edits the detail view for the given uid. If the uid is QString::null, 1175 Shows or edits the detail view for the given uid. If the uid is QString::null,
1171 the method will try to find a selected addressee in the view. 1176 the method will try to find a selected addressee in the view.
1172 */ 1177 */
1173void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1178void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1174{ 1179{
1175 if ( mMultipleViewsAtOnce ) 1180 if ( mMultipleViewsAtOnce )
1176 { 1181 {
1177 editContact( uid ); 1182 editContact( uid );
1178 } 1183 }
1179 else 1184 else
1180 { 1185 {
1181 setDetailsVisible( true ); 1186 setDetailsVisible( true );
1182 mActionDetails->setChecked(true); 1187 mActionDetails->setChecked(true);
1183 } 1188 }
1184 1189
1185} 1190}
1186 1191
1187void KABCore::save() 1192void KABCore::save()
1188{ 1193{
1189 if (syncManager->blockSave()) 1194 if (syncManager->blockSave())
1190 return; 1195 return;
1191 if ( !mModified ) 1196 if ( !mModified )
1192 return; 1197 return;
1193 1198
1194 syncManager->setBlockSave(true); 1199 syncManager->setBlockSave(true);
1195 QString text = i18n( "There was an error while attempting to save\n the " 1200 QString text = i18n( "There was an error while attempting to save\n the "
1196 "address book. Please check that some \nother application is " 1201 "address book. Please check that some \nother application is "
1197 "not using it. " ); 1202 "not using it. " );
1198 statusMessage(i18n("Saving addressbook ... ")); 1203 message(i18n("Saving addressbook ... "));
1199#ifndef KAB_EMBEDDED 1204#ifndef KAB_EMBEDDED
1200 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1205 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1201 if ( !b || !b->save() ) { 1206 if ( !b || !b->save() ) {
1202 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1207 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1203 } 1208 }
1204#else //KAB_EMBEDDED 1209#else //KAB_EMBEDDED
1205 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1210 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1206 if ( !b || !b->save() ) { 1211 if ( !b || !b->save() ) {
1207 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1212 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1208 } 1213 }
1209#endif //KAB_EMBEDDED 1214#endif //KAB_EMBEDDED
1210 1215
1211 statusMessage(i18n("Addressbook saved!")); 1216 message(i18n("Addressbook saved!"));
1212 setModified( false ); 1217 setModified( false );
1213 syncManager->setBlockSave(false); 1218 syncManager->setBlockSave(false);
1214} 1219}
1215 1220
1216void KABCore::statusMessage(QString mess , int time ) 1221
1217{
1218 //topLevelWidget()->setCaption( mess );
1219 // pending setting timer to revome message
1220}
1221void KABCore::undo() 1222void KABCore::undo()
1222{ 1223{
1223 UndoStack::instance()->undo(); 1224 UndoStack::instance()->undo();
1224 1225
1225 // Refresh the view 1226 // Refresh the view
1226 mViewManager->refreshView(); 1227 mViewManager->refreshView();
1227} 1228}
1228 1229
1229void KABCore::redo() 1230void KABCore::redo()
1230{ 1231{
1231 RedoStack::instance()->redo(); 1232 RedoStack::instance()->redo();
1232 1233
1233 // Refresh the view 1234 // Refresh the view
1234 mViewManager->refreshView(); 1235 mViewManager->refreshView();
1235} 1236}
1236 1237
1237void KABCore::setJumpButtonBarVisible( bool visible ) 1238void KABCore::setJumpButtonBarVisible( bool visible )
1238{ 1239{
1239 if (mMultipleViewsAtOnce) 1240 if (mMultipleViewsAtOnce)
1240 { 1241 {
1241 if ( visible ) 1242 if ( visible )
1242 mJumpButtonBar->show(); 1243 mJumpButtonBar->show();
1243 else 1244 else
1244 mJumpButtonBar->hide(); 1245 mJumpButtonBar->hide();
1245 } 1246 }
1246 else 1247 else
1247 { 1248 {
1248 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1249 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1249 if (mViewManager->isVisible()) 1250 if (mViewManager->isVisible())
1250 { 1251 {
1251 if ( visible ) 1252 if ( visible )
1252 mJumpButtonBar->show(); 1253 mJumpButtonBar->show();
1253 else 1254 else
1254 mJumpButtonBar->hide(); 1255 mJumpButtonBar->hide();
1255 } 1256 }
1256 else 1257 else
1257 { 1258 {
1258 mJumpButtonBar->hide(); 1259 mJumpButtonBar->hide();
1259 } 1260 }
1260 } 1261 }
1261} 1262}
1262 1263
1263 1264
1264void KABCore::setDetailsToState() 1265void KABCore::setDetailsToState()
1265{ 1266{
1266 setDetailsVisible( mActionDetails->isChecked() ); 1267 setDetailsVisible( mActionDetails->isChecked() );
1267} 1268}
1268 1269
1269 1270
1270 1271
1271void KABCore::setDetailsVisible( bool visible ) 1272void KABCore::setDetailsVisible( bool visible )
1272{ 1273{
1273 if (visible && mDetails->isHidden()) 1274 if (visible && mDetails->isHidden())
1274 { 1275 {
1275 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1276 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1276 if ( addrList.count() > 0 ) 1277 if ( addrList.count() > 0 )
1277 mDetails->setAddressee( addrList[ 0 ] ); 1278 mDetails->setAddressee( addrList[ 0 ] );
1278 } 1279 }
1279 1280
1280 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1281 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1281 // the listview and the detailview. We do that by changing the splitbar size. 1282 // the listview and the detailview. We do that by changing the splitbar size.
1282 if (mMultipleViewsAtOnce) 1283 if (mMultipleViewsAtOnce)
1283 { 1284 {
1284 if ( visible ) 1285 if ( visible )
1285 mDetails->show(); 1286 mDetails->show();
1286 else 1287 else
1287 mDetails->hide(); 1288 mDetails->hide();
1288 } 1289 }
1289 else 1290 else
1290 { 1291 {
1291 if ( visible ) { 1292 if ( visible ) {
1292 mViewManager->hide(); 1293 mViewManager->hide();
1293 mDetails->show(); 1294 mDetails->show();
1294 } 1295 }
1295 else { 1296 else {
1296 mViewManager->show(); 1297 mViewManager->show();
1297 mDetails->hide(); 1298 mDetails->hide();
1298 } 1299 }
1299 setJumpButtonBarVisible( !visible ); 1300 setJumpButtonBarVisible( !visible );
1300 } 1301 }
1301 1302
1302} 1303}
1303 1304
1304void KABCore::extensionChanged( int id ) 1305void KABCore::extensionChanged( int id )
1305{ 1306{
1306 //change the details view only for non desktop systems 1307 //change the details view only for non desktop systems
1307#ifndef DESKTOP_VERSION 1308#ifndef DESKTOP_VERSION
1308 1309
1309 if (id == 0) 1310 if (id == 0)
1310 { 1311 {
1311 //the user disabled the extension. 1312 //the user disabled the extension.
1312 1313
1313 if (mMultipleViewsAtOnce) 1314 if (mMultipleViewsAtOnce)
1314 { // enable detailsview again 1315 { // enable detailsview again
1315 setDetailsVisible( true ); 1316 setDetailsVisible( true );
1316 mActionDetails->setChecked( true ); 1317 mActionDetails->setChecked( true );
1317 } 1318 }
1318 else 1319 else
1319 { //go back to the listview 1320 { //go back to the listview
1320 setDetailsVisible( false ); 1321 setDetailsVisible( false );
1321 mActionDetails->setChecked( false ); 1322 mActionDetails->setChecked( false );
1322 mActionDetails->setEnabled(true); 1323 mActionDetails->setEnabled(true);
1323 } 1324 }
1324 1325
1325 } 1326 }
1326 else 1327 else
1327 { 1328 {
1328 //the user enabled the extension. 1329 //the user enabled the extension.
1329 setDetailsVisible( false ); 1330 setDetailsVisible( false );
1330 mActionDetails->setChecked( false ); 1331 mActionDetails->setChecked( false );
1331 1332
1332 if (!mMultipleViewsAtOnce) 1333 if (!mMultipleViewsAtOnce)
1333 { 1334 {
1334 mActionDetails->setEnabled(false); 1335 mActionDetails->setEnabled(false);
1335 } 1336 }
1336 1337
1337 mExtensionManager->setSelectionChanged(); 1338 mExtensionManager->setSelectionChanged();
1338 1339
1339 } 1340 }
1340 1341
1341#endif// DESKTOP_VERSION 1342#endif// DESKTOP_VERSION
1342 1343
1343} 1344}
1344 1345
1345 1346
1346void KABCore::extensionModified( const KABC::Addressee::List &list ) 1347void KABCore::extensionModified( const KABC::Addressee::List &list )
1347{ 1348{
1348 1349
1349 if ( list.count() != 0 ) { 1350 if ( list.count() != 0 ) {
1350 KABC::Addressee::List::ConstIterator it; 1351 KABC::Addressee::List::ConstIterator it;
1351 for ( it = list.begin(); it != list.end(); ++it ) 1352 for ( it = list.begin(); it != list.end(); ++it )
1352 mAddressBook->insertAddressee( *it ); 1353 mAddressBook->insertAddressee( *it );
1353 if ( list.count() > 1 ) 1354 if ( list.count() > 1 )
1354 setModified(); 1355 setModified();
1355 else 1356 else
1356 setModifiedWOrefresh(); 1357 setModifiedWOrefresh();
1357 } 1358 }
1358 if ( list.count() == 0 ) 1359 if ( list.count() == 0 )
1359 mViewManager->refreshView(); 1360 mViewManager->refreshView();
1360 else 1361 else
1361 mViewManager->refreshView( list[ 0 ].uid() ); 1362 mViewManager->refreshView( list[ 0 ].uid() );
1362 1363
1363 1364
1364 1365
1365} 1366}
1366 1367
1367QString KABCore::getNameByPhone( const QString &phone ) 1368QString KABCore::getNameByPhone( const QString &phone )
1368{ 1369{
1369#ifndef KAB_EMBEDDED 1370#ifndef KAB_EMBEDDED
1370 QRegExp r( "[/*/-/ ]" ); 1371 QRegExp r( "[/*/-/ ]" );
1371 QString localPhone( phone ); 1372 QString localPhone( phone );
1372 1373
1373 bool found = false; 1374 bool found = false;
1374 QString ownerName = ""; 1375 QString ownerName = "";
1375 KABC::AddressBook::Iterator iter; 1376 KABC::AddressBook::Iterator iter;
1376 KABC::PhoneNumber::List::Iterator phoneIter; 1377 KABC::PhoneNumber::List::Iterator phoneIter;
1377 KABC::PhoneNumber::List phoneList; 1378 KABC::PhoneNumber::List phoneList;
1378 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1379 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1379 phoneList = (*iter).phoneNumbers(); 1380 phoneList = (*iter).phoneNumbers();
1380 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1381 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1381 ++phoneIter) { 1382 ++phoneIter) {
1382 // Get rid of separator chars so just the numbers are compared. 1383 // Get rid of separator chars so just the numbers are compared.
1383 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1384 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1384 ownerName = (*iter).formattedName(); 1385 ownerName = (*iter).formattedName();
1385 found = true; 1386 found = true;
1386 } 1387 }
1387 } 1388 }
1388 } 1389 }
1389 1390
1390 return ownerName; 1391 return ownerName;
1391#else //KAB_EMBEDDED 1392#else //KAB_EMBEDDED
1392 qDebug("KABCore::getNameByPhone finsih method"); 1393 qDebug("KABCore::getNameByPhone finsih method");
1393 return ""; 1394 return "";
1394#endif //KAB_EMBEDDED 1395#endif //KAB_EMBEDDED
1395 1396
1396} 1397}
1397 1398
1398void KABCore::openConfigDialog() 1399void KABCore::openConfigDialog()
1399{ 1400{
1400 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1401 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1401 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1402 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1402 ConfigureDialog->addModule(kabcfg ); 1403 ConfigureDialog->addModule(kabcfg );
1403 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1404 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1404 ConfigureDialog->addModule(kdelibcfg ); 1405 ConfigureDialog->addModule(kdelibcfg );
1405 1406
1406 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1407 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1407 this, SLOT( configurationChanged() ) ); 1408 this, SLOT( configurationChanged() ) );
1408 connect( ConfigureDialog, SIGNAL( okClicked() ), 1409 connect( ConfigureDialog, SIGNAL( okClicked() ),
1409 this, SLOT( configurationChanged() ) ); 1410 this, SLOT( configurationChanged() ) );
1410 saveSettings(); 1411 saveSettings();
1411#ifndef DESKTOP_VERSION 1412#ifndef DESKTOP_VERSION
1412 ConfigureDialog->showMaximized(); 1413 ConfigureDialog->showMaximized();
1413#endif 1414#endif
1414 if ( ConfigureDialog->exec() ) 1415 if ( ConfigureDialog->exec() )
1415 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1416 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1416 delete ConfigureDialog; 1417 delete ConfigureDialog;
1417} 1418}
1418 1419
1419void KABCore::openLDAPDialog() 1420void KABCore::openLDAPDialog()
1420{ 1421{
1421#ifndef KAB_EMBEDDED 1422#ifndef KAB_EMBEDDED
1422 if ( !mLdapSearchDialog ) { 1423 if ( !mLdapSearchDialog ) {
1423 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1424 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1424 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1425 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1425 SLOT( refreshView() ) ); 1426 SLOT( refreshView() ) );
1426 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1427 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1427 SLOT( setModified() ) ); 1428 SLOT( setModified() ) );
1428 } else 1429 } else
1429 mLdapSearchDialog->restoreSettings(); 1430 mLdapSearchDialog->restoreSettings();
1430 1431
1431 if ( mLdapSearchDialog->isOK() ) 1432 if ( mLdapSearchDialog->isOK() )
1432 mLdapSearchDialog->exec(); 1433 mLdapSearchDialog->exec();
1433#else //KAB_EMBEDDED 1434#else //KAB_EMBEDDED
1434 qDebug("KABCore::openLDAPDialog() finsih method"); 1435 qDebug("KABCore::openLDAPDialog() finsih method");
1435#endif //KAB_EMBEDDED 1436#endif //KAB_EMBEDDED
1436} 1437}
1437 1438
1438void KABCore::print() 1439void KABCore::print()
1439{ 1440{
1440#ifndef KAB_EMBEDDED 1441#ifndef KAB_EMBEDDED
1441 KPrinter printer; 1442 KPrinter printer;
1442 if ( !printer.setup( this ) ) 1443 if ( !printer.setup( this ) )
1443 return; 1444 return;
1444 1445
1445 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1446 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1446 mViewManager->selectedUids(), this ); 1447 mViewManager->selectedUids(), this );
1447 1448
1448 wizard.exec(); 1449 wizard.exec();
1449#else //KAB_EMBEDDED 1450#else //KAB_EMBEDDED
1450 qDebug("KABCore::print() finsih method"); 1451 qDebug("KABCore::print() finsih method");
1451#endif //KAB_EMBEDDED 1452#endif //KAB_EMBEDDED
1452 1453
1453} 1454}
1454 1455
1455 1456
1456void KABCore::addGUIClient( KXMLGUIClient *client ) 1457void KABCore::addGUIClient( KXMLGUIClient *client )
1457{ 1458{
1458 if ( mGUIClient ) 1459 if ( mGUIClient )
1459 mGUIClient->insertChildClient( client ); 1460 mGUIClient->insertChildClient( client );
1460 else 1461 else
1461 KMessageBox::error( this, "no KXMLGUICLient"); 1462 KMessageBox::error( this, "no KXMLGUICLient");
1462} 1463}
1463 1464
1464 1465
1465void KABCore::configurationChanged() 1466void KABCore::configurationChanged()
1466{ 1467{
1467 mExtensionManager->reconfigure(); 1468 mExtensionManager->reconfigure();
1468} 1469}
1469 1470
1470void KABCore::addressBookChanged() 1471void KABCore::addressBookChanged()
1471{ 1472{
1472/*US 1473/*US
1473 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1474 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1474 while ( it.current() ) { 1475 while ( it.current() ) {
1475 if ( it.current()->dirty() ) { 1476 if ( it.current()->dirty() ) {
1476 QString text = i18n( "Data has been changed externally. Unsaved " 1477 QString text = i18n( "Data has been changed externally. Unsaved "
@@ -1902,513 +1903,513 @@ void KABCore::addActionsManually()
1902 mb->insertItem( "&Help", helpMenu ); 1903 mb->insertItem( "&Help", helpMenu );
1903 mIncSearchWidget = new IncSearchWidget( tb ); 1904 mIncSearchWidget = new IncSearchWidget( tb );
1904 // tb->insertWidget(-1, 0, mIncSearchWidget); 1905 // tb->insertWidget(-1, 0, mIncSearchWidget);
1905 1906
1906#else 1907#else
1907 //US setup toolbar 1908 //US setup toolbar
1908 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1909 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1909 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1910 QPopupMenu *popupBarTB = new QPopupMenu( this );
1910 menuBarTB->insertItem( "ME", popupBarTB); 1911 menuBarTB->insertItem( "ME", popupBarTB);
1911 tb->insertWidget(-1, 0, menuBarTB); 1912 tb->insertWidget(-1, 0, menuBarTB);
1912 mIncSearchWidget = new IncSearchWidget( tb ); 1913 mIncSearchWidget = new IncSearchWidget( tb );
1913 1914
1914 tb->enableMoving(false); 1915 tb->enableMoving(false);
1915 popupBarTB->insertItem( "&File", fileMenu ); 1916 popupBarTB->insertItem( "&File", fileMenu );
1916 popupBarTB->insertItem( "&Edit", editMenu ); 1917 popupBarTB->insertItem( "&Edit", editMenu );
1917 popupBarTB->insertItem( "&View", viewMenu ); 1918 popupBarTB->insertItem( "&View", viewMenu );
1918 popupBarTB->insertItem( "&Settings", settingsMenu ); 1919 popupBarTB->insertItem( "&Settings", settingsMenu );
1919 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1920 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1920 mViewManager->getFilterAction()->plug ( popupBarTB); 1921 mViewManager->getFilterAction()->plug ( popupBarTB);
1921 popupBarTB->insertItem( "&Change selected", changeMenu ); 1922 popupBarTB->insertItem( "&Change selected", changeMenu );
1922 popupBarTB->insertItem( "&Help", helpMenu ); 1923 popupBarTB->insertItem( "&Help", helpMenu );
1923 if (QApplication::desktop()->width() > 320 ) { 1924 if (QApplication::desktop()->width() > 320 ) {
1924 // mViewManager->getFilterAction()->plug ( tb); 1925 // mViewManager->getFilterAction()->plug ( tb);
1925 } 1926 }
1926#endif 1927#endif
1927 // mActionQuit->plug ( mMainWindow->toolBar()); 1928 // mActionQuit->plug ( mMainWindow->toolBar());
1928 1929
1929 1930
1930 1931
1931 //US Now connect the actions with the menue entries. 1932 //US Now connect the actions with the menue entries.
1932 mActionPrint->plug( fileMenu ); 1933 mActionPrint->plug( fileMenu );
1933 mActionMail->plug( fileMenu ); 1934 mActionMail->plug( fileMenu );
1934 fileMenu->insertSeparator(); 1935 fileMenu->insertSeparator();
1935 1936
1936 mActionNewContact->plug( fileMenu ); 1937 mActionNewContact->plug( fileMenu );
1937 mActionNewContact->plug( tb ); 1938 mActionNewContact->plug( tb );
1938 1939
1939 mActionEditAddressee->plug( fileMenu ); 1940 mActionEditAddressee->plug( fileMenu );
1940 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1941 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1941 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1942 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1942 mActionEditAddressee->plug( tb ); 1943 mActionEditAddressee->plug( tb );
1943 1944
1944 fileMenu->insertSeparator(); 1945 fileMenu->insertSeparator();
1945 mActionSave->plug( fileMenu ); 1946 mActionSave->plug( fileMenu );
1946 fileMenu->insertItem( "&Import", ImportMenu ); 1947 fileMenu->insertItem( "&Import", ImportMenu );
1947 fileMenu->insertItem( "&Export", ExportMenu ); 1948 fileMenu->insertItem( "&Export", ExportMenu );
1948 fileMenu->insertSeparator(); 1949 fileMenu->insertSeparator();
1949 mActionMailVCard->plug( fileMenu ); 1950 mActionMailVCard->plug( fileMenu );
1950#ifndef DESKTOP_VERSION 1951#ifndef DESKTOP_VERSION
1951 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1952 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1952 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1953 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1953#endif 1954#endif
1954 fileMenu->insertSeparator(); 1955 fileMenu->insertSeparator();
1955 mActionQuit->plug( fileMenu ); 1956 mActionQuit->plug( fileMenu );
1956#ifdef _WIN32_ 1957#ifdef _WIN32_
1957 mActionImportOL->plug( ImportMenu ); 1958 mActionImportOL->plug( ImportMenu );
1958#endif 1959#endif
1959 // edit menu 1960 // edit menu
1960 mActionUndo->plug( editMenu ); 1961 mActionUndo->plug( editMenu );
1961 mActionRedo->plug( editMenu ); 1962 mActionRedo->plug( editMenu );
1962 editMenu->insertSeparator(); 1963 editMenu->insertSeparator();
1963 mActionCut->plug( editMenu ); 1964 mActionCut->plug( editMenu );
1964 mActionCopy->plug( editMenu ); 1965 mActionCopy->plug( editMenu );
1965 mActionPaste->plug( editMenu ); 1966 mActionPaste->plug( editMenu );
1966 mActionDelete->plug( editMenu ); 1967 mActionDelete->plug( editMenu );
1967 editMenu->insertSeparator(); 1968 editMenu->insertSeparator();
1968 mActionSelectAll->plug( editMenu ); 1969 mActionSelectAll->plug( editMenu );
1969 1970
1970 mActionRemoveVoice->plug( changeMenu ); 1971 mActionRemoveVoice->plug( changeMenu );
1971 // settings menu 1972 // settings menu
1972//US special menuentry to configure the addressbook resources. On KDE 1973//US special menuentry to configure the addressbook resources. On KDE
1973// you do that through the control center !!! 1974// you do that through the control center !!!
1974 mActionConfigResources->plug( settingsMenu ); 1975 mActionConfigResources->plug( settingsMenu );
1975 settingsMenu->insertSeparator(); 1976 settingsMenu->insertSeparator();
1976 1977
1977 mActionConfigKAddressbook->plug( settingsMenu ); 1978 mActionConfigKAddressbook->plug( settingsMenu );
1978 1979
1979 if ( mIsPart ) { 1980 if ( mIsPart ) {
1980 mActionConfigShortcuts->plug( settingsMenu ); 1981 mActionConfigShortcuts->plug( settingsMenu );
1981 mActionConfigureToolbars->plug( settingsMenu ); 1982 mActionConfigureToolbars->plug( settingsMenu );
1982 1983
1983 } else { 1984 } else {
1984 mActionKeyBindings->plug( settingsMenu ); 1985 mActionKeyBindings->plug( settingsMenu );
1985 } 1986 }
1986 1987
1987 settingsMenu->insertSeparator(); 1988 settingsMenu->insertSeparator();
1988 1989
1989 mActionJumpBar->plug( settingsMenu ); 1990 mActionJumpBar->plug( settingsMenu );
1990 mActionDetails->plug( settingsMenu ); 1991 mActionDetails->plug( settingsMenu );
1991 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1992 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1992 mActionDetails->plug( tb ); 1993 mActionDetails->plug( tb );
1993 settingsMenu->insertSeparator(); 1994 settingsMenu->insertSeparator();
1994 1995
1995 mActionWhoAmI->plug( settingsMenu ); 1996 mActionWhoAmI->plug( settingsMenu );
1996 mActionCategories->plug( settingsMenu ); 1997 mActionCategories->plug( settingsMenu );
1997 1998
1998 1999
1999 mActionWN->plug( helpMenu ); 2000 mActionWN->plug( helpMenu );
2000 mActionSyncHowto->plug( helpMenu ); 2001 mActionSyncHowto->plug( helpMenu );
2001 mActionLicence->plug( helpMenu ); 2002 mActionLicence->plug( helpMenu );
2002 mActionFaq->plug( helpMenu ); 2003 mActionFaq->plug( helpMenu );
2003 mActionAboutKAddressbook->plug( helpMenu ); 2004 mActionAboutKAddressbook->plug( helpMenu );
2004 2005
2005 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2006 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2006 2007
2007 mActionSave->plug( tb ); 2008 mActionSave->plug( tb );
2008 mViewManager->getFilterAction()->plug ( tb); 2009 mViewManager->getFilterAction()->plug ( tb);
2009 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 2010 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
2010 mActionUndo->plug( tb ); 2011 mActionUndo->plug( tb );
2011 mActionDelete->plug( tb ); 2012 mActionDelete->plug( tb );
2012 mActionRedo->plug( tb ); 2013 mActionRedo->plug( tb );
2013 } 2014 }
2014 } 2015 }
2015 //mActionQuit->plug ( tb ); 2016 //mActionQuit->plug ( tb );
2016 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2017 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2017 2018
2018 //US link the searchwidget first to this. 2019 //US link the searchwidget first to this.
2019 // The real linkage to the toolbar happens later. 2020 // The real linkage to the toolbar happens later.
2020//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2021//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2021//US tb->insertItem( mIncSearchWidget ); 2022//US tb->insertItem( mIncSearchWidget );
2022/*US 2023/*US
2023 mIncSearchWidget = new IncSearchWidget( tb ); 2024 mIncSearchWidget = new IncSearchWidget( tb );
2024 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2025 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2025 SLOT( incrementalSearch( const QString& ) ) ); 2026 SLOT( incrementalSearch( const QString& ) ) );
2026 2027
2027 mJumpButtonBar = new JumpButtonBar( this, this ); 2028 mJumpButtonBar = new JumpButtonBar( this, this );
2028 2029
2029//US topLayout->addWidget( mJumpButtonBar ); 2030//US topLayout->addWidget( mJumpButtonBar );
2030 this->layout()->add( mJumpButtonBar ); 2031 this->layout()->add( mJumpButtonBar );
2031*/ 2032*/
2032 2033
2033#endif //KAB_EMBEDDED 2034#endif //KAB_EMBEDDED
2034 2035
2035 mActionExport2phone->plug( ExportMenu ); 2036 mActionExport2phone->plug( ExportMenu );
2036 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2037 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2037 syncManager->fillSyncMenu(); 2038 syncManager->fillSyncMenu();
2038 2039
2039} 2040}
2040void KABCore::showLicence() 2041void KABCore::showLicence()
2041{ 2042{
2042 KApplication::showLicence(); 2043 KApplication::showLicence();
2043} 2044}
2044void KABCore::removeVoice() 2045void KABCore::removeVoice()
2045{ 2046{
2046 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2047 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2047 return; 2048 return;
2048 KABC::Addressee::List list = mViewManager->selectedAddressees(); 2049 KABC::Addressee::List list = mViewManager->selectedAddressees();
2049 KABC::Addressee::List::Iterator it; 2050 KABC::Addressee::List::Iterator it;
2050 for ( it = list.begin(); it != list.end(); ++it ) { 2051 for ( it = list.begin(); it != list.end(); ++it ) {
2051 2052
2052 if ( (*it).removeVoice() ) 2053 if ( (*it).removeVoice() )
2053 contactModified((*it) ); 2054 contactModified((*it) );
2054 } 2055 }
2055} 2056}
2056 2057
2057 2058
2058 2059
2059void KABCore::clipboardDataChanged() 2060void KABCore::clipboardDataChanged()
2060{ 2061{
2061 2062
2062 if ( mReadWrite ) 2063 if ( mReadWrite )
2063 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2064 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2064 2065
2065} 2066}
2066 2067
2067void KABCore::updateActionMenu() 2068void KABCore::updateActionMenu()
2068{ 2069{
2069 UndoStack *undo = UndoStack::instance(); 2070 UndoStack *undo = UndoStack::instance();
2070 RedoStack *redo = RedoStack::instance(); 2071 RedoStack *redo = RedoStack::instance();
2071 2072
2072 if ( undo->isEmpty() ) 2073 if ( undo->isEmpty() )
2073 mActionUndo->setText( i18n( "Undo" ) ); 2074 mActionUndo->setText( i18n( "Undo" ) );
2074 else 2075 else
2075 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2076 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2076 2077
2077 mActionUndo->setEnabled( !undo->isEmpty() ); 2078 mActionUndo->setEnabled( !undo->isEmpty() );
2078 2079
2079 if ( !redo->top() ) 2080 if ( !redo->top() )
2080 mActionRedo->setText( i18n( "Redo" ) ); 2081 mActionRedo->setText( i18n( "Redo" ) );
2081 else 2082 else
2082 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2083 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2083 2084
2084 mActionRedo->setEnabled( !redo->isEmpty() ); 2085 mActionRedo->setEnabled( !redo->isEmpty() );
2085} 2086}
2086 2087
2087void KABCore::configureKeyBindings() 2088void KABCore::configureKeyBindings()
2088{ 2089{
2089#ifndef KAB_EMBEDDED 2090#ifndef KAB_EMBEDDED
2090 KKeyDialog::configure( actionCollection(), true ); 2091 KKeyDialog::configure( actionCollection(), true );
2091#else //KAB_EMBEDDED 2092#else //KAB_EMBEDDED
2092 qDebug("KABCore::configureKeyBindings() not implemented"); 2093 qDebug("KABCore::configureKeyBindings() not implemented");
2093#endif //KAB_EMBEDDED 2094#endif //KAB_EMBEDDED
2094} 2095}
2095 2096
2096#ifdef KAB_EMBEDDED 2097#ifdef KAB_EMBEDDED
2097void KABCore::configureResources() 2098void KABCore::configureResources()
2098{ 2099{
2099 KRES::KCMKResources dlg( this, "" , 0 ); 2100 KRES::KCMKResources dlg( this, "" , 0 );
2100 2101
2101 if ( !dlg.exec() ) 2102 if ( !dlg.exec() )
2102 return; 2103 return;
2103 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2104 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2104} 2105}
2105#endif //KAB_EMBEDDED 2106#endif //KAB_EMBEDDED
2106 2107
2107 2108
2108/* this method will be called through the QCop interface from Ko/Pi to select addresses 2109/* this method will be called through the QCop interface from Ko/Pi to select addresses
2109 * for the attendees list of an event. 2110 * for the attendees list of an event.
2110 */ 2111 */
2111void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2112void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2112{ 2113{
2113 QStringList nameList; 2114 QStringList nameList;
2114 QStringList emailList; 2115 QStringList emailList;
2115 QStringList uidList; 2116 QStringList uidList;
2116 2117
2117 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2118 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2118 uint i=0; 2119 uint i=0;
2119 for (i=0; i < list.count(); i++) 2120 for (i=0; i < list.count(); i++)
2120 { 2121 {
2121 nameList.append(list[i].realName()); 2122 nameList.append(list[i].realName());
2122 emailList.append(list[i].preferredEmail()); 2123 emailList.append(list[i].preferredEmail());
2123 uidList.append(list[i].uid()); 2124 uidList.append(list[i].uid());
2124 } 2125 }
2125 2126
2126 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2127 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2127 2128
2128} 2129}
2129 2130
2130/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2131/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2131 * to put them into the calendar. 2132 * to put them into the calendar.
2132 */ 2133 */
2133void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2134void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2134{ 2135{
2135 // qDebug("KABCore::requestForBirthdayList"); 2136 // qDebug("KABCore::requestForBirthdayList");
2136 QStringList birthdayList; 2137 QStringList birthdayList;
2137 QStringList anniversaryList; 2138 QStringList anniversaryList;
2138 QStringList realNameList; 2139 QStringList realNameList;
2139 QStringList preferredEmailList; 2140 QStringList preferredEmailList;
2140 QStringList assembledNameList; 2141 QStringList assembledNameList;
2141 QStringList uidList; 2142 QStringList uidList;
2142 2143
2143 KABC::AddressBook::Iterator it; 2144 KABC::AddressBook::Iterator it;
2144 2145
2145 int count = 0; 2146 int count = 0;
2146 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2147 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2147 ++count; 2148 ++count;
2148 } 2149 }
2149 QProgressBar bar(count,0 ); 2150 QProgressBar bar(count,0 );
2150 int w = 300; 2151 int w = 300;
2151 if ( QApplication::desktop()->width() < 320 ) 2152 if ( QApplication::desktop()->width() < 320 )
2152 w = 220; 2153 w = 220;
2153 int h = bar.sizeHint().height() ; 2154 int h = bar.sizeHint().height() ;
2154 int dw = QApplication::desktop()->width(); 2155 int dw = QApplication::desktop()->width();
2155 int dh = QApplication::desktop()->height(); 2156 int dh = QApplication::desktop()->height();
2156 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2157 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2157 bar.show(); 2158 bar.show();
2158 bar.setCaption (i18n("collecting birthdays - close to abort!") ); 2159 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2159 qApp->processEvents(); 2160 qApp->processEvents();
2160 2161
2161 QDate bday; 2162 QDate bday;
2162 QString anni; 2163 QString anni;
2163 QString formattedbday; 2164 QString formattedbday;
2164 2165
2165 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2166 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2166 { 2167 {
2167 if ( ! bar.isVisible() ) 2168 if ( ! bar.isVisible() )
2168 return; 2169 return;
2169 bar.setProgress( count++ ); 2170 bar.setProgress( count++ );
2170 qApp->processEvents(); 2171 qApp->processEvents();
2171 bday = (*it).birthday().date(); 2172 bday = (*it).birthday().date();
2172 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2173 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2173 2174
2174 if ( bday.isValid() || !anni.isEmpty()) 2175 if ( bday.isValid() || !anni.isEmpty())
2175 { 2176 {
2176 if (bday.isValid()) 2177 if (bday.isValid())
2177 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2178 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2178 else 2179 else
2179 formattedbday = "NOTVALID"; 2180 formattedbday = "NOTVALID";
2180 if (anni.isEmpty()) 2181 if (anni.isEmpty())
2181 anni = "INVALID"; 2182 anni = "INVALID";
2182 2183
2183 birthdayList.append(formattedbday); 2184 birthdayList.append(formattedbday);
2184 anniversaryList.append(anni); //should be ISODate 2185 anniversaryList.append(anni); //should be ISODate
2185 realNameList.append((*it).realName()); 2186 realNameList.append((*it).realName());
2186 preferredEmailList.append((*it).preferredEmail()); 2187 preferredEmailList.append((*it).preferredEmail());
2187 assembledNameList.append((*it).assembledName()); 2188 assembledNameList.append((*it).assembledName());
2188 uidList.append((*it).uid()); 2189 uidList.append((*it).uid());
2189 2190
2190 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2191 qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2191 } 2192 }
2192 } 2193 }
2193 2194
2194 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2195 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2195 2196
2196} 2197}
2197 2198
2198/* this method will be called through the QCop interface from other apps to show details of a contact. 2199/* this method will be called through the QCop interface from other apps to show details of a contact.
2199 */ 2200 */
2200void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2201void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2201{ 2202{
2202 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2203 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2203 2204
2204 QString foundUid = QString::null; 2205 QString foundUid = QString::null;
2205 if ( ! uid.isEmpty() ) { 2206 if ( ! uid.isEmpty() ) {
2206 Addressee adrr = mAddressBook->findByUid( uid ); 2207 Addressee adrr = mAddressBook->findByUid( uid );
2207 if ( !adrr.isEmpty() ) { 2208 if ( !adrr.isEmpty() ) {
2208 foundUid = uid; 2209 foundUid = uid;
2209 } 2210 }
2210 if ( email == "sendbacklist" ) { 2211 if ( email == "sendbacklist" ) {
2211 //qDebug("ssssssssssssssssssssssend "); 2212 //qDebug("ssssssssssssssssssssssend ");
2212 QStringList nameList; 2213 QStringList nameList;
2213 QStringList emailList; 2214 QStringList emailList;
2214 QStringList uidList; 2215 QStringList uidList;
2215 nameList.append(adrr.realName()); 2216 nameList.append(adrr.realName());
2216 emailList = adrr.emails(); 2217 emailList = adrr.emails();
2217 uidList.append( adrr.preferredEmail()); 2218 uidList.append( adrr.preferredEmail());
2218 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2219 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2219 return; 2220 return;
2220 } 2221 }
2221 2222
2222 } 2223 }
2223 2224
2224 if ( email == "sendbacklist" ) 2225 if ( email == "sendbacklist" )
2225 return; 2226 return;
2226 if (foundUid.isEmpty()) 2227 if (foundUid.isEmpty())
2227 { 2228 {
2228 //find the uid of the person first 2229 //find the uid of the person first
2229 Addressee::List namelist; 2230 Addressee::List namelist;
2230 Addressee::List emaillist; 2231 Addressee::List emaillist;
2231 2232
2232 if (!name.isEmpty()) 2233 if (!name.isEmpty())
2233 namelist = mAddressBook->findByName( name ); 2234 namelist = mAddressBook->findByName( name );
2234 2235
2235 if (!email.isEmpty()) 2236 if (!email.isEmpty())
2236 emaillist = mAddressBook->findByEmail( email ); 2237 emaillist = mAddressBook->findByEmail( email );
2237 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2238 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2238 //check if we have a match in Namelist and Emaillist 2239 //check if we have a match in Namelist and Emaillist
2239 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2240 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2240 foundUid = emaillist[0].uid(); 2241 foundUid = emaillist[0].uid();
2241 } 2242 }
2242 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2243 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2243 foundUid = namelist[0].uid(); 2244 foundUid = namelist[0].uid();
2244 else 2245 else
2245 { 2246 {
2246 for (int i = 0; i < namelist.count(); i++) 2247 for (int i = 0; i < namelist.count(); i++)
2247 { 2248 {
2248 for (int j = 0; j < emaillist.count(); j++) 2249 for (int j = 0; j < emaillist.count(); j++)
2249 { 2250 {
2250 if (namelist[i] == emaillist[j]) 2251 if (namelist[i] == emaillist[j])
2251 { 2252 {
2252 foundUid = namelist[i].uid(); 2253 foundUid = namelist[i].uid();
2253 } 2254 }
2254 } 2255 }
2255 } 2256 }
2256 } 2257 }
2257 } 2258 }
2258 else 2259 else
2259 { 2260 {
2260 foundUid = uid; 2261 foundUid = uid;
2261 } 2262 }
2262 2263
2263 if (!foundUid.isEmpty()) 2264 if (!foundUid.isEmpty())
2264 { 2265 {
2265 2266
2266 // raise Ka/Pi if it is in the background 2267 // raise Ka/Pi if it is in the background
2267#ifndef DESKTOP_VERSION 2268#ifndef DESKTOP_VERSION
2268#ifndef KORG_NODCOP 2269#ifndef KORG_NODCOP
2269 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2270 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2270#endif 2271#endif
2271#endif 2272#endif
2272 2273
2273 mMainWindow->showMaximized(); 2274 mMainWindow->showMaximized();
2274 mMainWindow-> raise(); 2275 mMainWindow-> raise();
2275 2276
2276 mViewManager->setSelected( "", false); 2277 mViewManager->setSelected( "", false);
2277 mViewManager->refreshView( "" ); 2278 mViewManager->refreshView( "" );
2278 mViewManager->setSelected( foundUid, true ); 2279 mViewManager->setSelected( foundUid, true );
2279 mViewManager->refreshView( foundUid ); 2280 mViewManager->refreshView( foundUid );
2280 2281
2281 if ( !mMultipleViewsAtOnce ) 2282 if ( !mMultipleViewsAtOnce )
2282 { 2283 {
2283 setDetailsVisible( true ); 2284 setDetailsVisible( true );
2284 mActionDetails->setChecked(true); 2285 mActionDetails->setChecked(true);
2285 } 2286 }
2286 } 2287 }
2287} 2288}
2288 2289
2289void KABCore::whatsnew() 2290void KABCore::whatsnew()
2290{ 2291{
2291 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2292 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2292} 2293}
2293void KABCore::synchowto() 2294void KABCore::synchowto()
2294{ 2295{
2295 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2296 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2296} 2297}
2297 2298
2298void KABCore::faq() 2299void KABCore::faq()
2299{ 2300{
2300 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2301 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2301} 2302}
2302 2303
2303#include <libkcal/syncdefines.h> 2304#include <libkcal/syncdefines.h>
2304 2305
2305KABC::Addressee KABCore::getLastSyncAddressee() 2306KABC::Addressee KABCore::getLastSyncAddressee()
2306{ 2307{
2307 Addressee lse; 2308 Addressee lse;
2308 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2309 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2309 2310
2310 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2311 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2311 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2312 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2312 if (lse.isEmpty()) { 2313 if (lse.isEmpty()) {
2313 qDebug("Creating new last-syncAddressee "); 2314 qDebug("Creating new last-syncAddressee ");
2314 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2315 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2315 QString sum = ""; 2316 QString sum = "";
2316 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2317 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2317 sum = "E: "; 2318 sum = "E: ";
2318 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2319 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2319 lse.setRevision( mLastAddressbookSync ); 2320 lse.setRevision( mLastAddressbookSync );
2320 lse.setCategories( i18n("SyncEvent") ); 2321 lse.setCategories( i18n("SyncEvent") );
2321 mAddressBook->insertAddressee( lse ); 2322 mAddressBook->insertAddressee( lse );
2322 } 2323 }
2323 return lse; 2324 return lse;
2324} 2325}
2325int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2326int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2326{ 2327{
2327 2328
2328 //void setZaurusId(int id); 2329 //void setZaurusId(int id);
2329 // int zaurusId() const; 2330 // int zaurusId() const;
2330 // void setZaurusUid(int id); 2331 // void setZaurusUid(int id);
2331 // int zaurusUid() const; 2332 // int zaurusUid() const;
2332 // void setZaurusStat(int id); 2333 // void setZaurusStat(int id);
2333 // int zaurusStat() const; 2334 // int zaurusStat() const;
2334 // 0 equal 2335 // 0 equal
2335 // 1 take local 2336 // 1 take local
2336 // 2 take remote 2337 // 2 take remote
2337 // 3 cancel 2338 // 3 cancel
2338 QDateTime lastSync = mLastAddressbookSync; 2339 QDateTime lastSync = mLastAddressbookSync;
2339 QDateTime localMod = local->revision(); 2340 QDateTime localMod = local->revision();
2340 QDateTime remoteMod = remote->revision(); 2341 QDateTime remoteMod = remote->revision();
2341 2342
2342 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2343 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2343 2344
2344 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2345 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2345 bool remCh, locCh; 2346 bool remCh, locCh;
2346 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2347 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2347 2348
2348 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2349 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2349 locCh = ( localMod > mLastAddressbookSync ); 2350 locCh = ( localMod > mLastAddressbookSync );
2350 if ( !remCh && ! locCh ) { 2351 if ( !remCh && ! locCh ) {
2351 //qDebug("both not changed "); 2352 //qDebug("both not changed ");
2352 lastSync = localMod.addDays(1); 2353 lastSync = localMod.addDays(1);
2353 if ( mode <= SYNC_PREF_ASK ) 2354 if ( mode <= SYNC_PREF_ASK )
2354 return 0; 2355 return 0;
2355 } else { 2356 } else {
2356 if ( locCh ) { 2357 if ( locCh ) {
2357 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2358 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2358 lastSync = localMod.addDays( -1 ); 2359 lastSync = localMod.addDays( -1 );
2359 if ( !remCh ) 2360 if ( !remCh )
2360 remoteMod =( lastSync.addDays( -1 ) ); 2361 remoteMod =( lastSync.addDays( -1 ) );
2361 } else { 2362 } else {
2362 //qDebug(" not loc changed "); 2363 //qDebug(" not loc changed ");
2363 lastSync = localMod.addDays( 1 ); 2364 lastSync = localMod.addDays( 1 );
2364 if ( remCh ) 2365 if ( remCh )
2365 remoteMod =( lastSync.addDays( 1 ) ); 2366 remoteMod =( lastSync.addDays( 1 ) );
2366 2367
2367 } 2368 }
2368 } 2369 }
2369 full = true; 2370 full = true;
2370 if ( mode < SYNC_PREF_ASK ) 2371 if ( mode < SYNC_PREF_ASK )
2371 mode = SYNC_PREF_ASK; 2372 mode = SYNC_PREF_ASK;
2372 } else { 2373 } else {
2373 if ( localMod == remoteMod ) 2374 if ( localMod == remoteMod )
2374 return 0; 2375 return 0;
2375 2376
2376 } 2377 }
2377 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2378 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2378 2379
2379 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2380 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2380 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2381 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2381 //full = true; //debug only 2382 //full = true; //debug only
2382 if ( full ) { 2383 if ( full ) {
2383 bool equ = ( (*local) == (*remote) ); 2384 bool equ = ( (*local) == (*remote) );
2384 if ( equ ) { 2385 if ( equ ) {
2385 //qDebug("equal "); 2386 //qDebug("equal ");
2386 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2387 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2387 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2388 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2388 } 2389 }
2389 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2390 if ( mode < SYNC_PREF_FORCE_LOCAL )
2390 return 0; 2391 return 0;
2391 2392
2392 }//else //debug only 2393 }//else //debug only
2393 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2394 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2394 } 2395 }
2395 int result; 2396 int result;
2396 bool localIsNew; 2397 bool localIsNew;
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() ); 2398 //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() );
2398 2399
2399 if ( full && mode < SYNC_PREF_NEWEST ) 2400 if ( full && mode < SYNC_PREF_NEWEST )
2400 mode = SYNC_PREF_ASK; 2401 mode = SYNC_PREF_ASK;
2401 2402
2402 switch( mode ) { 2403 switch( mode ) {
2403 case SYNC_PREF_LOCAL: 2404 case SYNC_PREF_LOCAL:
2404 if ( lastSync > remoteMod ) 2405 if ( lastSync > remoteMod )
2405 return 1; 2406 return 1;
2406 if ( lastSync > localMod ) 2407 if ( lastSync > localMod )
2407 return 2; 2408 return 2;
2408 return 1; 2409 return 1;
2409 break; 2410 break;
2410 case SYNC_PREF_REMOTE: 2411 case SYNC_PREF_REMOTE:
2411 if ( lastSync > remoteMod ) 2412 if ( lastSync > remoteMod )
2412 return 1; 2413 return 1;
2413 if ( lastSync > localMod ) 2414 if ( lastSync > localMod )
2414 return 2; 2415 return 2;
@@ -2556,319 +2557,319 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2556 //qDebug("take %d %s ", take, inL.summary().latin1()); 2557 //qDebug("take %d %s ", take, inL.summary().latin1());
2557 if ( take == 3 ) 2558 if ( take == 3 )
2558 return false; 2559 return false;
2559 if ( take == 1 ) {// take local 2560 if ( take == 1 ) {// take local
2560 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2561 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2561 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2562 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2562 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2563 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2563 local->insertAddressee( inL, false ); 2564 local->insertAddressee( inL, false );
2564 idS = inR.externalUID(); 2565 idS = inR.externalUID();
2565 OidS = inR.originalExternalUID(); 2566 OidS = inR.originalExternalUID();
2566 } 2567 }
2567 else 2568 else
2568 idS = inR.IDStr(); 2569 idS = inR.IDStr();
2569 remote->removeAddressee( inR ); 2570 remote->removeAddressee( inR );
2570 inR = inL; 2571 inR = inL;
2571 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2572 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2572 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2573 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2573 inR.setOriginalExternalUID( OidS ); 2574 inR.setOriginalExternalUID( OidS );
2574 inR.setExternalUID( idS ); 2575 inR.setExternalUID( idS );
2575 } else { 2576 } else {
2576 inR.setIDStr( idS ); 2577 inR.setIDStr( idS );
2577 } 2578 }
2578 inR.setResource( 0 ); 2579 inR.setResource( 0 );
2579 remote->insertAddressee( inR , false); 2580 remote->insertAddressee( inR , false);
2580 ++changedRemote; 2581 ++changedRemote;
2581 } else { // take == 2 take remote 2582 } else { // take == 2 take remote
2582 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2583 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2583 if ( inR.revision().date().year() < 2004 ) 2584 if ( inR.revision().date().year() < 2004 )
2584 inR.setRevision( modifiedCalendar ); 2585 inR.setRevision( modifiedCalendar );
2585 } 2586 }
2586 idS = inL.IDStr(); 2587 idS = inL.IDStr();
2587 local->removeAddressee( inL ); 2588 local->removeAddressee( inL );
2588 inL = inR; 2589 inL = inR;
2589 inL.setIDStr( idS ); 2590 inL.setIDStr( idS );
2590 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2591 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2591 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2592 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2592 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2593 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2593 } 2594 }
2594 inL.setResource( 0 ); 2595 inL.setResource( 0 );
2595 local->insertAddressee( inL , false ); 2596 local->insertAddressee( inL , false );
2596 ++changedLocal; 2597 ++changedLocal;
2597 } 2598 }
2598 } 2599 }
2599 } 2600 }
2600 } else { // no conflict 2601 } else { // no conflict
2601 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2602 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2602 QString des = addresseeLSync.note(); 2603 QString des = addresseeLSync.note();
2603 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2604 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2604 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2605 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2605 remote->insertAddressee( inR, false ); 2606 remote->insertAddressee( inR, false );
2606 ++deletedAddresseeR; 2607 ++deletedAddresseeR;
2607 } else { 2608 } else {
2608 inR.setRevision( modifiedCalendar ); 2609 inR.setRevision( modifiedCalendar );
2609 remote->insertAddressee( inR, false ); 2610 remote->insertAddressee( inR, false );
2610 inL = inR; 2611 inL = inR;
2611 inL.setResource( 0 ); 2612 inL.setResource( 0 );
2612 local->insertAddressee( inL , false); 2613 local->insertAddressee( inL , false);
2613 ++addedAddressee; 2614 ++addedAddressee;
2614 } 2615 }
2615 } else { 2616 } else {
2616 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2617 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2617 inR.setRevision( modifiedCalendar ); 2618 inR.setRevision( modifiedCalendar );
2618 remote->insertAddressee( inR, false ); 2619 remote->insertAddressee( inR, false );
2619 inR.setResource( 0 ); 2620 inR.setResource( 0 );
2620 local->insertAddressee( inR, false ); 2621 local->insertAddressee( inR, false );
2621 ++addedAddressee; 2622 ++addedAddressee;
2622 } else { 2623 } else {
2623 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2624 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2624 remote->removeAddressee( inR ); 2625 remote->removeAddressee( inR );
2625 ++deletedAddresseeR; 2626 ++deletedAddresseeR;
2626 } 2627 }
2627 } 2628 }
2628 } 2629 }
2629 } 2630 }
2630 ++incCounter; 2631 ++incCounter;
2631 } 2632 }
2632 er.clear(); 2633 er.clear();
2633 QStringList el = local->uidList(); 2634 QStringList el = local->uidList();
2634 modulo = (el.count()/10)+1; 2635 modulo = (el.count()/10)+1;
2635 2636
2636 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2637 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2637 incCounter = 0; 2638 incCounter = 0;
2638 while ( incCounter < el.count()) { 2639 while ( incCounter < el.count()) {
2639 qApp->processEvents(); 2640 qApp->processEvents();
2640 if (syncManager->isProgressBarCanceled()) 2641 if (syncManager->isProgressBarCanceled())
2641 return false; 2642 return false;
2642 if ( incCounter % modulo == 0 ) 2643 if ( incCounter % modulo == 0 )
2643 syncManager->showProgressBar(incCounter); 2644 syncManager->showProgressBar(incCounter);
2644 uid = el[ incCounter ]; 2645 uid = el[ incCounter ];
2645 bool skipIncidence = false; 2646 bool skipIncidence = false;
2646 if ( uid.left(19) == QString("last-syncAddressee-") ) 2647 if ( uid.left(19) == QString("last-syncAddressee-") )
2647 skipIncidence = true; 2648 skipIncidence = true;
2648 if ( !skipIncidence ) { 2649 if ( !skipIncidence ) {
2649 inL = local->findByUid( uid ); 2650 inL = local->findByUid( uid );
2650 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2651 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2651 inR = remote->findByUid( uid ); 2652 inR = remote->findByUid( uid );
2652 if ( inR.isEmpty() ) { 2653 if ( inR.isEmpty() ) {
2653 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2654 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2654 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2655 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2655 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2656 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2656 local->removeAddressee( inL ); 2657 local->removeAddressee( inL );
2657 ++deletedAddresseeL; 2658 ++deletedAddresseeL;
2658 } else { 2659 } else {
2659 if ( ! syncManager->mWriteBackExistingOnly ) { 2660 if ( ! syncManager->mWriteBackExistingOnly ) {
2660 inL.removeID(mCurrentSyncDevice ); 2661 inL.removeID(mCurrentSyncDevice );
2661 ++addedAddresseeR; 2662 ++addedAddresseeR;
2662 inL.setRevision( modifiedCalendar ); 2663 inL.setRevision( modifiedCalendar );
2663 local->insertAddressee( inL, false ); 2664 local->insertAddressee( inL, false );
2664 inR = inL; 2665 inR = inL;
2665 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2666 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2666 inR.setResource( 0 ); 2667 inR.setResource( 0 );
2667 remote->insertAddressee( inR, false ); 2668 remote->insertAddressee( inR, false );
2668 } 2669 }
2669 } 2670 }
2670 } else { 2671 } else {
2671 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2672 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2672 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2673 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2673 local->removeAddressee( inL ); 2674 local->removeAddressee( inL );
2674 ++deletedAddresseeL; 2675 ++deletedAddresseeL;
2675 } else { 2676 } else {
2676 if ( ! syncManager->mWriteBackExistingOnly ) { 2677 if ( ! syncManager->mWriteBackExistingOnly ) {
2677 ++addedAddresseeR; 2678 ++addedAddresseeR;
2678 inL.setRevision( modifiedCalendar ); 2679 inL.setRevision( modifiedCalendar );
2679 local->insertAddressee( inL, false ); 2680 local->insertAddressee( inL, false );
2680 inR = inL; 2681 inR = inL;
2681 inR.setResource( 0 ); 2682 inR.setResource( 0 );
2682 remote->insertAddressee( inR, false ); 2683 remote->insertAddressee( inR, false );
2683 } 2684 }
2684 } 2685 }
2685 } 2686 }
2686 } 2687 }
2687 } 2688 }
2688 } 2689 }
2689 ++incCounter; 2690 ++incCounter;
2690 } 2691 }
2691 el.clear(); 2692 el.clear();
2692 syncManager->hideProgressBar(); 2693 syncManager->hideProgressBar();
2693 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2694 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2694 // get rid of micro seconds 2695 // get rid of micro seconds
2695 QTime t = mLastAddressbookSync.time(); 2696 QTime t = mLastAddressbookSync.time();
2696 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2697 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2697 addresseeLSync.setRevision( mLastAddressbookSync ); 2698 addresseeLSync.setRevision( mLastAddressbookSync );
2698 addresseeRSync.setRevision( mLastAddressbookSync ); 2699 addresseeRSync.setRevision( mLastAddressbookSync );
2699 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2700 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2700 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2701 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2701 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2702 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2702 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2703 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2703 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2704 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2704 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2705 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2705 addresseeRSync.setNote( "" ) ; 2706 addresseeRSync.setNote( "" ) ;
2706 addresseeLSync.setNote( "" ); 2707 addresseeLSync.setNote( "" );
2707 2708
2708 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2709 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2709 remote->insertAddressee( addresseeRSync, false ); 2710 remote->insertAddressee( addresseeRSync, false );
2710 local->insertAddressee( addresseeLSync, false ); 2711 local->insertAddressee( addresseeLSync, false );
2711 QString mes; 2712 QString mes;
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 ); 2713 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 );
2713 if ( syncManager->mShowSyncSummary ) { 2714 if ( syncManager->mShowSyncSummary ) {
2714 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2715 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2715 } 2716 }
2716 qDebug( mes ); 2717 qDebug( mes );
2717 return syncOK; 2718 return syncOK;
2718} 2719}
2719 2720
2720 2721
2721//this is a overwritten callbackmethods from the syncinterface 2722//this is a overwritten callbackmethods from the syncinterface
2722bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2723bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2723{ 2724{
2724 2725
2725 //pending prepare addresseeview for output 2726 //pending prepare addresseeview for output
2726 //pending detect, if remote file has REV field. if not switch to external sync 2727 //pending detect, if remote file has REV field. if not switch to external sync
2727 mGlobalSyncMode = SYNC_MODE_NORMAL; 2728 mGlobalSyncMode = SYNC_MODE_NORMAL;
2728 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2729 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2729 2730
2730 AddressBook abLocal(filename,"syncContact"); 2731 AddressBook abLocal(filename,"syncContact");
2731 bool syncOK = false; 2732 bool syncOK = false;
2732 if ( abLocal.load() ) { 2733 if ( abLocal.load() ) {
2733 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2734 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2734 bool external = false; 2735 bool external = false;
2735 bool isXML = false; 2736 bool isXML = false;
2736 if ( filename.right(4) == ".xml") { 2737 if ( filename.right(4) == ".xml") {
2737 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2738 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2738 isXML = true; 2739 isXML = true;
2739 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2740 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2740 } else { 2741 } else {
2741 external = !manager->mIsKapiFile; 2742 external = !manager->mIsKapiFile;
2742 if ( external ) { 2743 if ( external ) {
2743 qDebug("Setting vcf mode to external "); 2744 qDebug("Setting vcf mode to external ");
2744 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2745 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2745 AddressBook::Iterator it; 2746 AddressBook::Iterator it;
2746 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2747 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2747 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2748 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2748 (*it).computeCsum( mCurrentSyncDevice ); 2749 (*it).computeCsum( mCurrentSyncDevice );
2749 } 2750 }
2750 } 2751 }
2751 } 2752 }
2752 //AddressBook::Iterator it; 2753 //AddressBook::Iterator it;
2753 //QStringList vcards; 2754 //QStringList vcards;
2754 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2755 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2755 // qDebug("Name %s ", (*it).familyName().latin1()); 2756 // qDebug("Name %s ", (*it).familyName().latin1());
2756 //} 2757 //}
2757 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2758 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2758 if ( syncOK ) { 2759 if ( syncOK ) {
2759 if ( syncManager->mWriteBackFile ) 2760 if ( syncManager->mWriteBackFile )
2760 { 2761 {
2761 if ( external ) 2762 if ( external )
2762 abLocal.removeSyncAddressees( !isXML); 2763 abLocal.removeSyncAddressees( !isXML);
2763 qDebug("Saving remote AB "); 2764 qDebug("Saving remote AB ");
2764 if ( ! abLocal.saveAB()) 2765 if ( ! abLocal.saveAB())
2765 qDebug("Error writing back AB to file "); 2766 qDebug("Error writing back AB to file ");
2766 if ( isXML ) { 2767 if ( isXML ) {
2767 // afterwrite processing 2768 // afterwrite processing
2768 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2769 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2769 } 2770 }
2770 } 2771 }
2771 } 2772 }
2772 setModified(); 2773 setModified();
2773 2774
2774 } 2775 }
2775 if ( syncOK ) 2776 if ( syncOK )
2776 mViewManager->refreshView(); 2777 mViewManager->refreshView();
2777 return syncOK; 2778 return syncOK;
2778 2779
2779} 2780}
2780 2781
2781 2782
2782//this is a overwritten callbackmethods from the syncinterface 2783//this is a overwritten callbackmethods from the syncinterface
2783bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2784bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2784{ 2785{
2785 if ( resource == "phone" ) 2786 if ( resource == "phone" )
2786 return syncPhone(); 2787 return syncPhone();
2787 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2788 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2788 2789
2789 AddressBook abLocal( resource,"syncContact"); 2790 AddressBook abLocal( resource,"syncContact");
2790 bool syncOK = false; 2791 bool syncOK = false;
2791 if ( abLocal.load() ) { 2792 if ( abLocal.load() ) {
2792 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2793 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2793 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2794 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2794 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 2795 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
2795 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2796 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2796 if ( syncOK ) { 2797 if ( syncOK ) {
2797 if ( syncManager->mWriteBackFile ) { 2798 if ( syncManager->mWriteBackFile ) {
2798 abLocal.removeSyncAddressees( false ); 2799 abLocal.removeSyncAddressees( false );
2799 abLocal.saveAB(); 2800 abLocal.saveAB();
2800 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2801 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2801 } 2802 }
2802 } 2803 }
2803 setModified(); 2804 setModified();
2804 } 2805 }
2805 if ( syncOK ) 2806 if ( syncOK )
2806 mViewManager->refreshView(); 2807 mViewManager->refreshView();
2807 return syncOK; 2808 return syncOK;
2808 2809
2809} 2810}
2810void KABCore::message( QString m ) 2811void KABCore::message( QString m )
2811{ 2812{
2812
2813 topLevelWidget()->setCaption( m ); 2813 topLevelWidget()->setCaption( m );
2814 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2814 mMessageTimer->start( 15000, true );
2815} 2815}
2816bool KABCore::syncPhone() 2816bool KABCore::syncPhone()
2817{ 2817{
2818 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2818 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2819 QString fileName = getPhoneFile(); 2819 QString fileName = getPhoneFile();
2820 if ( !PhoneAccess::readFromPhone( fileName) ) { 2820 if ( !PhoneAccess::readFromPhone( fileName) ) {
2821 message(i18n("Phone access failed!")); 2821 message(i18n("Phone access failed!"));
2822 return false; 2822 return false;
2823 } 2823 }
2824 AddressBook abLocal( fileName,"syncContact"); 2824 AddressBook abLocal( fileName,"syncContact");
2825 bool syncOK = false; 2825 bool syncOK = false;
2826 { 2826 {
2827 abLocal.importFromFile( fileName ); 2827 abLocal.importFromFile( fileName );
2828 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2828 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2829 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2829 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2830 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2830 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2831 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 2831 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
2832 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2832 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2833 if ( syncOK ) { 2833 if ( syncOK ) {
2834 if ( syncManager->mWriteBackFile ) { 2834 if ( syncManager->mWriteBackFile ) {
2835 abLocal.removeSyncAddressees( true ); 2835 abLocal.removeSyncAddressees( true );
2836 abLocal.saveABphone( fileName ); 2836 abLocal.saveABphone( fileName );
2837 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 2837 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2838 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2838 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2839 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2839 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2840 } 2840 }
2841 } 2841 }
2842 setModified(); 2842 setModified();
2843 } 2843 }
2844 if ( syncOK ) 2844 if ( syncOK )
2845 mViewManager->refreshView(); 2845 mViewManager->refreshView();
2846 return syncOK; 2846 return syncOK;
2847} 2847}
2848void KABCore::getFile( bool success ) 2848void KABCore::getFile( bool success )
2849{ 2849{
2850 if ( ! success ) { 2850 if ( ! success ) {
2851 message( i18n("Error receiving file. Nothing changed!") ); 2851 message( i18n("Error receiving file. Nothing changed!") );
2852 return; 2852 return;
2853 } 2853 }
2854 mAddressBook->importFromFile( sentSyncFile() , false, true ); 2854 mAddressBook->importFromFile( sentSyncFile() , false, true );
2855 message( i18n("Pi-Sync successful!") ); 2855 message( i18n("Pi-Sync successful!") );
2856 mViewManager->refreshView(); 2856 mViewManager->refreshView();
2857} 2857}
2858void KABCore::syncFileRequest() 2858void KABCore::syncFileRequest()
2859{ 2859{
2860 mAddressBook->export2File( sentSyncFile() ); 2860 mAddressBook->export2File( sentSyncFile() );
2861} 2861}
2862QString KABCore::sentSyncFile() 2862QString KABCore::sentSyncFile()
2863{ 2863{
2864#ifdef _WIN32_ 2864#ifdef _WIN32_
2865 return locateLocal( "tmp", "copysyncab.vcf" ); 2865 return locateLocal( "tmp", "copysyncab.vcf" );
2866#else 2866#else
2867 return QString( "/tmp/copysyncab.vcf" ); 2867 return QString( "/tmp/copysyncab.vcf" );
2868#endif 2868#endif
2869} 2869}
2870 2870
2871void KABCore::setCaptionBack() 2871void KABCore::setCaptionBack()
2872{ 2872{
2873 mMessageTimer->stop();
2873 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2874 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2874} 2875}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 5871d39..c7be343 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,490 +1,491 @@
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#include <qtimer.h>
32 33
33#include <qwidget.h> 34#include <qwidget.h>
34#include <qpopupmenu.h> 35#include <qpopupmenu.h>
35#include <ksyncmanager.h> 36#include <ksyncmanager.h>
36 37
37namespace KABC { 38namespace KABC {
38class AddressBook; 39class AddressBook;
39} 40}
40 41
41#ifndef KAB_EMBEDDED 42#ifndef KAB_EMBEDDED
42class KAboutData; 43class KAboutData;
43class KConfig; 44class KConfig;
44 45
45class KAddressBookService; 46class KAddressBookService;
46class LDAPSearchDialog; 47class LDAPSearchDialog;
47#else //KAB_EMBEDDED 48#else //KAB_EMBEDDED
48class KAddressBookMain; 49class KAddressBookMain;
49//US class QAction; 50//US class QAction;
50#endif //KAB_EMBEDDED 51#endif //KAB_EMBEDDED
51class KCMultiDialog; 52class KCMultiDialog;
52class KXMLGUIClient; 53class KXMLGUIClient;
53class ExtensionManager; 54class ExtensionManager;
54class XXPortManager; 55class XXPortManager;
55class JumpButtonBar; 56class JumpButtonBar;
56class IncSearchWidget; 57class IncSearchWidget;
57class KDGanttMinimizeSplitter; 58class KDGanttMinimizeSplitter;
58class KAction; 59class KAction;
59class KActionCollection; 60class KActionCollection;
60class KToggleAction; 61class KToggleAction;
61class KSyncProfile; 62class KSyncProfile;
62 63
63class QAction; 64class QAction;
64class QMenuBar; 65class QMenuBar;
65class QSplitter; 66class QSplitter;
66class ViewContainer; 67class ViewContainer;
67class ViewManager; 68class ViewManager;
68class AddresseeEditorDialog; 69class AddresseeEditorDialog;
69class Ir; 70class Ir;
70 71
71class KABCore : public QWidget, public KSyncInterface 72class KABCore : public QWidget, public KSyncInterface
72{ 73{
73 Q_OBJECT 74 Q_OBJECT
74 75
75 public: 76 public:
76 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 77 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
77 78
78 79
79 ~KABCore(); 80 ~KABCore();
80 81
81 82
82#ifdef KAB_EMBEDDED 83#ifdef KAB_EMBEDDED
83 //US added functionality 84 //US added functionality
84 QPopupMenu* getViewMenu() {return viewMenu;} 85 QPopupMenu* getViewMenu() {return viewMenu;}
85 QPopupMenu* getFilterMenu() {return filterMenu;} 86 QPopupMenu* getFilterMenu() {return filterMenu;}
86 QPopupMenu* getSettingsMenu() {return settingsMenu;} 87 QPopupMenu* getSettingsMenu() {return settingsMenu;}
87 void addActionsManually(); 88 void addActionsManually();
88#endif //KAB_EMBEDDED 89#endif //KAB_EMBEDDED
89 /** 90 /**
90 Restores the global settings. 91 Restores the global settings.
91 */ 92 */
92 void restoreSettings(); 93 void restoreSettings();
93 94
94 /** 95 /**
95 Saves the global settings. 96 Saves the global settings.
96 */ 97 */
97 void saveSettings(); 98 void saveSettings();
98 99
99 /** 100 /**
100 Returns a pointer to the StdAddressBook of the application. 101 Returns a pointer to the StdAddressBook of the application.
101 */ 102 */
102 KABC::AddressBook *addressBook() const; 103 KABC::AddressBook *addressBook() const;
103 104
104 /** 105 /**
105 Returns a pointer to the KConfig object of the application. 106 Returns a pointer to the KConfig object of the application.
106 */ 107 */
107 static KConfig *config(); 108 static KConfig *config();
108 109
109 /** 110 /**
110 Returns a pointer to the global KActionCollection object. So 111 Returns a pointer to the global KActionCollection object. So
111 other classes can register their actions easily. 112 other classes can register their actions easily.
112 */ 113 */
113 KActionCollection *actionCollection() const; 114 KActionCollection *actionCollection() const;
114 115
115 /** 116 /**
116 Returns the current search field of the Incremental Search Widget. 117 Returns the current search field of the Incremental Search Widget.
117 */ 118 */
118 KABC::Field *currentSearchField() const; 119 KABC::Field *currentSearchField() const;
119 120
120 /** 121 /**
121 Returns the uid list of the currently selected contacts. 122 Returns the uid list of the currently selected contacts.
122 */ 123 */
123 QStringList selectedUIDs() const; 124 QStringList selectedUIDs() const;
124 125
125 /** 126 /**
126 Displays the ResourceSelectDialog and returns the selected 127 Displays the ResourceSelectDialog and returns the selected
127 resource or a null pointer if no resource was selected by 128 resource or a null pointer if no resource was selected by
128 the user. 129 the user.
129 */ 130 */
130 KABC::Resource *requestResource( QWidget *parent ); 131 KABC::Resource *requestResource( QWidget *parent );
131 132
132#ifndef KAB_EMBEDDED 133#ifndef KAB_EMBEDDED
133 static KAboutData *createAboutData(); 134 static KAboutData *createAboutData();
134#endif //KAB_EMBEDDED 135#endif //KAB_EMBEDDED
135 136
136#ifdef KAB_EMBEDDED 137#ifdef KAB_EMBEDDED
137 inline QPopupMenu* getImportMenu() { return ImportMenu;} 138 inline QPopupMenu* getImportMenu() { return ImportMenu;}
138 inline QPopupMenu* getExportMenu() { return ExportMenu;} 139 inline QPopupMenu* getExportMenu() { return ExportMenu;}
139#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
140 141
141 public slots: 142 public slots:
142#ifdef KAB_EMBEDDED 143#ifdef KAB_EMBEDDED
143 void createAboutData(); 144 void createAboutData();
144#endif //KAB_EMBEDDED 145#endif //KAB_EMBEDDED
145 146
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 void writeToPhone();
152 152
153 /** 153 /**
154 Is called whenever a contact is selected in the view. 154 Is called whenever a contact is selected in the view.
155 */ 155 */
156 void setContactSelected( const QString &uid ); 156 void setContactSelected( const QString &uid );
157 157
158 /** 158 /**
159 Opens the preferred mail composer with all selected contacts as 159 Opens the preferred mail composer with all selected contacts as
160 arguments. 160 arguments.
161 */ 161 */
162 void sendMail(); 162 void sendMail();
163 163
164 /** 164 /**
165 Opens the preferred mail composer with the given contacts as 165 Opens the preferred mail composer with the given contacts as
166 arguments. 166 arguments.
167 */ 167 */
168 void sendMail( const QString& email ); 168 void sendMail( const QString& email );
169 169
170 170
171 void mailVCard(); 171 void mailVCard();
172 void mailVCard(const QStringList& uids); 172 void mailVCard(const QStringList& uids);
173 173
174 /** 174 /**
175 Beams the "WhoAmI contact. 175 Beams the "WhoAmI contact.
176 */ 176 */
177 void beamMySelf(); 177 void beamMySelf();
178 178
179 void beamVCard(); 179 void beamVCard();
180 void export2phone(); 180 void export2phone();
181 void beamVCard(const QStringList& uids); 181 void beamVCard(const QStringList& uids);
182 void beamDone( Ir *ir ); 182 void beamDone( Ir *ir );
183 183
184 184
185 /** 185 /**
186 Starts the preferred web browser with the given URL as argument. 186 Starts the preferred web browser with the given URL as argument.
187 */ 187 */
188 void browse( const QString& url ); 188 void browse( const QString& url );
189 189
190 /** 190 /**
191 Select all contacts in the view. 191 Select all contacts in the view.
192 */ 192 */
193 void selectAllContacts(); 193 void selectAllContacts();
194 194
195 /** 195 /**
196 Deletes all selected contacts from the address book. 196 Deletes all selected contacts from the address book.
197 */ 197 */
198 void deleteContacts(); 198 void deleteContacts();
199 199
200 /** 200 /**
201 Deletes given contacts from the address book. 201 Deletes given contacts from the address book.
202 202
203 @param uids The uids of the contacts, which shall be deleted. 203 @param uids The uids of the contacts, which shall be deleted.
204 */ 204 */
205 void deleteContacts( const QStringList &uids ); 205 void deleteContacts( const QStringList &uids );
206 206
207 /** 207 /**
208 Copys the selected contacts into clipboard for later pasting. 208 Copys the selected contacts into clipboard for later pasting.
209 */ 209 */
210 void copyContacts(); 210 void copyContacts();
211 211
212 /** 212 /**
213 Cuts the selected contacts and stores them for later pasting. 213 Cuts the selected contacts and stores them for later pasting.
214 */ 214 */
215 void cutContacts(); 215 void cutContacts();
216 216
217 /** 217 /**
218 Paste contacts from clipboard into the address book. 218 Paste contacts from clipboard into the address book.
219 */ 219 */
220 void pasteContacts(); 220 void pasteContacts();
221 221
222 /** 222 /**
223 Paste given contacts into the address book. 223 Paste given contacts into the address book.
224 224
225 @param list The list of addressee, which shall be pasted. 225 @param list The list of addressee, which shall be pasted.
226 */ 226 */
227 void pasteContacts( KABC::Addressee::List &list ); 227 void pasteContacts( KABC::Addressee::List &list );
228 228
229 /** 229 /**
230 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
231 get personal information about the current user. 231 get personal information about the current user.
232 */ 232 */
233 void setWhoAmI(); 233 void setWhoAmI();
234 234
235 /** 235 /**
236 Displays the category dialog and applies the result to all 236 Displays the category dialog and applies the result to all
237 selected contacts. 237 selected contacts.
238 */ 238 */
239 void setCategories(); 239 void setCategories();
240 240
241 /** 241 /**
242 Sets the field list of the Incremental Search Widget. 242 Sets the field list of the Incremental Search Widget.
243 */ 243 */
244 void setSearchFields( const KABC::Field::List &fields ); 244 void setSearchFields( const KABC::Field::List &fields );
245 245
246 /** 246 /**
247 Search with the current search field for a contact, that matches 247 Search with the current search field for a contact, that matches
248 the given text, and selects it in the view. 248 the given text, and selects it in the view.
249 */ 249 */
250 void incrementalSearch( const QString& text ); 250 void incrementalSearch( const QString& text );
251 251
252 /** 252 /**
253 Marks the address book as modified. 253 Marks the address book as modified.
254 */ 254 */
255 void setModified(); 255 void setModified();
256 /** 256 /**
257 Marks the address book as modified without refreshing the view. 257 Marks the address book as modified without refreshing the view.
258 */ 258 */
259 void setModifiedWOrefresh(); 259 void setModifiedWOrefresh();
260 260
261 /** 261 /**
262 Marks the address book as modified concerning the argument. 262 Marks the address book as modified concerning the argument.
263 */ 263 */
264 void setModified( bool modified ); 264 void setModified( bool modified );
265 265
266 /** 266 /**
267 Returns whether the address book is modified. 267 Returns whether the address book is modified.
268 */ 268 */
269 bool modified() const; 269 bool modified() const;
270 270
271 /** 271 /**
272 Called whenever an contact is modified in the contact editor 272 Called whenever an contact is modified in the contact editor
273 dialog or the quick edit. 273 dialog or the quick edit.
274 */ 274 */
275 void contactModified( const KABC::Addressee &addr ); 275 void contactModified( const KABC::Addressee &addr );
276 276
277 /** 277 /**
278 DCOP METHODS. 278 DCOP METHODS.
279 */ 279 */
280 void addEmail( QString addr ); 280 void addEmail( QString addr );
281 void importVCard( const KURL& url, bool showPreview ); 281 void importVCard( const KURL& url, bool showPreview );
282 void importVCard( const QString& vCard, bool showPreview ); 282 void importVCard( const QString& vCard, bool showPreview );
283 void newContact(); 283 void newContact();
284 QString getNameByPhone( const QString& phone ); 284 QString getNameByPhone( const QString& phone );
285 /** 285 /**
286 END DCOP METHODS 286 END DCOP METHODS
287 */ 287 */
288 288
289 /** 289 /**
290 Saves the contents of the AddressBook back to disk. 290 Saves the contents of the AddressBook back to disk.
291 */ 291 */
292 void save(); 292 void save();
293 293
294 /** 294 /**
295 Undos the last command using the undo stack. 295 Undos the last command using the undo stack.
296 */ 296 */
297 void undo(); 297 void undo();
298 298
299 /** 299 /**
300 Redos the last command that was undone, using the redo stack. 300 Redos the last command that was undone, using the redo stack.
301 */ 301 */
302 void redo(); 302 void redo();
303 303
304 /** 304 /**
305 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,
306 the method will try to find a selected addressee in the view. 306 the method will try to find a selected addressee in the view.
307 */ 307 */
308 void editContact( const QString &uid /*US = QString::null*/ ); 308 void editContact( const QString &uid /*US = QString::null*/ );
309//US added a second method without defaultparameter 309//US added a second method without defaultparameter
310 void editContact2(); 310 void editContact2();
311 311
312 /** 312 /**
313 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,
314 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.
315 */ 315 */
316 void executeContact( const QString &uid /*US = QString::null*/ ); 316 void executeContact( const QString &uid /*US = QString::null*/ );
317 317
318 /** 318 /**
319 Launches the configuration dialog. 319 Launches the configuration dialog.
320 */ 320 */
321 void openConfigDialog(); 321 void openConfigDialog();
322 322
323 /** 323 /**
324 Launches the ldap search dialog. 324 Launches the ldap search dialog.
325 */ 325 */
326 void openLDAPDialog(); 326 void openLDAPDialog();
327 327
328 /** 328 /**
329 Creates a KAddressBookPrinter, which will display the print 329 Creates a KAddressBookPrinter, which will display the print
330 dialog and do the printing. 330 dialog and do the printing.
331 */ 331 */
332 void print(); 332 void print();
333 333
334 /** 334 /**
335 Registers a new GUI client, so plugins can register its actions. 335 Registers a new GUI client, so plugins can register its actions.
336 */ 336 */
337 void addGUIClient( KXMLGUIClient *client ); 337 void addGUIClient( KXMLGUIClient *client );
338 338
339 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 339 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
340 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);
341 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 341 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
342 342
343 343
344 signals: 344 signals:
345 void contactSelected( const QString &name ); 345 void contactSelected( const QString &name );
346 void contactSelected( const QPixmap &pixmap ); 346 void contactSelected( const QPixmap &pixmap );
347 public slots: 347 public slots:
348 void recieve(QString cmsg ); 348 void recieve(QString cmsg );
349 void getFile( bool success ); 349 void getFile( bool success );
350 void syncFileRequest(); 350 void syncFileRequest();
351 void setDetailsVisible( bool visible ); 351 void setDetailsVisible( bool visible );
352 void setDetailsToState(); 352 void setDetailsToState();
353 // void slotSyncMenu( int ); 353 // void slotSyncMenu( int );
354 private slots: 354 private slots:
355 void setJumpButtonBarVisible( bool visible ); 355 void setJumpButtonBarVisible( bool visible );
356 void setCaptionBack(); 356 void setCaptionBack();
357 void importFromOL(); 357 void importFromOL();
358 void extensionModified( const KABC::Addressee::List &list ); 358 void extensionModified( const KABC::Addressee::List &list );
359 void extensionChanged( int id ); 359 void extensionChanged( int id );
360 void clipboardDataChanged(); 360 void clipboardDataChanged();
361 void updateActionMenu(); 361 void updateActionMenu();
362 void configureKeyBindings(); 362 void configureKeyBindings();
363 void removeVoice(); 363 void removeVoice();
364#ifdef KAB_EMBEDDED 364#ifdef KAB_EMBEDDED
365 void configureResources(); 365 void configureResources();
366#endif //KAB_EMBEDDED 366#endif //KAB_EMBEDDED
367 367
368 void slotEditorDestroyed( const QString &uid ); 368 void slotEditorDestroyed( const QString &uid );
369 void configurationChanged(); 369 void configurationChanged();
370 void addressBookChanged(); 370 void addressBookChanged();
371 371
372 private: 372 private:
373 QTimer *mMessageTimer;
373 void initGUI(); 374 void initGUI();
374 void initActions(); 375 void initActions();
375 QString getPhoneFile(); 376 QString getPhoneFile();
376 377
377 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 378 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
378 const char *name = 0 ); 379 const char *name = 0 );
379 380
380 KXMLGUIClient *mGUIClient; 381 KXMLGUIClient *mGUIClient;
381 382
382 KABC::AddressBook *mAddressBook; 383 KABC::AddressBook *mAddressBook;
383 384
384 ViewManager *mViewManager; 385 ViewManager *mViewManager;
385 // QSplitter *mDetailsSplitter; 386 // QSplitter *mDetailsSplitter;
386 KDGanttMinimizeSplitter *mExtensionBarSplitter; 387 KDGanttMinimizeSplitter *mExtensionBarSplitter;
387 ViewContainer *mDetails; 388 ViewContainer *mDetails;
388 KDGanttMinimizeSplitter* mMiniSplitter; 389 KDGanttMinimizeSplitter* mMiniSplitter;
389 XXPortManager *mXXPortManager; 390 XXPortManager *mXXPortManager;
390 JumpButtonBar *mJumpButtonBar; 391 JumpButtonBar *mJumpButtonBar;
391 IncSearchWidget *mIncSearchWidget; 392 IncSearchWidget *mIncSearchWidget;
392 ExtensionManager *mExtensionManager; 393 ExtensionManager *mExtensionManager;
393 394
394 KCMultiDialog *mConfigureDialog; 395 KCMultiDialog *mConfigureDialog;
395 396
396#ifndef KAB_EMBEDDED 397#ifndef KAB_EMBEDDED
397 LDAPSearchDialog *mLdapSearchDialog; 398 LDAPSearchDialog *mLdapSearchDialog;
398#endif //KAB_EMBEDDED 399#endif //KAB_EMBEDDED
399 // QDict<AddresseeEditorDialog> mEditorDict; 400 // QDict<AddresseeEditorDialog> mEditorDict;
400 AddresseeEditorDialog *mEditorDialog; 401 AddresseeEditorDialog *mEditorDialog;
401 bool mReadWrite; 402 bool mReadWrite;
402 bool mModified; 403 bool mModified;
403 bool mIsPart; 404 bool mIsPart;
404 bool mMultipleViewsAtOnce; 405 bool mMultipleViewsAtOnce;
405 406
406 407
407 //US file menu 408 //US file menu
408 KAction *mActionMail; 409 KAction *mActionMail;
409 KAction *mActionBeam; 410 KAction *mActionBeam;
410 KAction *mActionExport2phone; 411 KAction *mActionExport2phone;
411 KAction* mActionPrint; 412 KAction* mActionPrint;
412 KAction* mActionNewContact; 413 KAction* mActionNewContact;
413 KAction *mActionSave; 414 KAction *mActionSave;
414 KAction *mActionEditAddressee; 415 KAction *mActionEditAddressee;
415 KAction *mActionMailVCard; 416 KAction *mActionMailVCard;
416 KAction *mActionBeamVCard; 417 KAction *mActionBeamVCard;
417 418
418 KAction *mActionQuit; 419 KAction *mActionQuit;
419 420
420 //US edit menu 421 //US edit menu
421 KAction *mActionCopy; 422 KAction *mActionCopy;
422 KAction *mActionCut; 423 KAction *mActionCut;
423 KAction *mActionPaste; 424 KAction *mActionPaste;
424 KAction *mActionSelectAll; 425 KAction *mActionSelectAll;
425 KAction *mActionUndo; 426 KAction *mActionUndo;
426 KAction *mActionRedo; 427 KAction *mActionRedo;
427 KAction *mActionDelete; 428 KAction *mActionDelete;
428 429
429 //US settings menu 430 //US settings menu
430 KAction *mActionConfigResources; 431 KAction *mActionConfigResources;
431 KAction *mActionConfigKAddressbook; 432 KAction *mActionConfigKAddressbook;
432 KAction *mActionConfigShortcuts; 433 KAction *mActionConfigShortcuts;
433 KAction *mActionConfigureToolbars; 434 KAction *mActionConfigureToolbars;
434 KAction *mActionKeyBindings; 435 KAction *mActionKeyBindings;
435 KToggleAction *mActionJumpBar; 436 KToggleAction *mActionJumpBar;
436 KToggleAction *mActionDetails; 437 KToggleAction *mActionDetails;
437 KAction *mActionWhoAmI; 438 KAction *mActionWhoAmI;
438 KAction *mActionCategories; 439 KAction *mActionCategories;
439 KAction *mActionAboutKAddressbook; 440 KAction *mActionAboutKAddressbook;
440 KAction *mActionLicence; 441 KAction *mActionLicence;
441 KAction *mActionFaq; 442 KAction *mActionFaq;
442 KAction *mActionWN; 443 KAction *mActionWN;
443 KAction *mActionSyncHowto; 444 KAction *mActionSyncHowto;
444 445
445 KAction *mActionDeleteView; 446 KAction *mActionDeleteView;
446 447
447 QPopupMenu *viewMenu; 448 QPopupMenu *viewMenu;
448 QPopupMenu *filterMenu; 449 QPopupMenu *filterMenu;
449 QPopupMenu *settingsMenu; 450 QPopupMenu *settingsMenu;
450 QPopupMenu *changeMenu; 451 QPopupMenu *changeMenu;
451//US QAction *mActionSave; 452//US QAction *mActionSave;
452 QPopupMenu *ImportMenu; 453 QPopupMenu *ImportMenu;
453 QPopupMenu *ExportMenu; 454 QPopupMenu *ExportMenu;
454 //LR additional methods 455 //LR additional methods
455 KAction *mActionRemoveVoice; 456 KAction *mActionRemoveVoice;
456 KAction * mActionImportOL; 457 KAction * mActionImportOL;
457 458
458#ifndef KAB_EMBEDDED 459#ifndef KAB_EMBEDDED
459 KAddressBookService *mAddressBookService; 460 KAddressBookService *mAddressBookService;
460#endif //KAB_EMBEDDED 461#endif //KAB_EMBEDDED
461 462
462 class KABCorePrivate; 463 class KABCorePrivate;
463 KABCorePrivate *d; 464 KABCorePrivate *d;
464 //US bool mBlockSaveFlag; 465 //US bool mBlockSaveFlag;
465 466
466#ifdef KAB_EMBEDDED 467#ifdef KAB_EMBEDDED
467 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 468 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
468#endif //KAB_EMBEDDED 469#endif //KAB_EMBEDDED
469 470
470 //this are the overwritten callbackmethods from the syncinterface 471 //this are the overwritten callbackmethods from the syncinterface
471 virtual bool sync(KSyncManager* manager, QString filename, int mode); 472 virtual bool sync(KSyncManager* manager, QString filename, int mode);
472 virtual bool syncExternal(KSyncManager* manager, QString resource); 473 virtual bool syncExternal(KSyncManager* manager, QString resource);
473 bool syncPhone(); 474 bool syncPhone();
474 void message( QString m ); 475 void message( QString m );
475 476
476 // LR ******************************* 477 // LR *******************************
477 // sync stuff! 478 // sync stuff!
478 QString sentSyncFile(); 479 QString sentSyncFile();
479 QPopupMenu *syncMenu; 480 QPopupMenu *syncMenu;
480 KSyncManager* syncManager; 481 KSyncManager* syncManager;
481 int mGlobalSyncMode; 482 int mGlobalSyncMode;
482 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 483 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
483 KABC::Addressee getLastSyncAddressee(); 484 KABC::Addressee getLastSyncAddressee();
484 QDateTime mLastAddressbookSync; 485 QDateTime mLastAddressbookSync;
485 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 486 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
486 // ********************* 487 // *********************
487 488
488}; 489};
489 490
490#endif 491#endif