summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmmisc.c4
-rw-r--r--gammu/emb/common/service/gsmpbk.c17
-rw-r--r--gammu/emb/gammu/gammu.c2
-rw-r--r--kabc/addressbook.cpp148
-rw-r--r--kabc/addressbook.h2
-rw-r--r--kabc/addressee.cpp46
-rw-r--r--kabc/addressee.h1
-rw-r--r--kabc/phonenumber.cpp4
-rw-r--r--kaddressbook/kabcore.cpp86
-rw-r--r--libkdepim/ksyncprefsdialog.cpp11
10 files changed, 217 insertions, 104 deletions
diff --git a/gammu/emb/common/service/gsmmisc.c b/gammu/emb/common/service/gsmmisc.c
index 6959a22..1c6ec8b 100644
--- a/gammu/emb/common/service/gsmmisc.c
+++ b/gammu/emb/common/service/gsmmisc.c
@@ -109,154 +109,154 @@ static void GSM_JADFindLine(GSM_File File, char *Name, char *Value)
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 EncodeUTF8QuotedPrintable(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;CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:%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 EncodeUnicode(Value,Buffer+strlen(Start)+1,strlen(Buffer)-(strlen(Start)+1));
225 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 225 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
226 return true; 226 return true;
227 } 227 }
228 /* SE T68i */ 228 /* SE T68i */
229 strcpy(buff,Start); 229 strcpy(buff,Start);
230 strcat(buff,";ENCODING=QUOTED-PRINTABLE:"); 230 strcat(buff,";ENCODING=QUOTED-PRINTABLE:");
231 if (!strncmp(Buffer,buff,strlen(buff))) { 231 if (!strncmp(Buffer,buff,strlen(buff))) {
232 DecodeUTF8QuotedPrintable(Value,Buffer+strlen(Start)+27,strlen(Buffer)-(strlen(Start)+27)); 232 DecodeUTF8QuotedPrintable(Value,Buffer+strlen(Start)+27,strlen(Buffer)-(strlen(Start)+27));
233 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 233 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
234 return true; 234 return true;
235 } 235 }
236 strcpy(buff,Start); 236 strcpy(buff,Start);
237 strcat(buff,";CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:"); 237 strcat(buff,";CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE:");
238 if (!strncmp(Buffer,buff,strlen(buff))) { 238 if (!strncmp(Buffer,buff,strlen(buff))) {
239 DecodeUTF8QuotedPrintable(Value,Buffer+strlen(Start)+41,strlen(Buffer)-(strlen(Start)+41)); 239 DecodeUTF8QuotedPrintable(Value,Buffer+strlen(Start)+41,strlen(Buffer)-(strlen(Start)+41));
240 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 240 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
241 return true; 241 return true;
242 } 242 }
243 strcpy(buff,Start); 243 strcpy(buff,Start);
244 strcat(buff,";CHARSET=UTF-8:"); 244 strcat(buff,";CHARSET=UTF-8:");
245 if (!strncmp(Buffer,buff,strlen(buff))) { 245 if (!strncmp(Buffer,buff,strlen(buff))) {
246 DecodeUTF8(Value,Buffer+strlen(Start)+15,strlen(Buffer)-(strlen(Start)+15)); 246 DecodeUTF8(Value,Buffer+strlen(Start)+15,strlen(Buffer)-(strlen(Start)+15));
247 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 247 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
248 return true; 248 return true;
249 } 249 }
250 strcpy(buff,Start); 250 strcpy(buff,Start);
251 strcat(buff,";CHARSET=UTF-7:"); 251 strcat(buff,";CHARSET=UTF-7:");
252 if (!strncmp(Buffer,buff,strlen(buff))) { 252 if (!strncmp(Buffer,buff,strlen(buff))) {
253 DecodeUTF7(Value,Buffer+strlen(Start)+15,strlen(Buffer)-(strlen(Start)+15)); 253 DecodeUTF7(Value,Buffer+strlen(Start)+15,strlen(Buffer)-(strlen(Start)+15));
254 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value)); 254 dbgprintf("ReadVCalText is \"%s\"\n",DecodeUnicodeConsole(Value));
255 return true; 255 return true;
256 } 256 }
257 return false; 257 return false;
258} 258}
259 259
260/* How should editor hadle tabs in this file? Add editor commands here. 260/* How should editor hadle tabs in this file? Add editor commands here.
261 * vim: noexpandtab sw=8 ts=8 sts=8: 261 * vim: noexpandtab sw=8 ts=8 sts=8:
262 */ 262 */
diff --git a/gammu/emb/common/service/gsmpbk.c b/gammu/emb/common/service/gsmpbk.c
index 05e5cb9..f7cf7d7 100644
--- a/gammu/emb/common/service/gsmpbk.c
+++ b/gammu/emb/common/service/gsmpbk.c
@@ -38,240 +38,241 @@ unsigned char *GSM_PhonebookGetEntryName (GSM_MemoryEntry *entry)
38 len = UnicodeLength(entry->Entries[last].Text); 38 len = UnicodeLength(entry->Entries[last].Text);
39 CopyUnicodeString(dest, entry->Entries[last].Text); 39 CopyUnicodeString(dest, entry->Entries[last].Text);
40 CopyUnicodeString(dest + 2*len, split); 40 CopyUnicodeString(dest + 2*len, split);
41 CopyUnicodeString(dest + 2*len + 4, entry->Entries[first].Text); 41 CopyUnicodeString(dest + 2*len + 4, entry->Entries[first].Text);
42 } else if (last != -1) { 42 } else if (last != -1) {
43 CopyUnicodeString(dest, entry->Entries[last].Text); 43 CopyUnicodeString(dest, entry->Entries[last].Text);
44 } else if (first != -1) { 44 } else if (first != -1) {
45 CopyUnicodeString(dest, entry->Entries[first].Text); 45 CopyUnicodeString(dest, entry->Entries[first].Text);
46 } else { 46 } else {
47 return NULL; 47 return NULL;
48 } 48 }
49 } 49 }
50 50
51 return dest; 51 return dest;
52} 52}
53 53
54void GSM_PhonebookFindDefaultNameNumberGroup(GSM_MemoryEntry *entry, int *Name, int *Number, int *Group) 54void GSM_PhonebookFindDefaultNameNumberGroup(GSM_MemoryEntry *entry, int *Name, int *Number, int *Group)
55{ 55{
56 int i; 56 int i;
57 57
58 *Name = -1; 58 *Name = -1;
59 *Number = -1; 59 *Number = -1;
60 *Group = -1; 60 *Group = -1;
61 for (i = 0; i < entry->EntriesNum; i++) { 61 for (i = 0; i < entry->EntriesNum; i++) {
62 switch (entry->Entries[i].EntryType) { 62 switch (entry->Entries[i].EntryType) {
63 case PBK_Number_General : if (*Number == -1) *Number = i; break; 63 case PBK_Number_General : if (*Number == -1) *Number = i; break;
64 case PBK_Text_Name : if (*Name == -1) *Name = i; break; 64 case PBK_Text_Name : if (*Name == -1) *Name = i; break;
65 case PBK_Caller_Group : if (*Group == -1) *Group = i; break; 65 case PBK_Caller_Group : if (*Group == -1) *Group = i; break;
66 default : break; 66 default : break;
67 } 67 }
68 } 68 }
69 if ((*Number) == -1) { 69 if ((*Number) == -1) {
70 for (i = 0; i < entry->EntriesNum; i++) { 70 for (i = 0; i < entry->EntriesNum; i++) {
71 switch (entry->Entries[i].EntryType) { 71 switch (entry->Entries[i].EntryType) {
72 case PBK_Number_Mobile: 72 case PBK_Number_Mobile:
73 case PBK_Number_Work: 73 case PBK_Number_Work:
74 case PBK_Number_Fax: 74 case PBK_Number_Fax:
75 case PBK_Number_Home: 75 case PBK_Number_Home:
76 case PBK_Number_Pager: 76 case PBK_Number_Pager:
77 case PBK_Number_Other: 77 case PBK_Number_Other:
78 *Number = i; 78 *Number = i;
79 break; 79 break;
80 default: 80 default:
81 break; 81 break;
82 } 82 }
83 if (*Number != -1) break; 83 if (*Number != -1) break;
84 } 84 }
85 } 85 }
86 if ((*Name) == -1) { 86 if ((*Name) == -1) {
87 for (i = 0; i < entry->EntriesNum; i++) { 87 for (i = 0; i < entry->EntriesNum; i++) {
88 if (entry->Entries[i].EntryType != PBK_Text_LastName) continue; 88 if (entry->Entries[i].EntryType != PBK_Text_LastName) continue;
89 *Name = i; 89 *Name = i;
90 break; 90 break;
91 } 91 }
92 } 92 }
93 if ((*Name) == -1) { 93 if ((*Name) == -1) {
94 for (i = 0; i < entry->EntriesNum; i++) { 94 for (i = 0; i < entry->EntriesNum; i++) {
95 if (entry->Entries[i].EntryType != PBK_Text_FirstName) continue; 95 if (entry->Entries[i].EntryType != PBK_Text_FirstName) continue;
96 *Name = i; 96 *Name = i;
97 break; 97 break;
98 } 98 }
99 } 99 }
100} 100}
101 101
102void GSM_EncodeVCARD(char *Buffer, int *Length, GSM_MemoryEntry *pbk, bool header, GSM_VCardVersion Version) 102void GSM_EncodeVCARD(char *Buffer, int *Length, GSM_MemoryEntry *pbk, bool header, GSM_VCardVersion Version)
103{ 103{
104 int Name, Number, Group, i; 104 int Name, Number, Group, i;
105 bool ignore; 105 bool ignore;
106 106
107 GSM_PhonebookFindDefaultNameNumberGroup(pbk, &Name, &Number, &Group); 107 GSM_PhonebookFindDefaultNameNumberGroup(pbk, &Name, &Number, &Group);
108 108
109 if (Version == Nokia_VCard10) { 109 if (Version == Nokia_VCard10) {
110 if (header) *Length+=sprintf(Buffer+(*Length),"BEGIN:VCARD%c%c",13,10); 110 if (header) *Length+=sprintf(Buffer+(*Length),"BEGIN:VCARD%c%c",13,10);
111 if (Name != -1) { 111 if (Name != -1) {
112 *Length+=sprintf(Buffer+(*Length),"N:%s%c%c",DecodeUnicodeString(pbk->Entries[Name].Text),13,10); 112 *Length+=sprintf(Buffer+(*Length),"N:%s%c%c",DecodeUnicodeString(pbk->Entries[Name].Text),13,10);
113 } 113 }
114 if (Number != -1) { 114 if (Number != -1) {
115 *Length +=sprintf(Buffer+(*Length),"TEL:%s%c%c",DecodeUnicodeString(pbk->Entries[Number].Text),13,10); 115 *Length +=sprintf(Buffer+(*Length),"TEL:%s%c%c",DecodeUnicodeString(pbk->Entries[Number].Text),13,10);
116 } 116 }
117 if (header) *Length+=sprintf(Buffer+(*Length),"END:VCARD%c%c",13,10); 117 if (header) *Length+=sprintf(Buffer+(*Length),"END:VCARD%c%c",13,10);
118 } else if (Version == Nokia_VCard21) { 118 } else if (Version == Nokia_VCard21) {
119 if (header) *Length+=sprintf(Buffer+(*Length),"BEGIN:VCARD%c%cVERSION:2.1%c%c",13,10,13,10); 119 if (header) *Length+=sprintf(Buffer+(*Length),"BEGIN:VCARD%c%cVERSION:2.1%c%c",13,10,13,10);
120 if (Name != -1) { 120 if (Name != -1) {
121 SaveVCALText(Buffer, Length, pbk->Entries[Name].Text, "N"); 121 SaveVCALText(Buffer, Length, pbk->Entries[Name].Text, "N");
122 } 122 }
123 for (i=0; i < pbk->EntriesNum; i++) { 123 for (i=0; i < pbk->EntriesNum; i++) {
124 if (i != Name) { 124 if (i != Name) {
125 ignore = false; 125 ignore = false;
126 switch(pbk->Entries[i].EntryType) { 126 switch(pbk->Entries[i].EntryType) {
127 case PBK_Text_Name : 127 case PBK_Text_Name :
128 case PBK_Date : 128 case PBK_Date :
129 case PBK_Caller_Group : 129 case PBK_Caller_Group :
130 ignore = true; 130 ignore = true;
131 break; 131 break;
132 case PBK_Number_General : 132 case PBK_Number_General :
133 *Length+=sprintf(Buffer+(*Length),"TEL"); 133 *Length+=sprintf(Buffer+(*Length),"TEL");
134 if (Number == i) (*Length)+=sprintf(Buffer+(*Length),";PREF"); 134 (*Length)+=sprintf(Buffer+(*Length),";PREF");
135 break; 135 break;
136 case PBK_Number_Mobile : 136 case PBK_Number_Mobile :
137 *Length+=sprintf(Buffer+(*Length),"TEL"); 137 *Length+=sprintf(Buffer+(*Length),"TEL");
138 if (Number == i) (*Length)+=sprintf(Buffer+(*Length),";PREF"); 138 //if (Number == i) (*Length)+=sprintf(Buffer+(*Length),";PREF");
139 *Length+=sprintf(Buffer+(*Length),";CELL"); 139 *Length+=sprintf(Buffer+(*Length),";CELL");
140 break; 140 break;
141 case PBK_Number_Work : 141 case PBK_Number_Work :
142 *Length+=sprintf(Buffer+(*Length),"TEL"); 142 *Length+=sprintf(Buffer+(*Length),"TEL");
143 if (Number == i) (*Length)+=sprintf(Buffer+(*Length),";PREF"); 143 //if (Number == i) (*Length)+=sprintf(Buffer+(*Length),";PREF");
144 *Length+=sprintf(Buffer+(*Length),";WORK;VOICE"); 144 *Length+=sprintf(Buffer+(*Length),";WORK");
145 break; 145 break;
146 case PBK_Number_Fax : 146 case PBK_Number_Fax :
147 *Length+=sprintf(Buffer+(*Length),"TEL"); 147 *Length+=sprintf(Buffer+(*Length),"TEL");
148 if (Number == i) (*Length)+=sprintf(Buffer+(*Length),";PREF"); 148 //if (Number == i) (*Length)+=sprintf(Buffer+(*Length),";PREF");
149 *Length+=sprintf(Buffer+(*Length),";FAX"); 149 *Length+=sprintf(Buffer+(*Length),";FAX");
150 break; 150 break;
151 case PBK_Number_Home : 151 case PBK_Number_Home :
152 *Length+=sprintf(Buffer+(*Length),"TEL"); 152 *Length+=sprintf(Buffer+(*Length),"TEL");
153 if (Number == i) (*Length)+=sprintf(Buffer+(*Length),";PREF"); 153 //if (Number == i) (*Length)+=sprintf(Buffer+(*Length),";PREF");
154 *Length+=sprintf(Buffer+(*Length),";HOME;VOICE"); 154 *Length+=sprintf(Buffer+(*Length),";HOME");
155 break; 155 break;
156 case PBK_Text_Note : 156 case PBK_Text_Note :
157 *Length+=sprintf(Buffer+(*Length),"NOTE"); 157 *Length+=sprintf(Buffer+(*Length),"NOTE");
158 break; 158 break;
159 case PBK_Text_Postal : 159 case PBK_Text_Postal :
160 /* Don't ask why. Nokia phones save postal address 160 /* Don't ask why. Nokia phones save postal address
161 * double - once like LABEL, second like ADR 161 * double - once like LABEL, second like ADR
162 */ 162 */
163 SaveVCALText(Buffer, Length, pbk->Entries[i].Text, "LABEL"); 163 //SaveVCALText(Buffer, Length, pbk->Entries[i].Text, "LABEL");
164 *Length+=sprintf(Buffer+(*Length),"ADR"); 164 *Length+=sprintf(Buffer+(*Length),"ADR");
165 break; 165 break;
166 case PBK_Text_Email : 166 case PBK_Text_Email :
167 case PBK_Text_Email2 : 167 case PBK_Text_Email2 :
168 *Length+=sprintf(Buffer+(*Length),"EMAIL"); 168 *Length+=sprintf(Buffer+(*Length),"EMAIL");
169 break; 169 break;
170 case PBK_Text_URL : 170 case PBK_Text_URL :
171 *Length+=sprintf(Buffer+(*Length),"URL"); 171 *Length+=sprintf(Buffer+(*Length),"URL");
172 break; 172 break;
173 default : 173 default :
174 ignore = true; 174 ignore = true;
175 break; 175 break;
176 } 176 }
177 if (!ignore) { 177 if (!ignore) {
178 SaveVCALText(Buffer, Length, pbk->Entries[i].Text, ""); 178 SaveVCALText(Buffer, Length, pbk->Entries[i].Text, "");
179 } 179 }
180 } 180 }
181 } 181 }
182 *Length+=sprintf(Buffer+(*Length), "X-KADDRESSBOOK-X-ExternalID:%d%c%c",pbk->Location,13,10);
182 if (header) *Length+=sprintf(Buffer+(*Length),"END:VCARD%c%c",13,10); 183 if (header) *Length+=sprintf(Buffer+(*Length),"END:VCARD%c%c",13,10);
183 } 184 }
184} 185}
185 186
186GSM_Error GSM_DecodeVCARD(unsigned char *Buffer, int *Pos, GSM_MemoryEntry *Pbk, GSM_VCardVersion Version) 187GSM_Error GSM_DecodeVCARD(unsigned char *Buffer, int *Pos, GSM_MemoryEntry *Pbk, GSM_VCardVersion Version)
187{ 188{
188 unsigned char Line[2000],Buff[2000]; 189 unsigned char Line[2000],Buff[2000];
189 int Level = 0; 190 int Level = 0;
190 191
191 Buff[0] = 0; 192 Buff[0] = 0;
192 Pbk->EntriesNum = 0; 193 Pbk->EntriesNum = 0;
193 194
194 while (1) { 195 while (1) {
195 MyGetLine(Buffer, Pos, Line, strlen(Buffer)); 196 MyGetLine(Buffer, Pos, Line, strlen(Buffer));
196 if (strlen(Line) == 0) break; 197 if (strlen(Line) == 0) break;
197 switch (Level) { 198 switch (Level) {
198 case 0: 199 case 0:
199 if (strstr(Line,"BEGIN:VCARD")) Level = 1; 200 if (strstr(Line,"BEGIN:VCARD")) Level = 1;
200 break; 201 break;
201 case 1: 202 case 1:
202 if (strstr(Line,"END:VCARD")) { 203 if (strstr(Line,"END:VCARD")) {
203 if (Pbk->EntriesNum == 0) return ERR_EMPTY; 204 if (Pbk->EntriesNum == 0) return ERR_EMPTY;
204 return ERR_NONE; 205 return ERR_NONE;
205 } 206 }
206 if (ReadVCALText(Line, "N", Buff)) { 207 if (ReadVCALText(Line, "N", Buff)) {
207 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 208 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
208 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Name; 209 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Name;
209 Pbk->EntriesNum++; 210 Pbk->EntriesNum++;
210 } 211 }
211 if (ReadVCALText(Line, "TEL", Buff) || 212 if (ReadVCALText(Line, "TEL", Buff) ||
212 ReadVCALText(Line, "TEL;VOICE", Buff) || 213 ReadVCALText(Line, "TEL;VOICE", Buff) ||
213 ReadVCALText(Line, "TEL;PREF", Buff) || 214 ReadVCALText(Line, "TEL;PREF", Buff) ||
214 ReadVCALText(Line, "TEL;PREF;VOICE", Buff)) { 215 ReadVCALText(Line, "TEL;PREF;VOICE", Buff)) {
215 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 216 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
216 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_General; 217 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_General;
217 Pbk->EntriesNum++; 218 Pbk->EntriesNum++;
218 } 219 }
219 if (ReadVCALText(Line, "TEL;CELL", Buff) || 220 if (ReadVCALText(Line, "TEL;CELL", Buff) ||
220 ReadVCALText(Line, "TEL;CELL;VOICE", Buff) || 221 ReadVCALText(Line, "TEL;CELL;VOICE", Buff) ||
221 ReadVCALText(Line, "TEL;PREF;CELL", Buff) || 222 ReadVCALText(Line, "TEL;PREF;CELL", Buff) ||
222 ReadVCALText(Line, "TEL;PREF;CELL;VOICE", Buff)) { 223 ReadVCALText(Line, "TEL;PREF;CELL;VOICE", Buff)) {
223 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 224 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
224 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Mobile; 225 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Mobile;
225 Pbk->EntriesNum++; 226 Pbk->EntriesNum++;
226 } 227 }
227 if (ReadVCALText(Line, "TEL;WORK", Buff) || 228 if (ReadVCALText(Line, "TEL;WORK", Buff) ||
228 ReadVCALText(Line, "TEL;PREF;WORK", Buff) || 229 ReadVCALText(Line, "TEL;PREF;WORK", Buff) ||
229 ReadVCALText(Line, "TEL;WORK;VOICE", Buff) || 230 ReadVCALText(Line, "TEL;WORK;VOICE", Buff) ||
230 ReadVCALText(Line, "TEL;PREF;WORK;VOICE", Buff)) { 231 ReadVCALText(Line, "TEL;PREF;WORK;VOICE", Buff)) {
231 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 232 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
232 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Work; 233 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Work;
233 Pbk->EntriesNum++; 234 Pbk->EntriesNum++;
234 } 235 }
235 if (ReadVCALText(Line, "TEL;FAX", Buff) || 236 if (ReadVCALText(Line, "TEL;FAX", Buff) ||
236 ReadVCALText(Line, "TEL;PREF;FAX", Buff) || 237 ReadVCALText(Line, "TEL;PREF;FAX", Buff) ||
237 ReadVCALText(Line, "TEL;FAX;VOICE", Buff) || 238 ReadVCALText(Line, "TEL;FAX;VOICE", Buff) ||
238 ReadVCALText(Line, "TEL;PREF;FAX;VOICE", Buff)) { 239 ReadVCALText(Line, "TEL;PREF;FAX;VOICE", Buff)) {
239 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 240 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
240 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Fax; 241 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Fax;
241 Pbk->EntriesNum++; 242 Pbk->EntriesNum++;
242 } 243 }
243 if (ReadVCALText(Line, "TEL;HOME", Buff) || 244 if (ReadVCALText(Line, "TEL;HOME", Buff) ||
244 ReadVCALText(Line, "TEL;PREF;HOME", Buff) || 245 ReadVCALText(Line, "TEL;PREF;HOME", Buff) ||
245 ReadVCALText(Line, "TEL;HOME;VOICE", Buff) || 246 ReadVCALText(Line, "TEL;HOME;VOICE", Buff) ||
246 ReadVCALText(Line, "TEL;PREF;HOME;VOICE", Buff)) { 247 ReadVCALText(Line, "TEL;PREF;HOME;VOICE", Buff)) {
247 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 248 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
248 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Home; 249 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Number_Home;
249 Pbk->EntriesNum++; 250 Pbk->EntriesNum++;
250 } 251 }
251 if (ReadVCALText(Line, "NOTE", Buff)) { 252 if (ReadVCALText(Line, "NOTE", Buff)) {
252 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 253 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
253 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Note; 254 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Note;
254 Pbk->EntriesNum++; 255 Pbk->EntriesNum++;
255 } 256 }
256 if (ReadVCALText(Line, "ADR", Buff)) { 257 if (ReadVCALText(Line, "ADR", Buff)) {
257 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 258 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
258 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Postal; 259 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Postal;
259 Pbk->EntriesNum++; 260 Pbk->EntriesNum++;
260 } 261 }
261 if (ReadVCALText(Line, "EMAIL", Buff)) { 262 if (ReadVCALText(Line, "EMAIL", Buff)) {
262 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 263 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
263 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Email; 264 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_Email;
264 Pbk->EntriesNum++; 265 Pbk->EntriesNum++;
265 } 266 }
266 if (ReadVCALText(Line, "URL", Buff)) { 267 if (ReadVCALText(Line, "URL", Buff)) {
267 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff); 268 CopyUnicodeString(Pbk->Entries[Pbk->EntriesNum].Text,Buff);
268 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_URL; 269 Pbk->Entries[Pbk->EntriesNum].EntryType = PBK_Text_URL;
269 Pbk->EntriesNum++; 270 Pbk->EntriesNum++;
270 } 271 }
271 break; 272 break;
272 } 273 }
273 } 274 }
274 275
275 if (Pbk->EntriesNum == 0) return ERR_EMPTY; 276 if (Pbk->EntriesNum == 0) return ERR_EMPTY;
276 return ERR_NONE; 277 return ERR_NONE;
277} 278}
diff --git a/gammu/emb/gammu/gammu.c b/gammu/emb/gammu/gammu.c
index 8db9afb..684e67c 100644
--- a/gammu/emb/gammu/gammu.c
+++ b/gammu/emb/gammu/gammu.c
@@ -4593,193 +4593,193 @@ static void Backup(int argc, char *argv[])
4593 printmsgerr("\n"); 4593 printmsgerr("\n");
4594 } 4594 }
4595 DoBackup = false; 4595 DoBackup = false;
4596 if (Info.GPRSPoint) { 4596 if (Info.GPRSPoint) {
4597 printmsg("Checking GPRS access points\n"); 4597 printmsg("Checking GPRS access points\n");
4598 GPRSPoint.Location = 1; 4598 GPRSPoint.Location = 1;
4599 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); 4599 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
4600 if (error == ERR_NONE || error == ERR_EMPTY) { 4600 if (error == ERR_NONE || error == ERR_EMPTY) {
4601 if (answer_yes(" Backup GPRS access points")) DoBackup = true; 4601 if (answer_yes(" Backup GPRS access points")) DoBackup = true;
4602 } 4602 }
4603 } 4603 }
4604 if (DoBackup) { 4604 if (DoBackup) {
4605 used= 0; 4605 used= 0;
4606 i = 1; 4606 i = 1;
4607 printmsgerr(" Reading: "); 4607 printmsgerr(" Reading: ");
4608 while (error == ERR_NONE || error == ERR_EMPTY) { 4608 while (error == ERR_NONE || error == ERR_EMPTY) {
4609 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); 4609 error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint);
4610 if (error == ERR_NONE) { 4610 if (error == ERR_NONE) {
4611 if (used < GSM_BACKUP_MAX_GPRSPOINT) { 4611 if (used < GSM_BACKUP_MAX_GPRSPOINT) {
4612 Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint)); 4612 Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint));
4613 if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY); 4613 if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY);
4614 Backup.GPRSPoint[used + 1] = NULL; 4614 Backup.GPRSPoint[used + 1] = NULL;
4615 } else { 4615 } else {
4616 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT"); 4616 printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_GPRSPOINT");
4617 GSM_Terminate(); 4617 GSM_Terminate();
4618 exit(-1); 4618 exit(-1);
4619 } 4619 }
4620 *Backup.GPRSPoint[used]=GPRSPoint; 4620 *Backup.GPRSPoint[used]=GPRSPoint;
4621 used++; 4621 used++;
4622 } 4622 }
4623 i++; 4623 i++;
4624 GPRSPoint.Location = i; 4624 GPRSPoint.Location = i;
4625 printmsgerr("*"); 4625 printmsgerr("*");
4626 } 4626 }
4627 printmsgerr("\n"); 4627 printmsgerr("\n");
4628 } 4628 }
4629 4629
4630 GSM_Terminate(); 4630 GSM_Terminate();
4631 4631
4632 GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode); 4632 GSM_SaveBackupFile(argv[2],&Backup, Info.UseUnicode);
4633 GSM_FreeBackup(&Backup); 4633 GSM_FreeBackup(&Backup);
4634} 4634}
4635 4635
4636static void Restore(int argc, char *argv[]) 4636static void Restore(int argc, char *argv[])
4637{ 4637{
4638 GSM_Backup Backup; 4638 GSM_Backup Backup;
4639 GSM_FMStation FMStation; 4639 GSM_FMStation FMStation;
4640 GSM_DateTime date_time; 4640 GSM_DateTime date_time;
4641 GSM_CalendarEntryCalendar; 4641 GSM_CalendarEntryCalendar;
4642 GSM_Bitmap Bitmap; 4642 GSM_Bitmap Bitmap;
4643 GSM_Ringtone Ringtone; 4643 GSM_Ringtone Ringtone;
4644 GSM_MemoryEntry Pbk; 4644 GSM_MemoryEntry Pbk;
4645 GSM_MemoryStatusMemStatus; 4645 GSM_MemoryStatusMemStatus;
4646 GSM_ToDoEntry ToDo; 4646 GSM_ToDoEntry ToDo;
4647 GSM_ToDoStatus ToDoStatus; 4647 GSM_ToDoStatus ToDoStatus;
4648 GSM_Profile Profile; 4648 GSM_Profile Profile;
4649 GSM_MultiWAPSettingsSettings; 4649 GSM_MultiWAPSettingsSettings;
4650 GSM_GPRSAccessPointGPRSPoint; 4650 GSM_GPRSAccessPointGPRSPoint;
4651 GSM_WAPBookmark Bookmark; 4651 GSM_WAPBookmark Bookmark;
4652 int i, used, max = 0; 4652 int i, used, max = 0;
4653 bool Past = true; 4653 bool Past = true;
4654 bool Found, DoRestore; 4654 bool Found, DoRestore;
4655 4655
4656 error=GSM_ReadBackupFile(argv[2],&Backup); 4656 error=GSM_ReadBackupFile(argv[2],&Backup);
4657 if (error!=ERR_NOTIMPLEMENTED) { 4657 if (error!=ERR_NOTIMPLEMENTED) {
4658 Print_Error(error); 4658 Print_Error(error);
4659 } else { 4659 } else {
4660 printmsgerr("WARNING: Some data not read from file. It can be damaged or restoring some settings from this file format not implemented (maybe higher Gammu required ?)\n"); 4660 printmsgerr("WARNING: Some data not read from file. It can be damaged or restoring some settings from this file format not implemented (maybe higher Gammu required ?)\n");
4661 } 4661 }
4662 4662
4663 signal(SIGINT, interrupt); 4663 signal(SIGINT, interrupt);
4664 printmsgerr("Press Ctrl+C to break...\n"); 4664 printmsgerr("Press Ctrl+C to break...\n");
4665 4665
4666 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); 4666 if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false));
4667 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); 4667 if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model);
4668 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); 4668 if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI);
4669 if (Backup.Creator[0]!=0) printmsgerr("File created by : %s\n",Backup.Creator); 4669 if (Backup.Creator[0]!=0) printmsgerr("File created by : %s\n",Backup.Creator);
4670 4670
4671 if (Backup.MD5Calculated[0]!=0) { 4671 if (Backup.MD5Calculated[0]!=0) {
4672 dbgprintf("\"%s\"\n",Backup.MD5Original); 4672 dbgprintf("\"%s\"\n",Backup.MD5Original);
4673 dbgprintf("\"%s\"\n",Backup.MD5Calculated); 4673 dbgprintf("\"%s\"\n",Backup.MD5Calculated);
4674 if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) { 4674 if (strcmp(Backup.MD5Original,Backup.MD5Calculated)) {
4675 if (!answer_yes("Checksum in backup file do not match. Continue")) return; 4675 if (!answer_yes("Checksum in backup file do not match. Continue")) return;
4676 } 4676 }
4677 } 4677 }
4678 4678
4679 GSM_Init(true); 4679 GSM_Init(true);
4680 4680
4681 DoRestore = false; 4681 DoRestore = false;
4682 if (Backup.PhonePhonebook[0] != NULL) { 4682 if (Backup.PhonePhonebook[0] != NULL) {
4683 MemStatus.MemoryType = MEM_ME; 4683 MemStatus.MemoryType = MEM_ME;
4684 error=Phone->GetMemoryStatus(&s, &MemStatus); 4684 error=Phone->GetMemoryStatus(&s, &MemStatus);
4685 if (error==ERR_NONE) { 4685 if (error==ERR_NONE) {
4686 max = 0; 4686 max = 0;
4687 while (Backup.PhonePhonebook[max]!=NULL) max++; 4687 while (Backup.PhonePhonebook[max]!=NULL) max++;
4688 printmsgerr("%i entries in backup file\n",max); 4688 printmsgerr("%i entries in backup file\n",max);
4689 if (answer_yes("Restore phone phonebook")) DoRestore = true; 4689 /* LR if (answer_yes("Restore phone phonebook")) */DoRestore = true;
4690 } 4690 }
4691 } 4691 }
4692 if (DoRestore) { 4692 if (DoRestore) {
4693 used = 0; 4693 used = 0;
4694 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 4694 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
4695 Pbk.MemoryType = MEM_ME; 4695 Pbk.MemoryType = MEM_ME;
4696 Pbk.Location= i + 1; 4696 Pbk.Location= i + 1;
4697 Pbk.EntriesNum= 0; 4697 Pbk.EntriesNum= 0;
4698 if (used<max) { 4698 if (used<max) {
4699 if (Backup.PhonePhonebook[used]->Location == Pbk.Location) { 4699 if (Backup.PhonePhonebook[used]->Location == Pbk.Location) {
4700 Pbk = *Backup.PhonePhonebook[used]; 4700 Pbk = *Backup.PhonePhonebook[used];
4701 used++; 4701 used++;
4702 dbgprintf("Location %i\n",Pbk.Location); 4702 dbgprintf("Location %i\n",Pbk.Location);
4703 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); 4703 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk);
4704 } 4704 }
4705 } 4705 }
4706 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); 4706 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk);
4707 Print_Error(error); 4707 Print_Error(error);
4708 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 4708 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
4709 if (gshutdown) { 4709 if (gshutdown) {
4710 GSM_Terminate(); 4710 GSM_Terminate();
4711 exit(0); 4711 exit(0);
4712 } 4712 }
4713 } 4713 }
4714 printmsgerr("\n"); 4714 printmsgerr("\n");
4715 } 4715 }
4716 4716
4717 DoRestore = false; 4717 DoRestore = false;
4718 if (Backup.SIMPhonebook[0] != NULL) { 4718 if (Backup.SIMPhonebook[0] != NULL) {
4719 MemStatus.MemoryType = MEM_SM; 4719 MemStatus.MemoryType = MEM_SM;
4720 error=Phone->GetMemoryStatus(&s, &MemStatus); 4720 error=Phone->GetMemoryStatus(&s, &MemStatus);
4721 if (error==ERR_NONE) { 4721 if (error==ERR_NONE) {
4722 max = 0; 4722 max = 0;
4723 while (Backup.SIMPhonebook[max]!=NULL) max++; 4723 while (Backup.SIMPhonebook[max]!=NULL) max++;
4724 printmsgerr("%i entries in backup file\n",max); 4724 printmsgerr("%i entries in backup file\n",max);
4725 if (answer_yes("Restore SIM phonebook")) DoRestore = true; 4725 if (answer_yes("Restore SIM phonebook")) DoRestore = true;
4726 } 4726 }
4727 } 4727 }
4728 if (DoRestore) { 4728 if (DoRestore) {
4729 used = 0; 4729 used = 0;
4730 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { 4730 for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) {
4731 Pbk.MemoryType = MEM_SM; 4731 Pbk.MemoryType = MEM_SM;
4732 Pbk.Location= i + 1; 4732 Pbk.Location= i + 1;
4733 Pbk.EntriesNum= 0; 4733 Pbk.EntriesNum= 0;
4734 if (used<max) { 4734 if (used<max) {
4735 if (Backup.SIMPhonebook[used]->Location == Pbk.Location) { 4735 if (Backup.SIMPhonebook[used]->Location == Pbk.Location) {
4736 Pbk = *Backup.SIMPhonebook[used]; 4736 Pbk = *Backup.SIMPhonebook[used];
4737 used++; 4737 used++;
4738 dbgprintf("Location %i\n",Pbk.Location); 4738 dbgprintf("Location %i\n",Pbk.Location);
4739 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk); 4739 if (Pbk.EntriesNum != 0) error=Phone->SetMemory(&s, &Pbk);
4740 } 4740 }
4741 } 4741 }
4742 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk); 4742 if (Pbk.EntriesNum == 0) error=Phone->DeleteMemory(&s, &Pbk);
4743 Print_Error(error); 4743 Print_Error(error);
4744 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); 4744 printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree));
4745 if (gshutdown) { 4745 if (gshutdown) {
4746 GSM_Terminate(); 4746 GSM_Terminate();
4747 exit(0); 4747 exit(0);
4748 } 4748 }
4749 } 4749 }
4750 printmsgerr("\n"); 4750 printmsgerr("\n");
4751 } 4751 }
4752 4752
4753 DoRestore = false; 4753 DoRestore = false;
4754 if (Backup.CallerLogos[0] != NULL) { 4754 if (Backup.CallerLogos[0] != NULL) {
4755 Bitmap.Type = GSM_CallerGroupLogo; 4755 Bitmap.Type = GSM_CallerGroupLogo;
4756 Bitmap.Location = 1; 4756 Bitmap.Location = 1;
4757 error=Phone->GetBitmap(&s,&Bitmap); 4757 error=Phone->GetBitmap(&s,&Bitmap);
4758 if (error == ERR_NONE) { 4758 if (error == ERR_NONE) {
4759 if (answer_yes("Restore caller groups and logos")) DoRestore = true; 4759 if (answer_yes("Restore caller groups and logos")) DoRestore = true;
4760 } 4760 }
4761 } 4761 }
4762 if (DoRestore) { 4762 if (DoRestore) {
4763 max = 0; 4763 max = 0;
4764 while (Backup.CallerLogos[max]!=NULL) max++; 4764 while (Backup.CallerLogos[max]!=NULL) max++;
4765 for (i=0;i<max;i++) { 4765 for (i=0;i<max;i++) {
4766 error=Phone->SetBitmap(&s,Backup.CallerLogos[i]); 4766 error=Phone->SetBitmap(&s,Backup.CallerLogos[i]);
4767 Print_Error(error); 4767 Print_Error(error);
4768 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); 4768 printmsgerr("%cWriting: %i percent",13,(i+1)*100/max);
4769 if (gshutdown) { 4769 if (gshutdown) {
4770 GSM_Terminate(); 4770 GSM_Terminate();
4771 exit(0); 4771 exit(0);
4772 } 4772 }
4773 } 4773 }
4774 printmsgerr("\n"); 4774 printmsgerr("\n");
4775 } 4775 }
4776 4776
4777 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { 4777 if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) {
4778 if ( true /*LRanswer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/) { 4778 if ( true /*LRanswer_yes("Do you want to set date/time in phone (NOTE: in some phones it's required to correctly restore calendar notes and other items)")*/) {
4779 GSM_GetCurrentDateTime(&date_time); 4779 GSM_GetCurrentDateTime(&date_time);
4780 4780
4781 error=Phone->SetDateTime(&s, &date_time); 4781 error=Phone->SetDateTime(&s, &date_time);
4782 Print_Error(error); 4782 Print_Error(error);
4783 } 4783 }
4784 } 4784 }
4785 DoRestore = false; 4785 DoRestore = false;
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index d037d2f..ad0f702 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -248,445 +248,567 @@ void AddressBook::init(const QString &config, const QString &family )
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, false ); 280 d->mManager = new KRES::Manager<Resource>( fami, false );
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
345 clear(); 344 clear();
346
347 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
348 bool ok = true; 346 bool ok = true;
349 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
350 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
351 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 qDebug( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
352 ok = false; 350 ok = false;
351 } else {
352 qDebug( i18n("Resource loaded: '%1'").arg( (*it)->resourceName() ) );
353 } 353 }
354
355 // mark all addressees as unchanged 354 // mark all addressees as unchanged
356 Addressee::List::Iterator addrIt; 355 Addressee::List::Iterator addrIt;
357 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 356 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
358 (*addrIt).setChanged( false ); 357 (*addrIt).setChanged( false );
359 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 358 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
360 if ( !id.isEmpty() ) { 359 if ( !id.isEmpty() ) {
361 //qDebug("setId aa %s ", id.latin1()); 360 //qDebug("setId aa %s ", id.latin1());
362 (*addrIt).setIDStr(id ); 361 (*addrIt).setIDStr(id );
363 } 362 }
364 } 363 }
365 blockLSEchange = true; 364 blockLSEchange = true;
366 return ok; 365 return ok;
367} 366}
368 367
369bool AddressBook::save( Ticket *ticket ) 368bool AddressBook::save( Ticket *ticket )
370{ 369{
371 kdDebug(5700) << "AddressBook::save()"<< endl; 370 kdDebug(5700) << "AddressBook::save()"<< endl;
372 371
373 if ( ticket->resource() ) { 372 if ( ticket->resource() ) {
374 deleteRemovedAddressees(); 373 deleteRemovedAddressees();
375 return ticket->resource()->save( ticket ); 374 return ticket->resource()->save( ticket );
376 } 375 }
377 376
378 return false; 377 return false;
379} 378}
380void AddressBook::export2File( QString fileName ) 379void AddressBook::export2File( QString fileName )
381{ 380{
382 381
383 QFile outFile( fileName ); 382 QFile outFile( fileName );
384 if ( !outFile.open( IO_WriteOnly ) ) { 383 if ( !outFile.open( IO_WriteOnly ) ) {
385 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 384 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
386 KMessageBox::error( 0, text.arg( fileName ) ); 385 KMessageBox::error( 0, text.arg( fileName ) );
387 return ; 386 return ;
388 } 387 }
389 QTextStream t( &outFile ); 388 QTextStream t( &outFile );
390 t.setEncoding( QTextStream::UnicodeUTF8 ); 389 t.setEncoding( QTextStream::UnicodeUTF8 );
391 Iterator it; 390 Iterator it;
392 KABC::VCardConverter::Version version; 391 KABC::VCardConverter::Version version;
393 version = KABC::VCardConverter::v3_0; 392 version = KABC::VCardConverter::v3_0;
394 for ( it = begin(); it != end(); ++it ) { 393 for ( it = begin(); it != end(); ++it ) {
395 if ( !(*it).IDStr().isEmpty() ) { 394 if ( !(*it).IDStr().isEmpty() ) {
396 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 395 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
397 } 396 }
398 KABC::VCardConverter converter; 397 KABC::VCardConverter converter;
399 QString vcard; 398 QString vcard;
400 //Resource *resource() const; 399 //Resource *resource() const;
401 converter.addresseeToVCard( *it, vcard, version ); 400 converter.addresseeToVCard( *it, vcard, version );
402 t << vcard << "\r\n"; 401 t << vcard << "\r\n";
403 } 402 }
404 t << "\r\n\r\n"; 403 t << "\r\n\r\n";
405 outFile.close(); 404 outFile.close();
406} 405}
406// if QStringList uids is empty, all are exported
407bool AddressBook::export2PhoneFormat( QStringList uids ,QString fileName )
408{
409 KABC::VCardConverter converter;
410 QString datastream;
411 Iterator it;
412 bool all = uids.isEmpty();
413 for ( it = begin(); it != end(); ++it ) {
414 // for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
415 if ( ! all ) {
416 if ( ! ( uids.contains((*it).uid() ) ))
417 continue;
418 }
419 KABC::Addressee a = ( *it );
420 if ( a.isEmpty() )
421 continue;
422 a.simplifyEmails();
423 a.simplifyPhoneNumbers();
424 a.simplifyPhoneNumberTypes();
425 a.simplifyAddresses();
426
427 QString vcard;
428 QString vcardnew;
429 converter.addresseeToVCard( a, vcard );
430 int start = 0;
431 int next;
432 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
433 int semi = vcard.find(";", next);
434 int dopp = vcard.find(":", next);
435 int sep;
436 if ( semi < dopp && semi >= 0 )
437 sep = semi ;
438 else
439 sep = dopp;
440 vcardnew +=vcard.mid( start, next - start);
441 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
442 start = sep;
443 }
444 vcardnew += vcard.mid( start,vcard.length() );
445 vcard = "";
446 start = 0;
447 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
448 int sep = vcardnew.find(":", next);
449 vcard +=vcardnew.mid( start, next - start+3);
450 start = sep;
451 }
452 vcard += vcardnew.mid( start,vcardnew.length() );
453 vcard.replace ( QRegExp(";;;") , "" );
454 vcard.replace ( QRegExp(";;") , "" );
455 datastream += vcard;
456
457 }
458
459 QFile outFile(fileName);
460 if ( outFile.open(IO_WriteOnly) ) {
461 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
462 QTextStream t( &outFile ); // use a text stream
463 t.setEncoding( QTextStream::UnicodeUTF8 );
464 t <<datastream;
465 t << "\r\n\r\n";
466 outFile.close();
467
468 } else {
469 qDebug("Error open temp file ");
470 return false;
471 }
472 return true;
473
474}
407void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) 475void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld )
408{ 476{
409 477
410 if ( removeOld ) 478 if ( removeOld )
411 setUntagged(); 479 setUntagged();
412 KABC::Addressee::List list; 480 KABC::Addressee::List list;
413 QFile file( fileName ); 481 QFile file( fileName );
414 file.open( IO_ReadOnly ); 482 file.open( IO_ReadOnly );
415 QByteArray rawData = file.readAll(); 483 QByteArray rawData = file.readAll();
416 file.close(); 484 file.close();
417 QString data; 485 QString data;
418 if ( replaceLabel ) { 486 if ( replaceLabel ) {
419 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 487 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
420 data.replace ( QRegExp("LABEL") , "ADR" ); 488 data.replace ( QRegExp("LABEL") , "ADR" );
421 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 489 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
422 } else 490 } else
423 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 491 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
424 KABC::VCardTool tool; 492 KABC::VCardTool tool;
425 list = tool.parseVCards( data ); 493 list = tool.parseVCards( data );
426 KABC::Addressee::List::Iterator it; 494 KABC::Addressee::List::Iterator it;
427 for ( it = list.begin(); it != list.end(); ++it ) { 495 for ( it = list.begin(); it != list.end(); ++it ) {
496 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
497 if ( !id.isEmpty() )
498 (*it).setIDStr(id );
428 (*it).setResource( 0 ); 499 (*it).setResource( 0 );
429 if ( replaceLabel ) 500 if ( replaceLabel )
430 (*it).removeVoice(); 501 (*it).removeVoice();
431 if ( removeOld ) 502 if ( removeOld )
432 (*it).setTagged( true ); 503 (*it).setTagged( true );
433 insertAddressee( (*it), false, true ); 504 insertAddressee( (*it), false, true );
434 } 505 }
435 if ( removeOld ) 506 if ( removeOld )
436 removeUntagged(); 507 removeUntagged();
437} 508}
438void AddressBook::setUntagged() 509void AddressBook::setUntagged()
439{ 510{
440 Iterator ait; 511 Iterator ait;
441 for ( ait = begin(); ait != end(); ++ait ) { 512 for ( ait = begin(); ait != end(); ++ait ) {
442 (*ait).setTagged( false ); 513 (*ait).setTagged( false );
443 } 514 }
444} 515}
445void AddressBook::removeUntagged() 516void AddressBook::removeUntagged()
446{ 517{
447 Iterator ait; 518 Iterator ait;
448 bool todelete = false; 519 bool todelete = false;
449 Iterator todel; 520 Iterator todel;
450 for ( ait = begin(); ait != end(); ++ait ) { 521 for ( ait = begin(); ait != end(); ++ait ) {
451 if ( todelete ) 522 if ( todelete )
452 removeAddressee( todel ); 523 removeAddressee( todel );
453 if (!(*ait).tagged()) { 524 if (!(*ait).tagged()) {
454 todelete = true; 525 todelete = true;
455 todel = ait; 526 todel = ait;
456 } else 527 } else
457 todelete = false; 528 todelete = false;
458 } 529 }
459 if ( todelete ) 530 if ( todelete )
460 removeAddressee( todel ); 531 removeAddressee( todel );
461 deleteRemovedAddressees(); 532 deleteRemovedAddressees();
462} 533}
463void AddressBook::smplifyAddressees() 534void AddressBook::smplifyAddressees()
464{ 535{
465 Iterator ait; 536 Iterator ait;
466 for ( ait = begin(); ait != end(); ++ait ) { 537 for ( ait = begin(); ait != end(); ++ait ) {
467 (*ait).simplifyEmails(); 538 (*ait).simplifyEmails();
468 (*ait).simplifyPhoneNumbers(); 539 (*ait).simplifyPhoneNumbers();
469 (*ait).simplifyPhoneNumberTypes(); 540 (*ait).simplifyPhoneNumberTypes();
470 (*ait).simplifyAddresses(); 541 (*ait).simplifyAddresses();
471 } 542 }
472} 543}
473void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) 544void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync )
474{ 545{
475 Iterator ait; 546 Iterator ait;
476 for ( ait = begin(); ait != end(); ++ait ) { 547 for ( ait = begin(); ait != end(); ++ait ) {
477 QString id = (*ait).IDStr(); 548 QString id = (*ait).IDStr();
478 (*ait).setIDStr( ":"); 549 (*ait).setIDStr( ":");
479 (*ait).setExternalUID( id ); 550 (*ait).setExternalUID( id );
480 (*ait).setOriginalExternalUID( id ); 551 (*ait).setOriginalExternalUID( id );
481 if ( isPreSync ) 552 if ( isPreSync )
482 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 553 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
483 else 554 else {
484 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 555 (*ait).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
556 (*ait).setID( currentSyncDevice,id );
557
558 }
559 }
560}
561void AddressBook::findNewExtIds( QString fileName, QString currentSyncDevice )
562{
563
564 setUntagged();
565 KABC::Addressee::List list;
566 QFile file( fileName );
567 file.open( IO_ReadOnly );
568 QByteArray rawData = file.readAll();
569 file.close();
570 QString data;
571
572 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
573 KABC::VCardTool tool;
574 list = tool.parseVCards( data );
575 KABC::Addressee::List::Iterator it;
576 for ( it = list.begin(); it != list.end(); ++it ) {
577 Iterator ait;
578 for ( ait = begin(); ait != end(); ++ait ) {
579 if ( !(*ait).tagged() ) {
580 if ( (*ait).containsAdr(*it)) {
581 (*ait).setTagged(true);
582 QString id = (*it).custom( "KADDRESSBOOK", "X-ExternalID" );
583 (*it).setIDStr( ":");
584 (*it).setID( currentSyncDevice,id );
585 (*it).setExternalUID( id );
586 (*it).setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
587 (*it).setUid( ( (*ait).uid() ));
588 break;
589 }
590 }
591
592 }
593 if ( ait == end() )
594 qDebug("ERROR:: no ext ID found for uid: %s", (*it).uid().latin1());
595 }
596 clear();
597 for ( it = list.begin(); it != list.end(); ++it ) {
598 insertAddressee( (*it) );
485 } 599 }
486} 600}
601
487bool AddressBook::saveABphone( QString fileName ) 602bool AddressBook::saveABphone( QString fileName )
488{ 603{
489 smplifyAddressees(); 604 //smplifyAddressees();
490 qDebug("saveABphone:: saving AB... "); 605 qDebug("saveABphone:: saving AB... ");
491 if ( ! saveAB() ) 606 if ( ! export2PhoneFormat( QStringList() ,fileName ) )
492 return false; 607 return false;
493 qDebug("saveABphone:: writing to phone... "); 608 qDebug("saveABphone:: writing to phone... ");
494 if ( !PhoneAccess::writeToPhone( fileName) ) { 609 if ( !PhoneAccess::writeToPhone( fileName) ) {
495 return false; 610 return false;
496 } 611 }
497 qDebug("saveABphone:: re-reading from phone... "); 612 qDebug("saveABphone:: re-reading from phone... ");
498 if ( !PhoneAccess::readFromPhone( fileName) ) { 613 if ( !PhoneAccess::readFromPhone( fileName) ) {
499 return false; 614 return false;
500 } 615 }
501 qDebug("reloading phone book... ");
502 if ( !load() )
503 return false;
504 return true; 616 return true;
505} 617}
506bool AddressBook::saveAB() 618bool AddressBook::saveAB()
507{ 619{
508 bool ok = true; 620 bool ok = true;
509 621
510 deleteRemovedAddressees(); 622 deleteRemovedAddressees();
511 Iterator ait; 623 Iterator ait;
512 for ( ait = begin(); ait != end(); ++ait ) { 624 for ( ait = begin(); ait != end(); ++ait ) {
513 if ( !(*ait).IDStr().isEmpty() ) { 625 if ( !(*ait).IDStr().isEmpty() ) {
514 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 626 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
515 } 627 }
516 } 628 }
517 KRES::Manager<Resource>::ActiveIterator it; 629 KRES::Manager<Resource>::ActiveIterator it;
518 KRES::Manager<Resource> *manager = d->mManager; 630 KRES::Manager<Resource> *manager = d->mManager;
631 qDebug("SaveAB::saving..." );
519 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 632 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
633 qDebug("SaveAB::checking resource..." );
634 if ( (*it)->readOnly() )
635 qDebug("readonly." );
636 if ( (*it)->isOpen() )
637 qDebug("open" );
638
520 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 639 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
521 Ticket *ticket = requestSaveTicket( *it ); 640 Ticket *ticket = requestSaveTicket( *it );
522// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 641 qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
523 if ( !ticket ) { 642 if ( !ticket ) {
524 error( i18n( "Unable to save to resource '%1'. It is locked." ) 643 qDebug( i18n( "Unable to save to resource '%1'. It is locked." )
525 .arg( (*it)->resourceName() ) ); 644 .arg( (*it)->resourceName() ) );
526 return false; 645 return false;
527 } 646 }
528 647
529 //if ( !save( ticket ) ) 648 //if ( !save( ticket ) )
530 if ( ticket->resource() ) { 649 if ( ticket->resource() ) {
531 if ( ! ticket->resource()->save( ticket ) ) 650 if ( ! ticket->resource()->save( ticket ) )
532 ok = false; 651 ok = false;
652 else
653 qDebug("StdAddressBook::saved '%s'", ticket->resource()->resourceName().latin1() );
654
533 } else 655 } else
534 ok = false; 656 ok = false;
535 657
536 } 658 }
537 } 659 }
538 return ok; 660 return ok;
539} 661}
540 662
541AddressBook::Iterator AddressBook::begin() 663AddressBook::Iterator AddressBook::begin()
542{ 664{
543 Iterator it = Iterator(); 665 Iterator it = Iterator();
544 it.d->mIt = d->mAddressees.begin(); 666 it.d->mIt = d->mAddressees.begin();
545 return it; 667 return it;
546} 668}
547 669
548AddressBook::ConstIterator AddressBook::begin() const 670AddressBook::ConstIterator AddressBook::begin() const
549{ 671{
550 ConstIterator it = ConstIterator(); 672 ConstIterator it = ConstIterator();
551 it.d->mIt = d->mAddressees.begin(); 673 it.d->mIt = d->mAddressees.begin();
552 return it; 674 return it;
553} 675}
554 676
555AddressBook::Iterator AddressBook::end() 677AddressBook::Iterator AddressBook::end()
556{ 678{
557 Iterator it = Iterator(); 679 Iterator it = Iterator();
558 it.d->mIt = d->mAddressees.end(); 680 it.d->mIt = d->mAddressees.end();
559 return it; 681 return it;
560} 682}
561 683
562AddressBook::ConstIterator AddressBook::end() const 684AddressBook::ConstIterator AddressBook::end() const
563{ 685{
564 ConstIterator it = ConstIterator(); 686 ConstIterator it = ConstIterator();
565 it.d->mIt = d->mAddressees.end(); 687 it.d->mIt = d->mAddressees.end();
566 return it; 688 return it;
567} 689}
568 690
569void AddressBook::clear() 691void AddressBook::clear()
570{ 692{
571 d->mAddressees.clear(); 693 d->mAddressees.clear();
572} 694}
573 695
574Ticket *AddressBook::requestSaveTicket( Resource *resource ) 696Ticket *AddressBook::requestSaveTicket( Resource *resource )
575{ 697{
576 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 698 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
577 699
578 if ( !resource ) 700 if ( !resource )
579 { 701 {
580 qDebug("AddressBook::requestSaveTicket no resource" ); 702 qDebug("AddressBook::requestSaveTicket no resource" );
581 resource = standardResource(); 703 resource = standardResource();
582 } 704 }
583 705
584 KRES::Manager<Resource>::ActiveIterator it; 706 KRES::Manager<Resource>::ActiveIterator it;
585 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 707 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
586 if ( (*it) == resource ) { 708 if ( (*it) == resource ) {
587 if ( (*it)->readOnly() || !(*it)->isOpen() ) 709 if ( (*it)->readOnly() || !(*it)->isOpen() )
588 return 0; 710 return 0;
589 else 711 else
590 return (*it)->requestSaveTicket(); 712 return (*it)->requestSaveTicket();
591 } 713 }
592 } 714 }
593 715
594 return 0; 716 return 0;
595} 717}
596 718//void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
597void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 719void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
598{ 720{
599 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 721 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
600 //qDebug("block insert "); 722 //qDebug("block insert ");
601 return; 723 return;
602 } 724 }
603 //qDebug("inserting.... %s ",a.uid().latin1() ); 725 //qDebug("inserting.... %s ",a.uid().latin1() );
604 bool found = false; 726 bool found = false;
605 Addressee::List::Iterator it; 727 Addressee::List::Iterator it;
606 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 728 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
607 if ( a.uid() == (*it).uid() ) { 729 if ( a.uid() == (*it).uid() ) {
608 730
609 bool changed = false; 731 bool changed = false;
610 Addressee addr = a; 732 Addressee addr = a;
611 if ( addr != (*it) ) 733 if ( addr != (*it) )
612 changed = true; 734 changed = true;
613 735
614 if ( takeResource ) { 736 if ( takeResource ) {
615 Resource * res = (*it).resource(); 737 Resource * res = (*it).resource();
616 (*it) = a; 738 (*it) = a;
617 (*it).setResource( res ); 739 (*it).setResource( res );
618 } else { 740 } else {
619 (*it) = a; 741 (*it) = a;
620 if ( (*it).resource() == 0 ) 742 if ( (*it).resource() == 0 )
621 (*it).setResource( standardResource() ); 743 (*it).setResource( standardResource() );
622 } 744 }
623 if ( changed ) { 745 if ( changed ) {
624 if ( setRev ) { 746 if ( setRev ) {
625 747
626 // get rid of micro seconds 748 // get rid of micro seconds
627 QDateTime dt = QDateTime::currentDateTime(); 749 QDateTime dt = QDateTime::currentDateTime();
628 QTime t = dt.time(); 750 QTime t = dt.time();
629 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 751 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
630 (*it).setRevision( dt ); 752 (*it).setRevision( dt );
631 } 753 }
632 (*it).setChanged( true ); 754 (*it).setChanged( true );
633 } 755 }
634 756
635 found = true; 757 found = true;
636 } else { 758 } else {
637 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 759 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
638 QString name = (*it).uid().mid( 19 ); 760 QString name = (*it).uid().mid( 19 );
639 Addressee b = a; 761 Addressee b = a;
640 QString id = b.getID( name ); 762 QString id = b.getID( name );
641 if ( ! id.isEmpty() ) { 763 if ( ! id.isEmpty() ) {
642 QString des = (*it).note(); 764 QString des = (*it).note();
643 int startN; 765 int startN;
644 if( (startN = des.find( id ) ) >= 0 ) { 766 if( (startN = des.find( id ) ) >= 0 ) {
645 int endN = des.find( ",", startN+1 ); 767 int endN = des.find( ",", startN+1 );
646 des = des.left( startN ) + des.mid( endN+1 ); 768 des = des.left( startN ) + des.mid( endN+1 );
647 (*it).setNote( des ); 769 (*it).setNote( des );
648 } 770 }
649 } 771 }
650 } 772 }
651 } 773 }
652 } 774 }
653 if ( found ) 775 if ( found )
654 return; 776 return;
655 d->mAddressees.append( a ); 777 d->mAddressees.append( a );
656 Addressee& addr = d->mAddressees.last(); 778 Addressee& addr = d->mAddressees.last();
657 if ( addr.resource() == 0 ) 779 if ( addr.resource() == 0 )
658 addr.setResource( standardResource() ); 780 addr.setResource( standardResource() );
659 781
660 addr.setChanged( true ); 782 addr.setChanged( true );
661} 783}
662 784
663void AddressBook::removeAddressee( const Addressee &a ) 785void AddressBook::removeAddressee( const Addressee &a )
664{ 786{
665 Iterator it; 787 Iterator it;
666 Iterator it2; 788 Iterator it2;
667 bool found = false; 789 bool found = false;
668 for ( it = begin(); it != end(); ++it ) { 790 for ( it = begin(); it != end(); ++it ) {
669 if ( a.uid() == (*it).uid() ) { 791 if ( a.uid() == (*it).uid() ) {
670 found = true; 792 found = true;
671 it2 = it; 793 it2 = it;
672 } else { 794 } else {
673 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 795 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
674 QString name = (*it).uid().mid( 19 ); 796 QString name = (*it).uid().mid( 19 );
675 Addressee b = a; 797 Addressee b = a;
676 QString id = b.getID( name ); 798 QString id = b.getID( name );
677 if ( ! id.isEmpty() ) { 799 if ( ! id.isEmpty() ) {
678 QString des = (*it).note(); 800 QString des = (*it).note();
679 if( des.find( id ) < 0 ) { 801 if( des.find( id ) < 0 ) {
680 des += id + ","; 802 des += id + ",";
681 (*it).setNote( des ); 803 (*it).setNote( des );
682 } 804 }
683 } 805 }
684 } 806 }
685 807
686 } 808 }
687 } 809 }
688 810
689 if ( found ) 811 if ( found )
690 removeAddressee( it2 ); 812 removeAddressee( it2 );
691 813
692} 814}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index cc755d1..df9048b 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -53,195 +53,197 @@ class AddressBook : public QObject
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 void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); 150 void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false );
150 void setUntagged(); 151 void setUntagged();
151 void removeUntagged(); 152 void removeUntagged();
153 void findNewExtIds( QString fileName, QString currentSyncDevice );
152 /** 154 /**
153 Returns a iterator for first entry of address book. 155 Returns a iterator for first entry of address book.
154 */ 156 */
155 Iterator begin(); 157 Iterator begin();
156 158
157 /** 159 /**
158 Returns a const iterator for first entry of address book. 160 Returns a const iterator for first entry of address book.
159 */ 161 */
160 ConstIterator begin() const; 162 ConstIterator begin() const;
161 163
162 /** 164 /**
163 Returns a iterator for first entry of address book. 165 Returns a iterator for first entry of address book.
164 */ 166 */
165 Iterator end(); 167 Iterator end();
166 168
167 /** 169 /**
168 Returns a const iterator for first entry of address book. 170 Returns a const iterator for first entry of address book.
169 */ 171 */
170 ConstIterator end() const; 172 ConstIterator end() const;
171 173
172 /** 174 /**
173 Removes all entries from address book. 175 Removes all entries from address book.
174 */ 176 */
175 void clear(); 177 void clear();
176 178
177 /** 179 /**
178 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
179 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
180 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.
181 */ 183 */
182 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); 184 void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false);
183 185
184 /** 186 /**
185 Removes entry from the address book. 187 Removes entry from the address book.
186 */ 188 */
187 void removeAddressee( const Addressee & ); 189 void removeAddressee( const Addressee & );
188 190
189 /** 191 /**
190 This is like @ref removeAddressee() just above, with the difference that 192 This is like @ref removeAddressee() just above, with the difference that
191 the first element is a iterator, returned by @ref begin(). 193 the first element is a iterator, returned by @ref begin().
192 */ 194 */
193 void removeAddressee( const Iterator & ); 195 void removeAddressee( const Iterator & );
194 196
195 /** 197 /**
196 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
197 couldn't be found. 199 couldn't be found.
198 */ 200 */
199 Iterator find( const Addressee & ); 201 Iterator find( const Addressee & );
200 202
201 /** 203 /**
202 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
203 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.
204 */ 206 */
205 Addressee findByUid( const QString & ); 207 Addressee findByUid( const QString & );
206 208
207 209
208 /** 210 /**
209 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
210 be sorted with @ref KABC::AddresseeList for example. 212 be sorted with @ref KABC::AddresseeList for example.
211 */ 213 */
212 Addressee::List allAddressees(); 214 Addressee::List allAddressees();
213 215
214 /** 216 /**
215 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
216 an empty list, if no entries could be found. 218 an empty list, if no entries could be found.
217 */ 219 */
218 Addressee::List findByName( const QString & ); 220 Addressee::List findByName( const QString & );
219 221
220 /** 222 /**
221 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.
222 Returns an empty list, if no entries could be found. 224 Returns an empty list, if no entries could be found.
223 */ 225 */
224 Addressee::List findByEmail( const QString & ); 226 Addressee::List findByEmail( const QString & );
225 227
226 /** 228 /**
227 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.
228 Returns an empty list, if no entries could be found. 230 Returns an empty list, if no entries could be found.
229 */ 231 */
230 Addressee::List findByCategory( const QString & ); 232 Addressee::List findByCategory( const QString & );
231 233
232 /** 234 /**
233 Return a string identifying this addressbook. 235 Return a string identifying this addressbook.
234 */ 236 */
235 virtual QString identifier(); 237 virtual QString identifier();
236 238
237 /** 239 /**
238 Used for debug output. 240 Used for debug output.
239 */ 241 */
240 void dump() const; 242 void dump() const;
241 243
242 void emitAddressBookLocked() { emit addressBookLocked( this ); } 244 void emitAddressBookLocked() { emit addressBookLocked( this ); }
243 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 245 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
244 void emitAddressBookChanged() { emit addressBookChanged( this ); } 246 void emitAddressBookChanged() { emit addressBookChanged( this ); }
245 247
246 /** 248 /**
247 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
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 607ae26..548305a 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -210,230 +210,270 @@ void Addressee::computeCsum(const QString &dev)
210{ 210{
211 QStringList l; 211 QStringList l;
212 if ( !mData->name.isEmpty() ) l.append(mData->name); 212 if ( !mData->name.isEmpty() ) l.append(mData->name);
213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); 213 if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName );
214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); 214 if ( !mData->familyName.isEmpty() ) l.append( mData->familyName );
215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); 215 if ( !mData->givenName.isEmpty() ) l.append(mData->givenName );
216 if ( !mData->additionalName ) l.append( mData->additionalName ); 216 if ( !mData->additionalName ) l.append( mData->additionalName );
217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); 217 if ( !mData->prefix.isEmpty() ) l.append( mData->prefix );
218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); 218 if ( !mData->suffix.isEmpty() ) l.append( mData->suffix );
219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); 219 if ( !mData->nickName.isEmpty() ) l.append( mData->nickName );
220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); 220 if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() );
221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); 221 if ( !mData->mailer.isEmpty() ) l.append( mData->mailer );
222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); 222 if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() );
223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); 223 if ( mData->geo.isValid() ) l.append( mData->geo.asString() );
224 if ( !mData->title .isEmpty() ) l.append( mData->title ); 224 if ( !mData->title .isEmpty() ) l.append( mData->title );
225 if ( !mData->role.isEmpty() ) l.append( mData->role ); 225 if ( !mData->role.isEmpty() ) l.append( mData->role );
226 if ( !mData->organization.isEmpty() ) l.append( mData->organization ); 226 if ( !mData->organization.isEmpty() ) l.append( mData->organization );
227 if ( !mData->note.isEmpty() ) l.append( mData->note ); 227 if ( !mData->note.isEmpty() ) l.append( mData->note );
228 if ( !mData->productId.isEmpty() ) l.append(mData->productId ); 228 if ( !mData->productId.isEmpty() ) l.append(mData->productId );
229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); 229 if ( !mData->sortString.isEmpty() ) l.append( mData->sortString );
230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); 230 if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString());
231 // if ( !mData->logo.isEmpty() ) l.append( ); 231 // if ( !mData->logo.isEmpty() ) l.append( );
232 //if ( !mData->photo.isEmpty() ) l.append( ); 232 //if ( !mData->photo.isEmpty() ) l.append( );
233 //if ( !mData->sound.isEmpty() ) l.append( ); 233 //if ( !mData->sound.isEmpty() ) l.append( );
234 //if ( !mData->agent.isEmpty() ) l.append( ); 234 //if ( !mData->agent.isEmpty() ) l.append( );
235 //if ( mData->url.isValid() ) l.append( ); 235 //if ( mData->url.isValid() ) l.append( );
236#if 0 236#if 0
237 if ( !mData->phoneNumbers.isEmpty() ) l.append( ); 237 if ( !mData->phoneNumbers.isEmpty() ) l.append( );
238 if ( !mData->addresses.isEmpty() ) l.append( ); 238 if ( !mData->addresses.isEmpty() ) l.append( );
239 //if ( !mData->keys.isEmpty() ) l.append( ); 239 //if ( !mData->keys.isEmpty() ) l.append( );
240 if ( !mData->emails.isEmpty() ) l.append( ); 240 if ( !mData->emails.isEmpty() ) l.append( );
241 if ( !mData->categories .isEmpty() ) l.append( ); 241 if ( !mData->categories .isEmpty() ) l.append( );
242 if ( !mData->custom.isEmpty() ) l.append( ); 242 if ( !mData->custom.isEmpty() ) l.append( );
243#endif 243#endif
244 KABC::PhoneNumber::List phoneNumbers; 244 KABC::PhoneNumber::List phoneNumbers;
245 KABC::PhoneNumber::List::Iterator phoneIter; 245 KABC::PhoneNumber::List::Iterator phoneIter;
246 246
247 QStringList t; 247 QStringList t;
248 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 248 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
249 ++phoneIter ) 249 ++phoneIter )
250 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); 250 t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) );
251 t.sort(); 251 t.sort();
252 uint iii; 252 uint iii;
253 for ( iii = 0; iii < t.count(); ++iii) 253 for ( iii = 0; iii < t.count(); ++iii)
254 l.append( t[iii] ); 254 l.append( t[iii] );
255 t = mData->emails; 255 t = mData->emails;
256 t.sort(); 256 t.sort();
257 for ( iii = 0; iii < t.count(); ++iii) 257 for ( iii = 0; iii < t.count(); ++iii)
258 l.append( t[iii] ); 258 l.append( t[iii] );
259 t = mData->categories; 259 t = mData->categories;
260 t.sort(); 260 t.sort();
261 for ( iii = 0; iii < t.count(); ++iii) 261 for ( iii = 0; iii < t.count(); ++iii)
262 l.append( t[iii] ); 262 l.append( t[iii] );
263 t = mData->custom; 263 t = mData->custom;
264 t.sort(); 264 t.sort();
265 for ( iii = 0; iii < t.count(); ++iii) 265 for ( iii = 0; iii < t.count(); ++iii)
266 l.append( t[iii] ); 266 l.append( t[iii] );
267 KABC::Address::List::Iterator addressIter; 267 KABC::Address::List::Iterator addressIter;
268 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); 268 for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end();
269 ++addressIter ) { 269 ++addressIter ) {
270 t = (*addressIter).asList(); 270 t = (*addressIter).asList();
271 t.sort(); 271 t.sort();
272 for ( iii = 0; iii < t.count(); ++iii) 272 for ( iii = 0; iii < t.count(); ++iii)
273 l.append( t[iii] ); 273 l.append( t[iii] );
274 } 274 }
275 uint cs = getCsum4List(l); 275 uint cs = getCsum4List(l);
276 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); 276 // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() );
277 setCsum( dev, QString::number (cs )); 277 setCsum( dev, QString::number (cs ));
278} 278}
279 279
280void Addressee::mergeContact( const Addressee& ad ) 280void Addressee::mergeContact( const Addressee& ad )
281{ 281{
282 282
283 detach(); 283 detach();
284 if ( mData->name.isEmpty() ) mData->name = ad.mData->name; 284 if ( mData->name.isEmpty() ) mData->name = ad.mData->name;
285 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; 285 if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName;
286 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; 286 if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName;
287 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; 287 if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ;
288 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; 288 if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName;
289 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; 289 if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix;
290 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; 290 if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix;
291 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; 291 if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName;
292 if ( !mData->birthday.isValid() ) 292 if ( !mData->birthday.isValid() )
293 if ( ad.mData->birthday.isValid()) 293 if ( ad.mData->birthday.isValid())
294 mData->birthday = ad.mData->birthday; 294 mData->birthday = ad.mData->birthday;
295 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; 295 if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer;
296 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; 296 if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone;
297 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; 297 if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo;
298 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; 298 if ( mData->title .isEmpty() ) mData->title = ad.mData->title ;
299 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; 299 if ( mData->role.isEmpty() ) mData->role = ad.mData->role ;
300 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; 300 if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ;
301 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; 301 if ( mData->note.isEmpty() ) mData->note = ad.mData->note ;
302 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; 302 if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId;
303 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; 303 if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString;
304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; 304 if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy;
305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; 305 if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ;
306 PhoneNumber::List phoneAD = phoneNumbers();
307 PhoneNumber::List::Iterator phoneItAD;
308 bool found = false;
309 for ( phoneItAD = phoneAD.begin(); phoneItAD != phoneAD.end(); ++phoneItAD ) {
306 310
311
312 }
307 // pending: 313 // pending:
308 // merging phonenumbers 314 // merging phonenumbers
309 // merging addresses 315 // merging addresses
310 // merging emails; 316 // merging emails;
311 // merging categories; 317 // merging categories;
312 // merging custom; 318 // merging custom;
313 // merging keys 319 // merging keys
314 qDebug("merge contact %s ", ad.uid().latin1()); 320 //qDebug("merge contact %s ", ad.uid().latin1());
315 setUid( ad.uid() ); 321 setUid( ad.uid() );
316 setRevision( ad.revision() ); 322 setRevision( ad.revision() );
317} 323}
318 324
319bool Addressee::removeVoice() 325bool Addressee::removeVoice()
320{ 326{
321 PhoneNumber::List phoneN = phoneNumbers(); 327 PhoneNumber::List phoneN = phoneNumbers();
322 PhoneNumber::List::Iterator phoneIt; 328 PhoneNumber::List::Iterator phoneIt;
323 bool found = false; 329 bool found = false;
324 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { 330 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
325 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 331 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
326 if ((*phoneIt).type() - PhoneNumber::Voice ) { 332 if ((*phoneIt).type() - PhoneNumber::Voice ) {
327 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 333 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
328 insertPhoneNumber( (*phoneIt) ); 334 insertPhoneNumber( (*phoneIt) );
329 found = true; 335 found = true;
330 } 336 }
331 } 337 }
332 338
333 } 339 }
334 return found; 340 return found;
335} 341}
342
343bool Addressee::containsAdr(const Addressee& ad )
344{
345 if ( ! ad.mData->familyName.isEmpty() ) if ( mData->familyName != ad.mData->familyName) return false;
346 if ( ! ad.mData->givenName.isEmpty() )if ( mData->givenName != ad.mData->givenName ) return false;
347 if ( ad.mData->url.isValid() ) if (mData->url != ad.mData->url) return false ;
348 if ( ! ad.mData->role.isEmpty() ) if (mData->role != ad.mData->role) return false ;
349 if ( ! ad.mData->organization.isEmpty() ) if (mData->organization != ad.mData->organization) return false ;
350 if ( ! ad.mData->note.isEmpty() ) if (mData->note != ad.mData->note) return false ;
351 if ( ! ad.mData->title .isEmpty() ) if (mData->title != ad.mData->title ) return false ;
352
353 // compare phone numbers
354 PhoneNumber::List phoneN = ad.phoneNumbers();
355 PhoneNumber::List::Iterator phoneIt;
356 bool found = false;
357 for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) {
358 bool found = false;
359 PhoneNumber::List phoneL = ad.phoneNumbers();
360 PhoneNumber::List::Iterator phoneItL;
361 for ( phoneItL = phoneL.begin(); phoneItL != phoneL.end(); ++phoneItL ) {
362 if ( ( *phoneItL ).number() == ( *phoneIt ).number() ) {
363 found = true;
364 break;
365 }
366 }
367 if ( ! found )
368 return false;
369 }
370 return true;
371
372}
336void Addressee::simplifyAddresses() 373void Addressee::simplifyAddresses()
337{ 374{
338 if ( mData->addresses.count() < 3 ) return ; 375 int max = 2;
376 if ( mData->url.isValid() )
377 max = 1;
378 if ( mData->addresses.count() <= max ) return ;
339 int count = 0; 379 int count = 0;
340 Address::List list; 380 Address::List list;
341 Address::List::Iterator it; 381 Address::List::Iterator it;
342 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { 382 for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
343 if ( count > 1 ) 383 if ( count >= max )
344 list.append( *it ); 384 list.append( *it );
345 ++count; 385 ++count;
346 } 386 }
347 for( it = list.begin(); it != list.end(); ++it ) { 387 for( it = list.begin(); it != list.end(); ++it ) {
348 removeAddress( (*it) ); 388 removeAddress( (*it) );
349 } 389 }
350} 390}
351 391
352// removes all emails but the first 392// removes all emails but the first
353// needed by phone sync 393// needed by phone sync
354void Addressee::simplifyEmails() 394void Addressee::simplifyEmails()
355{ 395{
356 if ( mData->emails.count() == 0 ) return ; 396 if ( mData->emails.count() == 0 ) return ;
357 QString email = mData->emails.first(); 397 QString email = mData->emails.first();
358 detach(); 398 detach();
359 mData->emails.clear(); 399 mData->emails.clear();
360 mData->emails.append( email ); 400 mData->emails.append( email );
361} 401}
362 402
363void Addressee::simplifyPhoneNumbers() 403void Addressee::simplifyPhoneNumbers()
364{ 404{
365 KABC::PhoneNumber::List removeNumbers; 405 KABC::PhoneNumber::List removeNumbers;
366 KABC::PhoneNumber::List::Iterator phoneIter; 406 KABC::PhoneNumber::List::Iterator phoneIter;
367 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 407 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
368 ++phoneIter ) { 408 ++phoneIter ) {
369 if ( ! ( *phoneIter ).simplifyNumber() ) 409 if ( ! ( *phoneIter ).simplifyNumber() )
370 removeNumbers.append( ( *phoneIter ) ); 410 removeNumbers.append( ( *phoneIter ) );
371 } 411 }
372 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); 412 for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end();
373 ++phoneIter ) { 413 ++phoneIter ) {
374 removePhoneNumber(( *phoneIter )); 414 removePhoneNumber(( *phoneIter ));
375 } 415 }
376} 416}
377void Addressee::simplifyPhoneNumberTypes() 417void Addressee::simplifyPhoneNumberTypes()
378{ 418{
379 KABC::PhoneNumber::List::Iterator phoneIter; 419 KABC::PhoneNumber::List::Iterator phoneIter;
380 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); 420 for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end();
381 ++phoneIter ) 421 ++phoneIter )
382 ( *phoneIter ).simplifyType(); 422 ( *phoneIter ).simplifyType();
383} 423}
384void Addressee::removeID(const QString &prof) 424void Addressee::removeID(const QString &prof)
385{ 425{
386 detach(); 426 detach();
387 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); 427 mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof);
388 428
389} 429}
390void Addressee::setID( const QString & prof , const QString & id ) 430void Addressee::setID( const QString & prof , const QString & id )
391{ 431{
392 detach(); 432 detach();
393 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); 433 mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id );
394 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 434 //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
395} 435}
396void Addressee::setTempSyncStat( int id ) 436void Addressee::setTempSyncStat( int id )
397{ 437{
398 if ( mData->mTempSyncStat == id ) return; 438 if ( mData->mTempSyncStat == id ) return;
399 detach(); 439 detach();
400 mData->mTempSyncStat = id; 440 mData->mTempSyncStat = id;
401} 441}
402int Addressee::tempSyncStat() const 442int Addressee::tempSyncStat() const
403{ 443{
404 return mData->mTempSyncStat; 444 return mData->mTempSyncStat;
405} 445}
406 446
407QString Addressee::getID( const QString & prof) 447QString Addressee::getID( const QString & prof)
408{ 448{
409 return KIdManager::getId ( mData->mExternalId, prof ); 449 return KIdManager::getId ( mData->mExternalId, prof );
410} 450}
411 451
412void Addressee::setCsum( const QString & prof , const QString & id ) 452void Addressee::setCsum( const QString & prof , const QString & id )
413{ 453{
414 detach(); 454 detach();
415 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); 455 //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() );
416 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); 456 mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id );
417 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); 457 //qDebug("setcsum2 %s ",mData->mExternalId.latin1() );
418} 458}
419 459
420QString Addressee::getCsum( const QString & prof) 460QString Addressee::getCsum( const QString & prof)
421{ 461{
422 return KIdManager::getCsum ( mData->mExternalId, prof ); 462 return KIdManager::getCsum ( mData->mExternalId, prof );
423} 463}
424 464
425void Addressee::setIDStr( const QString & s ) 465void Addressee::setIDStr( const QString & s )
426{ 466{
427 detach(); 467 detach();
428 mData->mExternalId = s; 468 mData->mExternalId = s;
429} 469}
430 470
431QString Addressee::IDStr() const 471QString Addressee::IDStr() const
432{ 472{
433 return mData->mExternalId; 473 return mData->mExternalId;
434} 474}
435 475
436void Addressee::setExternalUID( const QString &id ) 476void Addressee::setExternalUID( const QString &id )
437{ 477{
438 if ( id == mData->externalUID ) return; 478 if ( id == mData->externalUID ) return;
439 detach(); 479 detach();
diff --git a/kabc/addressee.h b/kabc/addressee.h
index 0aa2c51..03138f6 100644
--- a/kabc/addressee.h
+++ b/kabc/addressee.h
@@ -29,192 +29,193 @@ $Id$
29#ifndef KABC_ADDRESSEE_H 29#ifndef KABC_ADDRESSEE_H
30#define KABC_ADDRESSEE_H 30#define KABC_ADDRESSEE_H
31 31
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qstring.h> 33#include <qstring.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37#include <ksharedptr.h> 37#include <ksharedptr.h>
38#include <kurl.h> 38#include <kurl.h>
39 39
40#include "address.h" 40#include "address.h"
41#include "agent.h" 41#include "agent.h"
42#include "geo.h" 42#include "geo.h"
43#include "key.h" 43#include "key.h"
44#include "phonenumber.h" 44#include "phonenumber.h"
45#include "picture.h" 45#include "picture.h"
46#include "secrecy.h" 46#include "secrecy.h"
47#include "sound.h" 47#include "sound.h"
48#include "timezone.h" 48#include "timezone.h"
49 49
50namespace KABC { 50namespace KABC {
51 51
52class Resource; 52class Resource;
53 53
54/** 54/**
55 @short address book entry 55 @short address book entry
56 56
57 This class represents an entry in the address book. 57 This class represents an entry in the address book.
58 58
59 The data of this class is implicitly shared. You can pass this class by value. 59 The data of this class is implicitly shared. You can pass this class by value.
60 60
61 If you need the name of a field for presenting it to the user you should use 61 If you need the name of a field for presenting it to the user you should use
62 the functions ending in Label(). They return a translated string which can be 62 the functions ending in Label(). They return a translated string which can be
63 used as label for the corresponding field. 63 used as label for the corresponding field.
64 64
65 About the name fields: 65 About the name fields:
66 66
67 givenName() is the first name and familyName() the last name. In some 67 givenName() is the first name and familyName() the last name. In some
68 countries the family name comes first, that's the reason for the 68 countries the family name comes first, that's the reason for the
69 naming. formattedName() is the full name with the correct formatting. 69 naming. formattedName() is the full name with the correct formatting.
70 It is used as an override, when the correct formatting can't be generated 70 It is used as an override, when the correct formatting can't be generated
71 from the other name fields automatically. 71 from the other name fields automatically.
72 72
73 realName() returns a fully formatted name(). It uses formattedName, if set, 73 realName() returns a fully formatted name(). It uses formattedName, if set,
74 otherwise it constucts the name from the name fields. As fallback, if 74 otherwise it constucts the name from the name fields. As fallback, if
75 nothing else is set it uses name(). 75 nothing else is set it uses name().
76 76
77 name() is the NAME type of RFC2426. It can be used as internal name for the 77 name() is the NAME type of RFC2426. It can be used as internal name for the
78 data enty, but shouldn't be used for displaying the data to the user. 78 data enty, but shouldn't be used for displaying the data to the user.
79 */ 79 */
80class Addressee 80class Addressee
81{ 81{
82 friend QDataStream &operator<<( QDataStream &, const Addressee & ); 82 friend QDataStream &operator<<( QDataStream &, const Addressee & );
83 friend QDataStream &operator>>( QDataStream &, Addressee & ); 83 friend QDataStream &operator>>( QDataStream &, Addressee & );
84 84
85 public: 85 public:
86 typedef QValueList<Addressee> List; 86 typedef QValueList<Addressee> List;
87 87
88 /** 88 /**
89 Construct an empty address book entry. 89 Construct an empty address book entry.
90 */ 90 */
91 Addressee(); 91 Addressee();
92 ~Addressee(); 92 ~Addressee();
93 93
94 Addressee( const Addressee & ); 94 Addressee( const Addressee & );
95 Addressee &operator=( const Addressee & ); 95 Addressee &operator=( const Addressee & );
96 96
97 bool operator==( const Addressee & ) const; 97 bool operator==( const Addressee & ) const;
98 bool operator!=( const Addressee & ) const; 98 bool operator!=( const Addressee & ) const;
99 // sync stuff 99 // sync stuff
100 void setTempSyncStat(int id); 100 void setTempSyncStat(int id);
101 int tempSyncStat() const; 101 int tempSyncStat() const;
102 void setIDStr( const QString & ); 102 void setIDStr( const QString & );
103 QString IDStr() const; 103 QString IDStr() const;
104 void setID( const QString &, const QString & ); 104 void setID( const QString &, const QString & );
105 QString getID( const QString & ); 105 QString getID( const QString & );
106 void setCsum( const QString &, const QString & ); 106 void setCsum( const QString &, const QString & );
107 QString getCsum( const QString & ); 107 QString getCsum( const QString & );
108 void removeID(const QString &); 108 void removeID(const QString &);
109 void computeCsum(const QString &dev); 109 void computeCsum(const QString &dev);
110 ulong getCsum4List( const QStringList & attList); 110 ulong getCsum4List( const QStringList & attList);
111 /** 111 /**
112 Return, if the address book entry is empty. 112 Return, if the address book entry is empty.
113 */ 113 */
114 bool isEmpty() const; 114 bool isEmpty() const;
115 void setExternalUID( const QString &id ); 115 void setExternalUID( const QString &id );
116 QString externalUID() const; 116 QString externalUID() const;
117 void setOriginalExternalUID( const QString &id ); 117 void setOriginalExternalUID( const QString &id );
118 QString originalExternalUID() const; 118 QString originalExternalUID() const;
119 void mergeContact( const Addressee& ad ); 119 void mergeContact( const Addressee& ad );
120 void simplifyEmails(); 120 void simplifyEmails();
121 void simplifyAddresses(); 121 void simplifyAddresses();
122 void simplifyPhoneNumbers(); 122 void simplifyPhoneNumbers();
123 void simplifyPhoneNumberTypes(); 123 void simplifyPhoneNumberTypes();
124 bool removeVoice(); 124 bool removeVoice();
125 bool containsAdr(const Addressee& addr );
125 126
126 /** 127 /**
127 Set unique identifier. 128 Set unique identifier.
128 */ 129 */
129 void setUid( const QString &uid ); 130 void setUid( const QString &uid );
130 /** 131 /**
131 Return unique identifier. 132 Return unique identifier.
132 */ 133 */
133 QString uid() const; 134 QString uid() const;
134 /** 135 /**
135 Return translated label for uid field. 136 Return translated label for uid field.
136 */ 137 */
137 static QString uidLabel(); 138 static QString uidLabel();
138 139
139 /** 140 /**
140 Set name. 141 Set name.
141 */ 142 */
142 void setName( const QString &name ); 143 void setName( const QString &name );
143 /** 144 /**
144 Return name. 145 Return name.
145 */ 146 */
146 QString name() const; 147 QString name() const;
147 /** 148 /**
148 Return translated label for name field. 149 Return translated label for name field.
149 */ 150 */
150 static QString nameLabel(); 151 static QString nameLabel();
151 152
152 /** 153 /**
153 Set formatted name. 154 Set formatted name.
154 */ 155 */
155 void setFormattedName( const QString &formattedName ); 156 void setFormattedName( const QString &formattedName );
156 /** 157 /**
157 Return formatted name. 158 Return formatted name.
158 */ 159 */
159 QString formattedName() const; 160 QString formattedName() const;
160 /** 161 /**
161 Return translated label for formattedName field. 162 Return translated label for formattedName field.
162 */ 163 */
163 static QString formattedNameLabel(); 164 static QString formattedNameLabel();
164 165
165 /** 166 /**
166 Set family name. 167 Set family name.
167 */ 168 */
168 void setFamilyName( const QString &familyName ); 169 void setFamilyName( const QString &familyName );
169 /** 170 /**
170 Return family name. 171 Return family name.
171 */ 172 */
172 QString familyName() const; 173 QString familyName() const;
173 /** 174 /**
174 Return translated label for familyName field. 175 Return translated label for familyName field.
175 */ 176 */
176 static QString familyNameLabel(); 177 static QString familyNameLabel();
177 178
178 /** 179 /**
179 Set given name. 180 Set given name.
180 */ 181 */
181 void setGivenName( const QString &givenName ); 182 void setGivenName( const QString &givenName );
182 /** 183 /**
183 Return given name. 184 Return given name.
184 */ 185 */
185 QString givenName() const; 186 QString givenName() const;
186 /** 187 /**
187 Return translated label for givenName field. 188 Return translated label for givenName field.
188 */ 189 */
189 static QString givenNameLabel(); 190 static QString givenNameLabel();
190 191
191 /** 192 /**
192 Set additional names. 193 Set additional names.
193 */ 194 */
194 void setAdditionalName( const QString &additionalName ); 195 void setAdditionalName( const QString &additionalName );
195 /** 196 /**
196 Return additional names. 197 Return additional names.
197 */ 198 */
198 QString additionalName() const; 199 QString additionalName() const;
199 /** 200 /**
200 Return translated label for additionalName field. 201 Return translated label for additionalName field.
201 */ 202 */
202 static QString additionalNameLabel(); 203 static QString additionalNameLabel();
203 204
204 /** 205 /**
205 Set honorific prefixes. 206 Set honorific prefixes.
206 */ 207 */
207 void setPrefix( const QString &prefix ); 208 void setPrefix( const QString &prefix );
208 /** 209 /**
209 Return honorific prefixes. 210 Return honorific prefixes.
210 */ 211 */
211 QString prefix() const; 212 QString prefix() const;
212 /** 213 /**
213 Return translated label for prefix field. 214 Return translated label for prefix field.
214 */ 215 */
215 static QString prefixLabel(); 216 static QString prefixLabel();
216 217
217 /** 218 /**
218 Set honorific suffixes. 219 Set honorific suffixes.
219 */ 220 */
220 void setSuffix( const QString &suffix ); 221 void setSuffix( const QString &suffix );
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index e5abc0e..6e94c7e 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -1,174 +1,172 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kapplication.h> 28#include <kapplication.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "phonenumber.h" 31#include "phonenumber.h"
32 32
33using namespace KABC; 33using namespace KABC;
34 34
35PhoneNumber::PhoneNumber() : 35PhoneNumber::PhoneNumber() :
36 mType( Home ) 36 mType( Home )
37{ 37{
38 init(); 38 init();
39} 39}
40 40
41PhoneNumber::PhoneNumber( const QString &number, int type ) : 41PhoneNumber::PhoneNumber( const QString &number, int type ) :
42 mType( type ), mNumber( number ) 42 mType( type ), mNumber( number )
43{ 43{
44 init(); 44 init();
45} 45}
46 46
47PhoneNumber::~PhoneNumber() 47PhoneNumber::~PhoneNumber()
48{ 48{
49} 49}
50 50
51void PhoneNumber::init() 51void PhoneNumber::init()
52{ 52{
53 mId = KApplication::randomString( 8 ); 53 mId = KApplication::randomString( 8 );
54} 54}
55 55
56bool PhoneNumber::operator==( const PhoneNumber &p ) const 56bool PhoneNumber::operator==( const PhoneNumber &p ) const
57{ 57{
58 if ( mNumber != p.mNumber ) return false; 58 if ( mNumber != p.mNumber ) return false;
59 if ( mType != p.mType ) return false; 59 if ( mType != p.mType ) return false;
60 60
61 return true; 61 return true;
62} 62}
63 63
64bool PhoneNumber::operator!=( const PhoneNumber &p ) const 64bool PhoneNumber::operator!=( const PhoneNumber &p ) const
65{ 65{
66 return !( p == *this ); 66 return !( p == *this );
67} 67}
68 68
69bool PhoneNumber::simplifyNumber() 69bool PhoneNumber::simplifyNumber()
70{ 70{
71 QString Number; 71 QString Number;
72 int i; 72 int i;
73 Number = mNumber.stripWhiteSpace (); 73 Number = mNumber.stripWhiteSpace ();
74 mNumber = ""; 74 mNumber = "";
75 if ( Number.at(0) == '+' )
76 mNumber += "+";
77 for ( i = 0; i < Number.length(); ++i) { 75 for ( i = 0; i < Number.length(); ++i) {
78 if ( Number.at(i).isDigit() ) 76 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' )
79 mNumber += Number.at(i); 77 mNumber += Number.at(i);
80 } 78 }
81 return ( mNumber.length() > 0 ); 79 return ( mNumber.length() > 0 );
82} 80}
83// make cellphone compatible 81// make cellphone compatible
84void PhoneNumber::simplifyType() 82void PhoneNumber::simplifyType()
85{ 83{
86 if ( mType & Fax ) mType = Fax; 84 if ( mType & Fax ) mType = Fax;
87 else if ( mType & Cell ) mType = Cell; 85 else if ( mType & Cell ) mType = Cell;
88 else if ( mType & Work ) mType = Work ; 86 else if ( mType & Work ) mType = Work ;
89 else if ( mType & Home ) mType = Home; 87 else if ( mType & Home ) mType = Home;
90 else mType = Pref; 88 else mType = Pref;
91} 89}
92void PhoneNumber::setId( const QString &id ) 90void PhoneNumber::setId( const QString &id )
93{ 91{
94 mId = id; 92 mId = id;
95} 93}
96 94
97QString PhoneNumber::id() const 95QString PhoneNumber::id() const
98{ 96{
99 return mId; 97 return mId;
100} 98}
101 99
102void PhoneNumber::setNumber( const QString &number ) 100void PhoneNumber::setNumber( const QString &number )
103{ 101{
104 mNumber = number; 102 mNumber = number;
105} 103}
106 104
107QString PhoneNumber::number() const 105QString PhoneNumber::number() const
108{ 106{
109 return mNumber; 107 return mNumber;
110} 108}
111 109
112void PhoneNumber::setType( int type ) 110void PhoneNumber::setType( int type )
113{ 111{
114 mType = type; 112 mType = type;
115} 113}
116 114
117int PhoneNumber::type() const 115int PhoneNumber::type() const
118{ 116{
119 return mType; 117 return mType;
120} 118}
121 119
122QString PhoneNumber::typeLabel() const 120QString PhoneNumber::typeLabel() const
123{ 121{
124 QString label; 122 QString label;
125 bool first = true; 123 bool first = true;
126 124
127 TypeList list = typeList(); 125 TypeList list = typeList();
128 126
129 TypeList::Iterator it; 127 TypeList::Iterator it;
130 for ( it = list.begin(); it != list.end(); ++it ) { 128 for ( it = list.begin(); it != list.end(); ++it ) {
131 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 129 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
132 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 130 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
133 if ( first ) 131 if ( first )
134 first = false; 132 first = false;
135 } 133 }
136 } 134 }
137 135
138 return label; 136 return label;
139} 137}
140 138
141QString PhoneNumber::label() const 139QString PhoneNumber::label() const
142{ 140{
143 return typeLabel( type() ); 141 return typeLabel( type() );
144} 142}
145 143
146PhoneNumber::TypeList PhoneNumber::typeList() 144PhoneNumber::TypeList PhoneNumber::typeList()
147{ 145{
148 TypeList list; 146 TypeList list;
149 147
150 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 148 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
151 << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip; 149 << Bbs << Modem << Car << Isdn << Pcs << Pager << Sip;
152 150
153 return list; 151 return list;
154} 152}
155 153
156QString PhoneNumber::label( int type ) 154QString PhoneNumber::label( int type )
157{ 155{
158 return typeLabel( type ); 156 return typeLabel( type );
159} 157}
160 158
161QString PhoneNumber::typeLabel( int type ) 159QString PhoneNumber::typeLabel( int type )
162{ 160{
163 QString typeString; 161 QString typeString;
164 162
165 if ((type & Home) == Home) 163 if ((type & Home) == Home)
166 typeString += i18n("Home"); 164 typeString += i18n("Home");
167 else if ((type & Work) == Work) 165 else if ((type & Work) == Work)
168 typeString += i18n("Work"); 166 typeString += i18n("Work");
169 167
170 if (!typeString.isEmpty()) 168 if (!typeString.isEmpty())
171 typeString += " "; 169 typeString += " ";
172 170
173 if ((type & Cell) == Cell) 171 if ((type & Cell) == Cell)
174 typeString += i18n("Mobile"); 172 typeString += i18n("Mobile");
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index a7967cb..cd261f6 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -92,194 +92,194 @@ $Id$
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
207bool pasteWithNewUid = true; 207bool pasteWithNewUid = true;
208 208
209#ifdef KAB_EMBEDDED 209#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 214#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 218 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220{ 220{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 222 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 223 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 224 mIsPart = !parent->inherits( "KAddressBookMain" );
225 225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
@@ -601,260 +601,205 @@ void KABCore::mailVCard( const QStringList& uids )
601{ 601{
602 QStringList urls; 602 QStringList urls;
603 603
604// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 604// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
605 605
606 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 606 QString dirName = "/tmp/" + KApplication::randomString( 8 );
607 607
608 608
609 609
610 QDir().mkdir( dirName, true ); 610 QDir().mkdir( dirName, true );
611 611
612 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 612 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
613 KABC::Addressee a = mAddressBook->findByUid( *it ); 613 KABC::Addressee a = mAddressBook->findByUid( *it );
614 614
615 if ( a.isEmpty() ) 615 if ( a.isEmpty() )
616 continue; 616 continue;
617 617
618 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 618 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
619 619
620 QString fileName = dirName + "/" + name; 620 QString fileName = dirName + "/" + name;
621 621
622 QFile outFile(fileName); 622 QFile outFile(fileName);
623 623
624 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 624 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
625 KABC::VCardConverter converter; 625 KABC::VCardConverter converter;
626 QString vcard; 626 QString vcard;
627 627
628 converter.addresseeToVCard( a, vcard ); 628 converter.addresseeToVCard( a, vcard );
629 629
630 QTextStream t( &outFile ); // use a text stream 630 QTextStream t( &outFile ); // use a text stream
631 t.setEncoding( QTextStream::UnicodeUTF8 ); 631 t.setEncoding( QTextStream::UnicodeUTF8 );
632 t << vcard; 632 t << vcard;
633 633
634 outFile.close(); 634 outFile.close();
635 635
636 urls.append( fileName ); 636 urls.append( fileName );
637 } 637 }
638 } 638 }
639 639
640 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 640 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
641 641
642 642
643/*US 643/*US
644 kapp->invokeMailer( QString::null, QString::null, QString::null, 644 kapp->invokeMailer( QString::null, QString::null, QString::null,
645 QString::null, // subject 645 QString::null, // subject
646 QString::null, // body 646 QString::null, // body
647 QString::null, 647 QString::null,
648 urls ); // attachments 648 urls ); // attachments
649*/ 649*/
650 650
651} 651}
652 652
653/** 653/**
654 Beams the "WhoAmI contact. 654 Beams the "WhoAmI contact.
655*/ 655*/
656void KABCore::beamMySelf() 656void KABCore::beamMySelf()
657{ 657{
658 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 658 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
659 if (!a.isEmpty()) 659 if (!a.isEmpty())
660 { 660 {
661 QStringList uids; 661 QStringList uids;
662 uids << a.uid(); 662 uids << a.uid();
663 663
664 beamVCard(uids); 664 beamVCard(uids);
665 } else { 665 } else {
666 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 666 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
667 667
668 668
669 } 669 }
670} 670}
671 671
672void KABCore::export2phone() 672void KABCore::export2phone()
673{ 673{
674 674
675 KAex2phonePrefs ex2phone; 675 KAex2phonePrefs ex2phone;
676 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 676 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
677 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 677 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
678 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 678 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
679 679
680 if ( !ex2phone.exec() ) { 680 if ( !ex2phone.exec() ) {
681 return; 681 return;
682 } 682 }
683 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 683 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
684 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 684 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
685 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 685 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
686 686
687 687
688 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 688 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
689 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 689 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
690 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 690 KPimGlobalPrefs::instance()->mEx2PhoneModel );
691 691
692 QStringList uids = mViewManager->selectedUids(); 692 QStringList uids = mViewManager->selectedUids();
693 if ( uids.isEmpty() ) 693 if ( uids.isEmpty() )
694 return; 694 return;
695 695
696#ifdef _WIN32_ 696#ifdef _WIN32_
697 QString fileName = locateLocal("tmp", "tempfile.vcf"); 697 QString fileName = locateLocal("tmp", "phonefile.vcf");
698#else 698#else
699 QString fileName = "/tmp/kdepimtemp.vcf"; 699 QString fileName = "/tmp/phonefile.vcf";
700#endif 700#endif
701 701
702 KABC::VCardConverter converter; 702 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
703 QString description;
704 QString datastream;
705 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
706 KABC::Addressee a = mAddressBook->findByUid( *it );
707
708 if ( a.isEmpty() )
709 continue;
710 a.simplifyEmails();
711 a.simplifyPhoneNumbers();
712 a.simplifyPhoneNumberTypes();
713 a.simplifyAddresses();
714
715 if (description.isEmpty())
716 description = a.formattedName();
717 QString vcard;
718 QString vcardnew;
719 converter.addresseeToVCard( a, vcard );
720 int start = 0;
721 int next;
722 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
723 int semi = vcard.find(";", next);
724 int dopp = vcard.find(":", next);
725 int sep;
726 if ( semi < dopp && semi >= 0 )
727 sep = semi ;
728 else
729 sep = dopp;
730 vcardnew +=vcard.mid( start, next - start);
731 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
732 start = sep;
733 }
734 vcardnew += vcard.mid( start,vcard.length() );
735 vcard = "";
736 start = 0;
737 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
738 int sep = vcardnew.find(":", next);
739 vcard +=vcardnew.mid( start, next - start+3);
740 start = sep;
741 }
742 vcard += vcardnew.mid( start,vcardnew.length() );
743 vcard.replace ( QRegExp(";;;") , "" );
744 vcard.replace ( QRegExp(";;") , "" );
745 datastream += vcard;
746
747 }
748 QFile outFile(fileName);
749 if ( outFile.open(IO_WriteOnly) ) {
750 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
751 QTextStream t( &outFile ); // use a text stream
752 t.setEncoding( QTextStream::UnicodeUTF8 );
753 t <<datastream;
754 outFile.close();
755 if ( PhoneAccess::writeToPhone( fileName ) )
756 qDebug("Export okay ");
757 else
758 qDebug("Error export contacts ");
759
760 } else {
761 qDebug("Error open temp file ");
762 return; 703 return;
763 } 704
764 705 if ( PhoneAccess::writeToPhone( fileName ) )
706 qDebug("Export okay ");
707 else
708 qDebug("Error export contacts ");
709
765 710
766#if 0 711#if 0
767 712
768 setCaption( i18n("Writing to phone...")); 713 setCaption( i18n("Writing to phone..."));
769 if ( PhoneFormat::writeToPhone( cal ) ) 714 if ( PhoneFormat::writeToPhone( cal ) )
770 setCaption( i18n("Export to phone successful!")); 715 setCaption( i18n("Export to phone successful!"));
771 else 716 else
772 setCaption( i18n("Error exporting to phone!")); 717 setCaption( i18n("Error exporting to phone!"));
773#endif 718#endif
774 719
775 720
776} 721}
777void KABCore::beamVCard() 722void KABCore::beamVCard()
778{ 723{
779 QStringList uids = mViewManager->selectedUids(); 724 QStringList uids = mViewManager->selectedUids();
780 if ( !uids.isEmpty() ) 725 if ( !uids.isEmpty() )
781 beamVCard( uids ); 726 beamVCard( uids );
782} 727}
783 728
784 729
785void KABCore::beamVCard(const QStringList& uids) 730void KABCore::beamVCard(const QStringList& uids)
786{ 731{
787/*US 732/*US
788 QString beamFilename; 733 QString beamFilename;
789 Opie::OPimContact c; 734 Opie::OPimContact c;
790 if ( actionPersonal->isOn() ) { 735 if ( actionPersonal->isOn() ) {
791 beamFilename = addressbookPersonalVCardName(); 736 beamFilename = addressbookPersonalVCardName();
792 if ( !QFile::exists( beamFilename ) ) 737 if ( !QFile::exists( beamFilename ) )
793 return; // can't beam a non-existent file 738 return; // can't beam a non-existent file
794 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 739 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
795 beamFilename ); 740 beamFilename );
796 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 741 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
797 Opie::OPimContactAccess::List allList = access->allRecords(); 742 Opie::OPimContactAccess::List allList = access->allRecords();
798 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 743 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
799 c = *it; 744 c = *it;
800 745
801 delete access; 746 delete access;
802 } else { 747 } else {
803 unlink( beamfile ); // delete if exists 748 unlink( beamfile ); // delete if exists
804 mkdir("/tmp/obex/", 0755); 749 mkdir("/tmp/obex/", 0755);
805 c = m_abView -> currentEntry(); 750 c = m_abView -> currentEntry();
806 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 751 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
807 beamfile ); 752 beamfile );
808 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 753 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
809 access->add( c ); 754 access->add( c );
810 access->save(); 755 access->save();
811 delete access; 756 delete access;
812 757
813 beamFilename = beamfile; 758 beamFilename = beamfile;
814 } 759 }
815 760
816 owarn << "Beaming: " << beamFilename << oendl; 761 owarn << "Beaming: " << beamFilename << oendl;
817*/ 762*/
818 763
819#if 0 764#if 0
820 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 765 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
821 766
822 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 767 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
823 768
824 QString name = "contact.vcf"; 769 QString name = "contact.vcf";
825 770
826 QString fileName = dirName + "/" + name; 771 QString fileName = dirName + "/" + name;
827#endif 772#endif
828 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 773 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
829 // 774 //
830 QString fileName = "/tmp/kapibeamfile.vcf"; 775 QString fileName = "/tmp/kapibeamfile.vcf";
831 776
832 777
833 //QDir().mkdir( dirName, true ); 778 //QDir().mkdir( dirName, true );
834 779
835 780
836 KABC::VCardConverter converter; 781 KABC::VCardConverter converter;
837 QString description; 782 QString description;
838 QString datastream; 783 QString datastream;
839 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 784 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
840 KABC::Addressee a = mAddressBook->findByUid( *it ); 785 KABC::Addressee a = mAddressBook->findByUid( *it );
841 786
842 if ( a.isEmpty() ) 787 if ( a.isEmpty() )
843 continue; 788 continue;
844 789
845 if (description.isEmpty()) 790 if (description.isEmpty())
846 description = a.formattedName(); 791 description = a.formattedName();
847 792
848 QString vcard; 793 QString vcard;
849 converter.addresseeToVCard( a, vcard ); 794 converter.addresseeToVCard( a, vcard );
850 int start = 0; 795 int start = 0;
851 int next; 796 int next;
852 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 797 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
853 int semi = vcard.find(";", next); 798 int semi = vcard.find(";", next);
854 int dopp = vcard.find(":", next); 799 int dopp = vcard.find(":", next);
855 int sep; 800 int sep;
856 if ( semi < dopp && semi >= 0 ) 801 if ( semi < dopp && semi >= 0 )
857 sep = semi ; 802 sep = semi ;
858 else 803 else
859 sep = dopp; 804 sep = dopp;
860 datastream +=vcard.mid( start, next - start); 805 datastream +=vcard.mid( start, next - start);
@@ -2750,175 +2695,178 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo
2750 return syncOK; 2695 return syncOK;
2751} 2696}
2752 2697
2753 2698
2754//this is a overwritten callbackmethods from the syncinterface 2699//this is a overwritten callbackmethods from the syncinterface
2755bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 2700bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
2756{ 2701{
2757 2702
2758 //pending prepare addresseeview for output 2703 //pending prepare addresseeview for output
2759 //pending detect, if remote file has REV field. if not switch to external sync 2704 //pending detect, if remote file has REV field. if not switch to external sync
2760 mGlobalSyncMode = SYNC_MODE_NORMAL; 2705 mGlobalSyncMode = SYNC_MODE_NORMAL;
2761 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2706 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2762 2707
2763 AddressBook abLocal(filename,"syncContact"); 2708 AddressBook abLocal(filename,"syncContact");
2764 bool syncOK = false; 2709 bool syncOK = false;
2765 if ( abLocal.load() ) { 2710 if ( abLocal.load() ) {
2766 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2711 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2767 bool external = false; 2712 bool external = false;
2768 bool isXML = false; 2713 bool isXML = false;
2769 if ( filename.right(4) == ".xml") { 2714 if ( filename.right(4) == ".xml") {
2770 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2715 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2771 isXML = true; 2716 isXML = true;
2772 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2717 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2773 } else { 2718 } else {
2774 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2719 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2775 if ( ! lse.isEmpty() ) { 2720 if ( ! lse.isEmpty() ) {
2776 if ( lse.familyName().left(4) == "!E: " ) 2721 if ( lse.familyName().left(4) == "!E: " )
2777 external = true; 2722 external = true;
2778 } else { 2723 } else {
2779 bool found = false; 2724 bool found = false;
2780 AddressBook::Iterator it; 2725 AddressBook::Iterator it;
2781 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2726 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2782 if ( (*it).revision().date().year() > 2003 ) { 2727 if ( (*it).revision().date().year() > 2003 ) {
2783 found = true; 2728 found = true;
2784 break; 2729 break;
2785 } 2730 }
2786 } 2731 }
2787 external = ! found; 2732 external = ! found;
2788 } 2733 }
2789 2734
2790 if ( external ) { 2735 if ( external ) {
2791 qDebug("Setting vcf mode to external "); 2736 qDebug("Setting vcf mode to external ");
2792 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2737 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2793 AddressBook::Iterator it; 2738 AddressBook::Iterator it;
2794 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2739 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2795 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2740 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2796 (*it).computeCsum( mCurrentSyncDevice ); 2741 (*it).computeCsum( mCurrentSyncDevice );
2797 } 2742 }
2798 } 2743 }
2799 } 2744 }
2800 //AddressBook::Iterator it; 2745 //AddressBook::Iterator it;
2801 //QStringList vcards; 2746 //QStringList vcards;
2802 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2747 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2803 // qDebug("Name %s ", (*it).familyName().latin1()); 2748 // qDebug("Name %s ", (*it).familyName().latin1());
2804 //} 2749 //}
2805 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2750 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2806 if ( syncOK ) { 2751 if ( syncOK ) {
2807 if ( syncManager->mWriteBackFile ) 2752 if ( syncManager->mWriteBackFile )
2808 { 2753 {
2809 if ( external ) 2754 if ( external )
2810 abLocal.removeSyncAddressees( !isXML); 2755 abLocal.removeSyncAddressees( !isXML);
2811 qDebug("Saving remote AB "); 2756 qDebug("Saving remote AB ");
2812 if ( ! abLocal.saveAB()) 2757 if ( ! abLocal.saveAB())
2813 qDebug("Error writing back AB to file "); 2758 qDebug("Error writing back AB to file ");
2814 if ( isXML ) { 2759 if ( isXML ) {
2815 // afterwrite processing 2760 // afterwrite processing
2816 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2761 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2817 } 2762 }
2818 } 2763 }
2819 } 2764 }
2820 setModified(); 2765 setModified();
2821 2766
2822 } 2767 }
2823 if ( syncOK ) 2768 if ( syncOK )
2824 mViewManager->refreshView(); 2769 mViewManager->refreshView();
2825 return syncOK; 2770 return syncOK;
2826 2771
2827} 2772}
2828 2773
2829 2774
2830//this is a overwritten callbackmethods from the syncinterface 2775//this is a overwritten callbackmethods from the syncinterface
2831bool KABCore::syncExternal(KSyncManager* manager, QString resource) 2776bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2832{ 2777{
2833 if ( resource == "phone" ) 2778 if ( resource == "phone" )
2834 return syncPhone(); 2779 return syncPhone();
2835 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2780 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2836 2781
2837 AddressBook abLocal( resource,"syncContact"); 2782 AddressBook abLocal( resource,"syncContact");
2838 bool syncOK = false; 2783 bool syncOK = false;
2839 if ( abLocal.load() ) { 2784 if ( abLocal.load() ) {
2840 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2785 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
2841 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2786 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2842 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2787 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2843 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2788 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2844 if ( syncOK ) { 2789 if ( syncOK ) {
2845 if ( syncManager->mWriteBackFile ) { 2790 if ( syncManager->mWriteBackFile ) {
2791 abLocal.removeSyncAddressees( false );
2846 abLocal.saveAB(); 2792 abLocal.saveAB();
2847 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2793 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2848 } 2794 }
2849 } 2795 }
2850 setModified(); 2796 setModified();
2851 } 2797 }
2852 if ( syncOK ) 2798 if ( syncOK )
2853 mViewManager->refreshView(); 2799 mViewManager->refreshView();
2854 return syncOK; 2800 return syncOK;
2855 2801
2856} 2802}
2857void KABCore::message( QString m ) 2803void KABCore::message( QString m )
2858{ 2804{
2859 2805
2860 topLevelWidget()->setCaption( m ); 2806 topLevelWidget()->setCaption( m );
2861 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2807 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
2862} 2808}
2863bool KABCore::syncPhone() 2809bool KABCore::syncPhone()
2864{ 2810{
2865 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2811 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2866 QString fileName; 2812 QString fileName;
2867#ifdef _WIN32_ 2813#ifdef _WIN32_
2868 fileName = locateLocal("tmp", "phonefile.vcf"); 2814 fileName = locateLocal("tmp", "phonefile.vcf");
2869#else 2815#else
2870 fileName = "/tmp/phonefile.vcf"; 2816 fileName = "/tmp/phonefile.vcf";
2871#endif 2817#endif
2872 if ( !PhoneAccess::readFromPhone( fileName) ) { 2818 if ( !PhoneAccess::readFromPhone( fileName) ) {
2873 message(i18n("Phone access failed!")); 2819 message(i18n("Phone access failed!"));
2874 return false; 2820 return false;
2875 } 2821 }
2876 AddressBook abLocal( fileName,"syncContact"); 2822 AddressBook abLocal( fileName,"syncContact");
2877 bool syncOK = false; 2823 bool syncOK = false;
2878 if ( abLocal.load() ) { 2824 {
2825 abLocal.importFromFile( fileName );
2879 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 2826 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
2880 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2827 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2881 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 2828 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
2882 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2829 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2883 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 2830 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
2884 if ( syncOK ) { 2831 if ( syncOK ) {
2885 if ( syncManager->mWriteBackFile ) { 2832 if ( syncManager->mWriteBackFile ) {
2833 abLocal.removeSyncAddressees( true );
2886 abLocal.saveABphone( fileName ); 2834 abLocal.saveABphone( fileName );
2887 abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 2835 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
2888 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2836 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
2889 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2837 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2890 } 2838 }
2891 } 2839 }
2892 setModified(); 2840 setModified();
2893 } 2841 }
2894 if ( syncOK ) 2842 if ( syncOK )
2895 mViewManager->refreshView(); 2843 mViewManager->refreshView();
2896 return syncOK; 2844 return syncOK;
2897} 2845}
2898void KABCore::getFile( bool success ) 2846void KABCore::getFile( bool success )
2899{ 2847{
2900 if ( ! success ) { 2848 if ( ! success ) {
2901 message( i18n("Error receiving file. Nothing changed!") ); 2849 message( i18n("Error receiving file. Nothing changed!") );
2902 return; 2850 return;
2903 } 2851 }
2904 mAddressBook->importFromFile( sentSyncFile() , false, true ); 2852 mAddressBook->importFromFile( sentSyncFile() , false, true );
2905 message( i18n("Pi-Sync successful!") ); 2853 message( i18n("Pi-Sync successful!") );
2906 mViewManager->refreshView(); 2854 mViewManager->refreshView();
2907} 2855}
2908void KABCore::syncFileRequest() 2856void KABCore::syncFileRequest()
2909{ 2857{
2910 mAddressBook->export2File( sentSyncFile() ); 2858 mAddressBook->export2File( sentSyncFile() );
2911} 2859}
2912QString KABCore::sentSyncFile() 2860QString KABCore::sentSyncFile()
2913{ 2861{
2914#ifdef _WIN32_ 2862#ifdef _WIN32_
2915 return locateLocal( "tmp", "copysyncab.vcf" ); 2863 return locateLocal( "tmp", "copysyncab.vcf" );
2916#else 2864#else
2917 return QString( "/tmp/copysyncab.vcf" ); 2865 return QString( "/tmp/copysyncab.vcf" );
2918#endif 2866#endif
2919} 2867}
2920 2868
2921void KABCore::setCaptionBack() 2869void KABCore::setCaptionBack()
2922{ 2870{
2923 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2871 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2924} 2872}
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 84cc448..cf8f996 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -107,193 +107,193 @@ void KSyncPrefsDialog::setupSyncAlgTab()
107 topLayout->setSpacing(spacingHint()); 107 topLayout->setSpacing(spacingHint());
108 topLayout->setMargin(marginHint()); 108 topLayout->setMargin(marginHint());
109 109
110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
111 int iii = 0; 111 int iii = 0;
112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
113 //++iii; 113 //++iii;
114 114
115 mMyMachineName = new QLineEdit(topFrame); 115 mMyMachineName = new QLineEdit(topFrame);
116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
117 topLayout->addWidget(lab ,iii,0); 117 topLayout->addWidget(lab ,iii,0);
118 topLayout->addWidget(mMyMachineName,iii,1); 118 topLayout->addWidget(mMyMachineName,iii,1);
119 ++iii; 119 ++iii;
120 120
121 QHBox* buttonbox = new QHBox( topFrame); 121 QHBox* buttonbox = new QHBox( topFrame);
122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
123 ++iii; 123 ++iii;
124 button = new QPushButton( i18n("New profile"), buttonbox ); 124 button = new QPushButton( i18n("New profile"), buttonbox );
125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
126 126
127 button = new QPushButton( i18n("Clone profile"), buttonbox ); 127 button = new QPushButton( i18n("Clone profile"), buttonbox );
128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
129 129
130 button = new QPushButton( i18n("Delete profile"), buttonbox ); 130 button = new QPushButton( i18n("Delete profile"), buttonbox );
131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
132 132
133 mProfileBox = new QComboBox(topFrame); 133 mProfileBox = new QComboBox(topFrame);
134 mProfileBox->setEditable ( true ); 134 mProfileBox->setEditable ( true );
135 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); 135 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion);
136 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 136 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
137 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 137 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
138 138
139 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 139 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
140 topLayout->addWidget(lab ,iii,0); 140 topLayout->addWidget(lab ,iii,0);
141 topLayout->addWidget(mProfileBox, iii,1); 141 topLayout->addWidget(mProfileBox, iii,1);
142 ++iii; 142 ++iii;
143 143
144 QHBox *iims = new QHBox( topFrame ); 144 QHBox *iims = new QHBox( topFrame );
145 new QLabel( i18n("Include in multiple "), iims ); 145 new QLabel( i18n("Include in multiple "), iims );
146 mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); 146 mIncludeInRing = new QCheckBox( i18n("calendar "), iims );
147 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); 147 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims );
148 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); 148 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims );
149 new QLabel( i18n(" sync"), iims ); 149 new QLabel( i18n(" sync"), iims );
150 topLayout->addMultiCellWidget(iims, iii,iii,0,1); 150 topLayout->addMultiCellWidget(iims, iii,iii,0,1);
151 ++iii; 151 ++iii;
152 152
153 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 153 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
154 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 154 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
155 ++iii; 155 ++iii;
156 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 156 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
157 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 157 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
158 ++iii; 158 ++iii;
159 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 159 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
160 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 160 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
161 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 161 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
162 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 162 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
163 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 163 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
164 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 164 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
165 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 165 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
166 166
167 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 167 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
168 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 168 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
169 ++iii; 169 ++iii;
170 170
171 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); 171 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
172 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 172 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
173 ++iii; 173 ++iii;
174 174
175 mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame ); 175 mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame );
176 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 176 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
177 ++iii; 177 ++iii;
178 178
179 mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame ); 179 mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame );
180 topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); 180 topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1);
181 ++iii; 181 ++iii;
182 topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0); 182 topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0);
183 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame); 183 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame);
184 topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); 184 topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1);
185 ++iii; 185 ++iii;
186 186
187 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 187 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
188 gr = proGr; 188 gr = proGr;
189 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 189 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
190 ++iii; 190 ++iii;
191 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 191 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
192 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr ); 192 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr );
193 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 193 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
194 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 194 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
195 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 195 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
196 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); 196 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
197 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 197 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
198 198
199 199
200 phoneWidget = new QVBox( topFrame); 200 phoneWidget = new QVBox( topFrame);
201 topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); 201 topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
202 ++iii; 202 ++iii;
203 mWriteContactToSIM= new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); 203 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
204 QHBox* temphb = new QHBox( phoneWidget ); 204 QHBox* temphb = new QHBox( phoneWidget );
205 new QLabel( i18n("I/O device: "), temphb ); 205 new QLabel( i18n("I/O device: "), temphb );
206 mPhoneDevice = new QLineEdit( temphb); 206 mPhoneDevice = new QLineEdit( temphb);
207 button = new QPushButton( i18n("Help..."), temphb ); 207 button = new QPushButton( i18n("Help..."), temphb );
208 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); 208 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
209 209
210 210
211 temphb = new QHBox( phoneWidget ); 211 temphb = new QHBox( phoneWidget );
212 new QLabel( i18n("Connection: "), temphb ); 212 new QLabel( i18n("Connection: "), temphb );
213 mPhoneConnection = new QLineEdit( temphb); 213 mPhoneConnection = new QLineEdit( temphb);
214 button = new QPushButton( i18n("Help..."), temphb ); 214 button = new QPushButton( i18n("Help..."), temphb );
215 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); 215 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
216 216
217 217
218 temphb = new QHBox( phoneWidget ); 218 temphb = new QHBox( phoneWidget );
219 new QLabel( i18n("Model(opt.): "), temphb ); 219 new QLabel( i18n("Model(opt.): "), temphb );
220 mPhoneModel = new QLineEdit( temphb); 220 mPhoneModel = new QLineEdit( temphb);
221 button = new QPushButton( i18n("Help..."), temphb ); 221 button = new QPushButton( i18n("Help..."), temphb );
222 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); 222 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
223 223
224 // *** local 224 // *** local
225 localFileWidget = new QVBox( topFrame); 225 localFileWidget = new QVBox( topFrame);
226 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 226 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
227 ++iii; 227 ++iii;
228 temphb = new QHBox( localFileWidget ); 228 temphb = new QHBox( localFileWidget );
229 229
230 lab = new QLabel( i18n("Local file Cal:"), temphb ); 230 lab = new QLabel( i18n("Local file Cal:"), temphb );
231 lab = new QLabel( i18n("Local file ABook:"), temphb ); 231 lab = new QLabel( i18n("Local file ABook:"), temphb );
232 lab = new QLabel( i18n("Local file PWMgr:"), temphb ); 232 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
233 temphb = new QHBox( localFileWidget ); 233 temphb = new QHBox( localFileWidget );
234 button = new QPushButton( i18n("Choose..."), temphb ); 234 button = new QPushButton( i18n("Choose..."), temphb );
235 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 235 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
236 button = new QPushButton( i18n("Choose..."), temphb ); 236 button = new QPushButton( i18n("Choose..."), temphb );
237 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); 237 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
238 button = new QPushButton( i18n("Choose..."), temphb ); 238 button = new QPushButton( i18n("Choose..."), temphb );
239 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); 239 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
240 temphb = new QHBox( localFileWidget ); 240 temphb = new QHBox( localFileWidget );
241 241
242 mRemoteFile = new QLineEdit( temphb); 242 mRemoteFile = new QLineEdit( temphb);
243 mRemoteFileAB = new QLineEdit( temphb); 243 mRemoteFileAB = new QLineEdit( temphb);
244 mRemoteFilePWM = new QLineEdit( temphb); 244 mRemoteFilePWM = new QLineEdit( temphb);
245 245
246 // *** remote 246 // *** remote
247 remoteFileWidget = new QVBox( topFrame); 247 remoteFileWidget = new QVBox( topFrame);
248 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 248 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
249 ++iii; 249 ++iii;
250 temphb = new QHBox( remoteFileWidget ); 250 temphb = new QHBox( remoteFileWidget );
251 new QLabel( i18n("Calendar:"), temphb); 251 new QLabel( i18n("Calendar:"), temphb);
252 new QLabel( i18n("AddressBook:"), temphb); 252 new QLabel( i18n("AddressBook:"), temphb);
253 new QLabel( i18n("PWManager:"), temphb); 253 new QLabel( i18n("PWManager:"), temphb);
254 254
255 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 255 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
256 temphb = new QHBox( remoteFileWidget ); 256 temphb = new QHBox( remoteFileWidget );
257 mRemotePrecommand = new QLineEdit(temphb); 257 mRemotePrecommand = new QLineEdit(temphb);
258 mRemotePrecommandAB = new QLineEdit(temphb); 258 mRemotePrecommandAB = new QLineEdit(temphb);
259 mRemotePrecommandPWM = new QLineEdit(temphb); 259 mRemotePrecommandPWM = new QLineEdit(temphb);
260 260
261 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 261 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
262 temphb = new QHBox( remoteFileWidget ); 262 temphb = new QHBox( remoteFileWidget );
263 mLocalTempFile = new QLineEdit(temphb); 263 mLocalTempFile = new QLineEdit(temphb);
264 mLocalTempFileAB = new QLineEdit(temphb); 264 mLocalTempFileAB = new QLineEdit(temphb);
265 mLocalTempFilePWM = new QLineEdit(temphb); 265 mLocalTempFilePWM = new QLineEdit(temphb);
266 266
267 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 267 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
268 temphb = new QHBox( remoteFileWidget ); 268 temphb = new QHBox( remoteFileWidget );
269 mRemotePostcommand = new QLineEdit(temphb ); 269 mRemotePostcommand = new QLineEdit(temphb );
270 mRemotePostcommandAB = new QLineEdit(temphb ); 270 mRemotePostcommandAB = new QLineEdit(temphb );
271 mRemotePostcommandPWM = new QLineEdit(temphb ); 271 mRemotePostcommandPWM = new QLineEdit(temphb );
272 272
273 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 273 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
274 temphb = new QHBox( remoteFileWidget ); 274 temphb = new QHBox( remoteFileWidget );
275 button = new QPushButton( i18n("ssh/scp"), temphb ); 275 button = new QPushButton( i18n("ssh/scp"), temphb );
276 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 276 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
277 button = new QPushButton( i18n("ftp"), temphb ); 277 button = new QPushButton( i18n("ftp"), temphb );
278 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 278 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
279 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 279 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
280 280
281 // *** pi-sync 281 // *** pi-sync
282 piWidget = new QVBox( topFrame); 282 piWidget = new QVBox( topFrame);
283 topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); 283 topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
284 ++iii; 284 ++iii;
285 temphb = new QHBox( piWidget ); 285 temphb = new QHBox( piWidget );
286 new QLabel( i18n("Calendar:"), temphb); 286 new QLabel( i18n("Calendar:"), temphb);
287 new QLabel( i18n("AddressBook:"), temphb); 287 new QLabel( i18n("AddressBook:"), temphb);
288 new QLabel( i18n("PWManager:"), temphb); 288 new QLabel( i18n("PWManager:"), temphb);
289 289
290 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); 290 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget);
291 temphb = new QHBox( piWidget ); 291 temphb = new QHBox( piWidget );
292 mRemotePw = new QLineEdit(temphb); 292 mRemotePw = new QLineEdit(temphb);
293 mRemotePwAB = new QLineEdit(temphb); 293 mRemotePwAB = new QLineEdit(temphb);
294 mRemotePwPWM = new QLineEdit(temphb); 294 mRemotePwPWM = new QLineEdit(temphb);
295 295
296 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); 296 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget);
297 temphb = new QHBox( piWidget ); 297 temphb = new QHBox( piWidget );
298 mRemoteIP = new QLineEdit(temphb); 298 mRemoteIP = new QLineEdit(temphb);
299 mRemoteIPAB = new QLineEdit(temphb); 299 mRemoteIPAB = new QLineEdit(temphb);
@@ -320,412 +320,413 @@ void KSyncPrefsDialog::slotOK()
320 int i; 320 int i;
321 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 321 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
322 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 322 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
323 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 323 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
324 return; 324 return;
325 } 325 }
326 } 326 }
327 usrWriteConfig(); 327 usrWriteConfig();
328 QDialog::accept(); 328 QDialog::accept();
329} 329}
330void KSyncPrefsDialog::accept() 330void KSyncPrefsDialog::accept()
331{ 331{
332 slotOK(); 332 slotOK();
333} 333}
334void KSyncPrefsDialog::chooseFile() 334void KSyncPrefsDialog::chooseFile()
335{ 335{
336 QString fn = QDir::homeDirPath(); 336 QString fn = QDir::homeDirPath();
337 337
338 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 338 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
339 if ( fn == "" ) 339 if ( fn == "" )
340 return; 340 return;
341 mRemoteFile->setText( fn ); 341 mRemoteFile->setText( fn );
342} 342}
343 343
344void KSyncPrefsDialog::chooseFileAB() 344void KSyncPrefsDialog::chooseFileAB()
345{ 345{
346 QString fn = QDir::homeDirPath(); 346 QString fn = QDir::homeDirPath();
347 347
348 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 348 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
349 if ( fn == "" ) 349 if ( fn == "" )
350 return; 350 return;
351 mRemoteFileAB->setText( fn ); 351 mRemoteFileAB->setText( fn );
352} 352}
353 353
354void KSyncPrefsDialog::chooseFilePWM() 354void KSyncPrefsDialog::chooseFilePWM()
355{ 355{
356 QString fn = QDir::homeDirPath(); 356 QString fn = QDir::homeDirPath();
357 357
358 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 358 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
359 if ( fn == "" ) 359 if ( fn == "" )
360 return; 360 return;
361 mRemoteFilePWM->setText( fn ); 361 mRemoteFilePWM->setText( fn );
362} 362}
363 363
364void KSyncPrefsDialog::textChanged( const QString & s ) 364void KSyncPrefsDialog::textChanged( const QString & s )
365{ 365{
366 if ( mProfileBox->count() == 0 ) 366 if ( mProfileBox->count() == 0 )
367 return; 367 return;
368 if ( currentSelection < 3 ) { 368 if ( currentSelection < 3 ) {
369 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 369 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
370 mProfileBox->blockSignals( true ); 370 mProfileBox->blockSignals( true );
371 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 371 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
372 mProfileBox->blockSignals( false ); 372 mProfileBox->blockSignals( false );
373 return; 373 return;
374 } 374 }
375 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 375 //qDebug("cur i %d ",mProfileBox-> currentItem () );
376 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 376 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
377 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 377 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
378 prof->setName( s ); 378 prof->setName( s );
379 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 379 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
380} 380}
381void KSyncPrefsDialog::profileChanged( int item ) 381void KSyncPrefsDialog::profileChanged( int item )
382{ 382{
383 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 383 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
384 KSyncProfile* prof; 384 KSyncProfile* prof;
385 saveProfile(); 385 saveProfile();
386 currentSelection = item; 386 currentSelection = item;
387 prof = mSyncProfiles.at(item) ; 387 prof = mSyncProfiles.at(item) ;
388 388
389 mRemotePw->setText(prof->getRemotePw()); 389 mRemotePw->setText(prof->getRemotePw());
390 mRemoteIP->setText(prof->getRemoteIP()); 390 mRemoteIP->setText(prof->getRemoteIP());
391 mRemotePort->setText(prof->getRemotePort()); 391 mRemotePort->setText(prof->getRemotePort());
392 392
393 mRemotePwAB->setText(prof->getRemotePwAB()); 393 mRemotePwAB->setText(prof->getRemotePwAB());
394 mRemoteIPAB->setText(prof->getRemoteIPAB()); 394 mRemoteIPAB->setText(prof->getRemoteIPAB());
395 mRemotePortAB->setText(prof->getRemotePortAB()); 395 mRemotePortAB->setText(prof->getRemotePortAB());
396 396
397 mRemotePwPWM->setText(prof->getRemotePwPWM()); 397 mRemotePwPWM->setText(prof->getRemotePwPWM());
398 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 398 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
399 mRemotePortPWM->setText(prof->getRemotePortPWM()); 399 mRemotePortPWM->setText(prof->getRemotePortPWM());
400 400
401 mRemotePrecommand->setText(prof->getPreSyncCommand()); 401 mRemotePrecommand->setText(prof->getPreSyncCommand());
402 mRemotePostcommand->setText(prof->getPostSyncCommand()); 402 mRemotePostcommand->setText(prof->getPostSyncCommand());
403 mLocalTempFile->setText(prof->getLocalTempFile()); 403 mLocalTempFile->setText(prof->getLocalTempFile());
404 mRemoteFile->setText(prof->getRemoteFileName()) ; 404 mRemoteFile->setText(prof->getRemoteFileName()) ;
405 405
406 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 406 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
407 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 407 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
408 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 408 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
409 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 409 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
410 410
411 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 411 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
412 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 412 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
413 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 413 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
414 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 414 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
415 415
416 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 416 if ( mWriteContactToSIM )
417 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
417 mPhoneDevice->setText(prof->getPhoneDevice()); 418 mPhoneDevice->setText(prof->getPhoneDevice());
418 mPhoneConnection->setText(prof->getPhoneConnection()); 419 mPhoneConnection->setText(prof->getPhoneConnection());
419 mPhoneModel->setText(prof->getPhoneModel()); 420 mPhoneModel->setText(prof->getPhoneModel());
420 421
421 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 422 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
422 mAskForPreferences->setChecked( prof->getAskForPreferences()); 423 mAskForPreferences->setChecked( prof->getAskForPreferences());
423 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 424 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
424 mWriteBackFile->setChecked( prof->getWriteBackFile()); 425 mWriteBackFile->setChecked( prof->getWriteBackFile());
425 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 426 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
426 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 427 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
427 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 428 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
428 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 429 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
429 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 430 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
430 431
431 switch ( prof->getSyncPrefs() ) { 432 switch ( prof->getSyncPrefs() ) {
432 case 0: 433 case 0:
433 loc->setChecked( true); 434 loc->setChecked( true);
434 break; 435 break;
435 case 1: 436 case 1:
436 rem->setChecked( true ); 437 rem->setChecked( true );
437 break; 438 break;
438 case 2: 439 case 2:
439 newest->setChecked( true); 440 newest->setChecked( true);
440 break; 441 break;
441 case 3: 442 case 3:
442 ask->setChecked( true); 443 ask->setChecked( true);
443 break; 444 break;
444 case 4: 445 case 4:
445 f_loc->setChecked( true); 446 f_loc->setChecked( true);
446 break; 447 break;
447 case 5: 448 case 5:
448 f_rem->setChecked( true); 449 f_rem->setChecked( true);
449 break; 450 break;
450 case 6: 451 case 6:
451 //both->setChecked( true); 452 //both->setChecked( true);
452 break; 453 break;
453 default: 454 default:
454 break; 455 break;
455 } 456 }
456 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 457 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
457 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 458 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
458 mIsPi->setChecked(prof->getIsPiSync()) ; 459 mIsPi->setChecked(prof->getIsPiSync()) ;
459 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() ); 460 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() );
460 proGr->setEnabled( item > 2 ); 461 proGr->setEnabled( item > 2 );
461 if ( item < 3 ) { 462 if ( item < 3 ) {
462 localFileWidget->hide(); 463 localFileWidget->hide();
463 remoteFileWidget->hide(); 464 remoteFileWidget->hide();
464 phoneWidget->hide(); 465 phoneWidget->hide();
465 piWidget->hide(); 466 piWidget->hide();
466 467
467 } else 468 } else
468 kindChanged( prof->getIsLocalFileSync() ); 469 kindChanged( prof->getIsLocalFileSync() );
469} 470}
470 471
471void KSyncPrefsDialog::fillSSH() 472void KSyncPrefsDialog::fillSSH()
472{ 473{
473 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 474 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
474 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 475 mLocalTempFile->setText("/tmp/mycalendar.ics" );
475 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 476 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
476 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 477 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
477 mLocalTempFileAB->setText("/tmp/std.vcf" ); 478 mLocalTempFileAB->setText("/tmp/std.vcf" );
478 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 479 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
479 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 480 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
480 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 481 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
481 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 482 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
482} 483}
483void KSyncPrefsDialog::fillFTP() 484void KSyncPrefsDialog::fillFTP()
484{ 485{
485 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 486 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
486 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 487 mLocalTempFile->setText("/tmp/mycalendar.ics" );
487 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 488 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
488 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 489 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
489 mLocalTempFileAB->setText("/tmp/std.vcf" ); 490 mLocalTempFileAB->setText("/tmp/std.vcf" );
490 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 491 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
491 492
492 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 493 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
493 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 494 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
494 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 495 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
495 496
496} 497}
497void KSyncPrefsDialog::kindChanged( bool b ) 498void KSyncPrefsDialog::kindChanged( bool b )
498{ 499{
499 500
500 if ( mIsLocal->isChecked () ) 501 if ( mIsLocal->isChecked () )
501 localFileWidget->show(); 502 localFileWidget->show();
502 else 503 else
503 localFileWidget->hide(); 504 localFileWidget->hide();
504 505
505 if ( mIsNotLocal->isChecked () ) 506 if ( mIsNotLocal->isChecked () )
506 remoteFileWidget->show(); 507 remoteFileWidget->show();
507 else 508 else
508 remoteFileWidget->hide(); 509 remoteFileWidget->hide();
509 510
510 if ( mIsPhone->isChecked () ) { 511 if ( mIsPhone->isChecked () ) {
511 phoneWidget->show(); 512 phoneWidget->show();
512 } 513 }
513 else { 514 else {
514 phoneWidget->hide(); 515 phoneWidget->hide();
515 } 516 }
516 if ( mIsPi->isChecked () ) { 517 if ( mIsPi->isChecked () ) {
517 piWidget->show(); 518 piWidget->show();
518 } 519 }
519 else { 520 else {
520 piWidget->hide(); 521 piWidget->hide();
521 } 522 }
522 523
523} 524}
524void KSyncPrefsDialog::deleteProfile() 525void KSyncPrefsDialog::deleteProfile()
525{ 526{
526 //qDebug("KSyncPrefsDialog::deleteProfile() "); 527 //qDebug("KSyncPrefsDialog::deleteProfile() ");
527 if ( currentSelection >= 0 ) { 528 if ( currentSelection >= 0 ) {
528 if ( currentSelection < 3 ) { 529 if ( currentSelection < 3 ) {
529 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 530 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
530 return; 531 return;
531 } 532 }
532 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 533 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
533 mSyncProfiles.remove( temp ); 534 mSyncProfiles.remove( temp );
534 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 535 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
535 insertProfiles(); 536 insertProfiles();
536 } 537 }
537} 538}
538 539
539void KSyncPrefsDialog::saveProfile() 540void KSyncPrefsDialog::saveProfile()
540{ 541{
541 KSyncProfile* prof; 542 KSyncProfile* prof;
542 if ( currentSelection >= 0 ) { 543 if ( currentSelection >= 0 ) {
543 prof = mSyncProfiles.at(currentSelection) ; 544 prof = mSyncProfiles.at(currentSelection) ;
544 545
545 prof->setRemotePw( mRemotePw->text()); 546 prof->setRemotePw( mRemotePw->text());
546 prof->setRemoteIP( mRemoteIP->text()); 547 prof->setRemoteIP( mRemoteIP->text());
547 prof->setRemotePort( mRemotePort->text()); 548 prof->setRemotePort( mRemotePort->text());
548 549
549 prof->setRemotePwAB( mRemotePwAB->text()); 550 prof->setRemotePwAB( mRemotePwAB->text());
550 prof->setRemoteIPAB( mRemoteIPAB->text()); 551 prof->setRemoteIPAB( mRemoteIPAB->text());
551 prof->setRemotePortAB( mRemotePortAB->text()); 552 prof->setRemotePortAB( mRemotePortAB->text());
552 553
553 prof->setRemotePwPWM( mRemotePwPWM->text()); 554 prof->setRemotePwPWM( mRemotePwPWM->text());
554 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 555 prof->setRemoteIPPWM( mRemoteIPPWM->text());
555 prof->setRemotePortPWM( mRemotePortPWM->text()); 556 prof->setRemotePortPWM( mRemotePortPWM->text());
556 557
557 prof->setPreSyncCommand( mRemotePrecommand->text()); 558 prof->setPreSyncCommand( mRemotePrecommand->text());
558 prof->setPostSyncCommand( mRemotePostcommand->text() ); 559 prof->setPostSyncCommand( mRemotePostcommand->text() );
559 prof->setLocalTempFile( mLocalTempFile->text()); 560 prof->setLocalTempFile( mLocalTempFile->text());
560 prof->setRemoteFileName( mRemoteFile->text() ); 561 prof->setRemoteFileName( mRemoteFile->text() );
561 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 562 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
562 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 563 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
563 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 564 prof->setLocalTempFileAB( mLocalTempFileAB->text());
564 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 565 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
565 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 566 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
566 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 567 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
567 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 568 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
568 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 569 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
569 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 570 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
570 prof->setAskForPreferences( mAskForPreferences->isChecked()); 571 prof->setAskForPreferences( mAskForPreferences->isChecked());
571 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 572 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
572 prof->setWriteBackFile( mWriteBackFile->isChecked()); 573 prof->setWriteBackFile( mWriteBackFile->isChecked());
573 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 574 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
574 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 575 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
575 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 576 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
576 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 577 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
577 prof->setSyncPrefs( syncprefs); 578 prof->setSyncPrefs( syncprefs);
578 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 579 prof->setIsLocalFileSync( mIsLocal->isChecked() );
579 prof->setIsPhoneSync( mIsPhone->isChecked() ); 580 prof->setIsPhoneSync( mIsPhone->isChecked() );
580 prof->setIsPiSync( mIsPi->isChecked() ); 581 prof->setIsPiSync( mIsPi->isChecked() );
581 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 582 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
582 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 583 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
583 584 if ( mWriteContactToSIM )
584 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 585 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
585 prof->setPhoneDevice( mPhoneDevice->text() ); 586 prof->setPhoneDevice( mPhoneDevice->text() );
586 prof->setPhoneConnection( mPhoneConnection->text() ); 587 prof->setPhoneConnection( mPhoneConnection->text() );
587 prof->setPhoneModel( mPhoneModel->text() ); 588 prof->setPhoneModel( mPhoneModel->text() );
588 589
589 } 590 }
590 591
591} 592}
592 593
593void KSyncPrefsDialog::insertProfiles() 594void KSyncPrefsDialog::insertProfiles()
594{ 595{
595 int curItem = mProfileBox->currentItem(); 596 int curItem = mProfileBox->currentItem();
596 mProfileBox->blockSignals( true ); 597 mProfileBox->blockSignals( true );
597 mProfileBox->clear(); 598 mProfileBox->clear();
598 mProfileBox->insertStringList (mSyncProfileNames ); 599 mProfileBox->insertStringList (mSyncProfileNames );
599 int item = mSyncProfileNames.count() -1; 600 int item = mSyncProfileNames.count() -1;
600 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 601 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
601 mProfileBox->setCurrentItem( curItem ); 602 mProfileBox->setCurrentItem( curItem );
602 else if ( item >= 0 ) { 603 else if ( item >= 0 ) {
603 mProfileBox->setCurrentItem( item ); 604 mProfileBox->setCurrentItem( item );
604 } 605 }
605 currentSelection = -1; 606 currentSelection = -1;
606 if ( mSyncProfileNames.count() > 0 ) { 607 if ( mSyncProfileNames.count() > 0 ) {
607 //qDebug(" profileChanged( mProfileBox->currentItem() "); 608 //qDebug(" profileChanged( mProfileBox->currentItem() ");
608 profileChanged( mProfileBox->currentItem() ); 609 profileChanged( mProfileBox->currentItem() );
609 currentSelection = mProfileBox->currentItem(); 610 currentSelection = mProfileBox->currentItem();
610 } 611 }
611 mProfileBox->blockSignals( false ); 612 mProfileBox->blockSignals( false );
612} 613}
613 614
614void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 615void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
615{ 616{
616 saveProfile(); 617 saveProfile();
617 mSyncProfiles.append( temp ); 618 mSyncProfiles.append( temp );
618 mSyncProfileNames << temp->getName(); 619 mSyncProfileNames << temp->getName();
619 insertProfiles(); 620 insertProfiles();
620 int last = mProfileBox->count() -1; 621 int last = mProfileBox->count() -1;
621 mProfileBox->blockSignals( true ); 622 mProfileBox->blockSignals( true );
622 mProfileBox->setCurrentItem( last ); 623 mProfileBox->setCurrentItem( last );
623 mProfileBox->blockSignals( false ); 624 mProfileBox->blockSignals( false );
624 profileChanged(last); 625 profileChanged(last);
625} 626}
626void KSyncPrefsDialog::newProfile() 627void KSyncPrefsDialog::newProfile()
627{ 628{
628 addProfile ( new KSyncProfile () ); 629 addProfile ( new KSyncProfile () );
629} 630}
630 631
631void KSyncPrefsDialog::cloneProfile() 632void KSyncPrefsDialog::cloneProfile()
632{ 633{
633 if ( currentSelection >= 0 ) 634 if ( currentSelection >= 0 )
634 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 635 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
635 else 636 else
636 newProfile(); 637 newProfile();
637} 638}
638 639
639void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 640void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
640{ 641{
641 mMyMachineName->setText( name ); 642 mMyMachineName->setText( name );
642 643
643} 644}
644QString KSyncPrefsDialog::getLocalMachineName ( ) 645QString KSyncPrefsDialog::getLocalMachineName ( )
645{ 646{
646 return mMyMachineName->text(); 647 return mMyMachineName->text();
647} 648}
648 649
649QStringList KSyncPrefsDialog::getSyncProfileNames() 650QStringList KSyncPrefsDialog::getSyncProfileNames()
650{ 651{
651 return mSyncProfileNames; 652 return mSyncProfileNames;
652} 653}
653void KSyncPrefsDialog::usrReadConfig() 654void KSyncPrefsDialog::usrReadConfig()
654{ 655{
655 //KConfig *config = KOGlobals::config(); 656 //KConfig *config = KOGlobals::config();
656 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 657 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
657 config.setGroup("General"); 658 config.setGroup("General");
658 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 659 mSyncProfileNames =config.readListEntry("SyncProfileNames");
659 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 660 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
660 int i; 661 int i;
661 KSyncProfile* temp ; 662 KSyncProfile* temp ;
662 mSyncProfiles.clear(); 663 mSyncProfiles.clear();
663 for ( i = 0; i < mSyncProfileNames.count();++i ) { 664 for ( i = 0; i < mSyncProfileNames.count();++i ) {
664 temp = new KSyncProfile (); 665 temp = new KSyncProfile ();
665 temp->setName( mSyncProfileNames[i] ); 666 temp->setName( mSyncProfileNames[i] );
666 temp->readConfig( &config ); 667 temp->readConfig( &config );
667 mSyncProfiles.append( temp ); 668 mSyncProfiles.append( temp );
668 } 669 }
669 insertProfiles(); 670 insertProfiles();
670 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 671 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
671} 672}
672 673
673 674
674void KSyncPrefsDialog::usrWriteConfig() 675void KSyncPrefsDialog::usrWriteConfig()
675{ 676{
676 saveProfile(); 677 saveProfile();
677 if ( currentSelection >= 0 ) 678 if ( currentSelection >= 0 )
678 profileChanged(currentSelection); 679 profileChanged(currentSelection);
679 //KConfig *config = KOGlobals::config(); 680 //KConfig *config = KOGlobals::config();
680 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 681 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
681 KSyncProfile* prof = mSyncProfiles.first(); 682 KSyncProfile* prof = mSyncProfiles.first();
682 QStringList externalSyncProfileNames; 683 QStringList externalSyncProfileNames;
683 externalSyncProfileNames.append("Sharp_DTM");; 684 externalSyncProfileNames.append("Sharp_DTM");;
684 while ( prof ) { 685 while ( prof ) {
685 prof->writeConfig(&config); 686 prof->writeConfig(&config);
686 if ( prof->getIsPhoneSync( ) ) 687 if ( prof->getIsPhoneSync( ) )
687 externalSyncProfileNames.append(prof->getName( ) ); 688 externalSyncProfileNames.append(prof->getName( ) );
688 prof = mSyncProfiles.next(); 689 prof = mSyncProfiles.next();
689 } 690 }
690 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 691 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
691 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 692 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
692 config.setGroup("General"); 693 config.setGroup("General");
693 config.writeEntry("SyncProfileNames",mSyncProfileNames); 694 config.writeEntry("SyncProfileNames",mSyncProfileNames);
694 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 695 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
695 config.writeEntry("LocalMachineName",mMyMachineName->text()); 696 config.writeEntry("LocalMachineName",mMyMachineName->text());
696 config.sync(); 697 config.sync();
697} 698}
698 699
699void KSyncPrefsDialog::helpDevice() 700void KSyncPrefsDialog::helpDevice()
700{ 701{
701 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 702 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
702#ifdef _WIN32_ 703#ifdef _WIN32_
703 hint += "Leave empty for Irda.\n" 704 hint += "Leave empty for Irda.\n"
704 "com1:\n(first serial port)\n" 705 "com1:\n(first serial port)\n"
705 "usb not supported\n" 706 "usb not supported\n"
706 "???\n(bluetooth device address)\n"; 707 "???\n(bluetooth device address)\n";
707 708
708#else 709#else
709 hint += "/dev/ircomm\n(Irda)\n" 710 hint += "/dev/ircomm\n(Irda)\n"
710 "/dev/ttyS0\n(first serial port)\n" 711 "/dev/ttyS0\n(first serial port)\n"
711 "/dev/ttyUSB0\n(first device usb port)\n" 712 "/dev/ttyUSB0\n(first device usb port)\n"
712 "???\n(bluetooth device address)\n"; 713 "???\n(bluetooth device address)\n";
713#endif 714#endif
714 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 715 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
715} 716}
716void KSyncPrefsDialog::helpModel() 717void KSyncPrefsDialog::helpModel()
717{ 718{
718 QString hint = i18n("Leave empty or\ninsert name of phone model:\n"); 719 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n");
719 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 720 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
720 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 721 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
721 722
722} 723}
723void KSyncPrefsDialog::helpConnection() 724void KSyncPrefsDialog::helpConnection()
724{ 725{
725 QString hint = i18n("Insert kind of connection,e.g.:\n"); 726 QString hint = i18n("Insert kind of connection,e.g.:\n");
726 hint += "irda | Nokia FBUS over infrared\n" 727 hint += "irda | Nokia FBUS over infrared\n"
727 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 728 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
728 "irdaobex | set also model as obex\n" 729 "irdaobex | set also model as obex\n"
729 "fbus | Nokia FBUS2 serial\n"; 730 "fbus | Nokia FBUS2 serial\n";
730 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 731 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
731} 732}