author | zautrix <zautrix> | 2004-10-10 16:00:04 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-10 16:00:04 (UTC) |
commit | ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a (patch) (unidiff) | |
tree | 1d908bfc23b8a49d43a58bbeadd82c4e08faeff6 | |
parent | 213a9d993e5a4751b64e18320cfbebb000681d13 (diff) | |
download | kdepimpi-ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a.zip kdepimpi-ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a.tar.gz kdepimpi-ee6e29a5092d32165b7bf6b39069bd8a1dcd5b0a.tar.bz2 |
many phone AB sync fixes
-rw-r--r-- | gammu/emb/common/service/gsmmisc.c | 4 | ||||
-rw-r--r-- | gammu/emb/common/service/gsmpbk.c | 17 | ||||
-rw-r--r-- | gammu/emb/gammu/gammu.c | 2 | ||||
-rw-r--r-- | kabc/addressbook.cpp | 148 | ||||
-rw-r--r-- | kabc/addressbook.h | 2 | ||||
-rw-r--r-- | kabc/addressee.cpp | 46 | ||||
-rw-r--r-- | kabc/addressee.h | 1 | ||||
-rw-r--r-- | kabc/phonenumber.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 86 | ||||
-rw-r--r-- | libkdepim/ksyncprefsdialog.cpp | 11 |
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 | |||
@@ -1,262 +1,262 @@ | |||
1 | /* (c) 2002-2004 by Marcin Wiacek */ | 1 | /* (c) 2002-2004 by Marcin Wiacek */ |
2 | 2 | ||
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | #ifdef WIN32 | 6 | #ifdef WIN32 |
7 | # include <io.h> | 7 | # include <io.h> |
8 | # include <fcntl.h> | 8 | # include <fcntl.h> |
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #include "../misc/coding/coding.h" | 11 | #include "../misc/coding/coding.h" |
12 | #include "../gsmcomon.h" | 12 | #include "../gsmcomon.h" |
13 | #include "gsmmisc.h" | 13 | #include "gsmmisc.h" |
14 | 14 | ||
15 | struct keys_table_position { | 15 | struct keys_table_position { |
16 | char whatchar; | 16 | char whatchar; |
17 | int whatcode; | 17 | int whatcode; |
18 | }; | 18 | }; |
19 | 19 | ||
20 | static struct keys_table_position Keys[] = { | 20 | static struct keys_table_position Keys[] = { |
21 | {'m',GSM_KEY_MENU}, {'M',GSM_KEY_MENU}, | 21 | {'m',GSM_KEY_MENU}, {'M',GSM_KEY_MENU}, |
22 | {'n',GSM_KEY_NAMES}, {'N',GSM_KEY_NAMES}, | 22 | {'n',GSM_KEY_NAMES}, {'N',GSM_KEY_NAMES}, |
23 | {'p',GSM_KEY_POWER}, {'P',GSM_KEY_POWER}, | 23 | {'p',GSM_KEY_POWER}, {'P',GSM_KEY_POWER}, |
24 | {'u',GSM_KEY_UP}, {'U',GSM_KEY_UP}, | 24 | {'u',GSM_KEY_UP}, {'U',GSM_KEY_UP}, |
25 | {'d',GSM_KEY_DOWN}, {'D',GSM_KEY_DOWN}, | 25 | {'d',GSM_KEY_DOWN}, {'D',GSM_KEY_DOWN}, |
26 | {'+',GSM_KEY_INCREASEVOLUME},{'-',GSM_KEY_DECREASEVOLUME}, | 26 | {'+',GSM_KEY_INCREASEVOLUME},{'-',GSM_KEY_DECREASEVOLUME}, |
27 | {'1',GSM_KEY_1}, {'2',GSM_KEY_2},{'3',GSM_KEY_3}, | 27 | {'1',GSM_KEY_1}, {'2',GSM_KEY_2},{'3',GSM_KEY_3}, |
28 | {'4',GSM_KEY_4}, {'5',GSM_KEY_5},{'6',GSM_KEY_6}, | 28 | {'4',GSM_KEY_4}, {'5',GSM_KEY_5},{'6',GSM_KEY_6}, |
29 | {'7',GSM_KEY_7}, {'8',GSM_KEY_8},{'9',GSM_KEY_9}, | 29 | {'7',GSM_KEY_7}, {'8',GSM_KEY_8},{'9',GSM_KEY_9}, |
30 | {'*',GSM_KEY_ASTERISK}, {'0',GSM_KEY_0},{'#',GSM_KEY_HASH}, | 30 | {'*',GSM_KEY_ASTERISK}, {'0',GSM_KEY_0},{'#',GSM_KEY_HASH}, |
31 | {'g',GSM_KEY_GREEN}, {'G',GSM_KEY_GREEN}, | 31 | {'g',GSM_KEY_GREEN}, {'G',GSM_KEY_GREEN}, |
32 | {'r',GSM_KEY_RED}, {'R',GSM_KEY_RED}, | 32 | {'r',GSM_KEY_RED}, {'R',GSM_KEY_RED}, |
33 | {' ',0} | 33 | {' ',0} |
34 | }; | 34 | }; |
35 | 35 | ||
36 | GSM_Error MakeKeySequence(char *text, GSM_KeyCode *KeyCode, int *Length) | 36 | GSM_Error MakeKeySequence(char *text, GSM_KeyCode *KeyCode, int *Length) |
37 | { | 37 | { |
38 | int i,j; | 38 | int i,j; |
39 | unsigned char key; | 39 | unsigned char key; |
40 | 40 | ||
41 | for (i=0;i<(int)(strlen(text));i++) { | 41 | for (i=0;i<(int)(strlen(text));i++) { |
42 | key = text[i]; | 42 | key = text[i]; |
43 | KeyCode[i] = GSM_KEY_NONE; | 43 | KeyCode[i] = GSM_KEY_NONE; |
44 | j = 0; | 44 | j = 0; |
45 | while (Keys[j].whatchar!=' ') { | 45 | while (Keys[j].whatchar!=' ') { |
46 | if (Keys[j].whatchar==key) { | 46 | if (Keys[j].whatchar==key) { |
47 | KeyCode[i]=Keys[j].whatcode; | 47 | KeyCode[i]=Keys[j].whatcode; |
48 | break; | 48 | break; |
49 | } | 49 | } |
50 | j++; | 50 | j++; |
51 | } | 51 | } |
52 | if (KeyCode[i] == GSM_KEY_NONE) { | 52 | if (KeyCode[i] == GSM_KEY_NONE) { |
53 | *Length = i; | 53 | *Length = i; |
54 | return ERR_NOTSUPPORTED; | 54 | return ERR_NOTSUPPORTED; |
55 | } | 55 | } |
56 | } | 56 | } |
57 | *Length = i; | 57 | *Length = i; |
58 | return ERR_NONE; | 58 | return ERR_NONE; |
59 | } | 59 | } |
60 | 60 | ||
61 | GSM_Error GSM_ReadFile(char *FileName, GSM_File *File) | 61 | GSM_Error GSM_ReadFile(char *FileName, GSM_File *File) |
62 | { | 62 | { |
63 | int i = 1000; | 63 | int i = 1000; |
64 | FILE *file; | 64 | FILE *file; |
65 | struct statfileinfo; | 65 | struct statfileinfo; |
66 | 66 | ||
67 | if (FileName[0] == 0x00) return ERR_UNKNOWN; | 67 | if (FileName[0] == 0x00) return ERR_UNKNOWN; |
68 | file = fopen(FileName,"rb"); | 68 | file = fopen(FileName,"rb"); |
69 | if (file == NULL) return ERR_CANTOPENFILE; | 69 | if (file == NULL) return ERR_CANTOPENFILE; |
70 | 70 | ||
71 | free(File->Buffer); | 71 | free(File->Buffer); |
72 | File->Buffer = NULL; | 72 | File->Buffer = NULL; |
73 | File->Used = 0; | 73 | File->Used = 0; |
74 | while (i == 1000) { | 74 | while (i == 1000) { |
75 | File->Buffer = realloc(File->Buffer,File->Used + 1000); | 75 | File->Buffer = realloc(File->Buffer,File->Used + 1000); |
76 | i = fread(File->Buffer+File->Used,1,1000,file); | 76 | i = fread(File->Buffer+File->Used,1,1000,file); |
77 | File->Used = File->Used + i; | 77 | File->Used = File->Used + i; |
78 | } | 78 | } |
79 | File->Buffer = realloc(File->Buffer,File->Used); | 79 | File->Buffer = realloc(File->Buffer,File->Used); |
80 | fclose(file); | 80 | fclose(file); |
81 | 81 | ||
82 | File->ModifiedEmpty = true; | 82 | File->ModifiedEmpty = true; |
83 | if (stat(FileName,&fileinfo) == 0) { | 83 | if (stat(FileName,&fileinfo) == 0) { |
84 | File->ModifiedEmpty = false; | 84 | File->ModifiedEmpty = false; |
85 | dbgprintf("File info read correctly\n"); | 85 | dbgprintf("File info read correctly\n"); |
86 | //st_mtime is time of last modification of file | 86 | //st_mtime is time of last modification of file |
87 | Fill_GSM_DateTime(&File->Modified, fileinfo.st_mtime); | 87 | Fill_GSM_DateTime(&File->Modified, fileinfo.st_mtime); |
88 | File->Modified.Year = File->Modified.Year + 1900; | 88 | File->Modified.Year = File->Modified.Year + 1900; |
89 | dbgprintf("FileTime: %02i-%02i-%04i %02i:%02i:%02i\n", | 89 | dbgprintf("FileTime: %02i-%02i-%04i %02i:%02i:%02i\n", |
90 | File->Modified.Day,File->Modified.Month,File->Modified.Year, | 90 | File->Modified.Day,File->Modified.Month,File->Modified.Year, |
91 | File->Modified.Hour,File->Modified.Minute,File->Modified.Second); | 91 | File->Modified.Hour,File->Modified.Minute,File->Modified.Second); |
92 | } | 92 | } |
93 | 93 | ||
94 | return ERR_NONE; | 94 | return ERR_NONE; |
95 | } | 95 | } |
96 | 96 | ||
97 | static void GSM_JADFindLine(GSM_File File, char *Name, char *Value) | 97 | static void GSM_JADFindLine(GSM_File File, char *Name, char *Value) |
98 | { | 98 | { |
99 | unsigned char Line[2000]; | 99 | unsigned char Line[2000]; |
100 | int Pos = 0; | 100 | int Pos = 0; |
101 | 101 | ||
102 | Value[0] = 0; | 102 | Value[0] = 0; |
103 | 103 | ||
104 | while (1) { | 104 | while (1) { |
105 | MyGetLine(File.Buffer, &Pos, Line, File.Used); | 105 | MyGetLine(File.Buffer, &Pos, Line, File.Used); |
106 | if (strlen(Line) == 0) break; | 106 | if (strlen(Line) == 0) break; |
107 | if (!strncmp(Line,Name,strlen(Name))) { | 107 | if (!strncmp(Line,Name,strlen(Name))) { |
108 | Pos = strlen(Name); | 108 | Pos = strlen(Name); |
109 | while (Line[Pos] == 0x20) Pos++; | 109 | while (Line[Pos] == 0x20) Pos++; |
110 | strcpy(Value,Line+Pos); | 110 | strcpy(Value,Line+Pos); |
111 | return; | 111 | return; |
112 | } | 112 | } |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | GSM_Error GSM_JADFindData(GSM_File File, char *Vendor, char *Name, char *JAR, char *Version, int *Size) | 116 | GSM_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 | ||
144 | void GSM_IdentifyFileFormat(GSM_File *File) | 144 | void 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 | ||
166 | void SaveVCALDateTime(char *Buffer, int *Length, GSM_DateTime *Date, char *Start) | 166 | void 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 | ||
176 | void ReadVCALDateTime(char *Buffer, GSM_DateTime *dt) | 176 | void 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 | ||
200 | void SaveVCALText(char *Buffer, int *Length, char *Text, char *Start) | 200 | void 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 | ||
214 | bool ReadVCALText(char *Buffer, char *Start, char *Value) | 214 | bool 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 | |||
@@ -1,370 +1,371 @@ | |||
1 | /* (c) 2001-2003 by Marcin Wiacek,... */ | 1 | /* (c) 2001-2003 by Marcin Wiacek,... */ |
2 | 2 | ||
3 | #include <string.h> | 3 | #include <string.h> |
4 | 4 | ||
5 | #include "../misc/coding/coding.h" | 5 | #include "../misc/coding/coding.h" |
6 | #include "gsmpbk.h" | 6 | #include "gsmpbk.h" |
7 | #include "gsmmisc.h" | 7 | #include "gsmmisc.h" |
8 | 8 | ||
9 | unsigned char *GSM_PhonebookGetEntryName (GSM_MemoryEntry *entry) | 9 | unsigned char *GSM_PhonebookGetEntryName (GSM_MemoryEntry *entry) |
10 | { | 10 | { |
11 | /* We possibly store here "LastName, FirstName" so allocate enough memory */ | 11 | /* We possibly store here "LastName, FirstName" so allocate enough memory */ |
12 | static char dest[(GSM_PHONEBOOK_TEXT_LENGTH*2+2+1)*2]; | 12 | static char dest[(GSM_PHONEBOOK_TEXT_LENGTH*2+2+1)*2]; |
13 | static char split[] = { '\0', ',', '\0', ' ', '\0', '\0'}; | 13 | static char split[] = { '\0', ',', '\0', ' ', '\0', '\0'}; |
14 | int i; | 14 | int i; |
15 | int first = -1, last = -1, name = -1; | 15 | int first = -1, last = -1, name = -1; |
16 | int len = 0; | 16 | int len = 0; |
17 | 17 | ||
18 | for (i = 0; i < entry->EntriesNum; i++) { | 18 | for (i = 0; i < entry->EntriesNum; i++) { |
19 | switch (entry->Entries[i].EntryType) { | 19 | switch (entry->Entries[i].EntryType) { |
20 | case PBK_Text_LastName: | 20 | case PBK_Text_LastName: |
21 | last = i; | 21 | last = i; |
22 | break; | 22 | break; |
23 | case PBK_Text_FirstName: | 23 | case PBK_Text_FirstName: |
24 | first = i; | 24 | first = i; |
25 | break; | 25 | break; |
26 | case PBK_Text_Name: | 26 | case PBK_Text_Name: |
27 | name = i; | 27 | name = i; |
28 | break; | 28 | break; |
29 | default: | 29 | default: |
30 | break; | 30 | break; |
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | if (name != -1) { | 34 | if (name != -1) { |
35 | CopyUnicodeString(dest, entry->Entries[name].Text); | 35 | CopyUnicodeString(dest, entry->Entries[name].Text); |
36 | } else { | 36 | } else { |
37 | if (last != -1 && first != -1) { | 37 | if (last != -1 && first != -1) { |
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 | ||
54 | void GSM_PhonebookFindDefaultNameNumberGroup(GSM_MemoryEntry *entry, int *Name, int *Number, int *Group) | 54 | void 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 | ||
102 | void GSM_EncodeVCARD(char *Buffer, int *Length, GSM_MemoryEntry *pbk, bool header, GSM_VCardVersion Version) | 102 | void 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 | ||
186 | GSM_Error GSM_DecodeVCARD(unsigned char *Buffer, int *Pos, GSM_MemoryEntry *Pbk, GSM_VCardVersion Version) | 187 | GSM_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 | } |
278 | 279 | ||
279 | /* -------------- OLD functions (c) by Timo Teras -------------------------- */ | 280 | /* -------------- OLD functions (c) by Timo Teras -------------------------- */ |
280 | 281 | ||
281 | #ifndef ENABLE_LGPL | 282 | #ifndef ENABLE_LGPL |
282 | 283 | ||
283 | static void ParseVCardLine(char **pos, char *Name, char *Parameters, char *Value) | 284 | static void ParseVCardLine(char **pos, char *Name, char *Parameters, char *Value) |
284 | { | 285 | { |
285 | int i; | 286 | int i; |
286 | 287 | ||
287 | Name[0] = Parameters[0] = Value[0] = 0; | 288 | Name[0] = Parameters[0] = Value[0] = 0; |
288 | 289 | ||
289 | if (**pos == 0) return; | 290 | if (**pos == 0) return; |
290 | 291 | ||
291 | for (i=0; **pos && **pos != ':' && **pos != ';'; i++, (*pos)++) Name[i] = **pos; | 292 | for (i=0; **pos && **pos != ':' && **pos != ';'; i++, (*pos)++) Name[i] = **pos; |
292 | Name[i] = 0; | 293 | Name[i] = 0; |
293 | 294 | ||
294 | //dbgprintf("ParseVCardLine: name tag = '%s'\n", Name); | 295 | //dbgprintf("ParseVCardLine: name tag = '%s'\n", Name); |
295 | if (**pos == ';') { | 296 | if (**pos == ';') { |
296 | (*pos)++; | 297 | (*pos)++; |
297 | for (i=0; **pos && **pos != ':'; i++, (*pos)++) Parameters[i] = **pos; | 298 | for (i=0; **pos && **pos != ':'; i++, (*pos)++) Parameters[i] = **pos; |
298 | Parameters[i] = ';'; | 299 | Parameters[i] = ';'; |
299 | Parameters[i+1] = 0; | 300 | Parameters[i+1] = 0; |
300 | //dbgprintf("ParseVCardLine: parameter tag = '%s'\n", Parameters); | 301 | //dbgprintf("ParseVCardLine: parameter tag = '%s'\n", Parameters); |
301 | } | 302 | } |
302 | 303 | ||
303 | if (**pos != 0) (*pos)++; | 304 | if (**pos != 0) (*pos)++; |
304 | 305 | ||
305 | i=0; | 306 | i=0; |
306 | while (**pos) { | 307 | while (**pos) { |
307 | if ((*pos)[0] == '\x0d' && (*pos)[1] == '\x0a') { | 308 | if ((*pos)[0] == '\x0d' && (*pos)[1] == '\x0a') { |
308 | (*pos) += 2; | 309 | (*pos) += 2; |
309 | if (**pos != '\t' && **pos != ' ') break; | 310 | if (**pos != '\t' && **pos != ' ') break; |
310 | while (**pos == '\t' || **pos == ' ') (*pos)++; | 311 | while (**pos == '\t' || **pos == ' ') (*pos)++; |
311 | continue; | 312 | continue; |
312 | } | 313 | } |
313 | Value[i++] = **pos; | 314 | Value[i++] = **pos; |
314 | (*pos)++; | 315 | (*pos)++; |
315 | } | 316 | } |
316 | Value[i] = 0; | 317 | Value[i] = 0; |
317 | 318 | ||
318 | //dbgprintf("ParseVCardLine: value tag = '%s'\n", Value); | 319 | //dbgprintf("ParseVCardLine: value tag = '%s'\n", Value); |
319 | } | 320 | } |
320 | 321 | ||
321 | void DecodeVCARD21Text(char *VCard, GSM_MemoryEntry *pbk) | 322 | void DecodeVCARD21Text(char *VCard, GSM_MemoryEntry *pbk) |
322 | { | 323 | { |
323 | char *pos = VCard; | 324 | char *pos = VCard; |
324 | char Name[32], Parameters[256], Value[1024]; | 325 | char Name[32], Parameters[256], Value[1024]; |
325 | 326 | ||
326 | dbgprintf("Parsing VCard:\n%s\n", VCard); | 327 | dbgprintf("Parsing VCard:\n%s\n", VCard); |
327 | 328 | ||
328 | ParseVCardLine(&pos, Name, Parameters, Value); | 329 | ParseVCardLine(&pos, Name, Parameters, Value); |
329 | if (!mystrncasecmp(Name, "BEGIN", 0) || !mystrncasecmp(Value, "VCARD", 0)) { | 330 | if (!mystrncasecmp(Name, "BEGIN", 0) || !mystrncasecmp(Value, "VCARD", 0)) { |
330 | dbgprintf("No valid VCARD signature\n"); | 331 | dbgprintf("No valid VCARD signature\n"); |
331 | return; | 332 | return; |
332 | } | 333 | } |
333 | 334 | ||
334 | while (1) { | 335 | while (1) { |
335 | GSM_SubMemoryEntry *pbe = &pbk->Entries[pbk->EntriesNum]; | 336 | GSM_SubMemoryEntry *pbe = &pbk->Entries[pbk->EntriesNum]; |
336 | 337 | ||
337 | ParseVCardLine(&pos, Name, Parameters, Value); | 338 | ParseVCardLine(&pos, Name, Parameters, Value); |
338 | if (Name[0] == 0x00 || | 339 | if (Name[0] == 0x00 || |
339 | (mystrncasecmp(Name, "END", 0) && mystrncasecmp(Value, "VCARD", 0))) | 340 | (mystrncasecmp(Name, "END", 0) && mystrncasecmp(Value, "VCARD", 0))) |
340 | return; | 341 | return; |
341 | 342 | ||
342 | if (mystrncasecmp(Name, "N", 0)) { | 343 | if (mystrncasecmp(Name, "N", 0)) { |
343 | //FIXME: Name is tagged field which should be parsed | 344 | //FIXME: Name is tagged field which should be parsed |
344 | pbe->EntryType = PBK_Text_Name; | 345 | pbe->EntryType = PBK_Text_Name; |
345 | EncodeUnicode(pbe->Text, Value, strlen(Value)); | 346 | EncodeUnicode(pbe->Text, Value, strlen(Value)); |
346 | pbk->EntriesNum++; | 347 | pbk->EntriesNum++; |
347 | } else if (mystrncasecmp(Name, "EMAIL", 0)) { | 348 | } else if (mystrncasecmp(Name, "EMAIL", 0)) { |
348 | pbe->EntryType = PBK_Text_Email; | 349 | pbe->EntryType = PBK_Text_Email; |
349 | EncodeUnicode(pbe->Text, Value, strlen(Value)); | 350 | EncodeUnicode(pbe->Text, Value, strlen(Value)); |
350 | pbk->EntriesNum++; | 351 | pbk->EntriesNum++; |
351 | } else if (mystrncasecmp(Name, "TEL", 0)) { | 352 | } else if (mystrncasecmp(Name, "TEL", 0)) { |
352 | if (strstr(Parameters, "WORK;")) | 353 | if (strstr(Parameters, "WORK;")) |
353 | pbe->EntryType = PBK_Number_Work; | 354 | pbe->EntryType = PBK_Number_Work; |
354 | else if (strstr(Name, "HOME;")) | 355 | else if (strstr(Name, "HOME;")) |
355 | pbe->EntryType = PBK_Number_Home; | 356 | pbe->EntryType = PBK_Number_Home; |
356 | else if (strstr(Name, "FAX;")) | 357 | else if (strstr(Name, "FAX;")) |
357 | pbe->EntryType = PBK_Number_Fax; | 358 | pbe->EntryType = PBK_Number_Fax; |
358 | else pbe->EntryType = PBK_Number_General; | 359 | else pbe->EntryType = PBK_Number_General; |
359 | 360 | ||
360 | EncodeUnicode(pbe->Text, Value, strlen(Value)); | 361 | EncodeUnicode(pbe->Text, Value, strlen(Value)); |
361 | pbk->EntriesNum++; | 362 | pbk->EntriesNum++; |
362 | } | 363 | } |
363 | } | 364 | } |
364 | } | 365 | } |
365 | 366 | ||
366 | #endif | 367 | #endif |
367 | 368 | ||
368 | /* How should editor hadle tabs in this file? Add editor commands here. | 369 | /* How should editor hadle tabs in this file? Add editor commands here. |
369 | * vim: noexpandtab sw=8 ts=8 sts=8: | 370 | * vim: noexpandtab sw=8 ts=8 sts=8: |
370 | */ | 371 | */ |
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 | |||
@@ -1617,6145 +1617,6145 @@ static void GetRingtone(int argc, char *argv[]) | |||
1617 | error=GSM_SaveRingtoneFile(argv[3], &ringtone); | 1617 | error=GSM_SaveRingtoneFile(argv[3], &ringtone); |
1618 | Print_Error(error); | 1618 | Print_Error(error); |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | GSM_Terminate(); | 1621 | GSM_Terminate(); |
1622 | } | 1622 | } |
1623 | 1623 | ||
1624 | static void GetRingtonesList(int argc, char *argv[]) | 1624 | static void GetRingtonesList(int argc, char *argv[]) |
1625 | { | 1625 | { |
1626 | GSM_AllRingtonesInfo Info; | 1626 | GSM_AllRingtonesInfo Info; |
1627 | int i; | 1627 | int i; |
1628 | 1628 | ||
1629 | GSM_Init(true); | 1629 | GSM_Init(true); |
1630 | 1630 | ||
1631 | error=Phone->GetRingtonesInfo(&s,&Info); | 1631 | error=Phone->GetRingtonesInfo(&s,&Info); |
1632 | Print_Error(error); | 1632 | Print_Error(error); |
1633 | 1633 | ||
1634 | GSM_Terminate(); | 1634 | GSM_Terminate(); |
1635 | 1635 | ||
1636 | for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name)); | 1636 | for (i=0;i<Info.Number;i++) printmsg("%i. \"%s\"\n",i,DecodeUnicodeConsole(Info.Ringtone[i].Name)); |
1637 | } | 1637 | } |
1638 | 1638 | ||
1639 | static void DialVoice(int argc, char *argv[]) | 1639 | static void DialVoice(int argc, char *argv[]) |
1640 | { | 1640 | { |
1641 | GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence; | 1641 | GSM_CallShowNumber ShowNumber = GSM_CALL_DefaultNumberPresence; |
1642 | 1642 | ||
1643 | if (argc > 3) { | 1643 | if (argc > 3) { |
1644 | if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber; | 1644 | if (mystrncasecmp(argv[3],"show",0)) { ShowNumber = GSM_CALL_ShowNumber; |
1645 | } else if (mystrncasecmp(argv[3],"hide",0)) {ShowNumber = GSM_CALL_HideNumber; | 1645 | } else if (mystrncasecmp(argv[3],"hide",0)) {ShowNumber = GSM_CALL_HideNumber; |
1646 | } else { | 1646 | } else { |
1647 | printmsg("Unknown parameter (\"%s\")\n",argv[3]); | 1647 | printmsg("Unknown parameter (\"%s\")\n",argv[3]); |
1648 | exit(-1); | 1648 | exit(-1); |
1649 | } | 1649 | } |
1650 | } | 1650 | } |
1651 | 1651 | ||
1652 | GSM_Init(true); | 1652 | GSM_Init(true); |
1653 | 1653 | ||
1654 | error=Phone->DialVoice(&s, argv[2], ShowNumber); | 1654 | error=Phone->DialVoice(&s, argv[2], ShowNumber); |
1655 | Print_Error(error); | 1655 | Print_Error(error); |
1656 | 1656 | ||
1657 | GSM_Terminate(); | 1657 | GSM_Terminate(); |
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | static void CancelCall(int argc, char *argv[]) | 1660 | static void CancelCall(int argc, char *argv[]) |
1661 | { | 1661 | { |
1662 | GSM_Init(true); | 1662 | GSM_Init(true); |
1663 | 1663 | ||
1664 | if (argc>2) { | 1664 | if (argc>2) { |
1665 | error=Phone->CancelCall(&s,atoi(argv[2]),false); | 1665 | error=Phone->CancelCall(&s,atoi(argv[2]),false); |
1666 | } else { | 1666 | } else { |
1667 | error=Phone->CancelCall(&s,0,true); | 1667 | error=Phone->CancelCall(&s,0,true); |
1668 | } | 1668 | } |
1669 | Print_Error(error); | 1669 | Print_Error(error); |
1670 | 1670 | ||
1671 | GSM_Terminate(); | 1671 | GSM_Terminate(); |
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | static void AnswerCall(int argc, char *argv[]) | 1674 | static void AnswerCall(int argc, char *argv[]) |
1675 | { | 1675 | { |
1676 | GSM_Init(true); | 1676 | GSM_Init(true); |
1677 | 1677 | ||
1678 | if (argc>2) { | 1678 | if (argc>2) { |
1679 | error=Phone->AnswerCall(&s,atoi(argv[2]),false); | 1679 | error=Phone->AnswerCall(&s,atoi(argv[2]),false); |
1680 | } else { | 1680 | } else { |
1681 | error=Phone->AnswerCall(&s,0,true); | 1681 | error=Phone->AnswerCall(&s,0,true); |
1682 | } | 1682 | } |
1683 | Print_Error(error); | 1683 | Print_Error(error); |
1684 | 1684 | ||
1685 | GSM_Terminate(); | 1685 | GSM_Terminate(); |
1686 | } | 1686 | } |
1687 | 1687 | ||
1688 | static void UnholdCall(int argc, char *argv[]) | 1688 | static void UnholdCall(int argc, char *argv[]) |
1689 | { | 1689 | { |
1690 | GSM_Init(true); | 1690 | GSM_Init(true); |
1691 | 1691 | ||
1692 | error=Phone->UnholdCall(&s,atoi(argv[2])); | 1692 | error=Phone->UnholdCall(&s,atoi(argv[2])); |
1693 | Print_Error(error); | 1693 | Print_Error(error); |
1694 | 1694 | ||
1695 | GSM_Terminate(); | 1695 | GSM_Terminate(); |
1696 | } | 1696 | } |
1697 | 1697 | ||
1698 | static void HoldCall(int argc, char *argv[]) | 1698 | static void HoldCall(int argc, char *argv[]) |
1699 | { | 1699 | { |
1700 | GSM_Init(true); | 1700 | GSM_Init(true); |
1701 | 1701 | ||
1702 | error=Phone->HoldCall(&s,atoi(argv[2])); | 1702 | error=Phone->HoldCall(&s,atoi(argv[2])); |
1703 | Print_Error(error); | 1703 | Print_Error(error); |
1704 | 1704 | ||
1705 | GSM_Terminate(); | 1705 | GSM_Terminate(); |
1706 | } | 1706 | } |
1707 | 1707 | ||
1708 | static void ConferenceCall(int argc, char *argv[]) | 1708 | static void ConferenceCall(int argc, char *argv[]) |
1709 | { | 1709 | { |
1710 | GSM_Init(true); | 1710 | GSM_Init(true); |
1711 | 1711 | ||
1712 | error=Phone->ConferenceCall(&s,atoi(argv[2])); | 1712 | error=Phone->ConferenceCall(&s,atoi(argv[2])); |
1713 | Print_Error(error); | 1713 | Print_Error(error); |
1714 | 1714 | ||
1715 | GSM_Terminate(); | 1715 | GSM_Terminate(); |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | static void SplitCall(int argc, char *argv[]) | 1718 | static void SplitCall(int argc, char *argv[]) |
1719 | { | 1719 | { |
1720 | GSM_Init(true); | 1720 | GSM_Init(true); |
1721 | 1721 | ||
1722 | error=Phone->SplitCall(&s,atoi(argv[2])); | 1722 | error=Phone->SplitCall(&s,atoi(argv[2])); |
1723 | Print_Error(error); | 1723 | Print_Error(error); |
1724 | 1724 | ||
1725 | GSM_Terminate(); | 1725 | GSM_Terminate(); |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | static void SwitchCall(int argc, char *argv[]) | 1728 | static void SwitchCall(int argc, char *argv[]) |
1729 | { | 1729 | { |
1730 | GSM_Init(true); | 1730 | GSM_Init(true); |
1731 | 1731 | ||
1732 | if (argc > 2) { | 1732 | if (argc > 2) { |
1733 | error=Phone->SwitchCall(&s,atoi(argv[2]),false); | 1733 | error=Phone->SwitchCall(&s,atoi(argv[2]),false); |
1734 | } else { | 1734 | } else { |
1735 | error=Phone->SwitchCall(&s,0,true); | 1735 | error=Phone->SwitchCall(&s,0,true); |
1736 | } | 1736 | } |
1737 | Print_Error(error); | 1737 | Print_Error(error); |
1738 | 1738 | ||
1739 | GSM_Terminate(); | 1739 | GSM_Terminate(); |
1740 | } | 1740 | } |
1741 | 1741 | ||
1742 | static void TransferCall(int argc, char *argv[]) | 1742 | static void TransferCall(int argc, char *argv[]) |
1743 | { | 1743 | { |
1744 | GSM_Init(true); | 1744 | GSM_Init(true); |
1745 | 1745 | ||
1746 | if (argc > 2) { | 1746 | if (argc > 2) { |
1747 | error=Phone->TransferCall(&s,atoi(argv[2]),false); | 1747 | error=Phone->TransferCall(&s,atoi(argv[2]),false); |
1748 | } else { | 1748 | } else { |
1749 | error=Phone->TransferCall(&s,0,true); | 1749 | error=Phone->TransferCall(&s,0,true); |
1750 | } | 1750 | } |
1751 | Print_Error(error); | 1751 | Print_Error(error); |
1752 | 1752 | ||
1753 | GSM_Terminate(); | 1753 | GSM_Terminate(); |
1754 | } | 1754 | } |
1755 | 1755 | ||
1756 | static void AddSMSFolder(int argc, char *argv[]) | 1756 | static void AddSMSFolder(int argc, char *argv[]) |
1757 | { | 1757 | { |
1758 | unsigned char buffer[200]; | 1758 | unsigned char buffer[200]; |
1759 | 1759 | ||
1760 | GSM_Init(true); | 1760 | GSM_Init(true); |
1761 | 1761 | ||
1762 | EncodeUnicode(buffer,argv[2],strlen(argv[2])); | 1762 | EncodeUnicode(buffer,argv[2],strlen(argv[2])); |
1763 | error=Phone->AddSMSFolder(&s,buffer); | 1763 | error=Phone->AddSMSFolder(&s,buffer); |
1764 | Print_Error(error); | 1764 | Print_Error(error); |
1765 | 1765 | ||
1766 | GSM_Terminate(); | 1766 | GSM_Terminate(); |
1767 | } | 1767 | } |
1768 | 1768 | ||
1769 | static void Reset(int argc, char *argv[]) | 1769 | static void Reset(int argc, char *argv[]) |
1770 | { | 1770 | { |
1771 | bool hard; | 1771 | bool hard; |
1772 | 1772 | ||
1773 | if (mystrncasecmp(argv[2],"SOFT",0)) { hard=false; | 1773 | if (mystrncasecmp(argv[2],"SOFT",0)) { hard=false; |
1774 | } else if (mystrncasecmp(argv[2],"HARD",0)) {hard=true; | 1774 | } else if (mystrncasecmp(argv[2],"HARD",0)) {hard=true; |
1775 | } else { | 1775 | } else { |
1776 | printmsg("What type of reset do you want (\"%s\") ?\n",argv[2]); | 1776 | printmsg("What type of reset do you want (\"%s\") ?\n",argv[2]); |
1777 | exit(-1); | 1777 | exit(-1); |
1778 | } | 1778 | } |
1779 | 1779 | ||
1780 | GSM_Init(true); | 1780 | GSM_Init(true); |
1781 | 1781 | ||
1782 | error=Phone->Reset(&s, hard); | 1782 | error=Phone->Reset(&s, hard); |
1783 | Print_Error(error); | 1783 | Print_Error(error); |
1784 | 1784 | ||
1785 | GSM_Terminate(); | 1785 | GSM_Terminate(); |
1786 | } | 1786 | } |
1787 | 1787 | ||
1788 | static void PrintCalendar(GSM_CalendarEntry *Note) | 1788 | static void PrintCalendar(GSM_CalendarEntry *Note) |
1789 | { | 1789 | { |
1790 | int i_age = 0,i; | 1790 | int i_age = 0,i; |
1791 | GSM_DateTime Alarm,DateTime; | 1791 | GSM_DateTime Alarm,DateTime; |
1792 | GSM_MemoryEntry entry; | 1792 | GSM_MemoryEntry entry; |
1793 | unsigned char *name; | 1793 | unsigned char *name; |
1794 | 1794 | ||
1795 | bool repeating = false; | 1795 | bool repeating = false; |
1796 | int repeat_dayofweek = -1; | 1796 | int repeat_dayofweek = -1; |
1797 | int repeat_day = -1; | 1797 | int repeat_day = -1; |
1798 | int repeat_weekofmonth = -1; | 1798 | int repeat_weekofmonth = -1; |
1799 | int repeat_month = -1; | 1799 | int repeat_month = -1; |
1800 | int repeat_frequency = -1; | 1800 | int repeat_frequency = -1; |
1801 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | 1801 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; |
1802 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | 1802 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; |
1803 | 1803 | ||
1804 | printmsg("Location : %d\n", Note->Location); | 1804 | printmsg("Location : %d\n", Note->Location); |
1805 | printmsg("Note type : "); | 1805 | printmsg("Note type : "); |
1806 | switch (Note->Type) { | 1806 | switch (Note->Type) { |
1807 | case GSM_CAL_REMINDER : printmsg("Reminder (Date)\n"); break; | 1807 | case GSM_CAL_REMINDER : printmsg("Reminder (Date)\n"); break; |
1808 | case GSM_CAL_CALL : printmsg("Call\n"); break; | 1808 | case GSM_CAL_CALL : printmsg("Call\n"); break; |
1809 | case GSM_CAL_MEETING : printmsg("Meeting\n"); break; | 1809 | case GSM_CAL_MEETING : printmsg("Meeting\n"); break; |
1810 | case GSM_CAL_BIRTHDAY : printmsg("Birthday (Anniversary)\n"); break; | 1810 | case GSM_CAL_BIRTHDAY : printmsg("Birthday (Anniversary)\n"); break; |
1811 | case GSM_CAL_MEMO : printmsg("Memo (Miscellaneous)\n"); break; | 1811 | case GSM_CAL_MEMO : printmsg("Memo (Miscellaneous)\n"); break; |
1812 | case GSM_CAL_TRAVEL : printmsg("Travel\n"); break; | 1812 | case GSM_CAL_TRAVEL : printmsg("Travel\n"); break; |
1813 | case GSM_CAL_VACATION : printmsg("Vacation\n"); break; | 1813 | case GSM_CAL_VACATION : printmsg("Vacation\n"); break; |
1814 | case GSM_CAL_ALARM : printmsg("Alarm\n"); break; | 1814 | case GSM_CAL_ALARM : printmsg("Alarm\n"); break; |
1815 | case GSM_CAL_DAILY_ALARM : printmsg("Daily alarm\n"); break; | 1815 | case GSM_CAL_DAILY_ALARM : printmsg("Daily alarm\n"); break; |
1816 | case GSM_CAL_T_ATHL : printmsg("Training/Athletism\n"); break; | 1816 | case GSM_CAL_T_ATHL : printmsg("Training/Athletism\n"); break; |
1817 | case GSM_CAL_T_BALL : printmsg("Training/Ball Games\n"); break; | 1817 | case GSM_CAL_T_BALL : printmsg("Training/Ball Games\n"); break; |
1818 | case GSM_CAL_T_CYCL : printmsg("Training/Cycling\n"); break; | 1818 | case GSM_CAL_T_CYCL : printmsg("Training/Cycling\n"); break; |
1819 | case GSM_CAL_T_BUDO : printmsg("Training/Budo\n"); break; | 1819 | case GSM_CAL_T_BUDO : printmsg("Training/Budo\n"); break; |
1820 | case GSM_CAL_T_DANC : printmsg("Training/Dance\n"); break; | 1820 | case GSM_CAL_T_DANC : printmsg("Training/Dance\n"); break; |
1821 | case GSM_CAL_T_EXTR : printmsg("Training/Extreme Sports\n"); break; | 1821 | case GSM_CAL_T_EXTR : printmsg("Training/Extreme Sports\n"); break; |
1822 | case GSM_CAL_T_FOOT : printmsg("Training/Football\n"); break; | 1822 | case GSM_CAL_T_FOOT : printmsg("Training/Football\n"); break; |
1823 | case GSM_CAL_T_GOLF : printmsg("Training/Golf\n"); break; | 1823 | case GSM_CAL_T_GOLF : printmsg("Training/Golf\n"); break; |
1824 | case GSM_CAL_T_GYM : printmsg("Training/Gym\n"); break; | 1824 | case GSM_CAL_T_GYM : printmsg("Training/Gym\n"); break; |
1825 | case GSM_CAL_T_HORS : printmsg("Training/Horse Races\n"); break; | 1825 | case GSM_CAL_T_HORS : printmsg("Training/Horse Races\n"); break; |
1826 | case GSM_CAL_T_HOCK : printmsg("Training/Hockey\n"); break; | 1826 | case GSM_CAL_T_HOCK : printmsg("Training/Hockey\n"); break; |
1827 | case GSM_CAL_T_RACE : printmsg("Training/Races\n"); break; | 1827 | case GSM_CAL_T_RACE : printmsg("Training/Races\n"); break; |
1828 | case GSM_CAL_T_RUGB : printmsg("Training/Rugby\n"); break; | 1828 | case GSM_CAL_T_RUGB : printmsg("Training/Rugby\n"); break; |
1829 | case GSM_CAL_T_SAIL : printmsg("Training/Sailing\n"); break; | 1829 | case GSM_CAL_T_SAIL : printmsg("Training/Sailing\n"); break; |
1830 | case GSM_CAL_T_STRE : printmsg("Training/Street Games\n"); break; | 1830 | case GSM_CAL_T_STRE : printmsg("Training/Street Games\n"); break; |
1831 | case GSM_CAL_T_SWIM : printmsg("Training/Swimming\n"); break; | 1831 | case GSM_CAL_T_SWIM : printmsg("Training/Swimming\n"); break; |
1832 | case GSM_CAL_T_TENN : printmsg("Training/Tennis\n"); break; | 1832 | case GSM_CAL_T_TENN : printmsg("Training/Tennis\n"); break; |
1833 | case GSM_CAL_T_TRAV : printmsg("Training/Travels\n"); break; | 1833 | case GSM_CAL_T_TRAV : printmsg("Training/Travels\n"); break; |
1834 | case GSM_CAL_T_WINT : printmsg("Training/Winter Games\n"); break; | 1834 | case GSM_CAL_T_WINT : printmsg("Training/Winter Games\n"); break; |
1835 | default : printmsg("UNKNOWN\n"); | 1835 | default : printmsg("UNKNOWN\n"); |
1836 | } | 1836 | } |
1837 | Alarm.Year = 0; | 1837 | Alarm.Year = 0; |
1838 | 1838 | ||
1839 | repeating = false; | 1839 | repeating = false; |
1840 | repeat_dayofweek = -1; | 1840 | repeat_dayofweek = -1; |
1841 | repeat_day = -1; | 1841 | repeat_day = -1; |
1842 | repeat_weekofmonth = -1; | 1842 | repeat_weekofmonth = -1; |
1843 | repeat_month = -1; | 1843 | repeat_month = -1; |
1844 | repeat_frequency = -1; | 1844 | repeat_frequency = -1; |
1845 | repeat_startdate.Day= 0; | 1845 | repeat_startdate.Day= 0; |
1846 | repeat_stopdate.Day = 0; | 1846 | repeat_stopdate.Day = 0; |
1847 | 1847 | ||
1848 | for (i=0;i<Note->EntriesNum;i++) { | 1848 | for (i=0;i<Note->EntriesNum;i++) { |
1849 | switch (Note->Entries[i].EntryType) { | 1849 | switch (Note->Entries[i].EntryType) { |
1850 | case CAL_START_DATETIME: | 1850 | case CAL_START_DATETIME: |
1851 | printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); | 1851 | printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); |
1852 | memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | 1852 | memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); |
1853 | break; | 1853 | break; |
1854 | case CAL_END_DATETIME: | 1854 | case CAL_END_DATETIME: |
1855 | printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); | 1855 | printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); |
1856 | memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | 1856 | memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); |
1857 | break; | 1857 | break; |
1858 | case CAL_ALARM_DATETIME: | 1858 | case CAL_ALARM_DATETIME: |
1859 | printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); | 1859 | printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); |
1860 | memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | 1860 | memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); |
1861 | break; | 1861 | break; |
1862 | case CAL_SILENT_ALARM_DATETIME: | 1862 | case CAL_SILENT_ALARM_DATETIME: |
1863 | printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); | 1863 | printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); |
1864 | memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | 1864 | memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); |
1865 | break; | 1865 | break; |
1866 | case CAL_RECURRANCE: | 1866 | case CAL_RECURRANCE: |
1867 | printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24, | 1867 | printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24, |
1868 | ((Note->Entries[i].Number/24)>1) ? "s":"" ); | 1868 | ((Note->Entries[i].Number/24)>1) ? "s":"" ); |
1869 | break; | 1869 | break; |
1870 | case CAL_TEXT: | 1870 | case CAL_TEXT: |
1871 | printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | 1871 | printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); |
1872 | break; | 1872 | break; |
1873 | case CAL_LOCATION: | 1873 | case CAL_LOCATION: |
1874 | printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | 1874 | printmsg("Location : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); |
1875 | break; | 1875 | break; |
1876 | case CAL_PHONE: | 1876 | case CAL_PHONE: |
1877 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | 1877 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); |
1878 | break; | 1878 | break; |
1879 | case CAL_PRIVATE: | 1879 | case CAL_PRIVATE: |
1880 | printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); | 1880 | printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); |
1881 | break; | 1881 | break; |
1882 | case CAL_CONTACTID: | 1882 | case CAL_CONTACTID: |
1883 | entry.Location = Note->Entries[i].Number; | 1883 | entry.Location = Note->Entries[i].Number; |
1884 | entry.MemoryType = MEM_ME; | 1884 | entry.MemoryType = MEM_ME; |
1885 | error=Phone->GetMemory(&s, &entry); | 1885 | error=Phone->GetMemory(&s, &entry); |
1886 | if (error == ERR_NONE) { | 1886 | if (error == ERR_NONE) { |
1887 | name = GSM_PhonebookGetEntryName(&entry); | 1887 | name = GSM_PhonebookGetEntryName(&entry); |
1888 | if (name != NULL) { | 1888 | if (name != NULL) { |
1889 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); | 1889 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); |
1890 | } else { | 1890 | } else { |
1891 | printmsg("Contact ID : %d\n",Note->Entries[i].Number); | 1891 | printmsg("Contact ID : %d\n",Note->Entries[i].Number); |
1892 | } | 1892 | } |
1893 | } else { | 1893 | } else { |
1894 | printmsg("Contact ID : %d\n",Note->Entries[i].Number); | 1894 | printmsg("Contact ID : %d\n",Note->Entries[i].Number); |
1895 | } | 1895 | } |
1896 | break; | 1896 | break; |
1897 | case CAL_REPEAT_DAYOFWEEK: | 1897 | case CAL_REPEAT_DAYOFWEEK: |
1898 | repeat_dayofweek = Note->Entries[i].Number; | 1898 | repeat_dayofweek = Note->Entries[i].Number; |
1899 | repeating = true; | 1899 | repeating = true; |
1900 | break; | 1900 | break; |
1901 | case CAL_REPEAT_DAY: | 1901 | case CAL_REPEAT_DAY: |
1902 | repeat_day = Note->Entries[i].Number; | 1902 | repeat_day = Note->Entries[i].Number; |
1903 | repeating = true; | 1903 | repeating = true; |
1904 | break; | 1904 | break; |
1905 | case CAL_REPEAT_WEEKOFMONTH: | 1905 | case CAL_REPEAT_WEEKOFMONTH: |
1906 | repeat_weekofmonth = Note->Entries[i].Number; | 1906 | repeat_weekofmonth = Note->Entries[i].Number; |
1907 | repeating = true; | 1907 | repeating = true; |
1908 | break; | 1908 | break; |
1909 | case CAL_REPEAT_MONTH: | 1909 | case CAL_REPEAT_MONTH: |
1910 | repeat_month = Note->Entries[i].Number; | 1910 | repeat_month = Note->Entries[i].Number; |
1911 | repeating = true; | 1911 | repeating = true; |
1912 | break; | 1912 | break; |
1913 | case CAL_REPEAT_FREQUENCY: | 1913 | case CAL_REPEAT_FREQUENCY: |
1914 | repeat_frequency = Note->Entries[i].Number; | 1914 | repeat_frequency = Note->Entries[i].Number; |
1915 | repeating = true; | 1915 | repeating = true; |
1916 | break; | 1916 | break; |
1917 | case CAL_REPEAT_STARTDATE: | 1917 | case CAL_REPEAT_STARTDATE: |
1918 | repeat_startdate = Note->Entries[i].Date; | 1918 | repeat_startdate = Note->Entries[i].Date; |
1919 | repeating = true; | 1919 | repeating = true; |
1920 | break; | 1920 | break; |
1921 | case CAL_REPEAT_STOPDATE: | 1921 | case CAL_REPEAT_STOPDATE: |
1922 | repeat_stopdate = Note->Entries[i].Date; | 1922 | repeat_stopdate = Note->Entries[i].Date; |
1923 | repeating = true; | 1923 | repeating = true; |
1924 | break; | 1924 | break; |
1925 | } | 1925 | } |
1926 | } | 1926 | } |
1927 | if (repeating) { | 1927 | if (repeating) { |
1928 | printmsg("Repeating : "); | 1928 | printmsg("Repeating : "); |
1929 | if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) { | 1929 | if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) { |
1930 | printmsg("Forever"); | 1930 | printmsg("Forever"); |
1931 | } else if (repeat_startdate.Day == 0) { | 1931 | } else if (repeat_startdate.Day == 0) { |
1932 | printmsg("Till %s", OSDate(repeat_stopdate)); | 1932 | printmsg("Till %s", OSDate(repeat_stopdate)); |
1933 | } else if (repeat_stopdate.Day == 0) { | 1933 | } else if (repeat_stopdate.Day == 0) { |
1934 | printmsg("Since %s", OSDate(repeat_startdate)); | 1934 | printmsg("Since %s", OSDate(repeat_startdate)); |
1935 | } else { | 1935 | } else { |
1936 | printmsg("Since %s till %s", OSDate(repeat_startdate), OSDate(repeat_stopdate)); | 1936 | printmsg("Since %s till %s", OSDate(repeat_startdate), OSDate(repeat_stopdate)); |
1937 | } | 1937 | } |
1938 | if (repeat_frequency != -1) { | 1938 | if (repeat_frequency != -1) { |
1939 | if (repeat_frequency == 1) { | 1939 | if (repeat_frequency == 1) { |
1940 | printmsg (" on each "); | 1940 | printmsg (" on each "); |
1941 | } else { | 1941 | } else { |
1942 | printmsg(" on each %d. ", repeat_frequency); | 1942 | printmsg(" on each %d. ", repeat_frequency); |
1943 | } | 1943 | } |
1944 | if (repeat_dayofweek > 0) { | 1944 | if (repeat_dayofweek > 0) { |
1945 | switch (repeat_dayofweek) { | 1945 | switch (repeat_dayofweek) { |
1946 | case 1 : printmsg("Monday"); break; | 1946 | case 1 : printmsg("Monday"); break; |
1947 | case 2 : printmsg("Tuesday"); break; | 1947 | case 2 : printmsg("Tuesday"); break; |
1948 | case 3 : printmsg("Wednesday"); break; | 1948 | case 3 : printmsg("Wednesday"); break; |
1949 | case 4 : printmsg("Thursday"); break; | 1949 | case 4 : printmsg("Thursday"); break; |
1950 | case 5 : printmsg("Friday"); break; | 1950 | case 5 : printmsg("Friday"); break; |
1951 | case 6 : printmsg("Saturday"); break; | 1951 | case 6 : printmsg("Saturday"); break; |
1952 | case 7 : printmsg("Sunday"); break; | 1952 | case 7 : printmsg("Sunday"); break; |
1953 | default: printmsg("Bad day!"); break; | 1953 | default: printmsg("Bad day!"); break; |
1954 | } | 1954 | } |
1955 | if (repeat_weekofmonth > 0) { | 1955 | if (repeat_weekofmonth > 0) { |
1956 | printmsg(" in %d. week of ", repeat_weekofmonth); | 1956 | printmsg(" in %d. week of ", repeat_weekofmonth); |
1957 | } else { | 1957 | } else { |
1958 | printmsg(" in "); | 1958 | printmsg(" in "); |
1959 | } | 1959 | } |
1960 | if (repeat_month > 0) { | 1960 | if (repeat_month > 0) { |
1961 | switch(repeat_month) { | 1961 | switch(repeat_month) { |
1962 | case 1 : printmsg("January"); break; | 1962 | case 1 : printmsg("January"); break; |
1963 | case 2 : printmsg("February"); break; | 1963 | case 2 : printmsg("February"); break; |
1964 | case 3 : printmsg("March"); break; | 1964 | case 3 : printmsg("March"); break; |
1965 | case 4 : printmsg("April"); break; | 1965 | case 4 : printmsg("April"); break; |
1966 | case 5 : printmsg("May"); break; | 1966 | case 5 : printmsg("May"); break; |
1967 | case 6 : printmsg("June"); break; | 1967 | case 6 : printmsg("June"); break; |
1968 | case 7 : printmsg("July"); break; | 1968 | case 7 : printmsg("July"); break; |
1969 | case 8 : printmsg("August"); break; | 1969 | case 8 : printmsg("August"); break; |
1970 | case 9 : printmsg("September"); break; | 1970 | case 9 : printmsg("September"); break; |
1971 | case 10: printmsg("October"); break; | 1971 | case 10: printmsg("October"); break; |
1972 | case 11: printmsg("November"); break; | 1972 | case 11: printmsg("November"); break; |
1973 | case 12: printmsg("December"); break; | 1973 | case 12: printmsg("December"); break; |
1974 | default: printmsg("Bad month!"); break; | 1974 | default: printmsg("Bad month!"); break; |
1975 | } | 1975 | } |
1976 | } else { | 1976 | } else { |
1977 | printmsg("each month"); | 1977 | printmsg("each month"); |
1978 | } | 1978 | } |
1979 | } else if (repeat_day > 0) { | 1979 | } else if (repeat_day > 0) { |
1980 | printmsg("%d. day of ", repeat_day); | 1980 | printmsg("%d. day of ", repeat_day); |
1981 | if (repeat_month > 0) { | 1981 | if (repeat_month > 0) { |
1982 | switch(repeat_month) { | 1982 | switch(repeat_month) { |
1983 | case 1 : printmsg("January"); break; | 1983 | case 1 : printmsg("January"); break; |
1984 | case 2 : printmsg("February"); break; | 1984 | case 2 : printmsg("February"); break; |
1985 | case 3 : printmsg("March");break; | 1985 | case 3 : printmsg("March");break; |
1986 | case 4 : printmsg("April"); break; | 1986 | case 4 : printmsg("April"); break; |
1987 | case 5 : printmsg("May"); break; | 1987 | case 5 : printmsg("May"); break; |
1988 | case 6 : printmsg("June"); break; | 1988 | case 6 : printmsg("June"); break; |
1989 | case 7 : printmsg("July"); break; | 1989 | case 7 : printmsg("July"); break; |
1990 | case 8 : printmsg("August"); break; | 1990 | case 8 : printmsg("August"); break; |
1991 | case 9 : printmsg("September"); break; | 1991 | case 9 : printmsg("September"); break; |
1992 | case 10: printmsg("October"); break; | 1992 | case 10: printmsg("October"); break; |
1993 | case 11: printmsg("November"); break; | 1993 | case 11: printmsg("November"); break; |
1994 | case 12: printmsg("December"); break; | 1994 | case 12: printmsg("December"); break; |
1995 | default: printmsg("Bad month!");break; | 1995 | default: printmsg("Bad month!");break; |
1996 | } | 1996 | } |
1997 | } else { | 1997 | } else { |
1998 | printmsg("each month"); | 1998 | printmsg("each month"); |
1999 | } | 1999 | } |
2000 | } else { | 2000 | } else { |
2001 | printmsg("day"); | 2001 | printmsg("day"); |
2002 | } | 2002 | } |
2003 | } | 2003 | } |
2004 | printf("\n"); | 2004 | printf("\n"); |
2005 | } | 2005 | } |
2006 | if (Note->Type == GSM_CAL_BIRTHDAY) { | 2006 | if (Note->Type == GSM_CAL_BIRTHDAY) { |
2007 | if (Alarm.Year == 0x00) GSM_GetCurrentDateTime (&Alarm); | 2007 | if (Alarm.Year == 0x00) GSM_GetCurrentDateTime (&Alarm); |
2008 | if (DateTime.Year != 0) { | 2008 | if (DateTime.Year != 0) { |
2009 | i_age = Alarm.Year - DateTime.Year; | 2009 | i_age = Alarm.Year - DateTime.Year; |
2010 | if (DateTime.Month < Alarm.Month) i_age++; | 2010 | if (DateTime.Month < Alarm.Month) i_age++; |
2011 | if (DateTime.Month == Alarm.Month && | 2011 | if (DateTime.Month == Alarm.Month && |
2012 | DateTime.Day < Alarm.Day) { | 2012 | DateTime.Day < Alarm.Day) { |
2013 | i_age++; | 2013 | i_age++; |
2014 | } | 2014 | } |
2015 | printmsg("Age : %d %s\n",i_age, (i_age==1)?"year":"years"); | 2015 | printmsg("Age : %d %s\n",i_age, (i_age==1)?"year":"years"); |
2016 | } | 2016 | } |
2017 | } | 2017 | } |
2018 | printf("\n"); | 2018 | printf("\n"); |
2019 | } | 2019 | } |
2020 | 2020 | ||
2021 | static void GetCalendar(int argc, char *argv[]) | 2021 | static void GetCalendar(int argc, char *argv[]) |
2022 | { | 2022 | { |
2023 | GSM_CalendarEntryNote; | 2023 | GSM_CalendarEntryNote; |
2024 | int start,stop; | 2024 | int start,stop; |
2025 | 2025 | ||
2026 | GetStartStop(&start, &stop, 2, argc, argv); | 2026 | GetStartStop(&start, &stop, 2, argc, argv); |
2027 | 2027 | ||
2028 | GSM_Init(true); | 2028 | GSM_Init(true); |
2029 | 2029 | ||
2030 | for (i=start;i<=stop;i++) { | 2030 | for (i=start;i<=stop;i++) { |
2031 | Note.Location=i; | 2031 | Note.Location=i; |
2032 | error = Phone->GetCalendar(&s, &Note); | 2032 | error = Phone->GetCalendar(&s, &Note); |
2033 | if (error == ERR_EMPTY) continue; | 2033 | if (error == ERR_EMPTY) continue; |
2034 | Print_Error(error); | 2034 | Print_Error(error); |
2035 | PrintCalendar(&Note); | 2035 | PrintCalendar(&Note); |
2036 | } | 2036 | } |
2037 | 2037 | ||
2038 | GSM_Terminate(); | 2038 | GSM_Terminate(); |
2039 | } | 2039 | } |
2040 | 2040 | ||
2041 | static void DeleteCalendar(int argc, char *argv[]) | 2041 | static void DeleteCalendar(int argc, char *argv[]) |
2042 | { | 2042 | { |
2043 | GSM_CalendarEntryNote; | 2043 | GSM_CalendarEntryNote; |
2044 | int start,stop; | 2044 | int start,stop; |
2045 | 2045 | ||
2046 | GetStartStop(&start, &stop, 2, argc, argv); | 2046 | GetStartStop(&start, &stop, 2, argc, argv); |
2047 | 2047 | ||
2048 | GSM_Init(true); | 2048 | GSM_Init(true); |
2049 | 2049 | ||
2050 | for (i=start;i<=stop;i++) { | 2050 | for (i=start;i<=stop;i++) { |
2051 | Note.Location=i; | 2051 | Note.Location=i; |
2052 | error = Phone->DeleteCalendar(&s, &Note); | 2052 | error = Phone->DeleteCalendar(&s, &Note); |
2053 | if (error == ERR_EMPTY) continue; | 2053 | if (error == ERR_EMPTY) continue; |
2054 | Print_Error(error); | 2054 | Print_Error(error); |
2055 | PrintCalendar(&Note); | 2055 | PrintCalendar(&Note); |
2056 | } | 2056 | } |
2057 | 2057 | ||
2058 | GSM_Terminate(); | 2058 | GSM_Terminate(); |
2059 | } | 2059 | } |
2060 | 2060 | ||
2061 | 2061 | ||
2062 | static void GetAllCalendar(int argc, char *argv[]) | 2062 | static void GetAllCalendar(int argc, char *argv[]) |
2063 | { | 2063 | { |
2064 | GSM_CalendarEntryNote; | 2064 | GSM_CalendarEntryNote; |
2065 | bool refresh= true; | 2065 | bool refresh= true; |
2066 | 2066 | ||
2067 | signal(SIGINT, interrupt); | 2067 | signal(SIGINT, interrupt); |
2068 | printmsgerr("Press Ctrl+C to break...\n"); | 2068 | printmsgerr("Press Ctrl+C to break...\n"); |
2069 | 2069 | ||
2070 | GSM_Init(true); | 2070 | GSM_Init(true); |
2071 | 2071 | ||
2072 | while (!gshutdown) { | 2072 | while (!gshutdown) { |
2073 | error=Phone->GetNextCalendar(&s,&Note,refresh); | 2073 | error=Phone->GetNextCalendar(&s,&Note,refresh); |
2074 | if (error == ERR_EMPTY) break; | 2074 | if (error == ERR_EMPTY) break; |
2075 | Print_Error(error); | 2075 | Print_Error(error); |
2076 | PrintCalendar(&Note); | 2076 | PrintCalendar(&Note); |
2077 | refresh=false; | 2077 | refresh=false; |
2078 | } | 2078 | } |
2079 | 2079 | ||
2080 | GSM_Terminate(); | 2080 | GSM_Terminate(); |
2081 | } | 2081 | } |
2082 | 2082 | ||
2083 | static void GetCalendarSettings(int argc, char *argv[]) | 2083 | static void GetCalendarSettings(int argc, char *argv[]) |
2084 | { | 2084 | { |
2085 | GSM_CalendarSettings settings; | 2085 | GSM_CalendarSettings settings; |
2086 | 2086 | ||
2087 | GSM_Init(true); | 2087 | GSM_Init(true); |
2088 | 2088 | ||
2089 | error=Phone->GetCalendarSettings(&s,&settings); | 2089 | error=Phone->GetCalendarSettings(&s,&settings); |
2090 | Print_Error(error); | 2090 | Print_Error(error); |
2091 | 2091 | ||
2092 | if (settings.AutoDelete == 0) { | 2092 | if (settings.AutoDelete == 0) { |
2093 | printmsg("Auto deleting disabled"); | 2093 | printmsg("Auto deleting disabled"); |
2094 | } else { | 2094 | } else { |
2095 | printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete); | 2095 | printmsg("Auto deleting notes after %i day(s)",settings.AutoDelete); |
2096 | } | 2096 | } |
2097 | printmsg("\nWeek start on "); | 2097 | printmsg("\nWeek start on "); |
2098 | switch(settings.StartDay) { | 2098 | switch(settings.StartDay) { |
2099 | case 1: printmsg("Monday"); break; | 2099 | case 1: printmsg("Monday"); break; |
2100 | case 6: printmsg("Saturday"); break; | 2100 | case 6: printmsg("Saturday"); break; |
2101 | case 7: printmsg("Sunday"); break; | 2101 | case 7: printmsg("Sunday"); break; |
2102 | } | 2102 | } |
2103 | printf("\n"); | 2103 | printf("\n"); |
2104 | 2104 | ||
2105 | GSM_Terminate(); | 2105 | GSM_Terminate(); |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | static void GetWAPBookmark(int argc, char *argv[]) | 2108 | static void GetWAPBookmark(int argc, char *argv[]) |
2109 | { | 2109 | { |
2110 | GSM_WAPBookmark bookmark; | 2110 | GSM_WAPBookmark bookmark; |
2111 | int start,stop; | 2111 | int start,stop; |
2112 | 2112 | ||
2113 | GetStartStop(&start, &stop, 2, argc, argv); | 2113 | GetStartStop(&start, &stop, 2, argc, argv); |
2114 | 2114 | ||
2115 | GSM_Init(true); | 2115 | GSM_Init(true); |
2116 | 2116 | ||
2117 | for (i=start;i<=stop;i++) { | 2117 | for (i=start;i<=stop;i++) { |
2118 | bookmark.Location=i; | 2118 | bookmark.Location=i; |
2119 | error=Phone->GetWAPBookmark(&s,&bookmark); | 2119 | error=Phone->GetWAPBookmark(&s,&bookmark); |
2120 | Print_Error(error); | 2120 | Print_Error(error); |
2121 | printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title)); | 2121 | printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(bookmark.Title)); |
2122 | printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address)); | 2122 | printmsg("Address : \"%s\"\n",DecodeUnicodeConsole(bookmark.Address)); |
2123 | } | 2123 | } |
2124 | 2124 | ||
2125 | GSM_Terminate(); | 2125 | GSM_Terminate(); |
2126 | } | 2126 | } |
2127 | 2127 | ||
2128 | static void DeleteWAPBookmark(int argc, char *argv[]) | 2128 | static void DeleteWAPBookmark(int argc, char *argv[]) |
2129 | { | 2129 | { |
2130 | GSM_WAPBookmarkbookmark; | 2130 | GSM_WAPBookmarkbookmark; |
2131 | int start, stop; | 2131 | int start, stop; |
2132 | 2132 | ||
2133 | GetStartStop(&start, &stop, 2, argc, argv); | 2133 | GetStartStop(&start, &stop, 2, argc, argv); |
2134 | 2134 | ||
2135 | GSM_Init(true); | 2135 | GSM_Init(true); |
2136 | 2136 | ||
2137 | for (i=start;i<=stop;i++) { | 2137 | for (i=start;i<=stop;i++) { |
2138 | bookmark.Location=i; | 2138 | bookmark.Location=i; |
2139 | error=Phone->DeleteWAPBookmark(&s, &bookmark); | 2139 | error=Phone->DeleteWAPBookmark(&s, &bookmark); |
2140 | Print_Error(error); | 2140 | Print_Error(error); |
2141 | } | 2141 | } |
2142 | 2142 | ||
2143 | GSM_Terminate(); | 2143 | GSM_Terminate(); |
2144 | } | 2144 | } |
2145 | 2145 | ||
2146 | static void GetGPRSPoint(int argc, char *argv[]) | 2146 | static void GetGPRSPoint(int argc, char *argv[]) |
2147 | { | 2147 | { |
2148 | GSM_GPRSAccessPointpoint; | 2148 | GSM_GPRSAccessPointpoint; |
2149 | int start,stop; | 2149 | int start,stop; |
2150 | 2150 | ||
2151 | GetStartStop(&start, &stop, 2, argc, argv); | 2151 | GetStartStop(&start, &stop, 2, argc, argv); |
2152 | 2152 | ||
2153 | GSM_Init(true); | 2153 | GSM_Init(true); |
2154 | 2154 | ||
2155 | for (i=start;i<=stop;i++) { | 2155 | for (i=start;i<=stop;i++) { |
2156 | point.Location=i; | 2156 | point.Location=i; |
2157 | error=Phone->GetGPRSAccessPoint(&s,&point); | 2157 | error=Phone->GetGPRSAccessPoint(&s,&point); |
2158 | if (error != ERR_EMPTY) { | 2158 | if (error != ERR_EMPTY) { |
2159 | Print_Error(error); | 2159 | Print_Error(error); |
2160 | printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name)); | 2160 | printmsg("%i. \"%s\"",point.Location,DecodeUnicodeConsole(point.Name)); |
2161 | } else { | 2161 | } else { |
2162 | printmsg("%i. Access point %i",point.Location,point.Location); | 2162 | printmsg("%i. Access point %i",point.Location,point.Location); |
2163 | } | 2163 | } |
2164 | if (point.Active) printmsg(" (active)"); | 2164 | if (point.Active) printmsg(" (active)"); |
2165 | if (error != ERR_EMPTY) { | 2165 | if (error != ERR_EMPTY) { |
2166 | printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL)); | 2166 | printmsg("\nAddress : \"%s\"\n\n",DecodeUnicodeConsole(point.URL)); |
2167 | } else { | 2167 | } else { |
2168 | printmsg("\n\n"); | 2168 | printmsg("\n\n"); |
2169 | } | 2169 | } |
2170 | } | 2170 | } |
2171 | 2171 | ||
2172 | GSM_Terminate(); | 2172 | GSM_Terminate(); |
2173 | } | 2173 | } |
2174 | 2174 | ||
2175 | static void GetBitmap(int argc, char *argv[]) | 2175 | static void GetBitmap(int argc, char *argv[]) |
2176 | { | 2176 | { |
2177 | GSM_File File; | 2177 | GSM_File File; |
2178 | GSM_MultiBitmap MultiBitmap; | 2178 | GSM_MultiBitmap MultiBitmap; |
2179 | int location=0; | 2179 | int location=0; |
2180 | GSM_AllRingtonesInfo Info; | 2180 | GSM_AllRingtonesInfo Info; |
2181 | 2181 | ||
2182 | if (mystrncasecmp(argv[2],"STARTUP",0)) { | 2182 | if (mystrncasecmp(argv[2],"STARTUP",0)) { |
2183 | MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; | 2183 | MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; |
2184 | } else if (mystrncasecmp(argv[2],"CALLER",0)) { | 2184 | } else if (mystrncasecmp(argv[2],"CALLER",0)) { |
2185 | MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo; | 2185 | MultiBitmap.Bitmap[0].Type=GSM_CallerGroupLogo; |
2186 | GetStartStop(&location, NULL, 3, argc, argv); | 2186 | GetStartStop(&location, NULL, 3, argc, argv); |
2187 | if (location>5) { | 2187 | if (location>5) { |
2188 | printmsg("Maximal location for caller logo can be 5\n"); | 2188 | printmsg("Maximal location for caller logo can be 5\n"); |
2189 | exit (-1); | 2189 | exit (-1); |
2190 | } | 2190 | } |
2191 | } else if (mystrncasecmp(argv[2],"PICTURE",0)) { | 2191 | } else if (mystrncasecmp(argv[2],"PICTURE",0)) { |
2192 | MultiBitmap.Bitmap[0].Type=GSM_PictureImage; | 2192 | MultiBitmap.Bitmap[0].Type=GSM_PictureImage; |
2193 | GetStartStop(&location, NULL, 3, argc, argv); | 2193 | GetStartStop(&location, NULL, 3, argc, argv); |
2194 | } else if (mystrncasecmp(argv[2],"TEXT",0)) { | 2194 | } else if (mystrncasecmp(argv[2],"TEXT",0)) { |
2195 | MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text; | 2195 | MultiBitmap.Bitmap[0].Type=GSM_WelcomeNote_Text; |
2196 | } else if (mystrncasecmp(argv[2],"DEALER",0)) { | 2196 | } else if (mystrncasecmp(argv[2],"DEALER",0)) { |
2197 | MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text; | 2197 | MultiBitmap.Bitmap[0].Type=GSM_DealerNote_Text; |
2198 | } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { | 2198 | } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { |
2199 | MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo; | 2199 | MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo; |
2200 | } else { | 2200 | } else { |
2201 | printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]); | 2201 | printmsg("What type of logo do you want to get (\"%s\") ?\n",argv[2]); |
2202 | exit(-1); | 2202 | exit(-1); |
2203 | } | 2203 | } |
2204 | MultiBitmap.Bitmap[0].Location=location; | 2204 | MultiBitmap.Bitmap[0].Location=location; |
2205 | 2205 | ||
2206 | GSM_Init(true); | 2206 | GSM_Init(true); |
2207 | 2207 | ||
2208 | error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]); | 2208 | error=Phone->GetBitmap(&s,&MultiBitmap.Bitmap[0]); |
2209 | Print_Error(error); | 2209 | Print_Error(error); |
2210 | 2210 | ||
2211 | MultiBitmap.Number = 1; | 2211 | MultiBitmap.Number = 1; |
2212 | 2212 | ||
2213 | error=ERR_NONE; | 2213 | error=ERR_NONE; |
2214 | switch (MultiBitmap.Bitmap[0].Type) { | 2214 | switch (MultiBitmap.Bitmap[0].Type) { |
2215 | case GSM_CallerGroupLogo: | 2215 | case GSM_CallerGroupLogo: |
2216 | if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); | 2216 | if (!MultiBitmap.Bitmap[0].DefaultBitmap) GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); |
2217 | printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); | 2217 | printmsg("Group name : \"%s\"",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); |
2218 | if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)"); | 2218 | if (MultiBitmap.Bitmap[0].DefaultName) printmsg(" (default)"); |
2219 | printf("\n"); | 2219 | printf("\n"); |
2220 | if (MultiBitmap.Bitmap[0].DefaultRingtone) { | 2220 | if (MultiBitmap.Bitmap[0].DefaultRingtone) { |
2221 | printmsg("Ringtone : default\n"); | 2221 | printmsg("Ringtone : default\n"); |
2222 | } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) { | 2222 | } else if (MultiBitmap.Bitmap[0].FileSystemRingtone) { |
2223 | sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID); | 2223 | sprintf(File.ID_FullName,"%i",MultiBitmap.Bitmap[0].RingtoneID); |
2224 | 2224 | ||
2225 | File.Buffer = NULL; | 2225 | File.Buffer = NULL; |
2226 | File.Used = 0; | 2226 | File.Used = 0; |
2227 | 2227 | ||
2228 | error = ERR_NONE; | 2228 | error = ERR_NONE; |
2229 | // while (error == ERR_NONE) { | 2229 | // while (error == ERR_NONE) { |
2230 | error = Phone->GetFilePart(&s,&File); | 2230 | error = Phone->GetFilePart(&s,&File); |
2231 | // } | 2231 | // } |
2232 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); | 2232 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); |
2233 | error = ERR_NONE; | 2233 | error = ERR_NONE; |
2234 | 2234 | ||
2235 | printmsg("Ringtone : \"%s\" (file with ID %i)\n", | 2235 | printmsg("Ringtone : \"%s\" (file with ID %i)\n", |
2236 | DecodeUnicodeString(File.Name), | 2236 | DecodeUnicodeString(File.Name), |
2237 | MultiBitmap.Bitmap[0].RingtoneID); | 2237 | MultiBitmap.Bitmap[0].RingtoneID); |
2238 | } else { | 2238 | } else { |
2239 | error = Phone->GetRingtonesInfo(&s,&Info); | 2239 | error = Phone->GetRingtonesInfo(&s,&Info); |
2240 | if (error != ERR_NONE) Info.Number = 0; | 2240 | if (error != ERR_NONE) Info.Number = 0; |
2241 | error = ERR_NONE; | 2241 | error = ERR_NONE; |
2242 | 2242 | ||
2243 | printmsg("Ringtone : "); | 2243 | printmsg("Ringtone : "); |
2244 | if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) { | 2244 | if (UnicodeLength(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID))!=0) { |
2245 | printmsg("\"%s\" (ID %i)\n", | 2245 | printmsg("\"%s\" (ID %i)\n", |
2246 | DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)), | 2246 | DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,MultiBitmap.Bitmap[0].RingtoneID)), |
2247 | MultiBitmap.Bitmap[0].RingtoneID); | 2247 | MultiBitmap.Bitmap[0].RingtoneID); |
2248 | } else { | 2248 | } else { |
2249 | printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID); | 2249 | printmsg("ID %i\n",MultiBitmap.Bitmap[0].RingtoneID); |
2250 | } | 2250 | } |
2251 | } | 2251 | } |
2252 | if (MultiBitmap.Bitmap[0].BitmapEnabled) { | 2252 | if (MultiBitmap.Bitmap[0].BitmapEnabled) { |
2253 | printmsg("Bitmap : enabled\n"); | 2253 | printmsg("Bitmap : enabled\n"); |
2254 | } else { | 2254 | } else { |
2255 | printmsg("Bitmap : disabled\n"); | 2255 | printmsg("Bitmap : disabled\n"); |
2256 | } | 2256 | } |
2257 | if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); | 2257 | if (argc>4 && !MultiBitmap.Bitmap[0].DefaultBitmap) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); |
2258 | break; | 2258 | break; |
2259 | case GSM_StartupLogo: | 2259 | case GSM_StartupLogo: |
2260 | GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); | 2260 | GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); |
2261 | if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); | 2261 | if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); |
2262 | break; | 2262 | break; |
2263 | case GSM_OperatorLogo: | 2263 | case GSM_OperatorLogo: |
2264 | if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) { | 2264 | if (strcmp(MultiBitmap.Bitmap[0].NetworkCode,"000 00")!=0) { |
2265 | GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); | 2265 | GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); |
2266 | if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); | 2266 | if (argc>3) error=GSM_SaveBitmapFile(argv[3],&MultiBitmap); |
2267 | } else { | 2267 | } else { |
2268 | printmsg("No operator logo in phone\n"); | 2268 | printmsg("No operator logo in phone\n"); |
2269 | } | 2269 | } |
2270 | break; | 2270 | break; |
2271 | case GSM_PictureImage: | 2271 | case GSM_PictureImage: |
2272 | GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); | 2272 | GSM_PrintBitmap(stdout,&MultiBitmap.Bitmap[0]); |
2273 | printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); | 2273 | printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); |
2274 | printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender)); | 2274 | printmsg("Sender : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Sender)); |
2275 | if (MultiBitmap.Bitmap[0].Name) | 2275 | if (MultiBitmap.Bitmap[0].Name) |
2276 | printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Name)); | 2276 | printmsg("Name : \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Name)); |
2277 | if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); | 2277 | if (argc>4) error=GSM_SaveBitmapFile(argv[4],&MultiBitmap); |
2278 | break; | 2278 | break; |
2279 | case GSM_WelcomeNote_Text: | 2279 | case GSM_WelcomeNote_Text: |
2280 | printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); | 2280 | printmsg("Welcome note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); |
2281 | break; | 2281 | break; |
2282 | case GSM_DealerNote_Text: | 2282 | case GSM_DealerNote_Text: |
2283 | printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); | 2283 | printmsg("Dealer note text is \"%s\"\n",DecodeUnicodeConsole(MultiBitmap.Bitmap[0].Text)); |
2284 | break; | 2284 | break; |
2285 | default: | 2285 | default: |
2286 | break; | 2286 | break; |
2287 | } | 2287 | } |
2288 | Print_Error(error); | 2288 | Print_Error(error); |
2289 | 2289 | ||
2290 | GSM_Terminate(); | 2290 | GSM_Terminate(); |
2291 | } | 2291 | } |
2292 | 2292 | ||
2293 | static void SetBitmap(int argc, char *argv[]) | 2293 | static void SetBitmap(int argc, char *argv[]) |
2294 | { | 2294 | { |
2295 | GSM_Bitmap Bitmap, NewBitmap; | 2295 | GSM_Bitmap Bitmap, NewBitmap; |
2296 | GSM_MultiBitmap MultiBitmap; | 2296 | GSM_MultiBitmap MultiBitmap; |
2297 | GSM_NetworkInfo NetInfo; | 2297 | GSM_NetworkInfo NetInfo; |
2298 | bool init = true; | 2298 | bool init = true; |
2299 | 2299 | ||
2300 | if (mystrncasecmp(argv[2],"STARTUP",0)) { | 2300 | if (mystrncasecmp(argv[2],"STARTUP",0)) { |
2301 | if (argc<4) { | 2301 | if (argc<4) { |
2302 | printmsg("More arguments required\n"); | 2302 | printmsg("More arguments required\n"); |
2303 | exit(-1); | 2303 | exit(-1); |
2304 | } | 2304 | } |
2305 | MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; | 2305 | MultiBitmap.Bitmap[0].Type=GSM_StartupLogo; |
2306 | MultiBitmap.Bitmap[0].Location=1; | 2306 | MultiBitmap.Bitmap[0].Location=1; |
2307 | if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2; | 2307 | if (!strcmp(argv[3],"1")) MultiBitmap.Bitmap[0].Location = 2; |
2308 | if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3; | 2308 | if (!strcmp(argv[3],"2")) MultiBitmap.Bitmap[0].Location = 3; |
2309 | if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4; | 2309 | if (!strcmp(argv[3],"3")) MultiBitmap.Bitmap[0].Location = 4; |
2310 | if (MultiBitmap.Bitmap[0].Location == 1) { | 2310 | if (MultiBitmap.Bitmap[0].Location == 1) { |
2311 | error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); | 2311 | error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); |
2312 | Print_Error(error); | 2312 | Print_Error(error); |
2313 | } | 2313 | } |
2314 | memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); | 2314 | memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); |
2315 | } else if (mystrncasecmp(argv[2],"TEXT",0)) { | 2315 | } else if (mystrncasecmp(argv[2],"TEXT",0)) { |
2316 | if (argc<4) { | 2316 | if (argc<4) { |
2317 | printmsg("More arguments required\n"); | 2317 | printmsg("More arguments required\n"); |
2318 | exit(-1); | 2318 | exit(-1); |
2319 | } | 2319 | } |
2320 | Bitmap.Type=GSM_WelcomeNote_Text; | 2320 | Bitmap.Type=GSM_WelcomeNote_Text; |
2321 | EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); | 2321 | EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); |
2322 | } else if (mystrncasecmp(argv[2],"DEALER",0)) { | 2322 | } else if (mystrncasecmp(argv[2],"DEALER",0)) { |
2323 | if (argc<4) { | 2323 | if (argc<4) { |
2324 | printmsg("More arguments required\n"); | 2324 | printmsg("More arguments required\n"); |
2325 | exit(-1); | 2325 | exit(-1); |
2326 | } | 2326 | } |
2327 | Bitmap.Type=GSM_DealerNote_Text; | 2327 | Bitmap.Type=GSM_DealerNote_Text; |
2328 | EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); | 2328 | EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3])); |
2329 | } else if (mystrncasecmp(argv[2],"CALLER",0)) { | 2329 | } else if (mystrncasecmp(argv[2],"CALLER",0)) { |
2330 | if (argc<4) { | 2330 | if (argc<4) { |
2331 | printmsg("More arguments required\n"); | 2331 | printmsg("More arguments required\n"); |
2332 | exit(-1); | 2332 | exit(-1); |
2333 | } | 2333 | } |
2334 | GetStartStop(&i, NULL, 3, argc, argv); | 2334 | GetStartStop(&i, NULL, 3, argc, argv); |
2335 | if (i>5 && i!=255) { | 2335 | if (i>5 && i!=255) { |
2336 | printmsg("Maximal location for caller logo can be 5\n"); | 2336 | printmsg("Maximal location for caller logo can be 5\n"); |
2337 | exit (-1); | 2337 | exit (-1); |
2338 | } | 2338 | } |
2339 | MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo; | 2339 | MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo; |
2340 | MultiBitmap.Bitmap[0].Location= i; | 2340 | MultiBitmap.Bitmap[0].Location= i; |
2341 | if (argc>4) { | 2341 | if (argc>4) { |
2342 | error=GSM_ReadBitmapFile(argv[4],&MultiBitmap); | 2342 | error=GSM_ReadBitmapFile(argv[4],&MultiBitmap); |
2343 | Print_Error(error); | 2343 | Print_Error(error); |
2344 | } | 2344 | } |
2345 | memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); | 2345 | memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); |
2346 | if (i!=255) { | 2346 | if (i!=255) { |
2347 | GSM_Init(true); | 2347 | GSM_Init(true); |
2348 | init = false; | 2348 | init = false; |
2349 | NewBitmap.Type = GSM_CallerGroupLogo; | 2349 | NewBitmap.Type = GSM_CallerGroupLogo; |
2350 | NewBitmap.Location = i; | 2350 | NewBitmap.Location = i; |
2351 | error=Phone->GetBitmap(&s,&NewBitmap); | 2351 | error=Phone->GetBitmap(&s,&NewBitmap); |
2352 | Print_Error(error); | 2352 | Print_Error(error); |
2353 | Bitmap.RingtoneID = NewBitmap.RingtoneID; | 2353 | Bitmap.RingtoneID = NewBitmap.RingtoneID; |
2354 | Bitmap.DefaultRingtone = NewBitmap.DefaultRingtone; | 2354 | Bitmap.DefaultRingtone = NewBitmap.DefaultRingtone; |
2355 | Bitmap.FileSystemRingtone = false; | 2355 | Bitmap.FileSystemRingtone = false; |
2356 | CopyUnicodeString(Bitmap.Text, NewBitmap.Text); | 2356 | CopyUnicodeString(Bitmap.Text, NewBitmap.Text); |
2357 | Bitmap.DefaultName = NewBitmap.DefaultName; | 2357 | Bitmap.DefaultName = NewBitmap.DefaultName; |
2358 | } | 2358 | } |
2359 | } else if (mystrncasecmp(argv[2],"PICTURE",0)) { | 2359 | } else if (mystrncasecmp(argv[2],"PICTURE",0)) { |
2360 | if (argc<5) { | 2360 | if (argc<5) { |
2361 | printmsg("More arguments required\n"); | 2361 | printmsg("More arguments required\n"); |
2362 | exit(-1); | 2362 | exit(-1); |
2363 | } | 2363 | } |
2364 | MultiBitmap.Bitmap[0].Type = GSM_PictureImage; | 2364 | MultiBitmap.Bitmap[0].Type = GSM_PictureImage; |
2365 | MultiBitmap.Bitmap[0].Location = atoi(argv[4]); | 2365 | MultiBitmap.Bitmap[0].Location = atoi(argv[4]); |
2366 | error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); | 2366 | error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); |
2367 | Print_Error(error); | 2367 | Print_Error(error); |
2368 | memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); | 2368 | memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); |
2369 | Bitmap.Text[0]=0; | 2369 | Bitmap.Text[0]=0; |
2370 | Bitmap.Text[1]=0; | 2370 | Bitmap.Text[1]=0; |
2371 | if (argc == 6) EncodeUnicode(Bitmap.Text,argv[5],strlen(argv[5])); | 2371 | if (argc == 6) EncodeUnicode(Bitmap.Text,argv[5],strlen(argv[5])); |
2372 | Bitmap.Sender[0]=0; | 2372 | Bitmap.Sender[0]=0; |
2373 | Bitmap.Sender[1]=0; | 2373 | Bitmap.Sender[1]=0; |
2374 | } else if (mystrncasecmp(argv[2],"COLOUROPERATOR",0)) { | 2374 | } else if (mystrncasecmp(argv[2],"COLOUROPERATOR",0)) { |
2375 | Bitmap.Type = GSM_ColourOperatorLogo_ID; | 2375 | Bitmap.Type = GSM_ColourOperatorLogo_ID; |
2376 | strcpy(Bitmap.NetworkCode,"000 00"); | 2376 | strcpy(Bitmap.NetworkCode,"000 00"); |
2377 | if (argc > 3) { | 2377 | if (argc > 3) { |
2378 | Bitmap.ID = atoi(argv[3]); | 2378 | Bitmap.ID = atoi(argv[3]); |
2379 | if (argc>4) { | 2379 | if (argc>4) { |
2380 | strncpy(Bitmap.NetworkCode,argv[4],6); | 2380 | strncpy(Bitmap.NetworkCode,argv[4],6); |
2381 | } else { | 2381 | } else { |
2382 | GSM_Init(true); | 2382 | GSM_Init(true); |
2383 | init = false; | 2383 | init = false; |
2384 | error=Phone->GetNetworkInfo(&s,&NetInfo); | 2384 | error=Phone->GetNetworkInfo(&s,&NetInfo); |
2385 | Print_Error(error); | 2385 | Print_Error(error); |
2386 | strcpy(Bitmap.NetworkCode,NetInfo.NetworkCode); | 2386 | strcpy(Bitmap.NetworkCode,NetInfo.NetworkCode); |
2387 | } | 2387 | } |
2388 | } | 2388 | } |
2389 | } else if (mystrncasecmp(argv[2],"COLOURSTARTUP",0)) { | 2389 | } else if (mystrncasecmp(argv[2],"COLOURSTARTUP",0)) { |
2390 | Bitmap.Type = GSM_ColourStartupLogo_ID; | 2390 | Bitmap.Type = GSM_ColourStartupLogo_ID; |
2391 | Bitmap.Location = 0; | 2391 | Bitmap.Location = 0; |
2392 | if (argc > 3) { | 2392 | if (argc > 3) { |
2393 | Bitmap.Location = 1; | 2393 | Bitmap.Location = 1; |
2394 | Bitmap.ID = atoi(argv[3]); | 2394 | Bitmap.ID = atoi(argv[3]); |
2395 | } | 2395 | } |
2396 | } else if (mystrncasecmp(argv[2],"WALLPAPER",0)) { | 2396 | } else if (mystrncasecmp(argv[2],"WALLPAPER",0)) { |
2397 | Bitmap.Type = GSM_ColourWallPaper_ID; | 2397 | Bitmap.Type = GSM_ColourWallPaper_ID; |
2398 | Bitmap.ID = 0; | 2398 | Bitmap.ID = 0; |
2399 | if (argc > 3) Bitmap.ID = atoi(argv[3]); | 2399 | if (argc > 3) Bitmap.ID = atoi(argv[3]); |
2400 | } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { | 2400 | } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { |
2401 | MultiBitmap.Bitmap[0].Type= GSM_OperatorLogo; | 2401 | MultiBitmap.Bitmap[0].Type= GSM_OperatorLogo; |
2402 | MultiBitmap.Bitmap[0].Location = 1; | 2402 | MultiBitmap.Bitmap[0].Location = 1; |
2403 | strcpy(MultiBitmap.Bitmap[0].NetworkCode,"000 00"); | 2403 | strcpy(MultiBitmap.Bitmap[0].NetworkCode,"000 00"); |
2404 | if (argc>3) { | 2404 | if (argc>3) { |
2405 | error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); | 2405 | error=GSM_ReadBitmapFile(argv[3],&MultiBitmap); |
2406 | Print_Error(error); | 2406 | Print_Error(error); |
2407 | if (argc>4) { | 2407 | if (argc>4) { |
2408 | strncpy(MultiBitmap.Bitmap[0].NetworkCode,argv[4],6); | 2408 | strncpy(MultiBitmap.Bitmap[0].NetworkCode,argv[4],6); |
2409 | } else { | 2409 | } else { |
2410 | GSM_Init(true); | 2410 | GSM_Init(true); |
2411 | init = false; | 2411 | init = false; |
2412 | error=Phone->GetNetworkInfo(&s,&NetInfo); | 2412 | error=Phone->GetNetworkInfo(&s,&NetInfo); |
2413 | Print_Error(error); | 2413 | Print_Error(error); |
2414 | strcpy(MultiBitmap.Bitmap[0].NetworkCode,NetInfo.NetworkCode); | 2414 | strcpy(MultiBitmap.Bitmap[0].NetworkCode,NetInfo.NetworkCode); |
2415 | } | 2415 | } |
2416 | } | 2416 | } |
2417 | memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); | 2417 | memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap)); |
2418 | } else { | 2418 | } else { |
2419 | printmsg("What type of logo do you want to set (\"%s\") ?\n",argv[2]); | 2419 | printmsg("What type of logo do you want to set (\"%s\") ?\n",argv[2]); |
2420 | exit(-1); | 2420 | exit(-1); |
2421 | } | 2421 | } |
2422 | 2422 | ||
2423 | if (init) GSM_Init(true); | 2423 | if (init) GSM_Init(true); |
2424 | 2424 | ||
2425 | error=Phone->SetBitmap(&s,&Bitmap); | 2425 | error=Phone->SetBitmap(&s,&Bitmap); |
2426 | Print_Error(error); | 2426 | Print_Error(error); |
2427 | 2427 | ||
2428 | #ifdef GSM_ENABLE_BEEP | 2428 | #ifdef GSM_ENABLE_BEEP |
2429 | GSM_PhoneBeep(); | 2429 | GSM_PhoneBeep(); |
2430 | #endif | 2430 | #endif |
2431 | 2431 | ||
2432 | GSM_Terminate(); | 2432 | GSM_Terminate(); |
2433 | } | 2433 | } |
2434 | 2434 | ||
2435 | static void SetRingtone(int argc, char *argv[]) | 2435 | static void SetRingtone(int argc, char *argv[]) |
2436 | { | 2436 | { |
2437 | GSM_Ringtone ringtone; | 2437 | GSM_Ringtone ringtone; |
2438 | int i,nextlong=0; | 2438 | int i,nextlong=0; |
2439 | 2439 | ||
2440 | ringtone.Format= 0; | 2440 | ringtone.Format= 0; |
2441 | error=GSM_ReadRingtoneFile(argv[2],&ringtone); | 2441 | error=GSM_ReadRingtoneFile(argv[2],&ringtone); |
2442 | Print_Error(error); | 2442 | Print_Error(error); |
2443 | ringtone.Location = 255; | 2443 | ringtone.Location = 255; |
2444 | for (i=3;i<argc;i++) { | 2444 | for (i=3;i<argc;i++) { |
2445 | switch (nextlong) { | 2445 | switch (nextlong) { |
2446 | case 0: | 2446 | case 0: |
2447 | if (mystrncasecmp(argv[i],"-scale",0)) { | 2447 | if (mystrncasecmp(argv[i],"-scale",0)) { |
2448 | ringtone.NoteTone.AllNotesScale = true; | 2448 | ringtone.NoteTone.AllNotesScale = true; |
2449 | break; | 2449 | break; |
2450 | } | 2450 | } |
2451 | if (mystrncasecmp(argv[i],"-location",0)) { | 2451 | if (mystrncasecmp(argv[i],"-location",0)) { |
2452 | nextlong = 1; | 2452 | nextlong = 1; |
2453 | break; | 2453 | break; |
2454 | } | 2454 | } |
2455 | if (mystrncasecmp(argv[i],"-name",0)) { | 2455 | if (mystrncasecmp(argv[i],"-name",0)) { |
2456 | nextlong = 2; | 2456 | nextlong = 2; |
2457 | break; | 2457 | break; |
2458 | } | 2458 | } |
2459 | printmsg("Unknown parameter \"%s\"",argv[i]); | 2459 | printmsg("Unknown parameter \"%s\"",argv[i]); |
2460 | exit(-1); | 2460 | exit(-1); |
2461 | case 1: | 2461 | case 1: |
2462 | ringtone.Location=atoi(argv[i]); | 2462 | ringtone.Location=atoi(argv[i]); |
2463 | nextlong = 0; | 2463 | nextlong = 0; |
2464 | break; | 2464 | break; |
2465 | case 2: | 2465 | case 2: |
2466 | EncodeUnicode(ringtone.Name,argv[i],strlen(argv[i])); | 2466 | EncodeUnicode(ringtone.Name,argv[i],strlen(argv[i])); |
2467 | nextlong = 0; | 2467 | nextlong = 0; |
2468 | break; | 2468 | break; |
2469 | } | 2469 | } |
2470 | } | 2470 | } |
2471 | if (nextlong!=0) { | 2471 | if (nextlong!=0) { |
2472 | printmsg("Parameter missed...\n"); | 2472 | printmsg("Parameter missed...\n"); |
2473 | exit(-1); | 2473 | exit(-1); |
2474 | } | 2474 | } |
2475 | if (ringtone.Location==0) { | 2475 | if (ringtone.Location==0) { |
2476 | printmsg("ERROR: enumerate locations from 1\n"); | 2476 | printmsg("ERROR: enumerate locations from 1\n"); |
2477 | exit (-1); | 2477 | exit (-1); |
2478 | } | 2478 | } |
2479 | 2479 | ||
2480 | GSM_Init(true); | 2480 | GSM_Init(true); |
2481 | error=Phone->SetRingtone(&s, &ringtone, &i); | 2481 | error=Phone->SetRingtone(&s, &ringtone, &i); |
2482 | Print_Error(error); | 2482 | Print_Error(error); |
2483 | #ifdef GSM_ENABLE_BEEP | 2483 | #ifdef GSM_ENABLE_BEEP |
2484 | GSM_PhoneBeep(); | 2484 | GSM_PhoneBeep(); |
2485 | #endif | 2485 | #endif |
2486 | GSM_Terminate(); | 2486 | GSM_Terminate(); |
2487 | } | 2487 | } |
2488 | 2488 | ||
2489 | static void DisplaySMSFrame(GSM_SMSMessage *SMS) | 2489 | static void DisplaySMSFrame(GSM_SMSMessage *SMS) |
2490 | { | 2490 | { |
2491 | GSM_Error error; | 2491 | GSM_Error error; |
2492 | int i, length, current = 0; | 2492 | int i, length, current = 0; |
2493 | unsigned char req[1000], buffer[1000], hexreq[1000]; | 2493 | unsigned char req[1000], buffer[1000], hexreq[1000]; |
2494 | #ifdef OSCAR | 2494 | #ifdef OSCAR |
2495 | unsigned char hexmsg[1000], hexudh[1000]; | 2495 | unsigned char hexmsg[1000], hexudh[1000]; |
2496 | #endif | 2496 | #endif |
2497 | error=PHONE_EncodeSMSFrame(&s,SMS,buffer,PHONE_SMSSubmit,&length,true); | 2497 | error=PHONE_EncodeSMSFrame(&s,SMS,buffer,PHONE_SMSSubmit,&length,true); |
2498 | if (error != ERR_NONE) { | 2498 | if (error != ERR_NONE) { |
2499 | printmsg("Error\n"); | 2499 | printmsg("Error\n"); |
2500 | exit(-1); | 2500 | exit(-1); |
2501 | } | 2501 | } |
2502 | length = length - PHONE_SMSSubmit.Text; | 2502 | length = length - PHONE_SMSSubmit.Text; |
2503 | #ifdef OSCAR | 2503 | #ifdef OSCAR |
2504 | for(i=SMS->UDH.Length;i<length;i++) { | 2504 | for(i=SMS->UDH.Length;i<length;i++) { |
2505 | req[i-SMS->UDH.Length]=buffer[PHONE_SMSSubmit.Text+i]; | 2505 | req[i-SMS->UDH.Length]=buffer[PHONE_SMSSubmit.Text+i]; |
2506 | } | 2506 | } |
2507 | EncodeHexBin(hexmsg, req, length-SMS->UDH.Length); | 2507 | EncodeHexBin(hexmsg, req, length-SMS->UDH.Length); |
2508 | 2508 | ||
2509 | for(i=0;i<SMS->UDH.Length;i++) { | 2509 | for(i=0;i<SMS->UDH.Length;i++) { |
2510 | req[i]=buffer[PHONE_SMSSubmit.Text+i]; | 2510 | req[i]=buffer[PHONE_SMSSubmit.Text+i]; |
2511 | } | 2511 | } |
2512 | EncodeHexBin(hexudh, req, SMS->UDH.Length); | 2512 | EncodeHexBin(hexudh, req, SMS->UDH.Length); |
2513 | 2513 | ||
2514 | printf("msg:%s nb:%i udh:%s\n", | 2514 | printf("msg:%s nb:%i udh:%s\n", |
2515 | hexmsg, | 2515 | hexmsg, |
2516 | (buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8, | 2516 | (buffer[PHONE_SMSSubmit.TPUDL]-SMS->UDH.Length)*8, |
2517 | hexudh); | 2517 | hexudh); |
2518 | #else | 2518 | #else |
2519 | for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) { | 2519 | for (i=0;i<buffer[PHONE_SMSSubmit.SMSCNumber]+1;i++) { |
2520 | req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i]; | 2520 | req[current++]=buffer[PHONE_SMSSubmit.SMSCNumber+i]; |
2521 | } | 2521 | } |
2522 | req[current++]=buffer[PHONE_SMSSubmit.firstbyte]; | 2522 | req[current++]=buffer[PHONE_SMSSubmit.firstbyte]; |
2523 | req[current++]=buffer[PHONE_SMSSubmit.TPMR]; | 2523 | req[current++]=buffer[PHONE_SMSSubmit.TPMR]; |
2524 | for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) { | 2524 | for (i=0;i<((buffer[PHONE_SMSSubmit.Number]+1)/2+1)+1;i++) { |
2525 | req[current++]=buffer[PHONE_SMSSubmit.Number+i]; | 2525 | req[current++]=buffer[PHONE_SMSSubmit.Number+i]; |
2526 | } | 2526 | } |
2527 | req[current++]=buffer[PHONE_SMSSubmit.TPPID]; | 2527 | req[current++]=buffer[PHONE_SMSSubmit.TPPID]; |
2528 | req[current++]=buffer[PHONE_SMSSubmit.TPDCS]; | 2528 | req[current++]=buffer[PHONE_SMSSubmit.TPDCS]; |
2529 | req[current++]=buffer[PHONE_SMSSubmit.TPVP]; | 2529 | req[current++]=buffer[PHONE_SMSSubmit.TPVP]; |
2530 | req[current++]=buffer[PHONE_SMSSubmit.TPUDL]; | 2530 | req[current++]=buffer[PHONE_SMSSubmit.TPUDL]; |
2531 | for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i]; | 2531 | for(i=0;i<length;i++) req[current++]=buffer[PHONE_SMSSubmit.Text+i]; |
2532 | EncodeHexBin(hexreq, req, current); | 2532 | EncodeHexBin(hexreq, req, current); |
2533 | printmsg("%s\n\n",hexreq); | 2533 | printmsg("%s\n\n",hexreq); |
2534 | #endif | 2534 | #endif |
2535 | } | 2535 | } |
2536 | 2536 | ||
2537 | #define SEND_SAVE_SMS_BUFFER_SIZE 10000 | 2537 | #define SEND_SAVE_SMS_BUFFER_SIZE 10000 |
2538 | 2538 | ||
2539 | static GSM_Error SMSStatus; | 2539 | static GSM_Error SMSStatus; |
2540 | 2540 | ||
2541 | static void SendSMSStatus (char *Device, int status, int MessageReference) | 2541 | static void SendSMSStatus (char *Device, int status, int MessageReference) |
2542 | { | 2542 | { |
2543 | dbgprintf("Sent SMS on device: \"%s\"\n",Device); | 2543 | dbgprintf("Sent SMS on device: \"%s\"\n",Device); |
2544 | if (status==0) { | 2544 | if (status==0) { |
2545 | printmsg("..OK"); | 2545 | printmsg("..OK"); |
2546 | SMSStatus = ERR_NONE; | 2546 | SMSStatus = ERR_NONE; |
2547 | } else { | 2547 | } else { |
2548 | printmsg("..error %i",status); | 2548 | printmsg("..error %i",status); |
2549 | SMSStatus = ERR_UNKNOWN; | 2549 | SMSStatus = ERR_UNKNOWN; |
2550 | } | 2550 | } |
2551 | printmsg(", message reference=%d\n",MessageReference); | 2551 | printmsg(", message reference=%d\n",MessageReference); |
2552 | } | 2552 | } |
2553 | 2553 | ||
2554 | static void SendSaveDisplaySMS(int argc, char *argv[]) | 2554 | static void SendSaveDisplaySMS(int argc, char *argv[]) |
2555 | { | 2555 | { |
2556 | #ifdef GSM_ENABLE_BACKUP | 2556 | #ifdef GSM_ENABLE_BACKUP |
2557 | GSM_Backup Backup; | 2557 | GSM_Backup Backup; |
2558 | #endif | 2558 | #endif |
2559 | int i,j,z,FramesNum = 0; | 2559 | int i,j,z,FramesNum = 0; |
2560 | int Protected = 0; | 2560 | int Protected = 0; |
2561 | GSM_SMSFolders folders; | 2561 | GSM_SMSFolders folders; |
2562 | GSM_MultiSMSMessage sms; | 2562 | GSM_MultiSMSMessage sms; |
2563 | GSM_Ringtone ringtone[MAX_MULTI_SMS]; | 2563 | GSM_Ringtone ringtone[MAX_MULTI_SMS]; |
2564 | GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2; | 2564 | GSM_MultiBitmap bitmap[MAX_MULTI_SMS],bitmap2; |
2565 | GSM_MultiPartSMSInfo SMSInfo; | 2565 | GSM_MultiPartSMSInfo SMSInfo; |
2566 | GSM_NetworkInfo NetInfo; | 2566 | GSM_NetworkInfo NetInfo; |
2567 | GSM_MMSIndicator MMSInfo; | 2567 | GSM_MMSIndicator MMSInfo; |
2568 | FILE *ReplaceFile,*f; | 2568 | FILE *ReplaceFile,*f; |
2569 | char ReplaceBuffer2[200],ReplaceBuffer[200]; | 2569 | char ReplaceBuffer2[200],ReplaceBuffer[200]; |
2570 | char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1]; | 2570 | char InputBuffer[SEND_SAVE_SMS_BUFFER_SIZE/2+1]; |
2571 | char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE]; | 2571 | char Buffer [MAX_MULTI_SMS][SEND_SAVE_SMS_BUFFER_SIZE]; |
2572 | char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2]; | 2572 | char Sender [(GSM_MAX_NUMBER_LENGTH+1)*2]; |
2573 | char Name [(GSM_MAX_NUMBER_LENGTH+1)*2]; | 2573 | char Name [(GSM_MAX_NUMBER_LENGTH+1)*2]; |
2574 | char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2]; | 2574 | char SMSC [(GSM_MAX_NUMBER_LENGTH+1)*2]; |
2575 | int startarg = 0; | 2575 | int startarg = 0; |
2576 | int chars_read = 0; | 2576 | int chars_read = 0; |
2577 | int nextlong = 0; | 2577 | int nextlong = 0; |
2578 | bool ReplyViaSameSMSC = false; | 2578 | bool ReplyViaSameSMSC = false; |
2579 | int SMSCSet = 1; | 2579 | int SMSCSet = 1; |
2580 | int MaxSMS = -1; | 2580 | int MaxSMS = -1; |
2581 | bool EMS16Bit = false; | 2581 | bool EMS16Bit = false; |
2582 | bool SendSaved = false; | 2582 | bool SendSaved = false; |
2583 | 2583 | ||
2584 | /* Parameters required only during saving */ | 2584 | /* Parameters required only during saving */ |
2585 | int Folder = 1; /*Inbox by default */ | 2585 | int Folder = 1; /*Inbox by default */ |
2586 | GSM_SMS_State State = SMS_Sent; | 2586 | GSM_SMS_State State = SMS_Sent; |
2587 | 2587 | ||
2588 | /* Required only during sending */ | 2588 | /* Required only during sending */ |
2589 | GSM_SMSValidity Validity; | 2589 | GSM_SMSValidity Validity; |
2590 | GSM_SMSC PhoneSMSC; | 2590 | GSM_SMSC PhoneSMSC; |
2591 | bool DeliveryReport = false; | 2591 | bool DeliveryReport = false; |
2592 | 2592 | ||
2593 | ReplaceBuffer[0] = 0; | 2593 | ReplaceBuffer[0] = 0; |
2594 | ReplaceBuffer[1] = 0; | 2594 | ReplaceBuffer[1] = 0; |
2595 | GSM_ClearMultiPartSMSInfo(&SMSInfo); | 2595 | GSM_ClearMultiPartSMSInfo(&SMSInfo); |
2596 | SMSInfo.ReplaceMessage = 0; | 2596 | SMSInfo.ReplaceMessage = 0; |
2597 | SMSInfo.EntriesNum = 1; | 2597 | SMSInfo.EntriesNum = 1; |
2598 | 2598 | ||
2599 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2599 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2600 | EncodeUnicode(Sender,"Gammu",5); | 2600 | EncodeUnicode(Sender,"Gammu",5); |
2601 | Name[0] = 0; | 2601 | Name[0] = 0; |
2602 | Name[1] = 0; | 2602 | Name[1] = 0; |
2603 | startarg = 0; | 2603 | startarg = 0; |
2604 | } else { | 2604 | } else { |
2605 | EncodeUnicode(Sender,argv[3],strlen(argv[3])); | 2605 | EncodeUnicode(Sender,argv[3],strlen(argv[3])); |
2606 | startarg = 1; | 2606 | startarg = 1; |
2607 | Validity.Format = 0; | 2607 | Validity.Format = 0; |
2608 | } | 2608 | } |
2609 | if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) { | 2609 | if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) { |
2610 | startarg=startarg+2; | 2610 | startarg=startarg+2; |
2611 | EncodeUnicode(SMSC,"1234",4); | 2611 | EncodeUnicode(SMSC,"1234",4); |
2612 | SMSCSet= 0; | 2612 | SMSCSet= 0; |
2613 | } | 2613 | } |
2614 | 2614 | ||
2615 | if (mystrncasecmp(argv[2],"TEXT",0)) { | 2615 | if (mystrncasecmp(argv[2],"TEXT",0)) { |
2616 | chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin); | 2616 | chars_read = fread(InputBuffer, 1, SEND_SAVE_SMS_BUFFER_SIZE/2, stdin); |
2617 | if (chars_read == 0) printmsg("Warning: 0 chars read !\n"); | 2617 | if (chars_read == 0) printmsg("Warning: 0 chars read !\n"); |
2618 | InputBuffer[chars_read] = 0x00; | 2618 | InputBuffer[chars_read] = 0x00; |
2619 | InputBuffer[chars_read+1] = 0x00; | 2619 | InputBuffer[chars_read+1] = 0x00; |
2620 | EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer)); | 2620 | EncodeUnicode(Buffer[0],InputBuffer,strlen(InputBuffer)); |
2621 | SMSInfo.Entries[0].Buffer = Buffer[0]; | 2621 | SMSInfo.Entries[0].Buffer = Buffer[0]; |
2622 | SMSInfo.Entries[0].ID = SMS_Text; | 2622 | SMSInfo.Entries[0].ID = SMS_Text; |
2623 | SMSInfo.UnicodeCoding = false; | 2623 | SMSInfo.UnicodeCoding = false; |
2624 | startarg += 3; | 2624 | startarg += 3; |
2625 | } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { | 2625 | } else if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { |
2626 | SMSInfo.UnicodeCoding = false; | 2626 | SMSInfo.UnicodeCoding = false; |
2627 | SMSInfo.EntriesNum = 1; | 2627 | SMSInfo.EntriesNum = 1; |
2628 | Buffer[0][0] = 0x00; | 2628 | Buffer[0][0] = 0x00; |
2629 | Buffer[0][1] = 0x00; | 2629 | Buffer[0][1] = 0x00; |
2630 | SMSInfo.Entries[0].Buffer = Buffer[0]; | 2630 | SMSInfo.Entries[0].Buffer = Buffer[0]; |
2631 | SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName; | 2631 | SMSInfo.Entries[0].ID = SMS_AlcatelSMSTemplateName; |
2632 | startarg += 3; | 2632 | startarg += 3; |
2633 | } else if (mystrncasecmp(argv[2],"EMS",0)) { | 2633 | } else if (mystrncasecmp(argv[2],"EMS",0)) { |
2634 | SMSInfo.UnicodeCoding = false; | 2634 | SMSInfo.UnicodeCoding = false; |
2635 | SMSInfo.EntriesNum = 0; | 2635 | SMSInfo.EntriesNum = 0; |
2636 | startarg += 3; | 2636 | startarg += 3; |
2637 | } else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) { | 2637 | } else if (mystrncasecmp(argv[2],"MMSINDICATOR",0)) { |
2638 | if (argc<6+startarg) { | 2638 | if (argc<6+startarg) { |
2639 | printmsg("Where are parameters ?\n"); | 2639 | printmsg("Where are parameters ?\n"); |
2640 | exit(-1); | 2640 | exit(-1); |
2641 | } | 2641 | } |
2642 | SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong; | 2642 | SMSInfo.Entries[0].ID = SMS_MMSIndicatorLong; |
2643 | SMSInfo.Entries[0].MMSIndicator = &MMSInfo; | 2643 | SMSInfo.Entries[0].MMSIndicator = &MMSInfo; |
2644 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2644 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2645 | EncodeUnicode(Sender,"MMS Info",8); | 2645 | EncodeUnicode(Sender,"MMS Info",8); |
2646 | } | 2646 | } |
2647 | strcpy(MMSInfo.Address,argv[3+startarg]); | 2647 | strcpy(MMSInfo.Address,argv[3+startarg]); |
2648 | strcpy(MMSInfo.Title,argv[4+startarg]); | 2648 | strcpy(MMSInfo.Title,argv[4+startarg]); |
2649 | strcpy(MMSInfo.Sender,argv[5+startarg]); | 2649 | strcpy(MMSInfo.Sender,argv[5+startarg]); |
2650 | startarg += 6; | 2650 | startarg += 6; |
2651 | } else if (mystrncasecmp(argv[2],"WAPINDICATOR",0)) { | 2651 | } else if (mystrncasecmp(argv[2],"WAPINDICATOR",0)) { |
2652 | if (argc<5+startarg) { | 2652 | if (argc<5+startarg) { |
2653 | printmsg("Where are parameters ?\n"); | 2653 | printmsg("Where are parameters ?\n"); |
2654 | exit(-1); | 2654 | exit(-1); |
2655 | } | 2655 | } |
2656 | SMSInfo.Entries[0].ID = SMS_WAPIndicatorLong; | 2656 | SMSInfo.Entries[0].ID = SMS_WAPIndicatorLong; |
2657 | SMSInfo.Entries[0].MMSIndicator = &MMSInfo; | 2657 | SMSInfo.Entries[0].MMSIndicator = &MMSInfo; |
2658 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2658 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2659 | EncodeUnicode(Sender,"WAP Info",8); | 2659 | EncodeUnicode(Sender,"WAP Info",8); |
2660 | } | 2660 | } |
2661 | strcpy(MMSInfo.Address,argv[3+startarg]); | 2661 | strcpy(MMSInfo.Address,argv[3+startarg]); |
2662 | strcpy(MMSInfo.Title,argv[4+startarg]); | 2662 | strcpy(MMSInfo.Title,argv[4+startarg]); |
2663 | startarg += 5; | 2663 | startarg += 5; |
2664 | } else if (mystrncasecmp(argv[2],"RINGTONE",0)) { | 2664 | } else if (mystrncasecmp(argv[2],"RINGTONE",0)) { |
2665 | if (argc<4+startarg) { | 2665 | if (argc<4+startarg) { |
2666 | printmsg("Where is ringtone filename ?\n"); | 2666 | printmsg("Where is ringtone filename ?\n"); |
2667 | exit(-1); | 2667 | exit(-1); |
2668 | } | 2668 | } |
2669 | ringtone[0].Format=RING_NOTETONE; | 2669 | ringtone[0].Format=RING_NOTETONE; |
2670 | error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]); | 2670 | error=GSM_ReadRingtoneFile(argv[3+startarg],&ringtone[0]); |
2671 | Print_Error(error); | 2671 | Print_Error(error); |
2672 | SMSInfo.Entries[0].ID = SMS_NokiaRingtone; | 2672 | SMSInfo.Entries[0].ID = SMS_NokiaRingtone; |
2673 | SMSInfo.Entries[0].Ringtone = &ringtone[0]; | 2673 | SMSInfo.Entries[0].Ringtone = &ringtone[0]; |
2674 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2674 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2675 | CopyUnicodeString(Sender, ringtone[0].Name); | 2675 | CopyUnicodeString(Sender, ringtone[0].Name); |
2676 | EncodeUnicode(Name,"Ringtone ",9); | 2676 | EncodeUnicode(Name,"Ringtone ",9); |
2677 | CopyUnicodeString(Name+9*2, ringtone[0].Name); | 2677 | CopyUnicodeString(Name+9*2, ringtone[0].Name); |
2678 | } | 2678 | } |
2679 | startarg += 4; | 2679 | startarg += 4; |
2680 | } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { | 2680 | } else if (mystrncasecmp(argv[2],"OPERATOR",0)) { |
2681 | if (argc<4+startarg) { | 2681 | if (argc<4+startarg) { |
2682 | printmsg("Where is logo filename ?\n"); | 2682 | printmsg("Where is logo filename ?\n"); |
2683 | exit(-1); | 2683 | exit(-1); |
2684 | } | 2684 | } |
2685 | bitmap[0].Bitmap[0].Type=GSM_OperatorLogo; | 2685 | bitmap[0].Bitmap[0].Type=GSM_OperatorLogo; |
2686 | error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); | 2686 | error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); |
2687 | Print_Error(error); | 2687 | Print_Error(error); |
2688 | strcpy(bitmap[0].Bitmap[0].NetworkCode,"000 00"); | 2688 | strcpy(bitmap[0].Bitmap[0].NetworkCode,"000 00"); |
2689 | SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogo; | 2689 | SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogo; |
2690 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; | 2690 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; |
2691 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2691 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2692 | EncodeUnicode(Sender, "OpLogo",6); | 2692 | EncodeUnicode(Sender, "OpLogo",6); |
2693 | EncodeUnicode(Name,"OpLogo ",7); | 2693 | EncodeUnicode(Name,"OpLogo ",7); |
2694 | } | 2694 | } |
2695 | startarg += 4; | 2695 | startarg += 4; |
2696 | } else if (mystrncasecmp(argv[2],"CALLER",0)) { | 2696 | } else if (mystrncasecmp(argv[2],"CALLER",0)) { |
2697 | if (argc<4+startarg) { | 2697 | if (argc<4+startarg) { |
2698 | printmsg("Where is logo filename ?\n"); | 2698 | printmsg("Where is logo filename ?\n"); |
2699 | exit(-1); | 2699 | exit(-1); |
2700 | } | 2700 | } |
2701 | bitmap[0].Bitmap[0].Type=GSM_CallerGroupLogo; | 2701 | bitmap[0].Bitmap[0].Type=GSM_CallerGroupLogo; |
2702 | error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); | 2702 | error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); |
2703 | Print_Error(error); | 2703 | Print_Error(error); |
2704 | SMSInfo.Entries[0].ID = SMS_NokiaCallerLogo; | 2704 | SMSInfo.Entries[0].ID = SMS_NokiaCallerLogo; |
2705 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; | 2705 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; |
2706 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2706 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2707 | EncodeUnicode(Sender, "Caller",6); | 2707 | EncodeUnicode(Sender, "Caller",6); |
2708 | } | 2708 | } |
2709 | startarg += 4; | 2709 | startarg += 4; |
2710 | } else if (mystrncasecmp(argv[2],"ANIMATION",0)) { | 2710 | } else if (mystrncasecmp(argv[2],"ANIMATION",0)) { |
2711 | SMSInfo.UnicodeCoding = false; | 2711 | SMSInfo.UnicodeCoding = false; |
2712 | SMSInfo.EntriesNum = 1; | 2712 | SMSInfo.EntriesNum = 1; |
2713 | if (argc<4+startarg) { | 2713 | if (argc<4+startarg) { |
2714 | printmsg("Where is number of frames ?\n"); | 2714 | printmsg("Where is number of frames ?\n"); |
2715 | exit(-1); | 2715 | exit(-1); |
2716 | } | 2716 | } |
2717 | bitmap[0].Number = 0; | 2717 | bitmap[0].Number = 0; |
2718 | i = 1; | 2718 | i = 1; |
2719 | while (1) { | 2719 | while (1) { |
2720 | bitmap2.Bitmap[0].Type=GSM_StartupLogo; | 2720 | bitmap2.Bitmap[0].Type=GSM_StartupLogo; |
2721 | error=GSM_ReadBitmapFile(argv[3+startarg+i],&bitmap2); | 2721 | error=GSM_ReadBitmapFile(argv[3+startarg+i],&bitmap2); |
2722 | Print_Error(error); | 2722 | Print_Error(error); |
2723 | for (j=0;j<bitmap2.Number;j++) { | 2723 | for (j=0;j<bitmap2.Number;j++) { |
2724 | if (bitmap[0].Number == atoi(argv[3+startarg])) break; | 2724 | if (bitmap[0].Number == atoi(argv[3+startarg])) break; |
2725 | memcpy(&bitmap[0].Bitmap[bitmap[0].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap)); | 2725 | memcpy(&bitmap[0].Bitmap[bitmap[0].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap)); |
2726 | bitmap[0].Number++; | 2726 | bitmap[0].Number++; |
2727 | } | 2727 | } |
2728 | if (bitmap[0].Number == atoi(argv[3+startarg])) break; | 2728 | if (bitmap[0].Number == atoi(argv[3+startarg])) break; |
2729 | i++; | 2729 | i++; |
2730 | } | 2730 | } |
2731 | SMSInfo.Entries[0].ID = SMS_AlcatelMonoAnimationLong; | 2731 | SMSInfo.Entries[0].ID = SMS_AlcatelMonoAnimationLong; |
2732 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; | 2732 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; |
2733 | bitmap[0].Bitmap[0].Text[0]= 0; | 2733 | bitmap[0].Bitmap[0].Text[0]= 0; |
2734 | bitmap[0].Bitmap[0].Text[1]= 0; | 2734 | bitmap[0].Bitmap[0].Text[1]= 0; |
2735 | startarg += 4 + atoi(argv[3+startarg]); | 2735 | startarg += 4 + atoi(argv[3+startarg]); |
2736 | } else if (mystrncasecmp(argv[2],"PICTURE",0)) { | 2736 | } else if (mystrncasecmp(argv[2],"PICTURE",0)) { |
2737 | if (argc<4+startarg) { | 2737 | if (argc<4+startarg) { |
2738 | printmsg("Where is logo filename ?\n"); | 2738 | printmsg("Where is logo filename ?\n"); |
2739 | exit(-1); | 2739 | exit(-1); |
2740 | } | 2740 | } |
2741 | bitmap[0].Bitmap[0].Type=GSM_PictureImage; | 2741 | bitmap[0].Bitmap[0].Type=GSM_PictureImage; |
2742 | error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); | 2742 | error=GSM_ReadBitmapFile(argv[3+startarg],&bitmap[0]); |
2743 | printmsg("File \"%s\"\n",argv[3+startarg]); | 2743 | printmsg("File \"%s\"\n",argv[3+startarg]); |
2744 | Print_Error(error); | 2744 | Print_Error(error); |
2745 | SMSInfo.Entries[0].ID = SMS_NokiaPictureImageLong; | 2745 | SMSInfo.Entries[0].ID = SMS_NokiaPictureImageLong; |
2746 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; | 2746 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; |
2747 | SMSInfo.UnicodeCoding = false; | 2747 | SMSInfo.UnicodeCoding = false; |
2748 | bitmap[0].Bitmap[0].Text[0]= 0; | 2748 | bitmap[0].Bitmap[0].Text[0]= 0; |
2749 | bitmap[0].Bitmap[0].Text[1]= 0; | 2749 | bitmap[0].Bitmap[0].Text[1]= 0; |
2750 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2750 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2751 | EncodeUnicode(Sender, "Picture",7); | 2751 | EncodeUnicode(Sender, "Picture",7); |
2752 | EncodeUnicode(Name,"Picture Image",13); | 2752 | EncodeUnicode(Name,"Picture Image",13); |
2753 | } | 2753 | } |
2754 | startarg += 4; | 2754 | startarg += 4; |
2755 | #ifdef GSM_ENABLE_BACKUP | 2755 | #ifdef GSM_ENABLE_BACKUP |
2756 | } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { | 2756 | } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { |
2757 | if (argc<5+startarg) { | 2757 | if (argc<5+startarg) { |
2758 | printmsg("Where is backup filename and location ?\n"); | 2758 | printmsg("Where is backup filename and location ?\n"); |
2759 | exit(-1); | 2759 | exit(-1); |
2760 | } | 2760 | } |
2761 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); | 2761 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); |
2762 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 2762 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
2763 | i = 0; | 2763 | i = 0; |
2764 | while (Backup.WAPBookmark[i]!=NULL) { | 2764 | while (Backup.WAPBookmark[i]!=NULL) { |
2765 | if (i == atoi(argv[4+startarg])-1) break; | 2765 | if (i == atoi(argv[4+startarg])-1) break; |
2766 | i++; | 2766 | i++; |
2767 | } | 2767 | } |
2768 | if (i != atoi(argv[4+startarg])-1) { | 2768 | if (i != atoi(argv[4+startarg])-1) { |
2769 | printmsg("Bookmark not found in file\n"); | 2769 | printmsg("Bookmark not found in file\n"); |
2770 | exit(-1); | 2770 | exit(-1); |
2771 | } | 2771 | } |
2772 | SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong; | 2772 | SMSInfo.Entries[0].ID = SMS_NokiaWAPBookmarkLong; |
2773 | SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i]; | 2773 | SMSInfo.Entries[0].Bookmark = Backup.WAPBookmark[i]; |
2774 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2774 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2775 | EncodeUnicode(Sender, "Bookmark",8); | 2775 | EncodeUnicode(Sender, "Bookmark",8); |
2776 | EncodeUnicode(Name,"WAP Bookmark",12); | 2776 | EncodeUnicode(Name,"WAP Bookmark",12); |
2777 | } | 2777 | } |
2778 | startarg += 5; | 2778 | startarg += 5; |
2779 | } else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) { | 2779 | } else if (mystrncasecmp(argv[2],"WAPSETTINGS",0)) { |
2780 | if (argc<6+startarg) { | 2780 | if (argc<6+startarg) { |
2781 | printmsg("Where is backup filename and location ?\n"); | 2781 | printmsg("Where is backup filename and location ?\n"); |
2782 | exit(-1); | 2782 | exit(-1); |
2783 | } | 2783 | } |
2784 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); | 2784 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); |
2785 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 2785 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
2786 | i = 0; | 2786 | i = 0; |
2787 | while (Backup.WAPSettings[i]!=NULL) { | 2787 | while (Backup.WAPSettings[i]!=NULL) { |
2788 | if (i == atoi(argv[4+startarg])-1) break; | 2788 | if (i == atoi(argv[4+startarg])-1) break; |
2789 | i++; | 2789 | i++; |
2790 | } | 2790 | } |
2791 | if (i != atoi(argv[4+startarg])-1) { | 2791 | if (i != atoi(argv[4+startarg])-1) { |
2792 | printmsg("WAP settings not found in file\n"); | 2792 | printmsg("WAP settings not found in file\n"); |
2793 | exit(-1); | 2793 | exit(-1); |
2794 | } | 2794 | } |
2795 | SMSInfo.Entries[0].Settings = NULL; | 2795 | SMSInfo.Entries[0].Settings = NULL; |
2796 | for (j=0;j<Backup.WAPSettings[i]->Number;j++) { | 2796 | for (j=0;j<Backup.WAPSettings[i]->Number;j++) { |
2797 | switch (Backup.WAPSettings[i]->Settings[j].Bearer) { | 2797 | switch (Backup.WAPSettings[i]->Settings[j].Bearer) { |
2798 | case WAPSETTINGS_BEARER_GPRS: | 2798 | case WAPSETTINGS_BEARER_GPRS: |
2799 | if (mystrncasecmp(argv[5+startarg],"GPRS",0)) { | 2799 | if (mystrncasecmp(argv[5+startarg],"GPRS",0)) { |
2800 | SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j]; | 2800 | SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j]; |
2801 | break; | 2801 | break; |
2802 | } | 2802 | } |
2803 | case WAPSETTINGS_BEARER_DATA: | 2803 | case WAPSETTINGS_BEARER_DATA: |
2804 | if (mystrncasecmp(argv[5+startarg],"DATA",0)) { | 2804 | if (mystrncasecmp(argv[5+startarg],"DATA",0)) { |
2805 | SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j]; | 2805 | SMSInfo.Entries[0].Settings = &Backup.WAPSettings[i]->Settings[j]; |
2806 | break; | 2806 | break; |
2807 | } | 2807 | } |
2808 | default: | 2808 | default: |
2809 | break; | 2809 | break; |
2810 | } | 2810 | } |
2811 | } | 2811 | } |
2812 | if (SMSInfo.Entries[0].Settings == NULL) { | 2812 | if (SMSInfo.Entries[0].Settings == NULL) { |
2813 | printmsg("Sorry. For now there is only support for GPRS or DATA bearers end\n"); | 2813 | printmsg("Sorry. For now there is only support for GPRS or DATA bearers end\n"); |
2814 | exit(-1); | 2814 | exit(-1); |
2815 | } | 2815 | } |
2816 | SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong; | 2816 | SMSInfo.Entries[0].ID = SMS_NokiaWAPSettingsLong; |
2817 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2817 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2818 | EncodeUnicode(Sender, "Settings",8); | 2818 | EncodeUnicode(Sender, "Settings",8); |
2819 | EncodeUnicode(Name,"WAP Settings",12); | 2819 | EncodeUnicode(Name,"WAP Settings",12); |
2820 | } | 2820 | } |
2821 | startarg += 6; | 2821 | startarg += 6; |
2822 | } else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) { | 2822 | } else if (mystrncasecmp(argv[2],"MMSSETTINGS",0)) { |
2823 | if (argc<5+startarg) { | 2823 | if (argc<5+startarg) { |
2824 | printmsg("Where is backup filename and location ?\n"); | 2824 | printmsg("Where is backup filename and location ?\n"); |
2825 | exit(-1); | 2825 | exit(-1); |
2826 | } | 2826 | } |
2827 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); | 2827 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); |
2828 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 2828 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
2829 | i = 0; | 2829 | i = 0; |
2830 | while (Backup.MMSSettings[i]!=NULL) { | 2830 | while (Backup.MMSSettings[i]!=NULL) { |
2831 | if (i == atoi(argv[4+startarg])-1) break; | 2831 | if (i == atoi(argv[4+startarg])-1) break; |
2832 | i++; | 2832 | i++; |
2833 | } | 2833 | } |
2834 | if (i != atoi(argv[4+startarg])-1) { | 2834 | if (i != atoi(argv[4+startarg])-1) { |
2835 | printmsg("MMS settings not found in file\n"); | 2835 | printmsg("MMS settings not found in file\n"); |
2836 | exit(-1); | 2836 | exit(-1); |
2837 | } | 2837 | } |
2838 | SMSInfo.Entries[0].Settings = NULL; | 2838 | SMSInfo.Entries[0].Settings = NULL; |
2839 | for (j=0;j<Backup.MMSSettings[i]->Number;j++) { | 2839 | for (j=0;j<Backup.MMSSettings[i]->Number;j++) { |
2840 | switch (Backup.MMSSettings[i]->Settings[j].Bearer) { | 2840 | switch (Backup.MMSSettings[i]->Settings[j].Bearer) { |
2841 | case WAPSETTINGS_BEARER_GPRS: | 2841 | case WAPSETTINGS_BEARER_GPRS: |
2842 | SMSInfo.Entries[0].Settings = &Backup.MMSSettings[i]->Settings[j]; | 2842 | SMSInfo.Entries[0].Settings = &Backup.MMSSettings[i]->Settings[j]; |
2843 | break; | 2843 | break; |
2844 | default: | 2844 | default: |
2845 | break; | 2845 | break; |
2846 | } | 2846 | } |
2847 | } | 2847 | } |
2848 | if (SMSInfo.Entries[0].Settings == NULL) { | 2848 | if (SMSInfo.Entries[0].Settings == NULL) { |
2849 | printmsg("Sorry. No GPRS bearer found in MMS settings\n"); | 2849 | printmsg("Sorry. No GPRS bearer found in MMS settings\n"); |
2850 | exit(-1); | 2850 | exit(-1); |
2851 | } | 2851 | } |
2852 | SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong; | 2852 | SMSInfo.Entries[0].ID = SMS_NokiaMMSSettingsLong; |
2853 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2853 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2854 | EncodeUnicode(Sender, "Settings",8); | 2854 | EncodeUnicode(Sender, "Settings",8); |
2855 | EncodeUnicode(Name,"MMS Settings",12); | 2855 | EncodeUnicode(Name,"MMS Settings",12); |
2856 | } | 2856 | } |
2857 | startarg += 5; | 2857 | startarg += 5; |
2858 | } else if (mystrncasecmp(argv[2],"CALENDAR",0)) { | 2858 | } else if (mystrncasecmp(argv[2],"CALENDAR",0)) { |
2859 | if (argc<5+startarg) { | 2859 | if (argc<5+startarg) { |
2860 | printmsg("Where is backup filename and location ?\n"); | 2860 | printmsg("Where is backup filename and location ?\n"); |
2861 | exit(-1); | 2861 | exit(-1); |
2862 | } | 2862 | } |
2863 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); | 2863 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); |
2864 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 2864 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
2865 | i = 0; | 2865 | i = 0; |
2866 | while (Backup.Calendar[i]!=NULL) { | 2866 | while (Backup.Calendar[i]!=NULL) { |
2867 | if (i == atoi(argv[4+startarg])-1) break; | 2867 | if (i == atoi(argv[4+startarg])-1) break; |
2868 | i++; | 2868 | i++; |
2869 | } | 2869 | } |
2870 | if (i != atoi(argv[4+startarg])-1) { | 2870 | if (i != atoi(argv[4+startarg])-1) { |
2871 | printmsg("Calendar note not found in file\n"); | 2871 | printmsg("Calendar note not found in file\n"); |
2872 | exit(-1); | 2872 | exit(-1); |
2873 | } | 2873 | } |
2874 | SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long; | 2874 | SMSInfo.Entries[0].ID = SMS_NokiaVCALENDAR10Long; |
2875 | SMSInfo.Entries[0].Calendar = Backup.Calendar[i]; | 2875 | SMSInfo.Entries[0].Calendar = Backup.Calendar[i]; |
2876 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2876 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2877 | EncodeUnicode(Sender, "Calendar",8); | 2877 | EncodeUnicode(Sender, "Calendar",8); |
2878 | } | 2878 | } |
2879 | startarg += 5; | 2879 | startarg += 5; |
2880 | } else if (mystrncasecmp(argv[2],"TODO",0)) { | 2880 | } else if (mystrncasecmp(argv[2],"TODO",0)) { |
2881 | if (argc<5+startarg) { | 2881 | if (argc<5+startarg) { |
2882 | printmsg("Where is backup filename and location ?\n"); | 2882 | printmsg("Where is backup filename and location ?\n"); |
2883 | exit(-1); | 2883 | exit(-1); |
2884 | } | 2884 | } |
2885 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); | 2885 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); |
2886 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 2886 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
2887 | i = 0; | 2887 | i = 0; |
2888 | while (Backup.ToDo[i]!=NULL) { | 2888 | while (Backup.ToDo[i]!=NULL) { |
2889 | if (i == atoi(argv[4+startarg])-1) break; | 2889 | if (i == atoi(argv[4+startarg])-1) break; |
2890 | i++; | 2890 | i++; |
2891 | } | 2891 | } |
2892 | if (i != atoi(argv[4+startarg])-1) { | 2892 | if (i != atoi(argv[4+startarg])-1) { |
2893 | printmsg("ToDo note not found in file\n"); | 2893 | printmsg("ToDo note not found in file\n"); |
2894 | exit(-1); | 2894 | exit(-1); |
2895 | } | 2895 | } |
2896 | SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong; | 2896 | SMSInfo.Entries[0].ID = SMS_NokiaVTODOLong; |
2897 | SMSInfo.Entries[0].ToDo = Backup.ToDo[i]; | 2897 | SMSInfo.Entries[0].ToDo = Backup.ToDo[i]; |
2898 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2898 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2899 | EncodeUnicode(Sender, "ToDo",8); | 2899 | EncodeUnicode(Sender, "ToDo",8); |
2900 | } | 2900 | } |
2901 | startarg += 5; | 2901 | startarg += 5; |
2902 | } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { | 2902 | } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { |
2903 | if (argc<6+startarg) { | 2903 | if (argc<6+startarg) { |
2904 | printmsg("Where is backup filename and location and memory type ?\n"); | 2904 | printmsg("Where is backup filename and location and memory type ?\n"); |
2905 | exit(-1); | 2905 | exit(-1); |
2906 | } | 2906 | } |
2907 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); | 2907 | error=GSM_ReadBackupFile(argv[3+startarg],&Backup); |
2908 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 2908 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
2909 | i = 0; | 2909 | i = 0; |
2910 | if (mystrncasecmp(argv[4+startarg],"SM",0)) { | 2910 | if (mystrncasecmp(argv[4+startarg],"SM",0)) { |
2911 | while (Backup.SIMPhonebook[i]!=NULL) { | 2911 | while (Backup.SIMPhonebook[i]!=NULL) { |
2912 | if (i == atoi(argv[5+startarg])-1) break; | 2912 | if (i == atoi(argv[5+startarg])-1) break; |
2913 | i++; | 2913 | i++; |
2914 | } | 2914 | } |
2915 | if (i != atoi(argv[5+startarg])-1) { | 2915 | if (i != atoi(argv[5+startarg])-1) { |
2916 | printmsg("Phonebook entry not found in file\n"); | 2916 | printmsg("Phonebook entry not found in file\n"); |
2917 | exit(-1); | 2917 | exit(-1); |
2918 | } | 2918 | } |
2919 | SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i]; | 2919 | SMSInfo.Entries[0].Phonebook = Backup.SIMPhonebook[i]; |
2920 | } else if (mystrncasecmp(argv[4+startarg],"ME",0)) { | 2920 | } else if (mystrncasecmp(argv[4+startarg],"ME",0)) { |
2921 | while (Backup.PhonePhonebook[i]!=NULL) { | 2921 | while (Backup.PhonePhonebook[i]!=NULL) { |
2922 | if (i == atoi(argv[5+startarg])-1) break; | 2922 | if (i == atoi(argv[5+startarg])-1) break; |
2923 | i++; | 2923 | i++; |
2924 | } | 2924 | } |
2925 | if (i != atoi(argv[5+startarg])-1) { | 2925 | if (i != atoi(argv[5+startarg])-1) { |
2926 | printmsg("Phonebook entry not found in file\n"); | 2926 | printmsg("Phonebook entry not found in file\n"); |
2927 | exit(-1); | 2927 | exit(-1); |
2928 | } | 2928 | } |
2929 | SMSInfo.Entries[0].Phonebook = Backup.PhonePhonebook[i]; | 2929 | SMSInfo.Entries[0].Phonebook = Backup.PhonePhonebook[i]; |
2930 | } else { | 2930 | } else { |
2931 | printmsg("Unknown memory type: \"%s\"\n",argv[4+startarg]); | 2931 | printmsg("Unknown memory type: \"%s\"\n",argv[4+startarg]); |
2932 | exit(-1); | 2932 | exit(-1); |
2933 | } | 2933 | } |
2934 | if (mystrncasecmp(argv[2],"VCARD10",0)) { | 2934 | if (mystrncasecmp(argv[2],"VCARD10",0)) { |
2935 | SMSInfo.Entries[0].ID = SMS_VCARD10Long; | 2935 | SMSInfo.Entries[0].ID = SMS_VCARD10Long; |
2936 | } else { | 2936 | } else { |
2937 | SMSInfo.Entries[0].ID = SMS_VCARD21Long; | 2937 | SMSInfo.Entries[0].ID = SMS_VCARD21Long; |
2938 | } | 2938 | } |
2939 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2939 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2940 | EncodeUnicode(Sender, "VCARD",5); | 2940 | EncodeUnicode(Sender, "VCARD",5); |
2941 | EncodeUnicode(Name, "Phonebook entry",15); | 2941 | EncodeUnicode(Name, "Phonebook entry",15); |
2942 | } | 2942 | } |
2943 | startarg += 6; | 2943 | startarg += 6; |
2944 | #endif | 2944 | #endif |
2945 | } else if (mystrncasecmp(argv[2],"PROFILE",0)) { | 2945 | } else if (mystrncasecmp(argv[2],"PROFILE",0)) { |
2946 | SMSInfo.Entries[0].ID = SMS_NokiaProfileLong; | 2946 | SMSInfo.Entries[0].ID = SMS_NokiaProfileLong; |
2947 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2947 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2948 | EncodeUnicode(Sender, "Profile",7); | 2948 | EncodeUnicode(Sender, "Profile",7); |
2949 | } | 2949 | } |
2950 | startarg += 3; | 2950 | startarg += 3; |
2951 | } else { | 2951 | } else { |
2952 | printmsg("What format of sms (\"%s\") ?\n",argv[2]); | 2952 | printmsg("What format of sms (\"%s\") ?\n",argv[2]); |
2953 | exit(-1); | 2953 | exit(-1); |
2954 | } | 2954 | } |
2955 | 2955 | ||
2956 | for (i=startarg;i<argc;i++) { | 2956 | for (i=startarg;i<argc;i++) { |
2957 | switch (nextlong) { | 2957 | switch (nextlong) { |
2958 | case 0: | 2958 | case 0: |
2959 | if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) { | 2959 | if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) { |
2960 | if (mystrncasecmp(argv[i],"-folder",0)) { | 2960 | if (mystrncasecmp(argv[i],"-folder",0)) { |
2961 | nextlong=1; | 2961 | nextlong=1; |
2962 | continue; | 2962 | continue; |
2963 | } | 2963 | } |
2964 | } | 2964 | } |
2965 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 2965 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
2966 | if (mystrncasecmp(argv[i],"-unread",0)) { | 2966 | if (mystrncasecmp(argv[i],"-unread",0)) { |
2967 | State = SMS_UnRead; | 2967 | State = SMS_UnRead; |
2968 | continue; | 2968 | continue; |
2969 | } | 2969 | } |
2970 | if (mystrncasecmp(argv[i],"-read",0)) { | 2970 | if (mystrncasecmp(argv[i],"-read",0)) { |
2971 | State = SMS_Read; | 2971 | State = SMS_Read; |
2972 | continue; | 2972 | continue; |
2973 | } | 2973 | } |
2974 | if (mystrncasecmp(argv[i],"-unsent",0)) { | 2974 | if (mystrncasecmp(argv[i],"-unsent",0)) { |
2975 | State = SMS_UnSent; | 2975 | State = SMS_UnSent; |
2976 | continue; | 2976 | continue; |
2977 | } | 2977 | } |
2978 | if (mystrncasecmp(argv[i],"-sent",0)) { | 2978 | if (mystrncasecmp(argv[i],"-sent",0)) { |
2979 | State = SMS_Sent; | 2979 | State = SMS_Sent; |
2980 | continue; | 2980 | continue; |
2981 | } | 2981 | } |
2982 | if (mystrncasecmp(argv[i],"-sender",0)) { | 2982 | if (mystrncasecmp(argv[i],"-sender",0)) { |
2983 | nextlong=2; | 2983 | nextlong=2; |
2984 | continue; | 2984 | continue; |
2985 | } | 2985 | } |
2986 | } else { | 2986 | } else { |
2987 | if (mystrncasecmp(argv[i],"-save",0)) { | 2987 | if (mystrncasecmp(argv[i],"-save",0)) { |
2988 | SendSaved=true; | 2988 | SendSaved=true; |
2989 | continue; | 2989 | continue; |
2990 | } | 2990 | } |
2991 | if (mystrncasecmp(argv[i],"-report",0)) { | 2991 | if (mystrncasecmp(argv[i],"-report",0)) { |
2992 | DeliveryReport=true; | 2992 | DeliveryReport=true; |
2993 | continue; | 2993 | continue; |
2994 | } | 2994 | } |
2995 | if (mystrncasecmp(argv[i],"-validity",0)) { | 2995 | if (mystrncasecmp(argv[i],"-validity",0)) { |
2996 | nextlong=10; | 2996 | nextlong=10; |
2997 | continue; | 2997 | continue; |
2998 | } | 2998 | } |
2999 | } | 2999 | } |
3000 | if (mystrncasecmp(argv[i],"-smscset",0)) { | 3000 | if (mystrncasecmp(argv[i],"-smscset",0)) { |
3001 | nextlong=3; | 3001 | nextlong=3; |
3002 | continue; | 3002 | continue; |
3003 | } | 3003 | } |
3004 | if (mystrncasecmp(argv[i],"-smscnumber",0)) { | 3004 | if (mystrncasecmp(argv[i],"-smscnumber",0)) { |
3005 | nextlong=4; | 3005 | nextlong=4; |
3006 | continue; | 3006 | continue; |
3007 | } | 3007 | } |
3008 | if (mystrncasecmp(argv[i],"-protected",0)) { | 3008 | if (mystrncasecmp(argv[i],"-protected",0)) { |
3009 | nextlong=19; | 3009 | nextlong=19; |
3010 | continue; | 3010 | continue; |
3011 | } | 3011 | } |
3012 | if (mystrncasecmp(argv[i],"-reply",0)) { | 3012 | if (mystrncasecmp(argv[i],"-reply",0)) { |
3013 | ReplyViaSameSMSC=true; | 3013 | ReplyViaSameSMSC=true; |
3014 | continue; | 3014 | continue; |
3015 | } | 3015 | } |
3016 | if (mystrncasecmp(argv[i],"-maxsms",0)) { | 3016 | if (mystrncasecmp(argv[i],"-maxsms",0)) { |
3017 | nextlong=21; | 3017 | nextlong=21; |
3018 | continue; | 3018 | continue; |
3019 | } | 3019 | } |
3020 | if (mystrncasecmp(argv[2],"RINGTONE",0)) { | 3020 | if (mystrncasecmp(argv[2],"RINGTONE",0)) { |
3021 | if (mystrncasecmp(argv[i],"-long",0)) { | 3021 | if (mystrncasecmp(argv[i],"-long",0)) { |
3022 | SMSInfo.Entries[0].ID = SMS_NokiaRingtoneLong; | 3022 | SMSInfo.Entries[0].ID = SMS_NokiaRingtoneLong; |
3023 | break; | 3023 | break; |
3024 | } | 3024 | } |
3025 | if (mystrncasecmp(argv[i],"-scale",0)) { | 3025 | if (mystrncasecmp(argv[i],"-scale",0)) { |
3026 | ringtone[0].NoteTone.AllNotesScale=true; | 3026 | ringtone[0].NoteTone.AllNotesScale=true; |
3027 | break; | 3027 | break; |
3028 | } | 3028 | } |
3029 | } | 3029 | } |
3030 | if (mystrncasecmp(argv[2],"TEXT",0)) { | 3030 | if (mystrncasecmp(argv[2],"TEXT",0)) { |
3031 | if (mystrncasecmp(argv[i],"-inputunicode",0)) { | 3031 | if (mystrncasecmp(argv[i],"-inputunicode",0)) { |
3032 | ReadUnicodeFile(Buffer[0],InputBuffer); | 3032 | ReadUnicodeFile(Buffer[0],InputBuffer); |
3033 | break; | 3033 | break; |
3034 | } | 3034 | } |
3035 | if (mystrncasecmp(argv[i],"-16bit",0)) { | 3035 | if (mystrncasecmp(argv[i],"-16bit",0)) { |
3036 | if (SMSInfo.Entries[0].ID == SMS_ConcatenatedTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong16bit; | 3036 | if (SMSInfo.Entries[0].ID == SMS_ConcatenatedTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong16bit; |
3037 | if (SMSInfo.Entries[0].ID == SMS_ConcatenatedAutoTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong16bit; | 3037 | if (SMSInfo.Entries[0].ID == SMS_ConcatenatedAutoTextLong) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong16bit; |
3038 | break; | 3038 | break; |
3039 | } | 3039 | } |
3040 | if (mystrncasecmp(argv[i],"-flash",0)) { | 3040 | if (mystrncasecmp(argv[i],"-flash",0)) { |
3041 | SMSInfo.Class = 0; | 3041 | SMSInfo.Class = 0; |
3042 | break; | 3042 | break; |
3043 | } | 3043 | } |
3044 | if (mystrncasecmp(argv[i],"-len",0)) { | 3044 | if (mystrncasecmp(argv[i],"-len",0)) { |
3045 | nextlong = 5; | 3045 | nextlong = 5; |
3046 | break; | 3046 | break; |
3047 | } | 3047 | } |
3048 | if (mystrncasecmp(argv[i],"-autolen",0)) { | 3048 | if (mystrncasecmp(argv[i],"-autolen",0)) { |
3049 | nextlong = 5; | 3049 | nextlong = 5; |
3050 | break; | 3050 | break; |
3051 | } | 3051 | } |
3052 | if (mystrncasecmp(argv[i],"-unicode",0)) { | 3052 | if (mystrncasecmp(argv[i],"-unicode",0)) { |
3053 | SMSInfo.UnicodeCoding = true; | 3053 | SMSInfo.UnicodeCoding = true; |
3054 | break; | 3054 | break; |
3055 | } | 3055 | } |
3056 | if (mystrncasecmp(argv[i],"-enablevoice",0)) { | 3056 | if (mystrncasecmp(argv[i],"-enablevoice",0)) { |
3057 | SMSInfo.Entries[0].ID = SMS_EnableVoice; | 3057 | SMSInfo.Entries[0].ID = SMS_EnableVoice; |
3058 | break; | 3058 | break; |
3059 | } | 3059 | } |
3060 | if (mystrncasecmp(argv[i],"-disablevoice",0)) { | 3060 | if (mystrncasecmp(argv[i],"-disablevoice",0)) { |
3061 | SMSInfo.Entries[0].ID = SMS_DisableVoice; | 3061 | SMSInfo.Entries[0].ID = SMS_DisableVoice; |
3062 | break; | 3062 | break; |
3063 | } | 3063 | } |
3064 | if (mystrncasecmp(argv[i],"-enablefax",0)) { | 3064 | if (mystrncasecmp(argv[i],"-enablefax",0)) { |
3065 | SMSInfo.Entries[0].ID = SMS_EnableFax; | 3065 | SMSInfo.Entries[0].ID = SMS_EnableFax; |
3066 | break; | 3066 | break; |
3067 | } | 3067 | } |
3068 | if (mystrncasecmp(argv[i],"-disablefax",0)) { | 3068 | if (mystrncasecmp(argv[i],"-disablefax",0)) { |
3069 | SMSInfo.Entries[0].ID = SMS_DisableFax; | 3069 | SMSInfo.Entries[0].ID = SMS_DisableFax; |
3070 | break; | 3070 | break; |
3071 | } | 3071 | } |
3072 | if (mystrncasecmp(argv[i],"-enableemail",0)) { | 3072 | if (mystrncasecmp(argv[i],"-enableemail",0)) { |
3073 | SMSInfo.Entries[0].ID = SMS_EnableEmail; | 3073 | SMSInfo.Entries[0].ID = SMS_EnableEmail; |
3074 | break; | 3074 | break; |
3075 | } | 3075 | } |
3076 | if (mystrncasecmp(argv[i],"-disableemail",0)) { | 3076 | if (mystrncasecmp(argv[i],"-disableemail",0)) { |
3077 | SMSInfo.Entries[0].ID = SMS_DisableEmail; | 3077 | SMSInfo.Entries[0].ID = SMS_DisableEmail; |
3078 | break; | 3078 | break; |
3079 | } | 3079 | } |
3080 | if (mystrncasecmp(argv[i],"-voidsms",0)) { | 3080 | if (mystrncasecmp(argv[i],"-voidsms",0)) { |
3081 | SMSInfo.Entries[0].ID = SMS_VoidSMS; | 3081 | SMSInfo.Entries[0].ID = SMS_VoidSMS; |
3082 | break; | 3082 | break; |
3083 | } | 3083 | } |
3084 | if (mystrncasecmp(argv[i],"-replacemessages",0) && | 3084 | if (mystrncasecmp(argv[i],"-replacemessages",0) && |
3085 | SMSInfo.Entries[0].ID != SMS_ConcatenatedTextLong) { | 3085 | SMSInfo.Entries[0].ID != SMS_ConcatenatedTextLong) { |
3086 | nextlong = 8; | 3086 | nextlong = 8; |
3087 | break; | 3087 | break; |
3088 | } | 3088 | } |
3089 | if (mystrncasecmp(argv[i],"-replacefile",0)) { | 3089 | if (mystrncasecmp(argv[i],"-replacefile",0)) { |
3090 | nextlong = 9; | 3090 | nextlong = 9; |
3091 | continue; | 3091 | continue; |
3092 | } | 3092 | } |
3093 | } | 3093 | } |
3094 | if (mystrncasecmp(argv[2],"PICTURE",0)) { | 3094 | if (mystrncasecmp(argv[2],"PICTURE",0)) { |
3095 | if (mystrncasecmp(argv[i],"-text",0)) { | 3095 | if (mystrncasecmp(argv[i],"-text",0)) { |
3096 | nextlong = 6; | 3096 | nextlong = 6; |
3097 | break; | 3097 | break; |
3098 | } | 3098 | } |
3099 | if (mystrncasecmp(argv[i],"-unicode",0)) { | 3099 | if (mystrncasecmp(argv[i],"-unicode",0)) { |
3100 | SMSInfo.UnicodeCoding = true; | 3100 | SMSInfo.UnicodeCoding = true; |
3101 | break; | 3101 | break; |
3102 | } | 3102 | } |
3103 | if (mystrncasecmp(argv[i],"-alcatelbmmi",0)) { | 3103 | if (mystrncasecmp(argv[i],"-alcatelbmmi",0)) { |
3104 | bitmap[0].Bitmap[0].Type=GSM_StartupLogo; | 3104 | bitmap[0].Bitmap[0].Type=GSM_StartupLogo; |
3105 | error=GSM_ReadBitmapFile(argv[startarg-1],&bitmap[0]); | 3105 | error=GSM_ReadBitmapFile(argv[startarg-1],&bitmap[0]); |
3106 | Print_Error(error); | 3106 | Print_Error(error); |
3107 | SMSInfo.UnicodeCoding = true; | 3107 | SMSInfo.UnicodeCoding = true; |
3108 | SMSInfo.Entries[0].ID = SMS_AlcatelMonoBitmapLong; | 3108 | SMSInfo.Entries[0].ID = SMS_AlcatelMonoBitmapLong; |
3109 | break; | 3109 | break; |
3110 | } | 3110 | } |
3111 | break; | 3111 | break; |
3112 | } | 3112 | } |
3113 | if (mystrncasecmp(argv[2],"VCARD10",0)) { | 3113 | if (mystrncasecmp(argv[2],"VCARD10",0)) { |
3114 | if (mystrncasecmp(argv[i],"-nokia",0)) { | 3114 | if (mystrncasecmp(argv[i],"-nokia",0)) { |
3115 | SMSInfo.Entries[0].ID = SMS_NokiaVCARD10Long; | 3115 | SMSInfo.Entries[0].ID = SMS_NokiaVCARD10Long; |
3116 | break; | 3116 | break; |
3117 | } | 3117 | } |
3118 | break; | 3118 | break; |
3119 | } | 3119 | } |
3120 | if (mystrncasecmp(argv[2],"VCARD21",0)) { | 3120 | if (mystrncasecmp(argv[2],"VCARD21",0)) { |
3121 | if (mystrncasecmp(argv[i],"-nokia",0)) { | 3121 | if (mystrncasecmp(argv[i],"-nokia",0)) { |
3122 | SMSInfo.Entries[0].ID = SMS_NokiaVCARD21Long; | 3122 | SMSInfo.Entries[0].ID = SMS_NokiaVCARD21Long; |
3123 | break; | 3123 | break; |
3124 | } | 3124 | } |
3125 | break; | 3125 | break; |
3126 | } | 3126 | } |
3127 | if (mystrncasecmp(argv[2],"PROFILE",0)) { | 3127 | if (mystrncasecmp(argv[2],"PROFILE",0)) { |
3128 | if (mystrncasecmp(argv[i],"-name",0)) { | 3128 | if (mystrncasecmp(argv[i],"-name",0)) { |
3129 | nextlong = 22; | 3129 | nextlong = 22; |
3130 | break; | 3130 | break; |
3131 | } | 3131 | } |
3132 | if (mystrncasecmp(argv[i],"-ringtone",0)) { | 3132 | if (mystrncasecmp(argv[i],"-ringtone",0)) { |
3133 | nextlong = 23; | 3133 | nextlong = 23; |
3134 | break; | 3134 | break; |
3135 | } | 3135 | } |
3136 | if (mystrncasecmp(argv[i],"-bitmap",0)) { | 3136 | if (mystrncasecmp(argv[i],"-bitmap",0)) { |
3137 | nextlong = 24; | 3137 | nextlong = 24; |
3138 | break; | 3138 | break; |
3139 | } | 3139 | } |
3140 | } | 3140 | } |
3141 | if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { | 3141 | if (mystrncasecmp(argv[2],"SMSTEMPLATE",0)) { |
3142 | if (mystrncasecmp(argv[i],"-unicode",0)) { | 3142 | if (mystrncasecmp(argv[i],"-unicode",0)) { |
3143 | SMSInfo.UnicodeCoding = true; | 3143 | SMSInfo.UnicodeCoding = true; |
3144 | break; | 3144 | break; |
3145 | } | 3145 | } |
3146 | if (mystrncasecmp(argv[i],"-text",0)) { | 3146 | if (mystrncasecmp(argv[i],"-text",0)) { |
3147 | nextlong = 11; | 3147 | nextlong = 11; |
3148 | break; | 3148 | break; |
3149 | } | 3149 | } |
3150 | if (mystrncasecmp(argv[i],"-unicodefiletext",0)) { | 3150 | if (mystrncasecmp(argv[i],"-unicodefiletext",0)) { |
3151 | nextlong = 18; | 3151 | nextlong = 18; |
3152 | break; | 3152 | break; |
3153 | } | 3153 | } |
3154 | if (mystrncasecmp(argv[i],"-defsound",0)) { | 3154 | if (mystrncasecmp(argv[i],"-defsound",0)) { |
3155 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound; | 3155 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound; |
3156 | nextlong = 12; | 3156 | nextlong = 12; |
3157 | break; | 3157 | break; |
3158 | } | 3158 | } |
3159 | if (mystrncasecmp(argv[i],"-defanimation",0)) { | 3159 | if (mystrncasecmp(argv[i],"-defanimation",0)) { |
3160 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation; | 3160 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation; |
3161 | nextlong = 12; | 3161 | nextlong = 12; |
3162 | break; | 3162 | break; |
3163 | } | 3163 | } |
3164 | if (mystrncasecmp(argv[i],"-tone10",0)) { | 3164 | if (mystrncasecmp(argv[i],"-tone10",0)) { |
3165 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10; | 3165 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10; |
3166 | if (Protected != 0) { | 3166 | if (Protected != 0) { |
3167 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3167 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3168 | Protected --; | 3168 | Protected --; |
3169 | } | 3169 | } |
3170 | nextlong = 14; | 3170 | nextlong = 14; |
3171 | break; | 3171 | break; |
3172 | } | 3172 | } |
3173 | if (mystrncasecmp(argv[i],"-tone10long",0)) { | 3173 | if (mystrncasecmp(argv[i],"-tone10long",0)) { |
3174 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long; | 3174 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long; |
3175 | if (Protected != 0) { | 3175 | if (Protected != 0) { |
3176 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3176 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3177 | Protected --; | 3177 | Protected --; |
3178 | } | 3178 | } |
3179 | nextlong = 14; | 3179 | nextlong = 14; |
3180 | break; | 3180 | break; |
3181 | } | 3181 | } |
3182 | if (mystrncasecmp(argv[i],"-tone12",0)) { | 3182 | if (mystrncasecmp(argv[i],"-tone12",0)) { |
3183 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12; | 3183 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12; |
3184 | if (Protected != 0) { | 3184 | if (Protected != 0) { |
3185 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3185 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3186 | Protected --; | 3186 | Protected --; |
3187 | } | 3187 | } |
3188 | nextlong = 14; | 3188 | nextlong = 14; |
3189 | break; | 3189 | break; |
3190 | } | 3190 | } |
3191 | if (mystrncasecmp(argv[i],"-tone12long",0)) { | 3191 | if (mystrncasecmp(argv[i],"-tone12long",0)) { |
3192 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long; | 3192 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long; |
3193 | if (Protected != 0) { | 3193 | if (Protected != 0) { |
3194 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3194 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3195 | Protected --; | 3195 | Protected --; |
3196 | } | 3196 | } |
3197 | nextlong = 14; | 3197 | nextlong = 14; |
3198 | break; | 3198 | break; |
3199 | } | 3199 | } |
3200 | if (mystrncasecmp(argv[i],"-toneSE",0)) { | 3200 | if (mystrncasecmp(argv[i],"-toneSE",0)) { |
3201 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound; | 3201 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound; |
3202 | if (Protected != 0) { | 3202 | if (Protected != 0) { |
3203 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3203 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3204 | Protected --; | 3204 | Protected --; |
3205 | } | 3205 | } |
3206 | nextlong = 14; | 3206 | nextlong = 14; |
3207 | break; | 3207 | break; |
3208 | } | 3208 | } |
3209 | if (mystrncasecmp(argv[i],"-toneSElong",0)) { | 3209 | if (mystrncasecmp(argv[i],"-toneSElong",0)) { |
3210 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong; | 3210 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong; |
3211 | if (Protected != 0) { | 3211 | if (Protected != 0) { |
3212 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3212 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3213 | Protected --; | 3213 | Protected --; |
3214 | } | 3214 | } |
3215 | nextlong = 14; | 3215 | nextlong = 14; |
3216 | break; | 3216 | break; |
3217 | } | 3217 | } |
3218 | if (mystrncasecmp(argv[i],"-variablebitmap",0)) { | 3218 | if (mystrncasecmp(argv[i],"-variablebitmap",0)) { |
3219 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap; | 3219 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap; |
3220 | if (Protected != 0) { | 3220 | if (Protected != 0) { |
3221 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3221 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3222 | Protected --; | 3222 | Protected --; |
3223 | } | 3223 | } |
3224 | nextlong = 15; | 3224 | nextlong = 15; |
3225 | break; | 3225 | break; |
3226 | } | 3226 | } |
3227 | if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) { | 3227 | if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) { |
3228 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong; | 3228 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong; |
3229 | if (Protected != 0) { | 3229 | if (Protected != 0) { |
3230 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3230 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3231 | Protected --; | 3231 | Protected --; |
3232 | } | 3232 | } |
3233 | nextlong = 15; | 3233 | nextlong = 15; |
3234 | break; | 3234 | break; |
3235 | } | 3235 | } |
3236 | if (mystrncasecmp(argv[i],"-animation",0)) { | 3236 | if (mystrncasecmp(argv[i],"-animation",0)) { |
3237 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation; | 3237 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation; |
3238 | if (Protected != 0) { | 3238 | if (Protected != 0) { |
3239 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3239 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3240 | Protected --; | 3240 | Protected --; |
3241 | } | 3241 | } |
3242 | bitmap[SMSInfo.EntriesNum].Number = 0; | 3242 | bitmap[SMSInfo.EntriesNum].Number = 0; |
3243 | nextlong = 16; | 3243 | nextlong = 16; |
3244 | break; | 3244 | break; |
3245 | } | 3245 | } |
3246 | } | 3246 | } |
3247 | if (mystrncasecmp(argv[2],"EMS",0)) { | 3247 | if (mystrncasecmp(argv[2],"EMS",0)) { |
3248 | if (mystrncasecmp(argv[i],"-unicode",0)) { | 3248 | if (mystrncasecmp(argv[i],"-unicode",0)) { |
3249 | SMSInfo.UnicodeCoding = true; | 3249 | SMSInfo.UnicodeCoding = true; |
3250 | break; | 3250 | break; |
3251 | } | 3251 | } |
3252 | if (mystrncasecmp(argv[i],"-16bit",0)) { | 3252 | if (mystrncasecmp(argv[i],"-16bit",0)) { |
3253 | EMS16Bit = true; | 3253 | EMS16Bit = true; |
3254 | break; | 3254 | break; |
3255 | } | 3255 | } |
3256 | if (mystrncasecmp(argv[i],"-format",0)) { | 3256 | if (mystrncasecmp(argv[i],"-format",0)) { |
3257 | nextlong = 20; | 3257 | nextlong = 20; |
3258 | break; | 3258 | break; |
3259 | } | 3259 | } |
3260 | if (mystrncasecmp(argv[i],"-text",0)) { | 3260 | if (mystrncasecmp(argv[i],"-text",0)) { |
3261 | nextlong = 11; | 3261 | nextlong = 11; |
3262 | break; | 3262 | break; |
3263 | } | 3263 | } |
3264 | if (mystrncasecmp(argv[i],"-unicodefiletext",0)) { | 3264 | if (mystrncasecmp(argv[i],"-unicodefiletext",0)) { |
3265 | nextlong = 18; | 3265 | nextlong = 18; |
3266 | break; | 3266 | break; |
3267 | } | 3267 | } |
3268 | if (mystrncasecmp(argv[i],"-defsound",0)) { | 3268 | if (mystrncasecmp(argv[i],"-defsound",0)) { |
3269 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound; | 3269 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedSound; |
3270 | nextlong = 12; | 3270 | nextlong = 12; |
3271 | break; | 3271 | break; |
3272 | } | 3272 | } |
3273 | if (mystrncasecmp(argv[i],"-defanimation",0)) { | 3273 | if (mystrncasecmp(argv[i],"-defanimation",0)) { |
3274 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation; | 3274 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSPredefinedAnimation; |
3275 | nextlong = 12; | 3275 | nextlong = 12; |
3276 | break; | 3276 | break; |
3277 | } | 3277 | } |
3278 | if (mystrncasecmp(argv[i],"-tone10",0)) { | 3278 | if (mystrncasecmp(argv[i],"-tone10",0)) { |
3279 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10; | 3279 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10; |
3280 | if (Protected != 0) { | 3280 | if (Protected != 0) { |
3281 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3281 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3282 | Protected --; | 3282 | Protected --; |
3283 | } | 3283 | } |
3284 | nextlong = 14; | 3284 | nextlong = 14; |
3285 | break; | 3285 | break; |
3286 | } | 3286 | } |
3287 | if (mystrncasecmp(argv[i],"-tone10long",0)) { | 3287 | if (mystrncasecmp(argv[i],"-tone10long",0)) { |
3288 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long; | 3288 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound10Long; |
3289 | if (Protected != 0) { | 3289 | if (Protected != 0) { |
3290 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3290 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3291 | Protected --; | 3291 | Protected --; |
3292 | } | 3292 | } |
3293 | nextlong = 14; | 3293 | nextlong = 14; |
3294 | break; | 3294 | break; |
3295 | } | 3295 | } |
3296 | if (mystrncasecmp(argv[i],"-tone12",0)) { | 3296 | if (mystrncasecmp(argv[i],"-tone12",0)) { |
3297 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12; | 3297 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12; |
3298 | if (Protected != 0) { | 3298 | if (Protected != 0) { |
3299 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3299 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3300 | Protected --; | 3300 | Protected --; |
3301 | } | 3301 | } |
3302 | nextlong = 14; | 3302 | nextlong = 14; |
3303 | break; | 3303 | break; |
3304 | } | 3304 | } |
3305 | if (mystrncasecmp(argv[i],"-tone12long",0)) { | 3305 | if (mystrncasecmp(argv[i],"-tone12long",0)) { |
3306 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long; | 3306 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSound12Long; |
3307 | if (Protected != 0) { | 3307 | if (Protected != 0) { |
3308 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3308 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3309 | Protected --; | 3309 | Protected --; |
3310 | } | 3310 | } |
3311 | nextlong = 14; | 3311 | nextlong = 14; |
3312 | break; | 3312 | break; |
3313 | } | 3313 | } |
3314 | if (mystrncasecmp(argv[i],"-toneSE",0)) { | 3314 | if (mystrncasecmp(argv[i],"-toneSE",0)) { |
3315 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound; | 3315 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSound; |
3316 | if (Protected != 0) { | 3316 | if (Protected != 0) { |
3317 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3317 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3318 | Protected --; | 3318 | Protected --; |
3319 | } | 3319 | } |
3320 | nextlong = 14; | 3320 | nextlong = 14; |
3321 | break; | 3321 | break; |
3322 | } | 3322 | } |
3323 | if (mystrncasecmp(argv[i],"-toneSElong",0)) { | 3323 | if (mystrncasecmp(argv[i],"-toneSElong",0)) { |
3324 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong; | 3324 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSSonyEricssonSoundLong; |
3325 | if (Protected != 0) { | 3325 | if (Protected != 0) { |
3326 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3326 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3327 | Protected --; | 3327 | Protected --; |
3328 | } | 3328 | } |
3329 | nextlong = 14; | 3329 | nextlong = 14; |
3330 | break; | 3330 | break; |
3331 | } | 3331 | } |
3332 | if (mystrncasecmp(argv[i],"-fixedbitmap",0)) { | 3332 | if (mystrncasecmp(argv[i],"-fixedbitmap",0)) { |
3333 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSFixedBitmap; | 3333 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSFixedBitmap; |
3334 | if (Protected != 0) { | 3334 | if (Protected != 0) { |
3335 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3335 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3336 | Protected --; | 3336 | Protected --; |
3337 | } | 3337 | } |
3338 | nextlong = 15; | 3338 | nextlong = 15; |
3339 | break; | 3339 | break; |
3340 | } | 3340 | } |
3341 | if (mystrncasecmp(argv[i],"-variablebitmap",0)) { | 3341 | if (mystrncasecmp(argv[i],"-variablebitmap",0)) { |
3342 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap; | 3342 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmap; |
3343 | if (Protected != 0) { | 3343 | if (Protected != 0) { |
3344 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3344 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3345 | Protected --; | 3345 | Protected --; |
3346 | } | 3346 | } |
3347 | nextlong = 15; | 3347 | nextlong = 15; |
3348 | break; | 3348 | break; |
3349 | } | 3349 | } |
3350 | if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) { | 3350 | if (mystrncasecmp(argv[i],"-variablebitmaplong",0)) { |
3351 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong; | 3351 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSVariableBitmapLong; |
3352 | if (Protected != 0) { | 3352 | if (Protected != 0) { |
3353 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3353 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3354 | Protected --; | 3354 | Protected --; |
3355 | } | 3355 | } |
3356 | nextlong = 15; | 3356 | nextlong = 15; |
3357 | break; | 3357 | break; |
3358 | } | 3358 | } |
3359 | if (mystrncasecmp(argv[i],"-animation",0)) { | 3359 | if (mystrncasecmp(argv[i],"-animation",0)) { |
3360 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation; | 3360 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_EMSAnimation; |
3361 | if (Protected != 0) { | 3361 | if (Protected != 0) { |
3362 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; | 3362 | SMSInfo.Entries[SMSInfo.EntriesNum].Protected = true; |
3363 | Protected --; | 3363 | Protected --; |
3364 | } | 3364 | } |
3365 | bitmap[SMSInfo.EntriesNum].Number = 0; | 3365 | bitmap[SMSInfo.EntriesNum].Number = 0; |
3366 | nextlong = 16; | 3366 | nextlong = 16; |
3367 | break; | 3367 | break; |
3368 | } | 3368 | } |
3369 | } | 3369 | } |
3370 | if (mystrncasecmp(argv[2],"OPERATOR",0)) { | 3370 | if (mystrncasecmp(argv[2],"OPERATOR",0)) { |
3371 | if (mystrncasecmp(argv[i],"-netcode",0)) { | 3371 | if (mystrncasecmp(argv[i],"-netcode",0)) { |
3372 | nextlong = 7; | 3372 | nextlong = 7; |
3373 | break; | 3373 | break; |
3374 | } | 3374 | } |
3375 | if (mystrncasecmp(argv[i],"-biglogo",0)) { | 3375 | if (mystrncasecmp(argv[i],"-biglogo",0)) { |
3376 | SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogoLong; | 3376 | SMSInfo.Entries[0].ID = SMS_NokiaOperatorLogoLong; |
3377 | break; | 3377 | break; |
3378 | } | 3378 | } |
3379 | break; | 3379 | break; |
3380 | } | 3380 | } |
3381 | printmsg("Unknown parameter (\"%s\")\n",argv[i]); | 3381 | printmsg("Unknown parameter (\"%s\")\n",argv[i]); |
3382 | exit(-1); | 3382 | exit(-1); |
3383 | break; | 3383 | break; |
3384 | case 1: /* SMS folder - only during saving SMS */ | 3384 | case 1: /* SMS folder - only during saving SMS */ |
3385 | Folder = atoi(argv[i]); | 3385 | Folder = atoi(argv[i]); |
3386 | nextlong = 0; | 3386 | nextlong = 0; |
3387 | break; | 3387 | break; |
3388 | case 2: /* Sender number - only during saving SMS */ | 3388 | case 2: /* Sender number - only during saving SMS */ |
3389 | EncodeUnicode(Sender,argv[i],strlen(argv[i])); | 3389 | EncodeUnicode(Sender,argv[i],strlen(argv[i])); |
3390 | nextlong = 0; | 3390 | nextlong = 0; |
3391 | break; | 3391 | break; |
3392 | case 3: /* SMSC set number */ | 3392 | case 3: /* SMSC set number */ |
3393 | SMSCSet = atoi(argv[i]); | 3393 | SMSCSet = atoi(argv[i]); |
3394 | nextlong = 0; | 3394 | nextlong = 0; |
3395 | break; | 3395 | break; |
3396 | case 4: /* Number of SMSC */ | 3396 | case 4: /* Number of SMSC */ |
3397 | EncodeUnicode(SMSC,argv[i],strlen(argv[i])); | 3397 | EncodeUnicode(SMSC,argv[i],strlen(argv[i])); |
3398 | SMSCSet = 0; | 3398 | SMSCSet = 0; |
3399 | nextlong= 0; | 3399 | nextlong= 0; |
3400 | break; | 3400 | break; |
3401 | case 5: /* Length of text SMS */ | 3401 | case 5: /* Length of text SMS */ |
3402 | if (atoi(argv[i])<chars_read) | 3402 | if (atoi(argv[i])<chars_read) |
3403 | { | 3403 | { |
3404 | Buffer[0][atoi(argv[i])*2]= 0x00; | 3404 | Buffer[0][atoi(argv[i])*2]= 0x00; |
3405 | Buffer[0][atoi(argv[i])*2+1]= 0x00; | 3405 | Buffer[0][atoi(argv[i])*2+1]= 0x00; |
3406 | } | 3406 | } |
3407 | SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong; | 3407 | SMSInfo.Entries[0].ID = SMS_ConcatenatedTextLong; |
3408 | if (mystrncasecmp(argv[i-1],"-autolen",0)) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong; | 3408 | if (mystrncasecmp(argv[i-1],"-autolen",0)) SMSInfo.Entries[0].ID = SMS_ConcatenatedAutoTextLong; |
3409 | nextlong = 0; | 3409 | nextlong = 0; |
3410 | break; | 3410 | break; |
3411 | case 6:/* Picture Images - text */ | 3411 | case 6:/* Picture Images - text */ |
3412 | EncodeUnicode(bitmap[0].Bitmap[0].Text,argv[i],strlen(argv[i])); | 3412 | EncodeUnicode(bitmap[0].Bitmap[0].Text,argv[i],strlen(argv[i])); |
3413 | nextlong = 0; | 3413 | nextlong = 0; |
3414 | break; | 3414 | break; |
3415 | case 7:/* Operator Logo - network code */ | 3415 | case 7:/* Operator Logo - network code */ |
3416 | strncpy(bitmap[0].Bitmap[0].NetworkCode,argv[i],7); | 3416 | strncpy(bitmap[0].Bitmap[0].NetworkCode,argv[i],7); |
3417 | if (!strcmp(DecodeUnicodeConsole(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)),"unknown")) { | 3417 | if (!strcmp(DecodeUnicodeConsole(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)),"unknown")) { |
3418 | printmsg("Unknown GSM network code (\"%s\")\n",argv[i]); | 3418 | printmsg("Unknown GSM network code (\"%s\")\n",argv[i]); |
3419 | exit(-1); | 3419 | exit(-1); |
3420 | } | 3420 | } |
3421 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 3421 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
3422 | EncodeUnicode(Sender, "OpLogo",6); | 3422 | EncodeUnicode(Sender, "OpLogo",6); |
3423 | EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3); | 3423 | EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3); |
3424 | EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2); | 3424 | EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2); |
3425 | if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) { | 3425 | if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) { |
3426 | EncodeUnicode(Name,"OpLogo ",7); | 3426 | EncodeUnicode(Name,"OpLogo ",7); |
3427 | CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)); | 3427 | CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)); |
3428 | } else { | 3428 | } else { |
3429 | CopyUnicodeString(Name,Sender); | 3429 | CopyUnicodeString(Name,Sender); |
3430 | } | 3430 | } |
3431 | } | 3431 | } |
3432 | nextlong = 0; | 3432 | nextlong = 0; |
3433 | break; | 3433 | break; |
3434 | case 8:/* Reject duplicates ID */ | 3434 | case 8:/* Reject duplicates ID */ |
3435 | SMSInfo.ReplaceMessage = atoi(argv[i]); | 3435 | SMSInfo.ReplaceMessage = atoi(argv[i]); |
3436 | if (SMSInfo.ReplaceMessage < 1 || SMSInfo.ReplaceMessage > 7) { | 3436 | if (SMSInfo.ReplaceMessage < 1 || SMSInfo.ReplaceMessage > 7) { |
3437 | printmsg("You have to give number between 1 and 7 (\"%s\")\n",argv[i]); | 3437 | printmsg("You have to give number between 1 and 7 (\"%s\")\n",argv[i]); |
3438 | exit(-1); | 3438 | exit(-1); |
3439 | } | 3439 | } |
3440 | nextlong = 0; | 3440 | nextlong = 0; |
3441 | break; | 3441 | break; |
3442 | case 9:/* Replace file for text SMS */ | 3442 | case 9:/* Replace file for text SMS */ |
3443 | ReplaceFile = fopen(argv[i], "rb"); | 3443 | ReplaceFile = fopen(argv[i], "rb"); |
3444 | if (ReplaceFile == NULL) Print_Error(ERR_CANTOPENFILE); | 3444 | if (ReplaceFile == NULL) Print_Error(ERR_CANTOPENFILE); |
3445 | memset(ReplaceBuffer,0,sizeof(ReplaceBuffer)); | 3445 | memset(ReplaceBuffer,0,sizeof(ReplaceBuffer)); |
3446 | fread(ReplaceBuffer,1,sizeof(ReplaceBuffer),ReplaceFile); | 3446 | fread(ReplaceBuffer,1,sizeof(ReplaceBuffer),ReplaceFile); |
3447 | fclose(ReplaceFile); | 3447 | fclose(ReplaceFile); |
3448 | ReadUnicodeFile(ReplaceBuffer2,ReplaceBuffer); | 3448 | ReadUnicodeFile(ReplaceBuffer2,ReplaceBuffer); |
3449 | for(j=0;j<(int)(UnicodeLength(Buffer[0]));j++) { | 3449 | for(j=0;j<(int)(UnicodeLength(Buffer[0]));j++) { |
3450 | for (z=0;z<(int)(UnicodeLength(ReplaceBuffer2)/2);z++) { | 3450 | for (z=0;z<(int)(UnicodeLength(ReplaceBuffer2)/2);z++) { |
3451 | if (ReplaceBuffer2[z*4] == Buffer[0][j] && | 3451 | if (ReplaceBuffer2[z*4] == Buffer[0][j] && |
3452 | ReplaceBuffer2[z*4+1] == Buffer[0][j+1]) { | 3452 | ReplaceBuffer2[z*4+1] == Buffer[0][j+1]) { |
3453 | Buffer[0][j] = ReplaceBuffer2[z*4+2]; | 3453 | Buffer[0][j] = ReplaceBuffer2[z*4+2]; |
3454 | Buffer[0][j+1] = ReplaceBuffer2[z*4+3]; | 3454 | Buffer[0][j+1] = ReplaceBuffer2[z*4+3]; |
3455 | break; | 3455 | break; |
3456 | } | 3456 | } |
3457 | } | 3457 | } |
3458 | } | 3458 | } |
3459 | nextlong = 0; | 3459 | nextlong = 0; |
3460 | break; | 3460 | break; |
3461 | case 10: | 3461 | case 10: |
3462 | Validity.Format = SMS_Validity_RelativeFormat; | 3462 | Validity.Format = SMS_Validity_RelativeFormat; |
3463 | if (mystrncasecmp(argv[i],"HOUR",0)) Validity.Relative = SMS_VALID_1_Hour; | 3463 | if (mystrncasecmp(argv[i],"HOUR",0)) Validity.Relative = SMS_VALID_1_Hour; |
3464 | else if (mystrncasecmp(argv[i],"6HOURS",0))Validity.Relative = SMS_VALID_6_Hours; | 3464 | else if (mystrncasecmp(argv[i],"6HOURS",0))Validity.Relative = SMS_VALID_6_Hours; |
3465 | else if (mystrncasecmp(argv[i],"DAY",0)) Validity.Relative = SMS_VALID_1_Day; | 3465 | else if (mystrncasecmp(argv[i],"DAY",0)) Validity.Relative = SMS_VALID_1_Day; |
3466 | else if (mystrncasecmp(argv[i],"3DAYS",0)) Validity.Relative = SMS_VALID_3_Days; | 3466 | else if (mystrncasecmp(argv[i],"3DAYS",0)) Validity.Relative = SMS_VALID_3_Days; |
3467 | else if (mystrncasecmp(argv[i],"WEEK",0)) Validity.Relative = SMS_VALID_1_Week; | 3467 | else if (mystrncasecmp(argv[i],"WEEK",0)) Validity.Relative = SMS_VALID_1_Week; |
3468 | else if (mystrncasecmp(argv[i],"MAX",0)) Validity.Relative = SMS_VALID_Max_Time; | 3468 | else if (mystrncasecmp(argv[i],"MAX",0)) Validity.Relative = SMS_VALID_Max_Time; |
3469 | else { | 3469 | else { |
3470 | printmsg("Unknown validity string (\"%s\")\n",argv[i]); | 3470 | printmsg("Unknown validity string (\"%s\")\n",argv[i]); |
3471 | exit(-1); | 3471 | exit(-1); |
3472 | } | 3472 | } |
3473 | nextlong = 0; | 3473 | nextlong = 0; |
3474 | break; | 3474 | break; |
3475 | case 11:/* EMS text from parameter */ | 3475 | case 11:/* EMS text from parameter */ |
3476 | EncodeUnicode(Buffer[SMSInfo.EntriesNum],argv[i],strlen(argv[i])); | 3476 | EncodeUnicode(Buffer[SMSInfo.EntriesNum],argv[i],strlen(argv[i])); |
3477 | dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum])); | 3477 | dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum])); |
3478 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong; | 3478 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong; |
3479 | SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum]; | 3479 | SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum]; |
3480 | SMSInfo.EntriesNum++; | 3480 | SMSInfo.EntriesNum++; |
3481 | nextlong = 0; | 3481 | nextlong = 0; |
3482 | break; | 3482 | break; |
3483 | case 12:/* EMS predefined sound/animation number */ | 3483 | case 12:/* EMS predefined sound/animation number */ |
3484 | SMSInfo.Entries[SMSInfo.EntriesNum].Number = atoi(argv[i]); | 3484 | SMSInfo.Entries[SMSInfo.EntriesNum].Number = atoi(argv[i]); |
3485 | SMSInfo.EntriesNum++; | 3485 | SMSInfo.EntriesNum++; |
3486 | nextlong = 0; | 3486 | nextlong = 0; |
3487 | break; | 3487 | break; |
3488 | case 14: /* EMS ringtone - IMelody */ | 3488 | case 14: /* EMS ringtone - IMelody */ |
3489 | ringtone[SMSInfo.EntriesNum].Format=RING_NOTETONE; | 3489 | ringtone[SMSInfo.EntriesNum].Format=RING_NOTETONE; |
3490 | error=GSM_ReadRingtoneFile(argv[i],&ringtone[SMSInfo.EntriesNum]); | 3490 | error=GSM_ReadRingtoneFile(argv[i],&ringtone[SMSInfo.EntriesNum]); |
3491 | Print_Error(error); | 3491 | Print_Error(error); |
3492 | SMSInfo.Entries[SMSInfo.EntriesNum].Ringtone = &ringtone[SMSInfo.EntriesNum]; | 3492 | SMSInfo.Entries[SMSInfo.EntriesNum].Ringtone = &ringtone[SMSInfo.EntriesNum]; |
3493 | SMSInfo.EntriesNum++; | 3493 | SMSInfo.EntriesNum++; |
3494 | nextlong = 0; | 3494 | nextlong = 0; |
3495 | break; | 3495 | break; |
3496 | case 15:/* EMS bitmap file */ | 3496 | case 15:/* EMS bitmap file */ |
3497 | bitmap[SMSInfo.EntriesNum].Bitmap[0].Type=GSM_StartupLogo; | 3497 | bitmap[SMSInfo.EntriesNum].Bitmap[0].Type=GSM_StartupLogo; |
3498 | error=GSM_ReadBitmapFile(argv[i],&bitmap[SMSInfo.EntriesNum]); | 3498 | error=GSM_ReadBitmapFile(argv[i],&bitmap[SMSInfo.EntriesNum]); |
3499 | Print_Error(error); | 3499 | Print_Error(error); |
3500 | SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum]; | 3500 | SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum]; |
3501 | SMSInfo.EntriesNum++; | 3501 | SMSInfo.EntriesNum++; |
3502 | nextlong = 0; | 3502 | nextlong = 0; |
3503 | break; | 3503 | break; |
3504 | case 16:/* Number of frames for EMS animation */ | 3504 | case 16:/* Number of frames for EMS animation */ |
3505 | FramesNum = atoi(argv[i]); | 3505 | FramesNum = atoi(argv[i]); |
3506 | if (FramesNum < 1 || FramesNum > 4) { | 3506 | if (FramesNum < 1 || FramesNum > 4) { |
3507 | printmsg("You have to give number of EMS frames between 1 and 4 (\"%s\")\n",argv[i]); | 3507 | printmsg("You have to give number of EMS frames between 1 and 4 (\"%s\")\n",argv[i]); |
3508 | exit(-1); | 3508 | exit(-1); |
3509 | } | 3509 | } |
3510 | bitmap[SMSInfo.EntriesNum].Number = 0; | 3510 | bitmap[SMSInfo.EntriesNum].Number = 0; |
3511 | nextlong = 17; | 3511 | nextlong = 17; |
3512 | break; | 3512 | break; |
3513 | case 17:/*File for EMS animation */ | 3513 | case 17:/*File for EMS animation */ |
3514 | bitmap2.Bitmap[0].Type=GSM_StartupLogo; | 3514 | bitmap2.Bitmap[0].Type=GSM_StartupLogo; |
3515 | error=GSM_ReadBitmapFile(argv[i],&bitmap2); | 3515 | error=GSM_ReadBitmapFile(argv[i],&bitmap2); |
3516 | for (j=0;j<bitmap2.Number;j++) { | 3516 | for (j=0;j<bitmap2.Number;j++) { |
3517 | if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) break; | 3517 | if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) break; |
3518 | memcpy(&bitmap[SMSInfo.EntriesNum].Bitmap[bitmap[SMSInfo.EntriesNum].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap)); | 3518 | memcpy(&bitmap[SMSInfo.EntriesNum].Bitmap[bitmap[SMSInfo.EntriesNum].Number],&bitmap2.Bitmap[j],sizeof(GSM_Bitmap)); |
3519 | bitmap[SMSInfo.EntriesNum].Number++; | 3519 | bitmap[SMSInfo.EntriesNum].Number++; |
3520 | } | 3520 | } |
3521 | if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) { | 3521 | if (bitmap[SMSInfo.EntriesNum].Number == FramesNum) { |
3522 | SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum]; | 3522 | SMSInfo.Entries[SMSInfo.EntriesNum].Bitmap = &bitmap[SMSInfo.EntriesNum]; |
3523 | SMSInfo.EntriesNum++; | 3523 | SMSInfo.EntriesNum++; |
3524 | nextlong = 0; | 3524 | nextlong = 0; |
3525 | } | 3525 | } |
3526 | break; | 3526 | break; |
3527 | case 18:/* EMS text from Unicode file */ | 3527 | case 18:/* EMS text from Unicode file */ |
3528 | f = fopen(argv[i],"rb"); | 3528 | f = fopen(argv[i],"rb"); |
3529 | if (f == NULL) { | 3529 | if (f == NULL) { |
3530 | printmsg("Can't open file \"%s\"\n",argv[i]); | 3530 | printmsg("Can't open file \"%s\"\n",argv[i]); |
3531 | exit(-1); | 3531 | exit(-1); |
3532 | } | 3532 | } |
3533 | z=fread(InputBuffer,1,2000,f); | 3533 | z=fread(InputBuffer,1,2000,f); |
3534 | InputBuffer[z] = 0; | 3534 | InputBuffer[z] = 0; |
3535 | InputBuffer[z+1] = 0; | 3535 | InputBuffer[z+1] = 0; |
3536 | fclose(f); | 3536 | fclose(f); |
3537 | ReadUnicodeFile(Buffer[SMSInfo.EntriesNum],InputBuffer); | 3537 | ReadUnicodeFile(Buffer[SMSInfo.EntriesNum],InputBuffer); |
3538 | dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum])); | 3538 | dbgprintf("buffer is \"%s\"\n",DecodeUnicodeConsole(Buffer[SMSInfo.EntriesNum])); |
3539 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong; | 3539 | SMSInfo.Entries[SMSInfo.EntriesNum].ID = SMS_ConcatenatedTextLong; |
3540 | SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum]; | 3540 | SMSInfo.Entries[SMSInfo.EntriesNum].Buffer = Buffer[SMSInfo.EntriesNum]; |
3541 | SMSInfo.EntriesNum++; | 3541 | SMSInfo.EntriesNum++; |
3542 | nextlong = 0; | 3542 | nextlong = 0; |
3543 | break; | 3543 | break; |
3544 | case 19:/* Number of protected items */ | 3544 | case 19:/* Number of protected items */ |
3545 | Protected = atoi(argv[i]); | 3545 | Protected = atoi(argv[i]); |
3546 | nextlong = 0; | 3546 | nextlong = 0; |
3547 | break; | 3547 | break; |
3548 | case 20:/* Formatting text for EMS */ | 3548 | case 20:/* Formatting text for EMS */ |
3549 | if (SMSInfo.Entries[SMSInfo.EntriesNum-1].ID == SMS_ConcatenatedTextLong) { | 3549 | if (SMSInfo.Entries[SMSInfo.EntriesNum-1].ID == SMS_ConcatenatedTextLong) { |
3550 | for(j=0;j<(int)strlen(argv[i]);j++) { | 3550 | for(j=0;j<(int)strlen(argv[i]);j++) { |
3551 | switch(argv[i][j]) { | 3551 | switch(argv[i][j]) { |
3552 | case 'l': case 'L': | 3552 | case 'l': case 'L': |
3553 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Left = true; | 3553 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Left = true; |
3554 | break; | 3554 | break; |
3555 | case 'c': case 'C': | 3555 | case 'c': case 'C': |
3556 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Center = true; | 3556 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Center = true; |
3557 | break; | 3557 | break; |
3558 | case 'r': case 'R': | 3558 | case 'r': case 'R': |
3559 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Right = true; | 3559 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Right = true; |
3560 | break; | 3560 | break; |
3561 | case 'a': case 'A': | 3561 | case 'a': case 'A': |
3562 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Large = true; | 3562 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Large = true; |
3563 | break; | 3563 | break; |
3564 | case 's': case 'S': | 3564 | case 's': case 'S': |
3565 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Small = true; | 3565 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Small = true; |
3566 | break; | 3566 | break; |
3567 | case 'b': case 'B': | 3567 | case 'b': case 'B': |
3568 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Bold = true; | 3568 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Bold = true; |
3569 | break; | 3569 | break; |
3570 | case 'i': case 'I': | 3570 | case 'i': case 'I': |
3571 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Italic = true; | 3571 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Italic = true; |
3572 | break; | 3572 | break; |
3573 | case 'u': case 'U': | 3573 | case 'u': case 'U': |
3574 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Underlined = true; | 3574 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Underlined = true; |
3575 | break; | 3575 | break; |
3576 | case 't': case 'T': | 3576 | case 't': case 'T': |
3577 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Strikethrough = true; | 3577 | SMSInfo.Entries[SMSInfo.EntriesNum-1].Strikethrough = true; |
3578 | break; | 3578 | break; |
3579 | default: | 3579 | default: |
3580 | printmsg("Unknown parameter \"%c\"\n",argv[i][j]); | 3580 | printmsg("Unknown parameter \"%c\"\n",argv[i][j]); |
3581 | exit(-1); | 3581 | exit(-1); |
3582 | } | 3582 | } |
3583 | } | 3583 | } |
3584 | } else { | 3584 | } else { |
3585 | printmsg("Last parameter wasn't text\n"); | 3585 | printmsg("Last parameter wasn't text\n"); |
3586 | exit(-1); | 3586 | exit(-1); |
3587 | } | 3587 | } |
3588 | nextlong = 0; | 3588 | nextlong = 0; |
3589 | break; | 3589 | break; |
3590 | case 21:/*MaxSMS*/ | 3590 | case 21:/*MaxSMS*/ |
3591 | MaxSMS = atoi(argv[i]); | 3591 | MaxSMS = atoi(argv[i]); |
3592 | nextlong = 0; | 3592 | nextlong = 0; |
3593 | break; | 3593 | break; |
3594 | case 22:/* profile name */ | 3594 | case 22:/* profile name */ |
3595 | EncodeUnicode(Buffer[0],argv[i],strlen(argv[i])); | 3595 | EncodeUnicode(Buffer[0],argv[i],strlen(argv[i])); |
3596 | SMSInfo.Entries[0].Buffer = Buffer[0]; | 3596 | SMSInfo.Entries[0].Buffer = Buffer[0]; |
3597 | nextlong = 0; | 3597 | nextlong = 0; |
3598 | break; | 3598 | break; |
3599 | case 23:/* profile ringtone */ | 3599 | case 23:/* profile ringtone */ |
3600 | ringtone[0].Format = RING_NOTETONE; | 3600 | ringtone[0].Format = RING_NOTETONE; |
3601 | error=GSM_ReadRingtoneFile(argv[i],&ringtone[0]); | 3601 | error=GSM_ReadRingtoneFile(argv[i],&ringtone[0]); |
3602 | Print_Error(error); | 3602 | Print_Error(error); |
3603 | SMSInfo.Entries[0].Ringtone = &ringtone[0]; | 3603 | SMSInfo.Entries[0].Ringtone = &ringtone[0]; |
3604 | nextlong = 0; | 3604 | nextlong = 0; |
3605 | break; | 3605 | break; |
3606 | case 24:/* profile bitmap */ | 3606 | case 24:/* profile bitmap */ |
3607 | bitmap[0].Bitmap[0].Type = GSM_PictureImage; | 3607 | bitmap[0].Bitmap[0].Type = GSM_PictureImage; |
3608 | error=GSM_ReadBitmapFile(argv[i],&bitmap[0]); | 3608 | error=GSM_ReadBitmapFile(argv[i],&bitmap[0]); |
3609 | Print_Error(error); | 3609 | Print_Error(error); |
3610 | bitmap[0].Bitmap[0].Text[0] = 0; | 3610 | bitmap[0].Bitmap[0].Text[0] = 0; |
3611 | bitmap[0].Bitmap[0].Text[1] = 0; | 3611 | bitmap[0].Bitmap[0].Text[1] = 0; |
3612 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; | 3612 | SMSInfo.Entries[0].Bitmap = &bitmap[0]; |
3613 | nextlong = 0; | 3613 | nextlong = 0; |
3614 | break; | 3614 | break; |
3615 | } | 3615 | } |
3616 | } | 3616 | } |
3617 | if (nextlong!=0) { | 3617 | if (nextlong!=0) { |
3618 | printmsg("Parameter missed...\n"); | 3618 | printmsg("Parameter missed...\n"); |
3619 | exit(-1); | 3619 | exit(-1); |
3620 | } | 3620 | } |
3621 | 3621 | ||
3622 | if (mystrncasecmp(argv[2],"EMS",0) && EMS16Bit) { | 3622 | if (mystrncasecmp(argv[2],"EMS",0) && EMS16Bit) { |
3623 | for (i=0;i<SMSInfo.EntriesNum;i++) { | 3623 | for (i=0;i<SMSInfo.EntriesNum;i++) { |
3624 | switch (SMSInfo.Entries[i].ID) { | 3624 | switch (SMSInfo.Entries[i].ID) { |
3625 | case SMS_ConcatenatedTextLong: | 3625 | case SMS_ConcatenatedTextLong: |
3626 | SMSInfo.Entries[i].ID = SMS_ConcatenatedTextLong16bit; | 3626 | SMSInfo.Entries[i].ID = SMS_ConcatenatedTextLong16bit; |
3627 | default: | 3627 | default: |
3628 | break; | 3628 | break; |
3629 | 3629 | ||
3630 | } | 3630 | } |
3631 | } | 3631 | } |
3632 | 3632 | ||
3633 | } | 3633 | } |
3634 | if (mystrncasecmp(argv[2],"TEXT",0)) { | 3634 | if (mystrncasecmp(argv[2],"TEXT",0)) { |
3635 | chars_read = UnicodeLength(Buffer[0]); | 3635 | chars_read = UnicodeLength(Buffer[0]); |
3636 | if (chars_read != 0) { | 3636 | if (chars_read != 0) { |
3637 | /* Trim \n at the end of string */ | 3637 | /* Trim \n at the end of string */ |
3638 | if (Buffer[0][chars_read*2-1] == '\n' && Buffer[0][chars_read*2-2] == 0) | 3638 | if (Buffer[0][chars_read*2-1] == '\n' && Buffer[0][chars_read*2-2] == 0) |
3639 | { | 3639 | { |
3640 | Buffer[0][chars_read*2-1] = 0; | 3640 | Buffer[0][chars_read*2-1] = 0; |
3641 | } | 3641 | } |
3642 | } | 3642 | } |
3643 | } | 3643 | } |
3644 | 3644 | ||
3645 | if (mystrncasecmp(argv[1],"--displaysms",0) || mystrncasecmp(argv[1],"--sendsmsdsms",0)) { | 3645 | if (mystrncasecmp(argv[1],"--displaysms",0) || mystrncasecmp(argv[1],"--sendsmsdsms",0)) { |
3646 | if (mystrncasecmp(argv[2],"OPERATOR",0)) { | 3646 | if (mystrncasecmp(argv[2],"OPERATOR",0)) { |
3647 | if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) { | 3647 | if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) { |
3648 | printmsg("No network code\n"); | 3648 | printmsg("No network code\n"); |
3649 | exit(-1); | 3649 | exit(-1); |
3650 | } | 3650 | } |
3651 | } | 3651 | } |
3652 | } else { | 3652 | } else { |
3653 | GSM_Init(true); | 3653 | GSM_Init(true); |
3654 | 3654 | ||
3655 | if (mystrncasecmp(argv[2],"OPERATOR",0)) { | 3655 | if (mystrncasecmp(argv[2],"OPERATOR",0)) { |
3656 | if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) { | 3656 | if (bitmap[0].Bitmap[0].Type==GSM_OperatorLogo && strcmp(bitmap[0].Bitmap[0].NetworkCode,"000 00")==0) { |
3657 | error=Phone->GetNetworkInfo(&s,&NetInfo); | 3657 | error=Phone->GetNetworkInfo(&s,&NetInfo); |
3658 | Print_Error(error); | 3658 | Print_Error(error); |
3659 | strcpy(bitmap[0].Bitmap[0].NetworkCode,NetInfo.NetworkCode); | 3659 | strcpy(bitmap[0].Bitmap[0].NetworkCode,NetInfo.NetworkCode); |
3660 | if (mystrncasecmp(argv[1],"--savesms",0)) { | 3660 | if (mystrncasecmp(argv[1],"--savesms",0)) { |
3661 | EncodeUnicode(Sender, "OpLogo",6); | 3661 | EncodeUnicode(Sender, "OpLogo",6); |
3662 | EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3); | 3662 | EncodeUnicode(Sender+6*2,bitmap[0].Bitmap[0].NetworkCode,3); |
3663 | EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2); | 3663 | EncodeUnicode(Sender+6*2+3*2,bitmap[0].Bitmap[0].NetworkCode+4,2); |
3664 | if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) { | 3664 | if (UnicodeLength(GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode))<GSM_MAX_SMS_NAME_LENGTH-7) { |
3665 | EncodeUnicode(Name,"OpLogo ",7); | 3665 | EncodeUnicode(Name,"OpLogo ",7); |
3666 | CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)); | 3666 | CopyUnicodeString(Name+7*2,GSM_GetNetworkName(bitmap[0].Bitmap[0].NetworkCode)); |
3667 | } else { | 3667 | } else { |
3668 | CopyUnicodeString(Name,Sender); | 3668 | CopyUnicodeString(Name,Sender); |
3669 | } | 3669 | } |
3670 | } | 3670 | } |
3671 | } | 3671 | } |
3672 | } | 3672 | } |
3673 | } | 3673 | } |
3674 | 3674 | ||
3675 | error=GSM_EncodeMultiPartSMS(&SMSInfo,&sms); | 3675 | error=GSM_EncodeMultiPartSMS(&SMSInfo,&sms); |
3676 | Print_Error(error); | 3676 | Print_Error(error); |
3677 | 3677 | ||
3678 | for (i=0;i<SMSInfo.EntriesNum;i++) { | 3678 | for (i=0;i<SMSInfo.EntriesNum;i++) { |
3679 | switch (SMSInfo.Entries[i].ID) { | 3679 | switch (SMSInfo.Entries[i].ID) { |
3680 | case SMS_NokiaRingtone: | 3680 | case SMS_NokiaRingtone: |
3681 | case SMS_NokiaRingtoneLong: | 3681 | case SMS_NokiaRingtoneLong: |
3682 | case SMS_NokiaProfileLong: | 3682 | case SMS_NokiaProfileLong: |
3683 | case SMS_EMSSound10: | 3683 | case SMS_EMSSound10: |
3684 | case SMS_EMSSound12: | 3684 | case SMS_EMSSound12: |
3685 | case SMS_EMSSonyEricssonSound: | 3685 | case SMS_EMSSonyEricssonSound: |
3686 | case SMS_EMSSound10Long: | 3686 | case SMS_EMSSound10Long: |
3687 | case SMS_EMSSound12Long: | 3687 | case SMS_EMSSound12Long: |
3688 | case SMS_EMSSonyEricssonSoundLong: | 3688 | case SMS_EMSSonyEricssonSoundLong: |
3689 | if (SMSInfo.Entries[i].RingtoneNotes!=SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands) { | 3689 | if (SMSInfo.Entries[i].RingtoneNotes!=SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands) { |
3690 | printmsg("Warning: ringtone too long. %i percent part cut\n", | 3690 | printmsg("Warning: ringtone too long. %i percent part cut\n", |
3691 | (SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands-SMSInfo.Entries[i].RingtoneNotes)*100/SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands); | 3691 | (SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands-SMSInfo.Entries[i].RingtoneNotes)*100/SMSInfo.Entries[i].Ringtone->NoteTone.NrCommands); |
3692 | } | 3692 | } |
3693 | default: | 3693 | default: |
3694 | break; | 3694 | break; |
3695 | 3695 | ||
3696 | } | 3696 | } |
3697 | } | 3697 | } |
3698 | if (MaxSMS != -1 && sms.Number > MaxSMS) { | 3698 | if (MaxSMS != -1 && sms.Number > MaxSMS) { |
3699 | printmsg("There is %i SMS packed and %i limit. Exiting\n",sms.Number,MaxSMS); | 3699 | printmsg("There is %i SMS packed and %i limit. Exiting\n",sms.Number,MaxSMS); |
3700 | if (!mystrncasecmp(argv[1],"--displaysms",0) && !mystrncasecmp(argv[1],"--sendsmsdsms",0)) GSM_Terminate(); | 3700 | if (!mystrncasecmp(argv[1],"--displaysms",0) && !mystrncasecmp(argv[1],"--sendsmsdsms",0)) GSM_Terminate(); |
3701 | exit(-1); | 3701 | exit(-1); |
3702 | } | 3702 | } |
3703 | 3703 | ||
3704 | if (mystrncasecmp(argv[1],"--displaysms",0)) { | 3704 | if (mystrncasecmp(argv[1],"--displaysms",0)) { |
3705 | if (SMSCSet != 0) { | 3705 | if (SMSCSet != 0) { |
3706 | printmsg("Use -smscnumber option to give SMSC number\n"); | 3706 | printmsg("Use -smscnumber option to give SMSC number\n"); |
3707 | exit(-1); | 3707 | exit(-1); |
3708 | } | 3708 | } |
3709 | 3709 | ||
3710 | for (i=0;i<sms.Number;i++) { | 3710 | for (i=0;i<sms.Number;i++) { |
3711 | sms.SMS[i].Location = 0; | 3711 | sms.SMS[i].Location = 0; |
3712 | sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; | 3712 | sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; |
3713 | sms.SMS[i].SMSC.Location = 0; | 3713 | sms.SMS[i].SMSC.Location = 0; |
3714 | sms.SMS[i].PDU = SMS_Submit; | 3714 | sms.SMS[i].PDU = SMS_Submit; |
3715 | if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; | 3715 | if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; |
3716 | CopyUnicodeString(sms.SMS[i].Number, Sender); | 3716 | CopyUnicodeString(sms.SMS[i].Number, Sender); |
3717 | CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); | 3717 | CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); |
3718 | if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); | 3718 | if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); |
3719 | DisplaySMSFrame(&sms.SMS[i]); | 3719 | DisplaySMSFrame(&sms.SMS[i]); |
3720 | } | 3720 | } |
3721 | 3721 | ||
3722 | printmsg("\nNumber of SMS: %i\n",sms.Number); | 3722 | printmsg("\nNumber of SMS: %i\n",sms.Number); |
3723 | exit(sms.Number); | 3723 | exit(sms.Number); |
3724 | } | 3724 | } |
3725 | if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) { | 3725 | if (mystrncasecmp(argv[1],"--sendsmsdsms",0)) { |
3726 | if (SMSCSet != 0) { | 3726 | if (SMSCSet != 0) { |
3727 | printmsg("Use -smscnumber option to give SMSC number\n"); | 3727 | printmsg("Use -smscnumber option to give SMSC number\n"); |
3728 | exit(-1); | 3728 | exit(-1); |
3729 | } | 3729 | } |
3730 | 3730 | ||
3731 | for (i=0;i<sms.Number;i++) { | 3731 | for (i=0;i<sms.Number;i++) { |
3732 | sms.SMS[i].Location = 0; | 3732 | sms.SMS[i].Location = 0; |
3733 | sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; | 3733 | sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; |
3734 | sms.SMS[i].SMSC.Location = 0; | 3734 | sms.SMS[i].SMSC.Location = 0; |
3735 | sms.SMS[i].PDU = SMS_Submit; | 3735 | sms.SMS[i].PDU = SMS_Submit; |
3736 | if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; | 3736 | if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; |
3737 | CopyUnicodeString(sms.SMS[i].Number, Sender); | 3737 | CopyUnicodeString(sms.SMS[i].Number, Sender); |
3738 | CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); | 3738 | CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); |
3739 | if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); | 3739 | if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); |
3740 | } | 3740 | } |
3741 | SMSDaemonSendSMS(argv[4],argv[5],&sms); | 3741 | SMSDaemonSendSMS(argv[4],argv[5],&sms); |
3742 | exit(0); | 3742 | exit(0); |
3743 | } | 3743 | } |
3744 | if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) { | 3744 | if (mystrncasecmp(argv[1],"--savesms",0) || SendSaved) { |
3745 | error=Phone->GetSMSFolders(&s, &folders); | 3745 | error=Phone->GetSMSFolders(&s, &folders); |
3746 | Print_Error(error); | 3746 | Print_Error(error); |
3747 | 3747 | ||
3748 | if (SendSaved){ | 3748 | if (SendSaved){ |
3749 | if (Validity.Format != 0 && SMSCSet != 0) { | 3749 | if (Validity.Format != 0 && SMSCSet != 0) { |
3750 | PhoneSMSC.Location = SMSCSet; | 3750 | PhoneSMSC.Location = SMSCSet; |
3751 | error=Phone->GetSMSC(&s,&PhoneSMSC); | 3751 | error=Phone->GetSMSC(&s,&PhoneSMSC); |
3752 | Print_Error(error); | 3752 | Print_Error(error); |
3753 | CopyUnicodeString(SMSC,PhoneSMSC.Number); | 3753 | CopyUnicodeString(SMSC,PhoneSMSC.Number); |
3754 | SMSCSet = 0; | 3754 | SMSCSet = 0; |
3755 | } | 3755 | } |
3756 | 3756 | ||
3757 | s.User.SendSMSStatus = SendSMSStatus; | 3757 | s.User.SendSMSStatus = SendSMSStatus; |
3758 | 3758 | ||
3759 | signal(SIGINT, interrupt); | 3759 | signal(SIGINT, interrupt); |
3760 | printmsgerr("If you want break, press Ctrl+C...\n"); | 3760 | printmsgerr("If you want break, press Ctrl+C...\n"); |
3761 | } | 3761 | } |
3762 | 3762 | ||
3763 | for (i=0;i<sms.Number;i++) { | 3763 | for (i=0;i<sms.Number;i++) { |
3764 | printmsg("Saving SMS %i/%i\n",i+1,sms.Number); | 3764 | printmsg("Saving SMS %i/%i\n",i+1,sms.Number); |
3765 | // sms.SMS[i].Location = 0; | 3765 | // sms.SMS[i].Location = 0; |
3766 | sms.SMS[i].Folder = Folder; | 3766 | sms.SMS[i].Folder = Folder; |
3767 | sms.SMS[i].State = State; | 3767 | sms.SMS[i].State = State; |
3768 | sms.SMS[i].ReplyViaSameSMSC= ReplyViaSameSMSC; | 3768 | sms.SMS[i].ReplyViaSameSMSC= ReplyViaSameSMSC; |
3769 | sms.SMS[i].SMSC.Location= SMSCSet; | 3769 | sms.SMS[i].SMSC.Location= SMSCSet; |
3770 | 3770 | ||
3771 | if (SendSaved){ | 3771 | if (SendSaved){ |
3772 | sms.SMS[i].PDU= SMS_Submit; | 3772 | sms.SMS[i].PDU= SMS_Submit; |
3773 | if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report; | 3773 | if (DeliveryReport) sms.SMS[i].PDU = SMS_Status_Report; |
3774 | if (Validity.Format != 0) sms.SMS[i].SMSC.Validity = Validity; | 3774 | if (Validity.Format != 0) sms.SMS[i].SMSC.Validity = Validity; |
3775 | } else { | 3775 | } else { |
3776 | sms.SMS[i].PDU= SMS_Deliver; | 3776 | sms.SMS[i].PDU= SMS_Deliver; |
3777 | } | 3777 | } |
3778 | 3778 | ||
3779 | CopyUnicodeString(sms.SMS[i].Number, Sender); | 3779 | CopyUnicodeString(sms.SMS[i].Number, Sender); |
3780 | CopyUnicodeString(sms.SMS[i].Name, Name); | 3780 | CopyUnicodeString(sms.SMS[i].Name, Name); |
3781 | if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); | 3781 | if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); |
3782 | error=Phone->AddSMS(&s, &sms.SMS[i]); | 3782 | error=Phone->AddSMS(&s, &sms.SMS[i]); |
3783 | Print_Error(error); | 3783 | Print_Error(error); |
3784 | printmsg("Saved in folder \"%s\", location %i\n", | 3784 | printmsg("Saved in folder \"%s\", location %i\n", |
3785 | DecodeUnicodeConsole(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); | 3785 | DecodeUnicodeConsole(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); |
3786 | 3786 | ||
3787 | if (SendSaved) { | 3787 | if (SendSaved) { |
3788 | printmsg("Sending sms from folder \"%s\", location %i\n", | 3788 | printmsg("Sending sms from folder \"%s\", location %i\n", |
3789 | DecodeUnicodeString(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); | 3789 | DecodeUnicodeString(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location); |
3790 | SMSStatus = ERR_TIMEOUT; | 3790 | SMSStatus = ERR_TIMEOUT; |
3791 | error=Phone->SendSavedSMS(&s, 0, sms.SMS[i].Location); | 3791 | error=Phone->SendSavedSMS(&s, 0, sms.SMS[i].Location); |
3792 | Print_Error(error); | 3792 | Print_Error(error); |
3793 | printmsg("....waiting for network answer"); | 3793 | printmsg("....waiting for network answer"); |
3794 | while (!gshutdown) { | 3794 | while (!gshutdown) { |
3795 | GSM_ReadDevice(&s,true); | 3795 | GSM_ReadDevice(&s,true); |
3796 | if (SMSStatus == ERR_UNKNOWN) { | 3796 | if (SMSStatus == ERR_UNKNOWN) { |
3797 | GSM_Terminate(); | 3797 | GSM_Terminate(); |
3798 | exit(-1); | 3798 | exit(-1); |
3799 | } | 3799 | } |
3800 | if (SMSStatus == ERR_NONE) break; | 3800 | if (SMSStatus == ERR_NONE) break; |
3801 | } | 3801 | } |
3802 | } | 3802 | } |
3803 | } | 3803 | } |
3804 | } else { | 3804 | } else { |
3805 | if (Validity.Format != 0 && SMSCSet != 0) { | 3805 | if (Validity.Format != 0 && SMSCSet != 0) { |
3806 | PhoneSMSC.Location = SMSCSet; | 3806 | PhoneSMSC.Location = SMSCSet; |
3807 | error=Phone->GetSMSC(&s,&PhoneSMSC); | 3807 | error=Phone->GetSMSC(&s,&PhoneSMSC); |
3808 | Print_Error(error); | 3808 | Print_Error(error); |
3809 | CopyUnicodeString(SMSC,PhoneSMSC.Number); | 3809 | CopyUnicodeString(SMSC,PhoneSMSC.Number); |
3810 | SMSCSet = 0; | 3810 | SMSCSet = 0; |
3811 | } | 3811 | } |
3812 | 3812 | ||
3813 | signal(SIGINT, interrupt); | 3813 | signal(SIGINT, interrupt); |
3814 | printmsgerr("If you want break, press Ctrl+C...\n"); | 3814 | printmsgerr("If you want break, press Ctrl+C...\n"); |
3815 | 3815 | ||
3816 | s.User.SendSMSStatus = SendSMSStatus; | 3816 | s.User.SendSMSStatus = SendSMSStatus; |
3817 | 3817 | ||
3818 | for (i=0;i<sms.Number;i++) { | 3818 | for (i=0;i<sms.Number;i++) { |
3819 | printmsg("Sending SMS %i/%i",i+1,sms.Number); | 3819 | printmsg("Sending SMS %i/%i",i+1,sms.Number); |
3820 | sms.SMS[i].Location = 0; | 3820 | sms.SMS[i].Location = 0; |
3821 | sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; | 3821 | sms.SMS[i].ReplyViaSameSMSC = ReplyViaSameSMSC; |
3822 | sms.SMS[i].SMSC.Location = SMSCSet; | 3822 | sms.SMS[i].SMSC.Location = SMSCSet; |
3823 | sms.SMS[i].PDU = SMS_Submit; | 3823 | sms.SMS[i].PDU = SMS_Submit; |
3824 | if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; | 3824 | if (DeliveryReport) sms.SMS[i].PDU= SMS_Status_Report; |
3825 | CopyUnicodeString(sms.SMS[i].Number, Sender); | 3825 | CopyUnicodeString(sms.SMS[i].Number, Sender); |
3826 | if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); | 3826 | if (SMSCSet==0) CopyUnicodeString(sms.SMS[i].SMSC.Number, SMSC); |
3827 | if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); | 3827 | if (Validity.Format != 0) memcpy(&sms.SMS[i].SMSC.Validity,&Validity,sizeof(GSM_SMSValidity)); |
3828 | SMSStatus = ERR_TIMEOUT; | 3828 | SMSStatus = ERR_TIMEOUT; |
3829 | error=Phone->SendSMS(&s, &sms.SMS[i]); | 3829 | error=Phone->SendSMS(&s, &sms.SMS[i]); |
3830 | Print_Error(error); | 3830 | Print_Error(error); |
3831 | printmsg("....waiting for network answer"); | 3831 | printmsg("....waiting for network answer"); |
3832 | while (!gshutdown) { | 3832 | while (!gshutdown) { |
3833 | GSM_ReadDevice(&s,true); | 3833 | GSM_ReadDevice(&s,true); |
3834 | if (SMSStatus == ERR_UNKNOWN) { | 3834 | if (SMSStatus == ERR_UNKNOWN) { |
3835 | GSM_Terminate(); | 3835 | GSM_Terminate(); |
3836 | exit(-1); | 3836 | exit(-1); |
3837 | } | 3837 | } |
3838 | if (SMSStatus == ERR_NONE) break; | 3838 | if (SMSStatus == ERR_NONE) break; |
3839 | } | 3839 | } |
3840 | } | 3840 | } |
3841 | } | 3841 | } |
3842 | 3842 | ||
3843 | GSM_Terminate(); | 3843 | GSM_Terminate(); |
3844 | } | 3844 | } |
3845 | 3845 | ||
3846 | #ifdef GSM_ENABLE_BACKUP | 3846 | #ifdef GSM_ENABLE_BACKUP |
3847 | static void SaveFile(int argc, char *argv[]) | 3847 | static void SaveFile(int argc, char *argv[]) |
3848 | { | 3848 | { |
3849 | GSM_Backup Backup; | 3849 | GSM_Backup Backup; |
3850 | int i,j; | 3850 | int i,j; |
3851 | FILE *file; | 3851 | FILE *file; |
3852 | unsigned char Buffer[10000]; | 3852 | unsigned char Buffer[10000]; |
3853 | GSM_MemoryEntry *pbk; | 3853 | GSM_MemoryEntry *pbk; |
3854 | 3854 | ||
3855 | if (mystrncasecmp(argv[2],"CALENDAR",0)) { | 3855 | if (mystrncasecmp(argv[2],"CALENDAR",0)) { |
3856 | if (argc<5) { | 3856 | if (argc<5) { |
3857 | printmsg("Where is backup filename and location ?\n"); | 3857 | printmsg("Where is backup filename and location ?\n"); |
3858 | exit(-1); | 3858 | exit(-1); |
3859 | } | 3859 | } |
3860 | error=GSM_ReadBackupFile(argv[4],&Backup); | 3860 | error=GSM_ReadBackupFile(argv[4],&Backup); |
3861 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 3861 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
3862 | i = 0; | 3862 | i = 0; |
3863 | while (Backup.Calendar[i]!=NULL) { | 3863 | while (Backup.Calendar[i]!=NULL) { |
3864 | if (i == atoi(argv[5])-1) break; | 3864 | if (i == atoi(argv[5])-1) break; |
3865 | i++; | 3865 | i++; |
3866 | } | 3866 | } |
3867 | if (i != atoi(argv[5])-1) { | 3867 | if (i != atoi(argv[5])-1) { |
3868 | printmsg("Calendar note not found in file\n"); | 3868 | printmsg("Calendar note not found in file\n"); |
3869 | exit(-1); | 3869 | exit(-1); |
3870 | } | 3870 | } |
3871 | j = 0; | 3871 | j = 0; |
3872 | GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar); | 3872 | GSM_EncodeVCALENDAR(Buffer, &j, Backup.Calendar[i],true,Nokia_VCalendar); |
3873 | } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { | 3873 | } else if (mystrncasecmp(argv[2],"BOOKMARK",0)) { |
3874 | if (argc<5) { | 3874 | if (argc<5) { |
3875 | printmsg("Where is backup filename and location ?\n"); | 3875 | printmsg("Where is backup filename and location ?\n"); |
3876 | exit(-1); | 3876 | exit(-1); |
3877 | } | 3877 | } |
3878 | error=GSM_ReadBackupFile(argv[4],&Backup); | 3878 | error=GSM_ReadBackupFile(argv[4],&Backup); |
3879 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 3879 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
3880 | i = 0; | 3880 | i = 0; |
3881 | while (Backup.WAPBookmark[i]!=NULL) { | 3881 | while (Backup.WAPBookmark[i]!=NULL) { |
3882 | if (i == atoi(argv[5])-1) break; | 3882 | if (i == atoi(argv[5])-1) break; |
3883 | i++; | 3883 | i++; |
3884 | } | 3884 | } |
3885 | if (i != atoi(argv[5])-1) { | 3885 | if (i != atoi(argv[5])-1) { |
3886 | printmsg("WAP bookmark not found in file\n"); | 3886 | printmsg("WAP bookmark not found in file\n"); |
3887 | exit(-1); | 3887 | exit(-1); |
3888 | } | 3888 | } |
3889 | j = 0; | 3889 | j = 0; |
3890 | GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]); | 3890 | GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]); |
3891 | } else if (mystrncasecmp(argv[2],"NOTE",0)) { | 3891 | } else if (mystrncasecmp(argv[2],"NOTE",0)) { |
3892 | if (argc<5) { | 3892 | if (argc<5) { |
3893 | printmsg("Where is backup filename and location ?\n"); | 3893 | printmsg("Where is backup filename and location ?\n"); |
3894 | exit(-1); | 3894 | exit(-1); |
3895 | } | 3895 | } |
3896 | error=GSM_ReadBackupFile(argv[4],&Backup); | 3896 | error=GSM_ReadBackupFile(argv[4],&Backup); |
3897 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 3897 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
3898 | i = 0; | 3898 | i = 0; |
3899 | while (Backup.Note[i]!=NULL) { | 3899 | while (Backup.Note[i]!=NULL) { |
3900 | if (i == atoi(argv[5])-1) break; | 3900 | if (i == atoi(argv[5])-1) break; |
3901 | i++; | 3901 | i++; |
3902 | } | 3902 | } |
3903 | if (i != atoi(argv[5])-1) { | 3903 | if (i != atoi(argv[5])-1) { |
3904 | printmsg("Note not found in file\n"); | 3904 | printmsg("Note not found in file\n"); |
3905 | exit(-1); | 3905 | exit(-1); |
3906 | } | 3906 | } |
3907 | j = 0; | 3907 | j = 0; |
3908 | GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]); | 3908 | GSM_EncodeVNTFile(Buffer, &j, Backup.Note[i]); |
3909 | } else if (mystrncasecmp(argv[2],"TODO",0)) { | 3909 | } else if (mystrncasecmp(argv[2],"TODO",0)) { |
3910 | if (argc<5) { | 3910 | if (argc<5) { |
3911 | printmsg("Where is backup filename and location ?\n"); | 3911 | printmsg("Where is backup filename and location ?\n"); |
3912 | exit(-1); | 3912 | exit(-1); |
3913 | } | 3913 | } |
3914 | error=GSM_ReadBackupFile(argv[4],&Backup); | 3914 | error=GSM_ReadBackupFile(argv[4],&Backup); |
3915 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 3915 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
3916 | i = 0; | 3916 | i = 0; |
3917 | while (Backup.ToDo[i]!=NULL) { | 3917 | while (Backup.ToDo[i]!=NULL) { |
3918 | if (i == atoi(argv[5])-1) break; | 3918 | if (i == atoi(argv[5])-1) break; |
3919 | i++; | 3919 | i++; |
3920 | } | 3920 | } |
3921 | if (i != atoi(argv[5])-1) { | 3921 | if (i != atoi(argv[5])-1) { |
3922 | printmsg("ToDo note not found in file\n"); | 3922 | printmsg("ToDo note not found in file\n"); |
3923 | exit(-1); | 3923 | exit(-1); |
3924 | } | 3924 | } |
3925 | j = 0; | 3925 | j = 0; |
3926 | GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo); | 3926 | GSM_EncodeVTODO(Buffer, &j, Backup.ToDo[i], true, Nokia_VToDo); |
3927 | } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { | 3927 | } else if (mystrncasecmp(argv[2],"VCARD10",0) || mystrncasecmp(argv[2],"VCARD21",0)) { |
3928 | if (argc<6) { | 3928 | if (argc<6) { |
3929 | printmsg("Where is backup filename and location and memory type ?\n"); | 3929 | printmsg("Where is backup filename and location and memory type ?\n"); |
3930 | exit(-1); | 3930 | exit(-1); |
3931 | } | 3931 | } |
3932 | error=GSM_ReadBackupFile(argv[4],&Backup); | 3932 | error=GSM_ReadBackupFile(argv[4],&Backup); |
3933 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 3933 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
3934 | i = 0; | 3934 | i = 0; |
3935 | if (mystrncasecmp(argv[5],"SM",0)) { | 3935 | if (mystrncasecmp(argv[5],"SM",0)) { |
3936 | while (Backup.SIMPhonebook[i]!=NULL) { | 3936 | while (Backup.SIMPhonebook[i]!=NULL) { |
3937 | if (i == atoi(argv[6])-1) break; | 3937 | if (i == atoi(argv[6])-1) break; |
3938 | i++; | 3938 | i++; |
3939 | } | 3939 | } |
3940 | if (i != atoi(argv[6])-1) { | 3940 | if (i != atoi(argv[6])-1) { |
3941 | printmsg("Phonebook entry not found in file\n"); | 3941 | printmsg("Phonebook entry not found in file\n"); |
3942 | exit(-1); | 3942 | exit(-1); |
3943 | } | 3943 | } |
3944 | pbk = Backup.SIMPhonebook[i]; | 3944 | pbk = Backup.SIMPhonebook[i]; |
3945 | } else if (mystrncasecmp(argv[5],"ME",0)) { | 3945 | } else if (mystrncasecmp(argv[5],"ME",0)) { |
3946 | while (Backup.PhonePhonebook[i]!=NULL) { | 3946 | while (Backup.PhonePhonebook[i]!=NULL) { |
3947 | if (i == atoi(argv[6])-1) break; | 3947 | if (i == atoi(argv[6])-1) break; |
3948 | i++; | 3948 | i++; |
3949 | } | 3949 | } |
3950 | if (i != atoi(argv[6])-1) { | 3950 | if (i != atoi(argv[6])-1) { |
3951 | printmsg("Phonebook entry not found in file\n"); | 3951 | printmsg("Phonebook entry not found in file\n"); |
3952 | exit(-1); | 3952 | exit(-1); |
3953 | } | 3953 | } |
3954 | pbk = Backup.PhonePhonebook[i]; | 3954 | pbk = Backup.PhonePhonebook[i]; |
3955 | } else { | 3955 | } else { |
3956 | printmsg("Unknown memory type: \"%s\"\n",argv[5]); | 3956 | printmsg("Unknown memory type: \"%s\"\n",argv[5]); |
3957 | exit(-1); | 3957 | exit(-1); |
3958 | } | 3958 | } |
3959 | j = 0; | 3959 | j = 0; |
3960 | if (mystrncasecmp(argv[2],"VCARD10",0)) { | 3960 | if (mystrncasecmp(argv[2],"VCARD10",0)) { |
3961 | GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard10); | 3961 | GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard10); |
3962 | } else { | 3962 | } else { |
3963 | GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard21); | 3963 | GSM_EncodeVCARD(Buffer,&j,pbk,true,Nokia_VCard21); |
3964 | } | 3964 | } |
3965 | } else { | 3965 | } else { |
3966 | printmsg("What format of file (\"%s\") ?\n",argv[2]); | 3966 | printmsg("What format of file (\"%s\") ?\n",argv[2]); |
3967 | exit(-1); | 3967 | exit(-1); |
3968 | } | 3968 | } |
3969 | 3969 | ||
3970 | file = fopen(argv[3],"wb"); | 3970 | file = fopen(argv[3],"wb"); |
3971 | fwrite(Buffer,1,j,file); | 3971 | fwrite(Buffer,1,j,file); |
3972 | fclose(file); | 3972 | fclose(file); |
3973 | } | 3973 | } |
3974 | 3974 | ||
3975 | static void Backup(int argc, char *argv[]) | 3975 | static void Backup(int argc, char *argv[]) |
3976 | { | 3976 | { |
3977 | int i, used; | 3977 | int i, used; |
3978 | GSM_MemoryStatusMemStatus; | 3978 | GSM_MemoryStatusMemStatus; |
3979 | GSM_ToDoEntry ToDo; | 3979 | GSM_ToDoEntry ToDo; |
3980 | GSM_ToDoStatus ToDoStatus; | 3980 | GSM_ToDoStatus ToDoStatus; |
3981 | GSM_MemoryEntry Pbk; | 3981 | GSM_MemoryEntry Pbk; |
3982 | GSM_CalendarEntryCalendar; | 3982 | GSM_CalendarEntryCalendar; |
3983 | GSM_Bitmap Bitmap; | 3983 | GSM_Bitmap Bitmap; |
3984 | GSM_WAPBookmark Bookmark; | 3984 | GSM_WAPBookmark Bookmark; |
3985 | GSM_Profile Profile; | 3985 | GSM_Profile Profile; |
3986 | GSM_MultiWAPSettingsSettings; | 3986 | GSM_MultiWAPSettingsSettings; |
3987 | GSM_SyncMLSettingsSyncML; | 3987 | GSM_SyncMLSettingsSyncML; |
3988 | GSM_ChatSettingsChat; | 3988 | GSM_ChatSettingsChat; |
3989 | GSM_Ringtone Ringtone; | 3989 | GSM_Ringtone Ringtone; |
3990 | GSM_SMSC SMSC; | 3990 | GSM_SMSC SMSC; |
3991 | GSM_Backup Backup; | 3991 | GSM_Backup Backup; |
3992 | GSM_NoteEntry Note; | 3992 | GSM_NoteEntry Note; |
3993 | GSM_Backup_Info Info; | 3993 | GSM_Backup_Info Info; |
3994 | GSM_FMStation FMStation; | 3994 | GSM_FMStation FMStation; |
3995 | GSM_GPRSAccessPointGPRSPoint; | 3995 | GSM_GPRSAccessPointGPRSPoint; |
3996 | bool DoBackup; | 3996 | bool DoBackup; |
3997 | 3997 | ||
3998 | if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true; | 3998 | if (argc == 4 && mystrncasecmp(argv[3],"-yes",0)) always_answer_yes = true; |
3999 | 3999 | ||
4000 | GSM_ClearBackup(&Backup); | 4000 | GSM_ClearBackup(&Backup); |
4001 | GSM_GetBackupFormatFeatures(argv[2],&Info); | 4001 | GSM_GetBackupFormatFeatures(argv[2],&Info); |
4002 | 4002 | ||
4003 | sprintf(Backup.Creator,"Gammu %s",VERSION); | 4003 | sprintf(Backup.Creator,"Gammu %s",VERSION); |
4004 | if (strlen(GetOS()) != 0) { | 4004 | if (strlen(GetOS()) != 0) { |
4005 | strcat(Backup.Creator+strlen(Backup.Creator),", "); | 4005 | strcat(Backup.Creator+strlen(Backup.Creator),", "); |
4006 | strcat(Backup.Creator+strlen(Backup.Creator),GetOS()); | 4006 | strcat(Backup.Creator+strlen(Backup.Creator),GetOS()); |
4007 | } | 4007 | } |
4008 | if (strlen(GetCompiler()) != 0) { | 4008 | if (strlen(GetCompiler()) != 0) { |
4009 | strcat(Backup.Creator+strlen(Backup.Creator),", "); | 4009 | strcat(Backup.Creator+strlen(Backup.Creator),", "); |
4010 | strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler()); | 4010 | strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler()); |
4011 | } | 4011 | } |
4012 | 4012 | ||
4013 | signal(SIGINT, interrupt); | 4013 | signal(SIGINT, interrupt); |
4014 | printmsgerr("Press Ctrl+C to break...\n"); | 4014 | printmsgerr("Press Ctrl+C to break...\n"); |
4015 | 4015 | ||
4016 | GSM_Init(true); | 4016 | GSM_Init(true); |
4017 | 4017 | ||
4018 | if (Info.UseUnicode) { | 4018 | if (Info.UseUnicode) { |
4019 | Info.UseUnicode=answer_yes("Use Unicode subformat of backup file"); | 4019 | Info.UseUnicode=answer_yes("Use Unicode subformat of backup file"); |
4020 | } | 4020 | } |
4021 | if (Info.DateTime) { | 4021 | if (Info.DateTime) { |
4022 | GSM_GetCurrentDateTime (&Backup.DateTime); | 4022 | GSM_GetCurrentDateTime (&Backup.DateTime); |
4023 | Backup.DateTimeAvailable=true; | 4023 | Backup.DateTimeAvailable=true; |
4024 | } | 4024 | } |
4025 | if (Info.Model) { | 4025 | if (Info.Model) { |
4026 | error=Phone->GetManufacturer(&s); | 4026 | error=Phone->GetManufacturer(&s); |
4027 | Print_Error(error); | 4027 | Print_Error(error); |
4028 | sprintf(Backup.Model,"%s ",s.Phone.Data.Manufacturer); | 4028 | sprintf(Backup.Model,"%s ",s.Phone.Data.Manufacturer); |
4029 | if (s.Phone.Data.ModelInfo->model[0]!=0) { | 4029 | if (s.Phone.Data.ModelInfo->model[0]!=0) { |
4030 | strcat(Backup.Model,s.Phone.Data.ModelInfo->model); | 4030 | strcat(Backup.Model,s.Phone.Data.ModelInfo->model); |
4031 | } else { | 4031 | } else { |
4032 | strcat(Backup.Model,s.Phone.Data.Model); | 4032 | strcat(Backup.Model,s.Phone.Data.Model); |
4033 | } | 4033 | } |
4034 | strcat(Backup.Model," "); | 4034 | strcat(Backup.Model," "); |
4035 | strcat(Backup.Model,s.Phone.Data.Version); | 4035 | strcat(Backup.Model,s.Phone.Data.Version); |
4036 | } | 4036 | } |
4037 | if (Info.IMEI) { | 4037 | if (Info.IMEI) { |
4038 | error=Phone->GetIMEI(&s); | 4038 | error=Phone->GetIMEI(&s); |
4039 | if (error != ERR_NOTSUPPORTED) { | 4039 | if (error != ERR_NOTSUPPORTED) { |
4040 | strcpy(Backup.IMEI, s.Phone.Data.IMEI); | 4040 | strcpy(Backup.IMEI, s.Phone.Data.IMEI); |
4041 | Print_Error(error); | 4041 | Print_Error(error); |
4042 | } else { | 4042 | } else { |
4043 | Backup.IMEI[0] = 0; | 4043 | Backup.IMEI[0] = 0; |
4044 | } | 4044 | } |
4045 | } | 4045 | } |
4046 | printf("\n"); | 4046 | printf("\n"); |
4047 | 4047 | ||
4048 | DoBackup = false; | 4048 | DoBackup = false; |
4049 | if (Info.PhonePhonebook) { | 4049 | if (Info.PhonePhonebook) { |
4050 | printmsg("Checking phone phonebook\n"); | 4050 | printmsg("Checking phone phonebook\n"); |
4051 | MemStatus.MemoryType = MEM_ME; | 4051 | MemStatus.MemoryType = MEM_ME; |
4052 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 4052 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
4053 | if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { | 4053 | if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { |
4054 | /*LRif (answer_yes(" Backup phone phonebook")) */DoBackup = true; | 4054 | /*LRif (answer_yes(" Backup phone phonebook")) */DoBackup = true; |
4055 | } | 4055 | } |
4056 | } | 4056 | } |
4057 | if (DoBackup) { | 4057 | if (DoBackup) { |
4058 | Pbk.MemoryType = MEM_ME; | 4058 | Pbk.MemoryType = MEM_ME; |
4059 | i = 1; | 4059 | i = 1; |
4060 | used = 0; | 4060 | used = 0; |
4061 | while (used != MemStatus.MemoryUsed) { | 4061 | while (used != MemStatus.MemoryUsed) { |
4062 | Pbk.Location = i; | 4062 | Pbk.Location = i; |
4063 | error=Phone->GetMemory(&s, &Pbk); | 4063 | error=Phone->GetMemory(&s, &Pbk); |
4064 | if (error != ERR_EMPTY) { | 4064 | if (error != ERR_EMPTY) { |
4065 | Print_Error(error); | 4065 | Print_Error(error); |
4066 | if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) { | 4066 | if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) { |
4067 | Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); | 4067 | Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); |
4068 | if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4068 | if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4069 | Backup.PhonePhonebook[used+1] = NULL; | 4069 | Backup.PhonePhonebook[used+1] = NULL; |
4070 | } else { | 4070 | } else { |
4071 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PHONEPHONEBOOK"); | 4071 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PHONEPHONEBOOK"); |
4072 | GSM_Terminate(); | 4072 | GSM_Terminate(); |
4073 | exit(-1); | 4073 | exit(-1); |
4074 | } | 4074 | } |
4075 | *Backup.PhonePhonebook[used]=Pbk; | 4075 | *Backup.PhonePhonebook[used]=Pbk; |
4076 | used++; | 4076 | used++; |
4077 | } | 4077 | } |
4078 | printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); | 4078 | printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); |
4079 | i++; | 4079 | i++; |
4080 | if (gshutdown) { | 4080 | if (gshutdown) { |
4081 | GSM_Terminate(); | 4081 | GSM_Terminate(); |
4082 | exit(0); | 4082 | exit(0); |
4083 | } | 4083 | } |
4084 | } | 4084 | } |
4085 | printmsgerr("\n"); | 4085 | printmsgerr("\n"); |
4086 | } | 4086 | } |
4087 | DoBackup = false; | 4087 | DoBackup = false; |
4088 | if (Info.SIMPhonebook) { | 4088 | if (Info.SIMPhonebook) { |
4089 | printmsg("Checking SIM phonebook\n"); | 4089 | printmsg("Checking SIM phonebook\n"); |
4090 | MemStatus.MemoryType = MEM_SM; | 4090 | MemStatus.MemoryType = MEM_SM; |
4091 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 4091 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
4092 | if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { | 4092 | if (error==ERR_NONE && MemStatus.MemoryUsed != 0) { |
4093 | if (answer_yes(" Backup SIM phonebook")) DoBackup=true; | 4093 | if (answer_yes(" Backup SIM phonebook")) DoBackup=true; |
4094 | } | 4094 | } |
4095 | } | 4095 | } |
4096 | if (DoBackup) { | 4096 | if (DoBackup) { |
4097 | Pbk.MemoryType = MEM_SM; | 4097 | Pbk.MemoryType = MEM_SM; |
4098 | i = 1; | 4098 | i = 1; |
4099 | used = 0; | 4099 | used = 0; |
4100 | while (used != MemStatus.MemoryUsed) { | 4100 | while (used != MemStatus.MemoryUsed) { |
4101 | Pbk.Location = i; | 4101 | Pbk.Location = i; |
4102 | error=Phone->GetMemory(&s, &Pbk); | 4102 | error=Phone->GetMemory(&s, &Pbk); |
4103 | if (error != ERR_EMPTY) { | 4103 | if (error != ERR_EMPTY) { |
4104 | Print_Error(error); | 4104 | Print_Error(error); |
4105 | if (used < GSM_BACKUP_MAX_SIMPHONEBOOK) { | 4105 | if (used < GSM_BACKUP_MAX_SIMPHONEBOOK) { |
4106 | Backup.SIMPhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); | 4106 | Backup.SIMPhonebook[used] = malloc(sizeof(GSM_MemoryEntry)); |
4107 | if (Backup.SIMPhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4107 | if (Backup.SIMPhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4108 | Backup.SIMPhonebook[used + 1] = NULL; | 4108 | Backup.SIMPhonebook[used + 1] = NULL; |
4109 | } else { | 4109 | } else { |
4110 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK"); | 4110 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SIMPHONEBOOK"); |
4111 | GSM_Terminate(); | 4111 | GSM_Terminate(); |
4112 | exit(-1); | 4112 | exit(-1); |
4113 | } | 4113 | } |
4114 | *Backup.SIMPhonebook[used]=Pbk; | 4114 | *Backup.SIMPhonebook[used]=Pbk; |
4115 | used++; | 4115 | used++; |
4116 | } | 4116 | } |
4117 | printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); | 4117 | printmsgerr("%c Reading: %i percent",13,used*100/MemStatus.MemoryUsed); |
4118 | i++; | 4118 | i++; |
4119 | if (gshutdown) { | 4119 | if (gshutdown) { |
4120 | GSM_Terminate(); | 4120 | GSM_Terminate(); |
4121 | exit(0); | 4121 | exit(0); |
4122 | } | 4122 | } |
4123 | } | 4123 | } |
4124 | printmsgerr("\n"); | 4124 | printmsgerr("\n"); |
4125 | } | 4125 | } |
4126 | DoBackup = false; | 4126 | DoBackup = false; |
4127 | if (Info.Calendar) { | 4127 | if (Info.Calendar) { |
4128 | printmsg("Checking calendar\n"); | 4128 | printmsg("Checking calendar\n"); |
4129 | error=Phone->GetNextCalendar(&s,&Calendar,true); | 4129 | error=Phone->GetNextCalendar(&s,&Calendar,true); |
4130 | if (error==ERR_NONE) { | 4130 | if (error==ERR_NONE) { |
4131 | if (answer_yes(" Backup calendar notes")) DoBackup = true; | 4131 | if (answer_yes(" Backup calendar notes")) DoBackup = true; |
4132 | } | 4132 | } |
4133 | } | 4133 | } |
4134 | if (DoBackup) { | 4134 | if (DoBackup) { |
4135 | used = 0; | 4135 | used = 0; |
4136 | printmsgerr(" Reading : "); | 4136 | printmsgerr(" Reading : "); |
4137 | while (error == ERR_NONE) { | 4137 | while (error == ERR_NONE) { |
4138 | if (used < GSM_MAXCALENDARTODONOTES) { | 4138 | if (used < GSM_MAXCALENDARTODONOTES) { |
4139 | Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry)); | 4139 | Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry)); |
4140 | if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4140 | if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4141 | Backup.Calendar[used+1] = NULL; | 4141 | Backup.Calendar[used+1] = NULL; |
4142 | } else { | 4142 | } else { |
4143 | printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); | 4143 | printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); |
4144 | GSM_Terminate(); | 4144 | GSM_Terminate(); |
4145 | exit(-1); | 4145 | exit(-1); |
4146 | } | 4146 | } |
4147 | *Backup.Calendar[used]=Calendar; | 4147 | *Backup.Calendar[used]=Calendar; |
4148 | used ++; | 4148 | used ++; |
4149 | error=Phone->GetNextCalendar(&s,&Calendar,false); | 4149 | error=Phone->GetNextCalendar(&s,&Calendar,false); |
4150 | printmsgerr("*"); | 4150 | printmsgerr("*"); |
4151 | if (gshutdown) { | 4151 | if (gshutdown) { |
4152 | GSM_Terminate(); | 4152 | GSM_Terminate(); |
4153 | exit(0); | 4153 | exit(0); |
4154 | } | 4154 | } |
4155 | } | 4155 | } |
4156 | printmsgerr("\n"); | 4156 | printmsgerr("\n"); |
4157 | } | 4157 | } |
4158 | DoBackup = false; | 4158 | DoBackup = false; |
4159 | if (Info.ToDo) { | 4159 | if (Info.ToDo) { |
4160 | printmsg("Checking ToDo\n"); | 4160 | printmsg("Checking ToDo\n"); |
4161 | error=Phone->GetToDoStatus(&s,&ToDoStatus); | 4161 | error=Phone->GetToDoStatus(&s,&ToDoStatus); |
4162 | if (error == ERR_NONE && ToDoStatus.Used != 0) { | 4162 | if (error == ERR_NONE && ToDoStatus.Used != 0) { |
4163 | if (answer_yes(" Backup ToDo")) DoBackup = true; | 4163 | if (answer_yes(" Backup ToDo")) DoBackup = true; |
4164 | } | 4164 | } |
4165 | } | 4165 | } |
4166 | if (DoBackup) { | 4166 | if (DoBackup) { |
4167 | used = 0; | 4167 | used = 0; |
4168 | error=Phone->GetNextToDo(&s,&ToDo,true); | 4168 | error=Phone->GetNextToDo(&s,&ToDo,true); |
4169 | while (error == ERR_NONE) { | 4169 | while (error == ERR_NONE) { |
4170 | if (used < GSM_MAXCALENDARTODONOTES) { | 4170 | if (used < GSM_MAXCALENDARTODONOTES) { |
4171 | Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry)); | 4171 | Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry)); |
4172 | if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4172 | if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4173 | Backup.ToDo[used+1] = NULL; | 4173 | Backup.ToDo[used+1] = NULL; |
4174 | } else { | 4174 | } else { |
4175 | printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); | 4175 | printmsg(" Increase %s\n" , "GSM_MAXCALENDARTODONOTES"); |
4176 | GSM_Terminate(); | 4176 | GSM_Terminate(); |
4177 | exit(-1); | 4177 | exit(-1); |
4178 | } | 4178 | } |
4179 | *Backup.ToDo[used]=ToDo; | 4179 | *Backup.ToDo[used]=ToDo; |
4180 | used ++; | 4180 | used ++; |
4181 | error=Phone->GetNextToDo(&s,&ToDo,false); | 4181 | error=Phone->GetNextToDo(&s,&ToDo,false); |
4182 | printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used); | 4182 | printmsgerr("%c Reading: %i percent",13,used*100/ToDoStatus.Used); |
4183 | if (gshutdown) { | 4183 | if (gshutdown) { |
4184 | GSM_Terminate(); | 4184 | GSM_Terminate(); |
4185 | exit(0); | 4185 | exit(0); |
4186 | } | 4186 | } |
4187 | } | 4187 | } |
4188 | printmsgerr("\n"); | 4188 | printmsgerr("\n"); |
4189 | } | 4189 | } |
4190 | DoBackup = false; | 4190 | DoBackup = false; |
4191 | if (Info.Note) { | 4191 | if (Info.Note) { |
4192 | printmsg("Checking notes\n"); | 4192 | printmsg("Checking notes\n"); |
4193 | error=Phone->GetNextNote(&s,&Note,true); | 4193 | error=Phone->GetNextNote(&s,&Note,true); |
4194 | if (error==ERR_NONE) { | 4194 | if (error==ERR_NONE) { |
4195 | if (answer_yes(" Backup notes")) DoBackup = true; | 4195 | if (answer_yes(" Backup notes")) DoBackup = true; |
4196 | } | 4196 | } |
4197 | } | 4197 | } |
4198 | if (DoBackup) { | 4198 | if (DoBackup) { |
4199 | used = 0; | 4199 | used = 0; |
4200 | printmsgerr(" Reading : "); | 4200 | printmsgerr(" Reading : "); |
4201 | while (error == ERR_NONE) { | 4201 | while (error == ERR_NONE) { |
4202 | if (used < GSM_BACKUP_MAX_NOTE) { | 4202 | if (used < GSM_BACKUP_MAX_NOTE) { |
4203 | Backup.Note[used] = malloc(sizeof(GSM_NoteEntry)); | 4203 | Backup.Note[used] = malloc(sizeof(GSM_NoteEntry)); |
4204 | if (Backup.Note[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4204 | if (Backup.Note[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4205 | Backup.Note[used+1] = NULL; | 4205 | Backup.Note[used+1] = NULL; |
4206 | } else { | 4206 | } else { |
4207 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_NOTE"); | 4207 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_NOTE"); |
4208 | GSM_Terminate(); | 4208 | GSM_Terminate(); |
4209 | exit(-1); | 4209 | exit(-1); |
4210 | } | 4210 | } |
4211 | *Backup.Note[used]=Note; | 4211 | *Backup.Note[used]=Note; |
4212 | used ++; | 4212 | used ++; |
4213 | error=Phone->GetNextNote(&s,&Note,false); | 4213 | error=Phone->GetNextNote(&s,&Note,false); |
4214 | printmsgerr("*"); | 4214 | printmsgerr("*"); |
4215 | if (gshutdown) { | 4215 | if (gshutdown) { |
4216 | GSM_Terminate(); | 4216 | GSM_Terminate(); |
4217 | exit(0); | 4217 | exit(0); |
4218 | } | 4218 | } |
4219 | } | 4219 | } |
4220 | printmsgerr("\n"); | 4220 | printmsgerr("\n"); |
4221 | } | 4221 | } |
4222 | DoBackup = false; | 4222 | DoBackup = false; |
4223 | if (Info.CallerLogos) { | 4223 | if (Info.CallerLogos) { |
4224 | printmsg("Checking caller logos\n"); | 4224 | printmsg("Checking caller logos\n"); |
4225 | Bitmap.Type = GSM_CallerGroupLogo; | 4225 | Bitmap.Type = GSM_CallerGroupLogo; |
4226 | Bitmap.Location = 1; | 4226 | Bitmap.Location = 1; |
4227 | error=Phone->GetBitmap(&s,&Bitmap); | 4227 | error=Phone->GetBitmap(&s,&Bitmap); |
4228 | if (error == ERR_NONE) { | 4228 | if (error == ERR_NONE) { |
4229 | if (answer_yes(" Backup caller groups and logos")) DoBackup = true; | 4229 | if (answer_yes(" Backup caller groups and logos")) DoBackup = true; |
4230 | } | 4230 | } |
4231 | } | 4231 | } |
4232 | if (DoBackup) { | 4232 | if (DoBackup) { |
4233 | printmsgerr(" Reading : "); | 4233 | printmsgerr(" Reading : "); |
4234 | error = ERR_NONE; | 4234 | error = ERR_NONE; |
4235 | used = 0; | 4235 | used = 0; |
4236 | while (error == ERR_NONE) { | 4236 | while (error == ERR_NONE) { |
4237 | if (used < GSM_BACKUP_MAX_CALLER) { | 4237 | if (used < GSM_BACKUP_MAX_CALLER) { |
4238 | Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap)); | 4238 | Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap)); |
4239 | if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4239 | if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4240 | Backup.CallerLogos[used+1] = NULL; | 4240 | Backup.CallerLogos[used+1] = NULL; |
4241 | } else { | 4241 | } else { |
4242 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER"); | 4242 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CALLER"); |
4243 | GSM_Terminate(); | 4243 | GSM_Terminate(); |
4244 | exit(-1); | 4244 | exit(-1); |
4245 | } | 4245 | } |
4246 | *Backup.CallerLogos[used] = Bitmap; | 4246 | *Backup.CallerLogos[used] = Bitmap; |
4247 | used ++; | 4247 | used ++; |
4248 | Bitmap.Location = used + 1; | 4248 | Bitmap.Location = used + 1; |
4249 | error=Phone->GetBitmap(&s,&Bitmap); | 4249 | error=Phone->GetBitmap(&s,&Bitmap); |
4250 | printmsgerr("*"); | 4250 | printmsgerr("*"); |
4251 | if (gshutdown) { | 4251 | if (gshutdown) { |
4252 | GSM_Terminate(); | 4252 | GSM_Terminate(); |
4253 | exit(0); | 4253 | exit(0); |
4254 | } | 4254 | } |
4255 | } | 4255 | } |
4256 | printmsgerr("\n"); | 4256 | printmsgerr("\n"); |
4257 | } | 4257 | } |
4258 | DoBackup = false; | 4258 | DoBackup = false; |
4259 | if (Info.SMSC) { | 4259 | if (Info.SMSC) { |
4260 | printmsg("Checking SMS profiles\n"); | 4260 | printmsg("Checking SMS profiles\n"); |
4261 | if (answer_yes(" Backup SMS profiles")) DoBackup = true; | 4261 | if (answer_yes(" Backup SMS profiles")) DoBackup = true; |
4262 | } | 4262 | } |
4263 | if (DoBackup) { | 4263 | if (DoBackup) { |
4264 | used = 0; | 4264 | used = 0; |
4265 | printmsgerr(" Reading: "); | 4265 | printmsgerr(" Reading: "); |
4266 | while (true) { | 4266 | while (true) { |
4267 | SMSC.Location = used + 1; | 4267 | SMSC.Location = used + 1; |
4268 | error = Phone->GetSMSC(&s,&SMSC); | 4268 | error = Phone->GetSMSC(&s,&SMSC); |
4269 | if (error != ERR_NONE) break; | 4269 | if (error != ERR_NONE) break; |
4270 | if (used < GSM_BACKUP_MAX_SMSC) { | 4270 | if (used < GSM_BACKUP_MAX_SMSC) { |
4271 | Backup.SMSC[used] = malloc(sizeof(GSM_SMSC)); | 4271 | Backup.SMSC[used] = malloc(sizeof(GSM_SMSC)); |
4272 | if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4272 | if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4273 | Backup.SMSC[used + 1] = NULL; | 4273 | Backup.SMSC[used + 1] = NULL; |
4274 | } else { | 4274 | } else { |
4275 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC"); | 4275 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMSC"); |
4276 | GSM_Terminate(); | 4276 | GSM_Terminate(); |
4277 | exit(-1); | 4277 | exit(-1); |
4278 | } | 4278 | } |
4279 | *Backup.SMSC[used]=SMSC; | 4279 | *Backup.SMSC[used]=SMSC; |
4280 | used++; | 4280 | used++; |
4281 | printmsgerr("*"); | 4281 | printmsgerr("*"); |
4282 | } | 4282 | } |
4283 | printmsgerr("\n"); | 4283 | printmsgerr("\n"); |
4284 | } | 4284 | } |
4285 | DoBackup = false; | 4285 | DoBackup = false; |
4286 | if (Info.StartupLogo) { | 4286 | if (Info.StartupLogo) { |
4287 | printmsg("Checking startup text\n"); | 4287 | printmsg("Checking startup text\n"); |
4288 | Bitmap.Type = GSM_WelcomeNote_Text; | 4288 | Bitmap.Type = GSM_WelcomeNote_Text; |
4289 | error = Phone->GetBitmap(&s,&Bitmap); | 4289 | error = Phone->GetBitmap(&s,&Bitmap); |
4290 | if (error == ERR_NONE) { | 4290 | if (error == ERR_NONE) { |
4291 | if (answer_yes(" Backup startup logo/text")) DoBackup = true; | 4291 | if (answer_yes(" Backup startup logo/text")) DoBackup = true; |
4292 | } | 4292 | } |
4293 | } | 4293 | } |
4294 | if (DoBackup) { | 4294 | if (DoBackup) { |
4295 | Backup.StartupLogo = malloc(sizeof(GSM_Bitmap)); | 4295 | Backup.StartupLogo = malloc(sizeof(GSM_Bitmap)); |
4296 | if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY); | 4296 | if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY); |
4297 | *Backup.StartupLogo = Bitmap; | 4297 | *Backup.StartupLogo = Bitmap; |
4298 | if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) { | 4298 | if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) { |
4299 | Bitmap.Type = GSM_StartupLogo; | 4299 | Bitmap.Type = GSM_StartupLogo; |
4300 | error = Phone->GetBitmap(&s,&Bitmap); | 4300 | error = Phone->GetBitmap(&s,&Bitmap); |
4301 | if (error == ERR_NONE) *Backup.StartupLogo = Bitmap; | 4301 | if (error == ERR_NONE) *Backup.StartupLogo = Bitmap; |
4302 | } | 4302 | } |
4303 | } | 4303 | } |
4304 | DoBackup = false; | 4304 | DoBackup = false; |
4305 | if (Info.OperatorLogo) { | 4305 | if (Info.OperatorLogo) { |
4306 | printmsg("Checking operator logo\n"); | 4306 | printmsg("Checking operator logo\n"); |
4307 | Bitmap.Type = GSM_OperatorLogo; | 4307 | Bitmap.Type = GSM_OperatorLogo; |
4308 | error=Phone->GetBitmap(&s,&Bitmap); | 4308 | error=Phone->GetBitmap(&s,&Bitmap); |
4309 | if (error == ERR_NONE) { | 4309 | if (error == ERR_NONE) { |
4310 | if (strcmp(Bitmap.NetworkCode,"000 00")!=0) { | 4310 | if (strcmp(Bitmap.NetworkCode,"000 00")!=0) { |
4311 | if (answer_yes(" Backup operator logo")) DoBackup = true; | 4311 | if (answer_yes(" Backup operator logo")) DoBackup = true; |
4312 | } | 4312 | } |
4313 | } | 4313 | } |
4314 | } | 4314 | } |
4315 | if (DoBackup) { | 4315 | if (DoBackup) { |
4316 | Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap)); | 4316 | Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap)); |
4317 | if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY); | 4317 | if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY); |
4318 | *Backup.OperatorLogo = Bitmap; | 4318 | *Backup.OperatorLogo = Bitmap; |
4319 | } | 4319 | } |
4320 | DoBackup = false; | 4320 | DoBackup = false; |
4321 | if (Info.WAPBookmark) { | 4321 | if (Info.WAPBookmark) { |
4322 | printmsg("Checking WAP bookmarks\n"); | 4322 | printmsg("Checking WAP bookmarks\n"); |
4323 | Bookmark.Location = 1; | 4323 | Bookmark.Location = 1; |
4324 | error=Phone->GetWAPBookmark(&s,&Bookmark); | 4324 | error=Phone->GetWAPBookmark(&s,&Bookmark); |
4325 | if (error==ERR_NONE) { | 4325 | if (error==ERR_NONE) { |
4326 | if (answer_yes(" Backup WAP bookmarks")) DoBackup = true; | 4326 | if (answer_yes(" Backup WAP bookmarks")) DoBackup = true; |
4327 | } | 4327 | } |
4328 | } | 4328 | } |
4329 | if (DoBackup) { | 4329 | if (DoBackup) { |
4330 | used = 0; | 4330 | used = 0; |
4331 | printmsgerr(" Reading : "); | 4331 | printmsgerr(" Reading : "); |
4332 | while (error == ERR_NONE) { | 4332 | while (error == ERR_NONE) { |
4333 | if (used < GSM_BACKUP_MAX_WAPBOOKMARK) { | 4333 | if (used < GSM_BACKUP_MAX_WAPBOOKMARK) { |
4334 | Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark)); | 4334 | Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark)); |
4335 | if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4335 | if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4336 | Backup.WAPBookmark[used+1] = NULL; | 4336 | Backup.WAPBookmark[used+1] = NULL; |
4337 | } else { | 4337 | } else { |
4338 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK"); | 4338 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPBOOKMARK"); |
4339 | GSM_Terminate(); | 4339 | GSM_Terminate(); |
4340 | exit(-1); | 4340 | exit(-1); |
4341 | } | 4341 | } |
4342 | *Backup.WAPBookmark[used]=Bookmark; | 4342 | *Backup.WAPBookmark[used]=Bookmark; |
4343 | used ++; | 4343 | used ++; |
4344 | Bookmark.Location = used+1; | 4344 | Bookmark.Location = used+1; |
4345 | error=Phone->GetWAPBookmark(&s,&Bookmark); | 4345 | error=Phone->GetWAPBookmark(&s,&Bookmark); |
4346 | printmsgerr("*"); | 4346 | printmsgerr("*"); |
4347 | if (gshutdown) { | 4347 | if (gshutdown) { |
4348 | GSM_Terminate(); | 4348 | GSM_Terminate(); |
4349 | exit(0); | 4349 | exit(0); |
4350 | } | 4350 | } |
4351 | } | 4351 | } |
4352 | printmsgerr("\n"); | 4352 | printmsgerr("\n"); |
4353 | } | 4353 | } |
4354 | DoBackup = false; | 4354 | DoBackup = false; |
4355 | if (Info.WAPSettings) { | 4355 | if (Info.WAPSettings) { |
4356 | printmsg("Checking WAP settings\n"); | 4356 | printmsg("Checking WAP settings\n"); |
4357 | Settings.Location = 1; | 4357 | Settings.Location = 1; |
4358 | error=Phone->GetWAPSettings(&s,&Settings); | 4358 | error=Phone->GetWAPSettings(&s,&Settings); |
4359 | if (error==ERR_NONE) { | 4359 | if (error==ERR_NONE) { |
4360 | if (answer_yes(" Backup WAP settings")) DoBackup = true; | 4360 | if (answer_yes(" Backup WAP settings")) DoBackup = true; |
4361 | } | 4361 | } |
4362 | } | 4362 | } |
4363 | if (DoBackup) { | 4363 | if (DoBackup) { |
4364 | used = 0; | 4364 | used = 0; |
4365 | printmsgerr(" Reading : "); | 4365 | printmsgerr(" Reading : "); |
4366 | while (error == ERR_NONE) { | 4366 | while (error == ERR_NONE) { |
4367 | if (used < GSM_BACKUP_MAX_WAPSETTINGS) { | 4367 | if (used < GSM_BACKUP_MAX_WAPSETTINGS) { |
4368 | Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); | 4368 | Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); |
4369 | if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4369 | if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4370 | Backup.WAPSettings[used+1] = NULL; | 4370 | Backup.WAPSettings[used+1] = NULL; |
4371 | } else { | 4371 | } else { |
4372 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS"); | 4372 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_WAPSETTINGS"); |
4373 | GSM_Terminate(); | 4373 | GSM_Terminate(); |
4374 | exit(-1); | 4374 | exit(-1); |
4375 | } | 4375 | } |
4376 | *Backup.WAPSettings[used]=Settings; | 4376 | *Backup.WAPSettings[used]=Settings; |
4377 | used ++; | 4377 | used ++; |
4378 | Settings.Location = used+1; | 4378 | Settings.Location = used+1; |
4379 | error=Phone->GetWAPSettings(&s,&Settings); | 4379 | error=Phone->GetWAPSettings(&s,&Settings); |
4380 | printmsgerr("*"); | 4380 | printmsgerr("*"); |
4381 | if (gshutdown) { | 4381 | if (gshutdown) { |
4382 | GSM_Terminate(); | 4382 | GSM_Terminate(); |
4383 | exit(0); | 4383 | exit(0); |
4384 | } | 4384 | } |
4385 | } | 4385 | } |
4386 | printmsgerr("\n"); | 4386 | printmsgerr("\n"); |
4387 | } | 4387 | } |
4388 | DoBackup = false; | 4388 | DoBackup = false; |
4389 | if (Info.MMSSettings) { | 4389 | if (Info.MMSSettings) { |
4390 | printmsg("Checking MMS settings\n"); | 4390 | printmsg("Checking MMS settings\n"); |
4391 | Settings.Location = 1; | 4391 | Settings.Location = 1; |
4392 | error=Phone->GetMMSSettings(&s,&Settings); | 4392 | error=Phone->GetMMSSettings(&s,&Settings); |
4393 | if (error==ERR_NONE) { | 4393 | if (error==ERR_NONE) { |
4394 | if (answer_yes(" Backup MMS settings")) DoBackup = true; | 4394 | if (answer_yes(" Backup MMS settings")) DoBackup = true; |
4395 | } | 4395 | } |
4396 | } | 4396 | } |
4397 | if (DoBackup) { | 4397 | if (DoBackup) { |
4398 | used = 0; | 4398 | used = 0; |
4399 | printmsgerr(" Reading : "); | 4399 | printmsgerr(" Reading : "); |
4400 | while (error == ERR_NONE) { | 4400 | while (error == ERR_NONE) { |
4401 | if (used < GSM_BACKUP_MAX_MMSSETTINGS) { | 4401 | if (used < GSM_BACKUP_MAX_MMSSETTINGS) { |
4402 | Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); | 4402 | Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); |
4403 | if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4403 | if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4404 | Backup.MMSSettings[used+1] = NULL; | 4404 | Backup.MMSSettings[used+1] = NULL; |
4405 | } else { | 4405 | } else { |
4406 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS"); | 4406 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_MMSSETTINGS"); |
4407 | GSM_Terminate(); | 4407 | GSM_Terminate(); |
4408 | exit(-1); | 4408 | exit(-1); |
4409 | } | 4409 | } |
4410 | *Backup.MMSSettings[used]=Settings; | 4410 | *Backup.MMSSettings[used]=Settings; |
4411 | used ++; | 4411 | used ++; |
4412 | Settings.Location = used+1; | 4412 | Settings.Location = used+1; |
4413 | error=Phone->GetMMSSettings(&s,&Settings); | 4413 | error=Phone->GetMMSSettings(&s,&Settings); |
4414 | printmsgerr("*"); | 4414 | printmsgerr("*"); |
4415 | if (gshutdown) { | 4415 | if (gshutdown) { |
4416 | GSM_Terminate(); | 4416 | GSM_Terminate(); |
4417 | exit(0); | 4417 | exit(0); |
4418 | } | 4418 | } |
4419 | } | 4419 | } |
4420 | printmsgerr("\n"); | 4420 | printmsgerr("\n"); |
4421 | } | 4421 | } |
4422 | DoBackup = false; | 4422 | DoBackup = false; |
4423 | if (Info.ChatSettings) { | 4423 | if (Info.ChatSettings) { |
4424 | printmsg("Checking Chat settings\n"); | 4424 | printmsg("Checking Chat settings\n"); |
4425 | Chat.Location = 1; | 4425 | Chat.Location = 1; |
4426 | error=Phone->GetChatSettings(&s,&Chat); | 4426 | error=Phone->GetChatSettings(&s,&Chat); |
4427 | if (error==ERR_NONE) { | 4427 | if (error==ERR_NONE) { |
4428 | if (answer_yes(" Backup Chat settings")) DoBackup = true; | 4428 | if (answer_yes(" Backup Chat settings")) DoBackup = true; |
4429 | } | 4429 | } |
4430 | } | 4430 | } |
4431 | if (DoBackup) { | 4431 | if (DoBackup) { |
4432 | used = 0; | 4432 | used = 0; |
4433 | printmsgerr(" Reading : "); | 4433 | printmsgerr(" Reading : "); |
4434 | while (error == ERR_NONE) { | 4434 | while (error == ERR_NONE) { |
4435 | if (used < GSM_BACKUP_MAX_CHATSETTINGS) { | 4435 | if (used < GSM_BACKUP_MAX_CHATSETTINGS) { |
4436 | Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings)); | 4436 | Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings)); |
4437 | if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4437 | if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4438 | Backup.ChatSettings[used+1] = NULL; | 4438 | Backup.ChatSettings[used+1] = NULL; |
4439 | } else { | 4439 | } else { |
4440 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS"); | 4440 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_CHATSETTINGS"); |
4441 | GSM_Terminate(); | 4441 | GSM_Terminate(); |
4442 | exit(-1); | 4442 | exit(-1); |
4443 | } | 4443 | } |
4444 | *Backup.ChatSettings[used]=Chat; | 4444 | *Backup.ChatSettings[used]=Chat; |
4445 | used ++; | 4445 | used ++; |
4446 | Chat.Location = used+1; | 4446 | Chat.Location = used+1; |
4447 | error=Phone->GetChatSettings(&s,&Chat); | 4447 | error=Phone->GetChatSettings(&s,&Chat); |
4448 | printmsgerr("*"); | 4448 | printmsgerr("*"); |
4449 | if (gshutdown) { | 4449 | if (gshutdown) { |
4450 | GSM_Terminate(); | 4450 | GSM_Terminate(); |
4451 | exit(0); | 4451 | exit(0); |
4452 | } | 4452 | } |
4453 | } | 4453 | } |
4454 | printmsgerr("\n"); | 4454 | printmsgerr("\n"); |
4455 | } | 4455 | } |
4456 | DoBackup = false; | 4456 | DoBackup = false; |
4457 | if (Info.SyncMLSettings) { | 4457 | if (Info.SyncMLSettings) { |
4458 | printmsg("Checking SyncML settings\n"); | 4458 | printmsg("Checking SyncML settings\n"); |
4459 | SyncML.Location = 1; | 4459 | SyncML.Location = 1; |
4460 | error=Phone->GetSyncMLSettings(&s,&SyncML); | 4460 | error=Phone->GetSyncMLSettings(&s,&SyncML); |
4461 | if (error==ERR_NONE) { | 4461 | if (error==ERR_NONE) { |
4462 | if (answer_yes(" Backup SyncML settings")) DoBackup = true; | 4462 | if (answer_yes(" Backup SyncML settings")) DoBackup = true; |
4463 | } | 4463 | } |
4464 | } | 4464 | } |
4465 | if (DoBackup) { | 4465 | if (DoBackup) { |
4466 | used = 0; | 4466 | used = 0; |
4467 | printmsgerr(" Reading : "); | 4467 | printmsgerr(" Reading : "); |
4468 | while (error == ERR_NONE) { | 4468 | while (error == ERR_NONE) { |
4469 | if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) { | 4469 | if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) { |
4470 | Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings)); | 4470 | Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings)); |
4471 | if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4471 | if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4472 | Backup.SyncMLSettings[used+1] = NULL; | 4472 | Backup.SyncMLSettings[used+1] = NULL; |
4473 | } else { | 4473 | } else { |
4474 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS"); | 4474 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SYNCMLSETTINGS"); |
4475 | GSM_Terminate(); | 4475 | GSM_Terminate(); |
4476 | exit(-1); | 4476 | exit(-1); |
4477 | } | 4477 | } |
4478 | *Backup.SyncMLSettings[used]=SyncML; | 4478 | *Backup.SyncMLSettings[used]=SyncML; |
4479 | used ++; | 4479 | used ++; |
4480 | SyncML.Location = used+1; | 4480 | SyncML.Location = used+1; |
4481 | error=Phone->GetSyncMLSettings(&s,&SyncML); | 4481 | error=Phone->GetSyncMLSettings(&s,&SyncML); |
4482 | printmsgerr("*"); | 4482 | printmsgerr("*"); |
4483 | if (gshutdown) { | 4483 | if (gshutdown) { |
4484 | GSM_Terminate(); | 4484 | GSM_Terminate(); |
4485 | exit(0); | 4485 | exit(0); |
4486 | } | 4486 | } |
4487 | } | 4487 | } |
4488 | printmsgerr("\n"); | 4488 | printmsgerr("\n"); |
4489 | } | 4489 | } |
4490 | DoBackup = false; | 4490 | DoBackup = false; |
4491 | if (Info.Ringtone) { | 4491 | if (Info.Ringtone) { |
4492 | printmsg("Checking user ringtones\n"); | 4492 | printmsg("Checking user ringtones\n"); |
4493 | Ringtone.Location = 1; | 4493 | Ringtone.Location = 1; |
4494 | Ringtone.Format = 0; | 4494 | Ringtone.Format = 0; |
4495 | error=Phone->GetRingtone(&s,&Ringtone,false); | 4495 | error=Phone->GetRingtone(&s,&Ringtone,false); |
4496 | if (error==ERR_EMPTY || error == ERR_NONE) { | 4496 | if (error==ERR_EMPTY || error == ERR_NONE) { |
4497 | if (answer_yes(" Backup user ringtones")) DoBackup = true; | 4497 | if (answer_yes(" Backup user ringtones")) DoBackup = true; |
4498 | } | 4498 | } |
4499 | } | 4499 | } |
4500 | if (DoBackup) { | 4500 | if (DoBackup) { |
4501 | used = 0; | 4501 | used = 0; |
4502 | i= 1; | 4502 | i= 1; |
4503 | printmsgerr(" Reading : "); | 4503 | printmsgerr(" Reading : "); |
4504 | while (error == ERR_NONE || error == ERR_EMPTY) { | 4504 | while (error == ERR_NONE || error == ERR_EMPTY) { |
4505 | if (error == ERR_NONE) { | 4505 | if (error == ERR_NONE) { |
4506 | if (used < GSM_BACKUP_MAX_RINGTONES) { | 4506 | if (used < GSM_BACKUP_MAX_RINGTONES) { |
4507 | Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone)); | 4507 | Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone)); |
4508 | if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4508 | if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4509 | Backup.Ringtone[used+1] = NULL; | 4509 | Backup.Ringtone[used+1] = NULL; |
4510 | } else { | 4510 | } else { |
4511 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES"); | 4511 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_RINGTONES"); |
4512 | GSM_Terminate(); | 4512 | GSM_Terminate(); |
4513 | exit(-1); | 4513 | exit(-1); |
4514 | } | 4514 | } |
4515 | *Backup.Ringtone[used]=Ringtone; | 4515 | *Backup.Ringtone[used]=Ringtone; |
4516 | used ++; | 4516 | used ++; |
4517 | } | 4517 | } |
4518 | i++; | 4518 | i++; |
4519 | Ringtone.Location = i; | 4519 | Ringtone.Location = i; |
4520 | Ringtone.Format = 0; | 4520 | Ringtone.Format = 0; |
4521 | error=Phone->GetRingtone(&s,&Ringtone,false); | 4521 | error=Phone->GetRingtone(&s,&Ringtone,false); |
4522 | printmsgerr("*"); | 4522 | printmsgerr("*"); |
4523 | if (gshutdown) { | 4523 | if (gshutdown) { |
4524 | GSM_Terminate(); | 4524 | GSM_Terminate(); |
4525 | exit(0); | 4525 | exit(0); |
4526 | } | 4526 | } |
4527 | } | 4527 | } |
4528 | printmsgerr("\n"); | 4528 | printmsgerr("\n"); |
4529 | } | 4529 | } |
4530 | DoBackup = false; | 4530 | DoBackup = false; |
4531 | if (Info.Profiles) { | 4531 | if (Info.Profiles) { |
4532 | printmsg("Checking phone profiles\n"); | 4532 | printmsg("Checking phone profiles\n"); |
4533 | Profile.Location = 1; | 4533 | Profile.Location = 1; |
4534 | error = Phone->GetProfile(&s,&Profile); | 4534 | error = Phone->GetProfile(&s,&Profile); |
4535 | if (error == ERR_NONE) { | 4535 | if (error == ERR_NONE) { |
4536 | if (answer_yes(" Backup phone profiles")) DoBackup = true; | 4536 | if (answer_yes(" Backup phone profiles")) DoBackup = true; |
4537 | } | 4537 | } |
4538 | } | 4538 | } |
4539 | if (DoBackup) { | 4539 | if (DoBackup) { |
4540 | used = 0; | 4540 | used = 0; |
4541 | printmsgerr(" Reading: "); | 4541 | printmsgerr(" Reading: "); |
4542 | while (true) { | 4542 | while (true) { |
4543 | Profile.Location = used + 1; | 4543 | Profile.Location = used + 1; |
4544 | error = Phone->GetProfile(&s,&Profile); | 4544 | error = Phone->GetProfile(&s,&Profile); |
4545 | if (error != ERR_NONE) break; | 4545 | if (error != ERR_NONE) break; |
4546 | if (used < GSM_BACKUP_MAX_PROFILES) { | 4546 | if (used < GSM_BACKUP_MAX_PROFILES) { |
4547 | Backup.Profiles[used] = malloc(sizeof(GSM_Profile)); | 4547 | Backup.Profiles[used] = malloc(sizeof(GSM_Profile)); |
4548 | if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4548 | if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4549 | Backup.Profiles[used + 1] = NULL; | 4549 | Backup.Profiles[used + 1] = NULL; |
4550 | } else { | 4550 | } else { |
4551 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES"); | 4551 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_PROFILES"); |
4552 | GSM_Terminate(); | 4552 | GSM_Terminate(); |
4553 | exit(-1); | 4553 | exit(-1); |
4554 | } | 4554 | } |
4555 | *Backup.Profiles[used]=Profile; | 4555 | *Backup.Profiles[used]=Profile; |
4556 | used++; | 4556 | used++; |
4557 | printmsgerr("*"); | 4557 | printmsgerr("*"); |
4558 | } | 4558 | } |
4559 | printmsgerr("\n"); | 4559 | printmsgerr("\n"); |
4560 | } | 4560 | } |
4561 | DoBackup = false; | 4561 | DoBackup = false; |
4562 | if (Info.FMStation) { | 4562 | if (Info.FMStation) { |
4563 | printmsg("Checking FM stations\n"); | 4563 | printmsg("Checking FM stations\n"); |
4564 | FMStation.Location = 1; | 4564 | FMStation.Location = 1; |
4565 | error = Phone->GetFMStation(&s,&FMStation); | 4565 | error = Phone->GetFMStation(&s,&FMStation); |
4566 | if (error == ERR_NONE || error == ERR_EMPTY) { | 4566 | if (error == ERR_NONE || error == ERR_EMPTY) { |
4567 | if (answer_yes(" Backup phone FM stations")) DoBackup=true; | 4567 | if (answer_yes(" Backup phone FM stations")) DoBackup=true; |
4568 | } | 4568 | } |
4569 | } | 4569 | } |
4570 | if (DoBackup) { | 4570 | if (DoBackup) { |
4571 | used= 0; | 4571 | used= 0; |
4572 | i = 1; | 4572 | i = 1; |
4573 | printmsgerr(" Reading: "); | 4573 | printmsgerr(" Reading: "); |
4574 | while (error == ERR_NONE || error == ERR_EMPTY) { | 4574 | while (error == ERR_NONE || error == ERR_EMPTY) { |
4575 | error = Phone->GetFMStation(&s,&FMStation); | 4575 | error = Phone->GetFMStation(&s,&FMStation); |
4576 | if (error == ERR_NONE) { | 4576 | if (error == ERR_NONE) { |
4577 | if (used < GSM_BACKUP_MAX_FMSTATIONS) { | 4577 | if (used < GSM_BACKUP_MAX_FMSTATIONS) { |
4578 | Backup.FMStation[used] = malloc(sizeof(GSM_FMStation)); | 4578 | Backup.FMStation[used] = malloc(sizeof(GSM_FMStation)); |
4579 | if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY); | 4579 | if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY); |
4580 | Backup.FMStation[used + 1] = NULL; | 4580 | Backup.FMStation[used + 1] = NULL; |
4581 | } else { | 4581 | } else { |
4582 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS"); | 4582 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_FMSTATIONS"); |
4583 | GSM_Terminate(); | 4583 | GSM_Terminate(); |
4584 | exit(-1); | 4584 | exit(-1); |
4585 | } | 4585 | } |
4586 | *Backup.FMStation[used]=FMStation; | 4586 | *Backup.FMStation[used]=FMStation; |
4587 | used++; | 4587 | used++; |
4588 | } | 4588 | } |
4589 | i++; | 4589 | i++; |
4590 | FMStation.Location = i; | 4590 | FMStation.Location = i; |
4591 | printmsgerr("*"); | 4591 | printmsgerr("*"); |
4592 | } | 4592 | } |
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 | ||
4636 | static void Restore(int argc, char *argv[]) | 4636 | static 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; |
4786 | if (Backup.Calendar[0] != NULL) { | 4786 | if (Backup.Calendar[0] != NULL) { |
4787 | /* N6110 doesn't support getting calendar status */ | 4787 | /* N6110 doesn't support getting calendar status */ |
4788 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 4788 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
4789 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { | 4789 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { |
4790 | max = 0; | 4790 | max = 0; |
4791 | while (Backup.Calendar[max] != NULL) max++; | 4791 | while (Backup.Calendar[max] != NULL) max++; |
4792 | printmsgerr("%i entries in backup file\n",max); | 4792 | printmsgerr("%i entries in backup file\n",max); |
4793 | // LR | 4793 | // LR |
4794 | //if (answer_yes("Restore calendar notes")) { | 4794 | //if (answer_yes("Restore calendar notes")) { |
4795 | //Past = answer_yes("Restore notes from the past"); | 4795 | //Past = answer_yes("Restore notes from the past"); |
4796 | DoRestore = true; | 4796 | DoRestore = true; |
4797 | //} | 4797 | //} |
4798 | } | 4798 | } |
4799 | } | 4799 | } |
4800 | if (DoRestore) { | 4800 | if (DoRestore) { |
4801 | printmsgerr("Deleting old notes: "); | 4801 | printmsgerr("Deleting old notes: "); |
4802 | error = Phone->DeleteAllCalendar(&s); | 4802 | error = Phone->DeleteAllCalendar(&s); |
4803 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 4803 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
4804 | while (1) { | 4804 | while (1) { |
4805 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 4805 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
4806 | if (error != ERR_NONE) break; | 4806 | if (error != ERR_NONE) break; |
4807 | error = Phone->DeleteCalendar(&s,&Calendar); | 4807 | error = Phone->DeleteCalendar(&s,&Calendar); |
4808 | Print_Error(error); | 4808 | Print_Error(error); |
4809 | printmsgerr("*"); | 4809 | printmsgerr("*"); |
4810 | } | 4810 | } |
4811 | printmsgerr("\n"); | 4811 | printmsgerr("\n"); |
4812 | } else { | 4812 | } else { |
4813 | printmsgerr("Done\n"); | 4813 | printmsgerr("Done\n"); |
4814 | Print_Error(error); | 4814 | Print_Error(error); |
4815 | } | 4815 | } |
4816 | 4816 | ||
4817 | for (i=0;i<max;i++) { | 4817 | for (i=0;i<max;i++) { |
4818 | if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue; | 4818 | if (!Past && IsCalendarNoteFromThePast(Backup.Calendar[i])) continue; |
4819 | 4819 | ||
4820 | Calendar = *Backup.Calendar[i]; | 4820 | Calendar = *Backup.Calendar[i]; |
4821 | error=Phone->AddCalendar(&s,&Calendar); | 4821 | error=Phone->AddCalendar(&s,&Calendar); |
4822 | Print_Error(error); | 4822 | Print_Error(error); |
4823 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4823 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4824 | if (gshutdown) { | 4824 | if (gshutdown) { |
4825 | GSM_Terminate(); | 4825 | GSM_Terminate(); |
4826 | exit(0); | 4826 | exit(0); |
4827 | } | 4827 | } |
4828 | } | 4828 | } |
4829 | printmsgerr("\n"); | 4829 | printmsgerr("\n"); |
4830 | } | 4830 | } |
4831 | 4831 | ||
4832 | DoRestore = false; | 4832 | DoRestore = false; |
4833 | if (Backup.ToDo[0] != NULL) { | 4833 | if (Backup.ToDo[0] != NULL) { |
4834 | error = Phone->GetToDoStatus(&s,&ToDoStatus); | 4834 | error = Phone->GetToDoStatus(&s,&ToDoStatus); |
4835 | if (error == ERR_NONE) { | 4835 | if (error == ERR_NONE) { |
4836 | max = 0; | 4836 | max = 0; |
4837 | while (Backup.ToDo[max]!=NULL) max++; | 4837 | while (Backup.ToDo[max]!=NULL) max++; |
4838 | printmsgerr("%i entries in backup file\n",max); | 4838 | printmsgerr("%i entries in backup file\n",max); |
4839 | 4839 | ||
4840 | //LR if (answer_yes("Restore ToDo")) | 4840 | //LR if (answer_yes("Restore ToDo")) |
4841 | DoRestore = true; | 4841 | DoRestore = true; |
4842 | } | 4842 | } |
4843 | } | 4843 | } |
4844 | if (DoRestore) { | 4844 | if (DoRestore) { |
4845 | ToDo = *Backup.ToDo[0]; | 4845 | ToDo = *Backup.ToDo[0]; |
4846 | error = Phone->SetToDo(&s,&ToDo); | 4846 | error = Phone->SetToDo(&s,&ToDo); |
4847 | } | 4847 | } |
4848 | if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) { | 4848 | if (DoRestore && (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED)) { |
4849 | printmsgerr("Deleting old ToDo: "); | 4849 | printmsgerr("Deleting old ToDo: "); |
4850 | error=Phone->DeleteAllToDo(&s); | 4850 | error=Phone->DeleteAllToDo(&s); |
4851 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 4851 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
4852 | while (1) { | 4852 | while (1) { |
4853 | error = Phone->GetNextToDo(&s,&ToDo,true); | 4853 | error = Phone->GetNextToDo(&s,&ToDo,true); |
4854 | if (error != ERR_NONE) break; | 4854 | if (error != ERR_NONE) break; |
4855 | error = Phone->DeleteToDo(&s,&ToDo); | 4855 | error = Phone->DeleteToDo(&s,&ToDo); |
4856 | Print_Error(error); | 4856 | Print_Error(error); |
4857 | printmsgerr("*"); | 4857 | printmsgerr("*"); |
4858 | } | 4858 | } |
4859 | printmsgerr("\n"); | 4859 | printmsgerr("\n"); |
4860 | } else { | 4860 | } else { |
4861 | printmsgerr("Done\n"); | 4861 | printmsgerr("Done\n"); |
4862 | Print_Error(error); | 4862 | Print_Error(error); |
4863 | } | 4863 | } |
4864 | 4864 | ||
4865 | for (i=0;i<max;i++) { | 4865 | for (i=0;i<max;i++) { |
4866 | ToDo = *Backup.ToDo[i]; | 4866 | ToDo = *Backup.ToDo[i]; |
4867 | ToDo.Location = 0; | 4867 | ToDo.Location = 0; |
4868 | error=Phone->AddToDo(&s,&ToDo); | 4868 | error=Phone->AddToDo(&s,&ToDo); |
4869 | Print_Error(error); | 4869 | Print_Error(error); |
4870 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4870 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4871 | if (gshutdown) { | 4871 | if (gshutdown) { |
4872 | GSM_Terminate(); | 4872 | GSM_Terminate(); |
4873 | exit(0); | 4873 | exit(0); |
4874 | } | 4874 | } |
4875 | } | 4875 | } |
4876 | printmsgerr("\n"); | 4876 | printmsgerr("\n"); |
4877 | } else if (DoRestore) { | 4877 | } else if (DoRestore) { |
4878 | /* At first delete entries, that were deleted */ | 4878 | /* At first delete entries, that were deleted */ |
4879 | used = 0; | 4879 | used = 0; |
4880 | error = Phone->GetNextToDo(&s,&ToDo,true); | 4880 | error = Phone->GetNextToDo(&s,&ToDo,true); |
4881 | while (error == ERR_NONE) { | 4881 | while (error == ERR_NONE) { |
4882 | used++; | 4882 | used++; |
4883 | Found = false; | 4883 | Found = false; |
4884 | for (i=0;i<max;i++) { | 4884 | for (i=0;i<max;i++) { |
4885 | if (Backup.ToDo[i]->Location == ToDo.Location) { | 4885 | if (Backup.ToDo[i]->Location == ToDo.Location) { |
4886 | Found = true; | 4886 | Found = true; |
4887 | break; | 4887 | break; |
4888 | } | 4888 | } |
4889 | } | 4889 | } |
4890 | if (!Found) { | 4890 | if (!Found) { |
4891 | error=Phone->DeleteToDo(&s,&ToDo); | 4891 | error=Phone->DeleteToDo(&s,&ToDo); |
4892 | Print_Error(error); | 4892 | Print_Error(error); |
4893 | } | 4893 | } |
4894 | error = Phone->GetNextToDo(&s,&ToDo,false); | 4894 | error = Phone->GetNextToDo(&s,&ToDo,false); |
4895 | printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used); | 4895 | printmsgerr("%cCleaning: %i percent",13,used*100/ToDoStatus.Used); |
4896 | if (gshutdown) { | 4896 | if (gshutdown) { |
4897 | GSM_Terminate(); | 4897 | GSM_Terminate(); |
4898 | exit(0); | 4898 | exit(0); |
4899 | } | 4899 | } |
4900 | } | 4900 | } |
4901 | printmsgerr("\n"); | 4901 | printmsgerr("\n"); |
4902 | 4902 | ||
4903 | /* Now write modified/new entries */ | 4903 | /* Now write modified/new entries */ |
4904 | for (i=0;i<max;i++) { | 4904 | for (i=0;i<max;i++) { |
4905 | ToDo = *Backup.ToDo[i]; | 4905 | ToDo = *Backup.ToDo[i]; |
4906 | error = Phone->SetToDo(&s,&ToDo); | 4906 | error = Phone->SetToDo(&s,&ToDo); |
4907 | Print_Error(error); | 4907 | Print_Error(error); |
4908 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4908 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4909 | if (gshutdown) { | 4909 | if (gshutdown) { |
4910 | GSM_Terminate(); | 4910 | GSM_Terminate(); |
4911 | exit(0); | 4911 | exit(0); |
4912 | } | 4912 | } |
4913 | } | 4913 | } |
4914 | printmsgerr("\n"); | 4914 | printmsgerr("\n"); |
4915 | } | 4915 | } |
4916 | 4916 | ||
4917 | if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) { | 4917 | if (Backup.SMSC[0] != NULL && answer_yes("Restore SMSC profiles")) { |
4918 | max = 0; | 4918 | max = 0; |
4919 | while (Backup.SMSC[max]!=NULL) max++; | 4919 | while (Backup.SMSC[max]!=NULL) max++; |
4920 | for (i=0;i<max;i++) { | 4920 | for (i=0;i<max;i++) { |
4921 | error=Phone->SetSMSC(&s,Backup.SMSC[i]); | 4921 | error=Phone->SetSMSC(&s,Backup.SMSC[i]); |
4922 | Print_Error(error); | 4922 | Print_Error(error); |
4923 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4923 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4924 | if (gshutdown) { | 4924 | if (gshutdown) { |
4925 | GSM_Terminate(); | 4925 | GSM_Terminate(); |
4926 | exit(0); | 4926 | exit(0); |
4927 | } | 4927 | } |
4928 | } | 4928 | } |
4929 | printmsgerr("\n"); | 4929 | printmsgerr("\n"); |
4930 | } | 4930 | } |
4931 | if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) { | 4931 | if (Backup.StartupLogo != NULL && answer_yes("Restore startup logo/text")) { |
4932 | error=Phone->SetBitmap(&s,Backup.StartupLogo); | 4932 | error=Phone->SetBitmap(&s,Backup.StartupLogo); |
4933 | Print_Error(error); | 4933 | Print_Error(error); |
4934 | } | 4934 | } |
4935 | if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) { | 4935 | if (Backup.OperatorLogo != NULL && answer_yes("Restore operator logo")) { |
4936 | error=Phone->SetBitmap(&s,Backup.OperatorLogo); | 4936 | error=Phone->SetBitmap(&s,Backup.OperatorLogo); |
4937 | Print_Error(error); | 4937 | Print_Error(error); |
4938 | } | 4938 | } |
4939 | DoRestore = false; | 4939 | DoRestore = false; |
4940 | if (Backup.WAPBookmark[0] != NULL) { | 4940 | if (Backup.WAPBookmark[0] != NULL) { |
4941 | Bookmark.Location = 1; | 4941 | Bookmark.Location = 1; |
4942 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 4942 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
4943 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { | 4943 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { |
4944 | if (answer_yes("Restore WAP bookmarks")) DoRestore = true; | 4944 | if (answer_yes("Restore WAP bookmarks")) DoRestore = true; |
4945 | } | 4945 | } |
4946 | } | 4946 | } |
4947 | if (DoRestore) { | 4947 | if (DoRestore) { |
4948 | printmsgerr("Deleting old bookmarks: "); | 4948 | printmsgerr("Deleting old bookmarks: "); |
4949 | /* One thing to explain: DCT4 phones seems to have bug here. | 4949 | /* One thing to explain: DCT4 phones seems to have bug here. |
4950 | * When delete for example first bookmark, phone change | 4950 | * When delete for example first bookmark, phone change |
4951 | * numeration for getting frame, not for deleting. So, we try to | 4951 | * numeration for getting frame, not for deleting. So, we try to |
4952 | * get 1'st bookmark. Inside frame is "correct" location. We use | 4952 | * get 1'st bookmark. Inside frame is "correct" location. We use |
4953 | * it later | 4953 | * it later |
4954 | */ | 4954 | */ |
4955 | while (error==ERR_NONE) { | 4955 | while (error==ERR_NONE) { |
4956 | error = Phone->DeleteWAPBookmark(&s,&Bookmark); | 4956 | error = Phone->DeleteWAPBookmark(&s,&Bookmark); |
4957 | Bookmark.Location = 1; | 4957 | Bookmark.Location = 1; |
4958 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 4958 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
4959 | printmsgerr("*"); | 4959 | printmsgerr("*"); |
4960 | } | 4960 | } |
4961 | printmsgerr("\n"); | 4961 | printmsgerr("\n"); |
4962 | max = 0; | 4962 | max = 0; |
4963 | while (Backup.WAPBookmark[max]!=NULL) max++; | 4963 | while (Backup.WAPBookmark[max]!=NULL) max++; |
4964 | for (i=0;i<max;i++) { | 4964 | for (i=0;i<max;i++) { |
4965 | Bookmark = *Backup.WAPBookmark[i]; | 4965 | Bookmark = *Backup.WAPBookmark[i]; |
4966 | Bookmark.Location = 0; | 4966 | Bookmark.Location = 0; |
4967 | error=Phone->SetWAPBookmark(&s,&Bookmark); | 4967 | error=Phone->SetWAPBookmark(&s,&Bookmark); |
4968 | Print_Error(error); | 4968 | Print_Error(error); |
4969 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4969 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4970 | if (gshutdown) { | 4970 | if (gshutdown) { |
4971 | GSM_Terminate(); | 4971 | GSM_Terminate(); |
4972 | exit(0); | 4972 | exit(0); |
4973 | } | 4973 | } |
4974 | } | 4974 | } |
4975 | printmsgerr("\n"); | 4975 | printmsgerr("\n"); |
4976 | } | 4976 | } |
4977 | DoRestore = false; | 4977 | DoRestore = false; |
4978 | if (Backup.WAPSettings[0] != NULL) { | 4978 | if (Backup.WAPSettings[0] != NULL) { |
4979 | Settings.Location = 1; | 4979 | Settings.Location = 1; |
4980 | error = Phone->GetWAPSettings(&s,&Settings); | 4980 | error = Phone->GetWAPSettings(&s,&Settings); |
4981 | if (error == ERR_NONE) { | 4981 | if (error == ERR_NONE) { |
4982 | if (answer_yes("Restore WAP settings")) DoRestore = true; | 4982 | if (answer_yes("Restore WAP settings")) DoRestore = true; |
4983 | } | 4983 | } |
4984 | } | 4984 | } |
4985 | if (DoRestore) { | 4985 | if (DoRestore) { |
4986 | max = 0; | 4986 | max = 0; |
4987 | while (Backup.WAPSettings[max]!=NULL) max++; | 4987 | while (Backup.WAPSettings[max]!=NULL) max++; |
4988 | for (i=0;i<max;i++) { | 4988 | for (i=0;i<max;i++) { |
4989 | error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]); | 4989 | error=Phone->SetWAPSettings(&s,Backup.WAPSettings[i]); |
4990 | Print_Error(error); | 4990 | Print_Error(error); |
4991 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 4991 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
4992 | if (gshutdown) { | 4992 | if (gshutdown) { |
4993 | GSM_Terminate(); | 4993 | GSM_Terminate(); |
4994 | exit(0); | 4994 | exit(0); |
4995 | } | 4995 | } |
4996 | } | 4996 | } |
4997 | printmsgerr("\n"); | 4997 | printmsgerr("\n"); |
4998 | } | 4998 | } |
4999 | DoRestore = false; | 4999 | DoRestore = false; |
5000 | if (Backup.MMSSettings[0] != NULL) { | 5000 | if (Backup.MMSSettings[0] != NULL) { |
5001 | Settings.Location = 1; | 5001 | Settings.Location = 1; |
5002 | error = Phone->GetMMSSettings(&s,&Settings); | 5002 | error = Phone->GetMMSSettings(&s,&Settings); |
5003 | if (error == ERR_NONE) { | 5003 | if (error == ERR_NONE) { |
5004 | if (answer_yes("Restore MMS settings")) DoRestore = true; | 5004 | if (answer_yes("Restore MMS settings")) DoRestore = true; |
5005 | } | 5005 | } |
5006 | } | 5006 | } |
5007 | if (DoRestore) { | 5007 | if (DoRestore) { |
5008 | max = 0; | 5008 | max = 0; |
5009 | while (Backup.MMSSettings[max]!=NULL) max++; | 5009 | while (Backup.MMSSettings[max]!=NULL) max++; |
5010 | for (i=0;i<max;i++) { | 5010 | for (i=0;i<max;i++) { |
5011 | error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]); | 5011 | error=Phone->SetMMSSettings(&s,Backup.MMSSettings[i]); |
5012 | Print_Error(error); | 5012 | Print_Error(error); |
5013 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5013 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5014 | if (gshutdown) { | 5014 | if (gshutdown) { |
5015 | GSM_Terminate(); | 5015 | GSM_Terminate(); |
5016 | exit(0); | 5016 | exit(0); |
5017 | } | 5017 | } |
5018 | } | 5018 | } |
5019 | printmsgerr("\n"); | 5019 | printmsgerr("\n"); |
5020 | } | 5020 | } |
5021 | DoRestore = false; | 5021 | DoRestore = false; |
5022 | if (Backup.Ringtone[0] != NULL) { | 5022 | if (Backup.Ringtone[0] != NULL) { |
5023 | Ringtone.Location = 1; | 5023 | Ringtone.Location = 1; |
5024 | Ringtone.Format = 0; | 5024 | Ringtone.Format = 0; |
5025 | error = Phone->GetRingtone(&s,&Ringtone,false); | 5025 | error = Phone->GetRingtone(&s,&Ringtone,false); |
5026 | if (error == ERR_NONE || error ==ERR_EMPTY) { | 5026 | if (error == ERR_NONE || error ==ERR_EMPTY) { |
5027 | if (Phone->DeleteUserRingtones != NOTSUPPORTED) { | 5027 | if (Phone->DeleteUserRingtones != NOTSUPPORTED) { |
5028 | if (answer_yes("Delete all user ringtones")) DoRestore = true; | 5028 | if (answer_yes("Delete all user ringtones")) DoRestore = true; |
5029 | } | 5029 | } |
5030 | } | 5030 | } |
5031 | } | 5031 | } |
5032 | if (DoRestore) { | 5032 | if (DoRestore) { |
5033 | printmsgerr("Deleting: "); | 5033 | printmsgerr("Deleting: "); |
5034 | error=Phone->DeleteUserRingtones(&s); | 5034 | error=Phone->DeleteUserRingtones(&s); |
5035 | Print_Error(error); | 5035 | Print_Error(error); |
5036 | printmsgerr("Done\n"); | 5036 | printmsgerr("Done\n"); |
5037 | DoRestore = false; | 5037 | DoRestore = false; |
5038 | if (answer_yes("Restore user ringtones")) DoRestore = true; | 5038 | if (answer_yes("Restore user ringtones")) DoRestore = true; |
5039 | } | 5039 | } |
5040 | if (DoRestore) { | 5040 | if (DoRestore) { |
5041 | max = 0; | 5041 | max = 0; |
5042 | while (Backup.Ringtone[max]!=NULL) max++; | 5042 | while (Backup.Ringtone[max]!=NULL) max++; |
5043 | for (i=0;i<max;i++) { | 5043 | for (i=0;i<max;i++) { |
5044 | error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format); | 5044 | error=GSM_RingtoneConvert(&Ringtone, Backup.Ringtone[i], Ringtone.Format); |
5045 | Print_Error(error); | 5045 | Print_Error(error); |
5046 | error=Phone->SetRingtone(&s,&Ringtone,&i); | 5046 | error=Phone->SetRingtone(&s,&Ringtone,&i); |
5047 | Print_Error(error); | 5047 | Print_Error(error); |
5048 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5048 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5049 | if (gshutdown) { | 5049 | if (gshutdown) { |
5050 | GSM_Terminate(); | 5050 | GSM_Terminate(); |
5051 | exit(0); | 5051 | exit(0); |
5052 | } | 5052 | } |
5053 | } | 5053 | } |
5054 | printmsgerr("\n"); | 5054 | printmsgerr("\n"); |
5055 | } | 5055 | } |
5056 | DoRestore = false; | 5056 | DoRestore = false; |
5057 | if (Backup.Profiles[0] != NULL) { | 5057 | if (Backup.Profiles[0] != NULL) { |
5058 | Profile.Location = 1; | 5058 | Profile.Location = 1; |
5059 | error = Phone->GetProfile(&s,&Profile); | 5059 | error = Phone->GetProfile(&s,&Profile); |
5060 | if (error == ERR_NONE) { | 5060 | if (error == ERR_NONE) { |
5061 | if (answer_yes("Restore profiles")) DoRestore = true; | 5061 | if (answer_yes("Restore profiles")) DoRestore = true; |
5062 | } | 5062 | } |
5063 | } | 5063 | } |
5064 | if (DoRestore) { | 5064 | if (DoRestore) { |
5065 | Profile.Location= 0; | 5065 | Profile.Location= 0; |
5066 | max = 0; | 5066 | max = 0; |
5067 | while (Backup.Profiles[max]!=NULL) max++; | 5067 | while (Backup.Profiles[max]!=NULL) max++; |
5068 | for (i=0;i<max;i++) { | 5068 | for (i=0;i<max;i++) { |
5069 | Profile= *Backup.Profiles[i]; | 5069 | Profile= *Backup.Profiles[i]; |
5070 | error=Phone->SetProfile(&s,&Profile); | 5070 | error=Phone->SetProfile(&s,&Profile); |
5071 | Print_Error(error); | 5071 | Print_Error(error); |
5072 | if (gshutdown) { | 5072 | if (gshutdown) { |
5073 | GSM_Terminate(); | 5073 | GSM_Terminate(); |
5074 | exit(0); | 5074 | exit(0); |
5075 | } | 5075 | } |
5076 | } | 5076 | } |
5077 | printmsgerr("\n"); | 5077 | printmsgerr("\n"); |
5078 | } | 5078 | } |
5079 | DoRestore = false; | 5079 | DoRestore = false; |
5080 | if (Backup.FMStation[0] != NULL) { | 5080 | if (Backup.FMStation[0] != NULL) { |
5081 | FMStation.Location = 1; | 5081 | FMStation.Location = 1; |
5082 | error = Phone->GetFMStation(&s,&FMStation); | 5082 | error = Phone->GetFMStation(&s,&FMStation); |
5083 | if (error == ERR_NONE || error == ERR_EMPTY) { | 5083 | if (error == ERR_NONE || error == ERR_EMPTY) { |
5084 | if (answer_yes("Restore FM stations")) DoRestore = true; | 5084 | if (answer_yes("Restore FM stations")) DoRestore = true; |
5085 | } | 5085 | } |
5086 | } | 5086 | } |
5087 | if (DoRestore) { | 5087 | if (DoRestore) { |
5088 | printmsgerr("Deleting old FM stations: "); | 5088 | printmsgerr("Deleting old FM stations: "); |
5089 | error=Phone->ClearFMStations(&s); | 5089 | error=Phone->ClearFMStations(&s); |
5090 | Print_Error(error); | 5090 | Print_Error(error); |
5091 | printmsgerr("Done\n"); | 5091 | printmsgerr("Done\n"); |
5092 | max = 0; | 5092 | max = 0; |
5093 | while (Backup.FMStation[max]!=NULL) max++; | 5093 | while (Backup.FMStation[max]!=NULL) max++; |
5094 | for (i=0;i<max;i++) { | 5094 | for (i=0;i<max;i++) { |
5095 | FMStation = *Backup.FMStation[i]; | 5095 | FMStation = *Backup.FMStation[i]; |
5096 | error=Phone->SetFMStation(&s,&FMStation); | 5096 | error=Phone->SetFMStation(&s,&FMStation); |
5097 | Print_Error(error); | 5097 | Print_Error(error); |
5098 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5098 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5099 | if (gshutdown) { | 5099 | if (gshutdown) { |
5100 | GSM_Terminate(); | 5100 | GSM_Terminate(); |
5101 | exit(0); | 5101 | exit(0); |
5102 | } | 5102 | } |
5103 | } | 5103 | } |
5104 | printmsgerr("\n"); | 5104 | printmsgerr("\n"); |
5105 | } | 5105 | } |
5106 | DoRestore = false; | 5106 | DoRestore = false; |
5107 | if (Backup.GPRSPoint[0] != NULL) { | 5107 | if (Backup.GPRSPoint[0] != NULL) { |
5108 | GPRSPoint.Location = 1; | 5108 | GPRSPoint.Location = 1; |
5109 | error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); | 5109 | error = Phone->GetGPRSAccessPoint(&s,&GPRSPoint); |
5110 | if (error == ERR_NONE || error == ERR_EMPTY) { | 5110 | if (error == ERR_NONE || error == ERR_EMPTY) { |
5111 | if (answer_yes("Restore GPRS Points")) DoRestore = true; | 5111 | if (answer_yes("Restore GPRS Points")) DoRestore = true; |
5112 | } | 5112 | } |
5113 | } | 5113 | } |
5114 | if (DoRestore) { | 5114 | if (DoRestore) { |
5115 | max = 0; | 5115 | max = 0; |
5116 | while (Backup.GPRSPoint[max]!=NULL) max++; | 5116 | while (Backup.GPRSPoint[max]!=NULL) max++; |
5117 | for (i=0;i<max;i++) { | 5117 | for (i=0;i<max;i++) { |
5118 | error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]); | 5118 | error=Phone->SetGPRSAccessPoint(&s,Backup.GPRSPoint[i]); |
5119 | Print_Error(error); | 5119 | Print_Error(error); |
5120 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5120 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5121 | if (gshutdown) { | 5121 | if (gshutdown) { |
5122 | GSM_Terminate(); | 5122 | GSM_Terminate(); |
5123 | exit(0); | 5123 | exit(0); |
5124 | } | 5124 | } |
5125 | } | 5125 | } |
5126 | printmsgerr("\n"); | 5126 | printmsgerr("\n"); |
5127 | } | 5127 | } |
5128 | 5128 | ||
5129 | GSM_Terminate(); | 5129 | GSM_Terminate(); |
5130 | } | 5130 | } |
5131 | 5131 | ||
5132 | static void AddNew(int argc, char *argv[]) | 5132 | static void AddNew(int argc, char *argv[]) |
5133 | { | 5133 | { |
5134 | GSM_Backup Backup; | 5134 | GSM_Backup Backup; |
5135 | GSM_DateTime date_time; | 5135 | GSM_DateTime date_time; |
5136 | GSM_MemoryEntry Pbk; | 5136 | GSM_MemoryEntry Pbk; |
5137 | GSM_MemoryStatusMemStatus; | 5137 | GSM_MemoryStatusMemStatus; |
5138 | GSM_ToDoEntry ToDo; | 5138 | GSM_ToDoEntry ToDo; |
5139 | GSM_ToDoStatus ToDoStatus; | 5139 | GSM_ToDoStatus ToDoStatus; |
5140 | GSM_CalendarEntryCalendar; | 5140 | GSM_CalendarEntryCalendar; |
5141 | GSM_WAPBookmark Bookmark; | 5141 | GSM_WAPBookmark Bookmark; |
5142 | int i, max, j; | 5142 | int i, max, j; |
5143 | 5143 | ||
5144 | error=GSM_ReadBackupFile(argv[2],&Backup); | 5144 | error=GSM_ReadBackupFile(argv[2],&Backup); |
5145 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); | 5145 | if (error!=ERR_NOTIMPLEMENTED) Print_Error(error); |
5146 | 5146 | ||
5147 | signal(SIGINT, interrupt); | 5147 | signal(SIGINT, interrupt); |
5148 | printmsgerr("Press Ctrl+C to break...\n"); | 5148 | printmsgerr("Press Ctrl+C to break...\n"); |
5149 | 5149 | ||
5150 | if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); | 5150 | if (Backup.DateTimeAvailable) printmsgerr("Time of backup : %s\n",OSDateTime(Backup.DateTime,false)); |
5151 | if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); | 5151 | if (Backup.Model[0]!=0) printmsgerr("Phone : %s\n",Backup.Model); |
5152 | if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); | 5152 | if (Backup.IMEI[0]!=0) printmsgerr("IMEI : %s\n",Backup.IMEI); |
5153 | 5153 | ||
5154 | GSM_Init(true); | 5154 | GSM_Init(true); |
5155 | 5155 | ||
5156 | if (Backup.PhonePhonebook[0] != NULL) { | 5156 | if (Backup.PhonePhonebook[0] != NULL) { |
5157 | MemStatus.MemoryType = MEM_ME; | 5157 | MemStatus.MemoryType = MEM_ME; |
5158 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 5158 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
5159 | if (error==ERR_NONE) { | 5159 | if (error==ERR_NONE) { |
5160 | max = 0; | 5160 | max = 0; |
5161 | while (Backup.PhonePhonebook[max]!=NULL) max++; | 5161 | while (Backup.PhonePhonebook[max]!=NULL) max++; |
5162 | printmsgerr("%i entries in backup file\n",max); | 5162 | printmsgerr("%i entries in backup file\n",max); |
5163 | if (MemStatus.MemoryFree < max) { | 5163 | if (MemStatus.MemoryFree < max) { |
5164 | printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); | 5164 | printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); |
5165 | } else if (answer_yes("Add phone phonebook entries")) { | 5165 | } else if (answer_yes("Add phone phonebook entries")) { |
5166 | for (i=0;i<max;i++) { | 5166 | for (i=0;i<max;i++) { |
5167 | Pbk = *Backup.PhonePhonebook[i]; | 5167 | Pbk = *Backup.PhonePhonebook[i]; |
5168 | Pbk.MemoryType = MEM_ME; | 5168 | Pbk.MemoryType = MEM_ME; |
5169 | error=Phone->AddMemory(&s, &Pbk); | 5169 | error=Phone->AddMemory(&s, &Pbk); |
5170 | Print_Error(error); | 5170 | Print_Error(error); |
5171 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5171 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5172 | if (gshutdown) { | 5172 | if (gshutdown) { |
5173 | GSM_Terminate(); | 5173 | GSM_Terminate(); |
5174 | exit(0); | 5174 | exit(0); |
5175 | } | 5175 | } |
5176 | } | 5176 | } |
5177 | printmsgerr("\n"); | 5177 | printmsgerr("\n"); |
5178 | } | 5178 | } |
5179 | } | 5179 | } |
5180 | } | 5180 | } |
5181 | if (Backup.SIMPhonebook[0] != NULL) { | 5181 | if (Backup.SIMPhonebook[0] != NULL) { |
5182 | MemStatus.MemoryType = MEM_SM; | 5182 | MemStatus.MemoryType = MEM_SM; |
5183 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 5183 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
5184 | if (error==ERR_NONE) { | 5184 | if (error==ERR_NONE) { |
5185 | max = 0; | 5185 | max = 0; |
5186 | while (Backup.SIMPhonebook[max]!=NULL) max++; | 5186 | while (Backup.SIMPhonebook[max]!=NULL) max++; |
5187 | printmsgerr("%i entries in backup file\n",max); | 5187 | printmsgerr("%i entries in backup file\n",max); |
5188 | if (MemStatus.MemoryFree < max) { | 5188 | if (MemStatus.MemoryFree < max) { |
5189 | printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); | 5189 | printmsgerr("Memory has only %i free locations.Exiting\n",MemStatus.MemoryFree); |
5190 | } else if (answer_yes("Add SIM phonebook entries")) { | 5190 | } else if (answer_yes("Add SIM phonebook entries")) { |
5191 | j = 1; | 5191 | j = 1; |
5192 | for (i=0;i<max;i++) { | 5192 | for (i=0;i<max;i++) { |
5193 | Pbk = *Backup.SIMPhonebook[i]; | 5193 | Pbk = *Backup.SIMPhonebook[i]; |
5194 | Pbk.MemoryType = MEM_SM; | 5194 | Pbk.MemoryType = MEM_SM; |
5195 | error=Phone->AddMemory(&s, &Pbk); | 5195 | error=Phone->AddMemory(&s, &Pbk); |
5196 | Print_Error(error); | 5196 | Print_Error(error); |
5197 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5197 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5198 | if (gshutdown) { | 5198 | if (gshutdown) { |
5199 | GSM_Terminate(); | 5199 | GSM_Terminate(); |
5200 | exit(0); | 5200 | exit(0); |
5201 | } | 5201 | } |
5202 | } | 5202 | } |
5203 | printmsgerr("\n"); | 5203 | printmsgerr("\n"); |
5204 | } | 5204 | } |
5205 | } | 5205 | } |
5206 | } | 5206 | } |
5207 | 5207 | ||
5208 | if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { | 5208 | if (!mystrncasecmp(s.CurrentConfig->SyncTime,"yes",0)) { |
5209 | 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)")*/) { | 5209 | 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)")*/) { |
5210 | GSM_GetCurrentDateTime(&date_time); | 5210 | GSM_GetCurrentDateTime(&date_time); |
5211 | 5211 | ||
5212 | error=Phone->SetDateTime(&s, &date_time); | 5212 | error=Phone->SetDateTime(&s, &date_time); |
5213 | Print_Error(error); | 5213 | Print_Error(error); |
5214 | } | 5214 | } |
5215 | } | 5215 | } |
5216 | if (Backup.Calendar[0] != NULL) { | 5216 | if (Backup.Calendar[0] != NULL) { |
5217 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 5217 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
5218 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { | 5218 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION || error == ERR_EMPTY) { |
5219 | if (answer_yes("Add calendar notes")) { | 5219 | if (answer_yes("Add calendar notes")) { |
5220 | max = 0; | 5220 | max = 0; |
5221 | while (Backup.Calendar[max]!=NULL) max++; | 5221 | while (Backup.Calendar[max]!=NULL) max++; |
5222 | for (i=0;i<max;i++) { | 5222 | for (i=0;i<max;i++) { |
5223 | Calendar = *Backup.Calendar[i]; | 5223 | Calendar = *Backup.Calendar[i]; |
5224 | error=Phone->AddCalendar(&s,&Calendar); | 5224 | error=Phone->AddCalendar(&s,&Calendar); |
5225 | Print_Error(error); | 5225 | Print_Error(error); |
5226 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5226 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5227 | if (gshutdown) { | 5227 | if (gshutdown) { |
5228 | GSM_Terminate(); | 5228 | GSM_Terminate(); |
5229 | exit(0); | 5229 | exit(0); |
5230 | } | 5230 | } |
5231 | } | 5231 | } |
5232 | printmsgerr("\n"); | 5232 | printmsgerr("\n"); |
5233 | } | 5233 | } |
5234 | } | 5234 | } |
5235 | } | 5235 | } |
5236 | if (Backup.ToDo[0] != NULL) { | 5236 | if (Backup.ToDo[0] != NULL) { |
5237 | ToDo.Location = 1; | 5237 | ToDo.Location = 1; |
5238 | error=Phone->GetToDoStatus(&s,&ToDoStatus); | 5238 | error=Phone->GetToDoStatus(&s,&ToDoStatus); |
5239 | if (error == ERR_NONE) { | 5239 | if (error == ERR_NONE) { |
5240 | if (answer_yes("Add ToDo")) { | 5240 | if (answer_yes("Add ToDo")) { |
5241 | max = 0; | 5241 | max = 0; |
5242 | while (Backup.ToDo[max]!=NULL) max++; | 5242 | while (Backup.ToDo[max]!=NULL) max++; |
5243 | for (i=0;i<max;i++) { | 5243 | for (i=0;i<max;i++) { |
5244 | ToDo = *Backup.ToDo[i]; | 5244 | ToDo = *Backup.ToDo[i]; |
5245 | error = Phone->AddToDo(&s,&ToDo); | 5245 | error = Phone->AddToDo(&s,&ToDo); |
5246 | Print_Error(error); | 5246 | Print_Error(error); |
5247 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5247 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5248 | if (gshutdown) { | 5248 | if (gshutdown) { |
5249 | GSM_Terminate(); | 5249 | GSM_Terminate(); |
5250 | exit(0); | 5250 | exit(0); |
5251 | } | 5251 | } |
5252 | } | 5252 | } |
5253 | printmsgerr("\n"); | 5253 | printmsgerr("\n"); |
5254 | } | 5254 | } |
5255 | } | 5255 | } |
5256 | } | 5256 | } |
5257 | if (Backup.WAPBookmark[0] != NULL) { | 5257 | if (Backup.WAPBookmark[0] != NULL) { |
5258 | Bookmark.Location = 1; | 5258 | Bookmark.Location = 1; |
5259 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 5259 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
5260 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { | 5260 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { |
5261 | if (answer_yes("Add WAP bookmarks")) { | 5261 | if (answer_yes("Add WAP bookmarks")) { |
5262 | max = 0; | 5262 | max = 0; |
5263 | while (Backup.WAPBookmark[max]!=NULL) max++; | 5263 | while (Backup.WAPBookmark[max]!=NULL) max++; |
5264 | for (i=0;i<max;i++) { | 5264 | for (i=0;i<max;i++) { |
5265 | Bookmark = *Backup.WAPBookmark[i]; | 5265 | Bookmark = *Backup.WAPBookmark[i]; |
5266 | Bookmark.Location = 0; | 5266 | Bookmark.Location = 0; |
5267 | error=Phone->SetWAPBookmark(&s,&Bookmark); | 5267 | error=Phone->SetWAPBookmark(&s,&Bookmark); |
5268 | Print_Error(error); | 5268 | Print_Error(error); |
5269 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); | 5269 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/max); |
5270 | if (gshutdown) { | 5270 | if (gshutdown) { |
5271 | GSM_Terminate(); | 5271 | GSM_Terminate(); |
5272 | exit(0); | 5272 | exit(0); |
5273 | } | 5273 | } |
5274 | } | 5274 | } |
5275 | printmsgerr("\n"); | 5275 | printmsgerr("\n"); |
5276 | } | 5276 | } |
5277 | } | 5277 | } |
5278 | } | 5278 | } |
5279 | 5279 | ||
5280 | GSM_Terminate(); | 5280 | GSM_Terminate(); |
5281 | } | 5281 | } |
5282 | #endif | 5282 | #endif |
5283 | 5283 | ||
5284 | static void ClearAll(int argc, char *argv[]) | 5284 | static void ClearAll(int argc, char *argv[]) |
5285 | { | 5285 | { |
5286 | GSM_MemoryStatusMemStatus; | 5286 | GSM_MemoryStatusMemStatus; |
5287 | GSM_ToDoStatus ToDoStatus; | 5287 | GSM_ToDoStatus ToDoStatus; |
5288 | GSM_CalendarEntryCalendar; | 5288 | GSM_CalendarEntryCalendar; |
5289 | GSM_ToDoEntry ToDo; | 5289 | GSM_ToDoEntry ToDo; |
5290 | GSM_WAPBookmark Bookmark; | 5290 | GSM_WAPBookmark Bookmark; |
5291 | GSM_FMStation Station; | 5291 | GSM_FMStation Station; |
5292 | GSM_MemoryEntry Pbk; | 5292 | GSM_MemoryEntry Pbk; |
5293 | bool DoClear; | 5293 | bool DoClear; |
5294 | 5294 | ||
5295 | GSM_Init(true); | 5295 | GSM_Init(true); |
5296 | 5296 | ||
5297 | DoClear = false; | 5297 | DoClear = false; |
5298 | MemStatus.MemoryType = MEM_ME; | 5298 | MemStatus.MemoryType = MEM_ME; |
5299 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 5299 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
5300 | if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { | 5300 | if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { |
5301 | if (answer_yes("Delete phone phonebook")) DoClear = true; | 5301 | if (answer_yes("Delete phone phonebook")) DoClear = true; |
5302 | } | 5302 | } |
5303 | if (DoClear) { | 5303 | if (DoClear) { |
5304 | error = Phone->DeleteAllMemory(&s,MEM_ME); | 5304 | error = Phone->DeleteAllMemory(&s,MEM_ME); |
5305 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 5305 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
5306 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { | 5306 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { |
5307 | Pbk.MemoryType = MEM_ME; | 5307 | Pbk.MemoryType = MEM_ME; |
5308 | Pbk.Location= i + 1; | 5308 | Pbk.Location= i + 1; |
5309 | Pbk.EntriesNum= 0; | 5309 | Pbk.EntriesNum= 0; |
5310 | error=Phone->DeleteMemory(&s, &Pbk); | 5310 | error=Phone->DeleteMemory(&s, &Pbk); |
5311 | Print_Error(error); | 5311 | Print_Error(error); |
5312 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); | 5312 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); |
5313 | if (gshutdown) { | 5313 | if (gshutdown) { |
5314 | GSM_Terminate(); | 5314 | GSM_Terminate(); |
5315 | exit(0); | 5315 | exit(0); |
5316 | } | 5316 | } |
5317 | } | 5317 | } |
5318 | printmsgerr("\n"); | 5318 | printmsgerr("\n"); |
5319 | } else { | 5319 | } else { |
5320 | printmsgerr("Done\n"); | 5320 | printmsgerr("Done\n"); |
5321 | Print_Error(error); | 5321 | Print_Error(error); |
5322 | } | 5322 | } |
5323 | } | 5323 | } |
5324 | 5324 | ||
5325 | DoClear = false; | 5325 | DoClear = false; |
5326 | MemStatus.MemoryType = MEM_SM; | 5326 | MemStatus.MemoryType = MEM_SM; |
5327 | error=Phone->GetMemoryStatus(&s, &MemStatus); | 5327 | error=Phone->GetMemoryStatus(&s, &MemStatus); |
5328 | if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { | 5328 | if (error==ERR_NONE && MemStatus.MemoryUsed !=0) { |
5329 | if (answer_yes("Delete SIM phonebook")) DoClear = true; | 5329 | if (answer_yes("Delete SIM phonebook")) DoClear = true; |
5330 | } | 5330 | } |
5331 | if (DoClear) { | 5331 | if (DoClear) { |
5332 | error = Phone->DeleteAllMemory(&s,MEM_SM); | 5332 | error = Phone->DeleteAllMemory(&s,MEM_SM); |
5333 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 5333 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
5334 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { | 5334 | for (i=0;i<MemStatus.MemoryUsed+MemStatus.MemoryFree;i++) { |
5335 | Pbk.MemoryType = MEM_SM; | 5335 | Pbk.MemoryType = MEM_SM; |
5336 | Pbk.Location= i + 1; | 5336 | Pbk.Location= i + 1; |
5337 | Pbk.EntriesNum= 0; | 5337 | Pbk.EntriesNum= 0; |
5338 | error=Phone->DeleteMemory(&s, &Pbk); | 5338 | error=Phone->DeleteMemory(&s, &Pbk); |
5339 | Print_Error(error); | 5339 | Print_Error(error); |
5340 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); | 5340 | printmsgerr("%cWriting: %i percent",13,(i+1)*100/(MemStatus.MemoryUsed+MemStatus.MemoryFree)); |
5341 | if (gshutdown) { | 5341 | if (gshutdown) { |
5342 | GSM_Terminate(); | 5342 | GSM_Terminate(); |
5343 | exit(0); | 5343 | exit(0); |
5344 | } | 5344 | } |
5345 | } | 5345 | } |
5346 | printmsgerr("\n"); | 5346 | printmsgerr("\n"); |
5347 | } else { | 5347 | } else { |
5348 | printmsgerr("Done\n"); | 5348 | printmsgerr("Done\n"); |
5349 | Print_Error(error); | 5349 | Print_Error(error); |
5350 | } | 5350 | } |
5351 | } | 5351 | } |
5352 | 5352 | ||
5353 | DoClear = false; | 5353 | DoClear = false; |
5354 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 5354 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
5355 | if (error == ERR_NONE) { | 5355 | if (error == ERR_NONE) { |
5356 | if (answer_yes("Delete calendar notes")) DoClear = true; | 5356 | if (answer_yes("Delete calendar notes")) DoClear = true; |
5357 | } | 5357 | } |
5358 | if (DoClear) { | 5358 | if (DoClear) { |
5359 | printmsgerr("Deleting: "); | 5359 | printmsgerr("Deleting: "); |
5360 | error=Phone->DeleteAllCalendar(&s); | 5360 | error=Phone->DeleteAllCalendar(&s); |
5361 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 5361 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
5362 | while (1) { | 5362 | while (1) { |
5363 | error = Phone->GetNextCalendar(&s,&Calendar,true); | 5363 | error = Phone->GetNextCalendar(&s,&Calendar,true); |
5364 | if (error != ERR_NONE) break; | 5364 | if (error != ERR_NONE) break; |
5365 | error = Phone->DeleteCalendar(&s,&Calendar); | 5365 | error = Phone->DeleteCalendar(&s,&Calendar); |
5366 | Print_Error(error); | 5366 | Print_Error(error); |
5367 | printmsgerr("*"); | 5367 | printmsgerr("*"); |
5368 | } | 5368 | } |
5369 | printmsgerr("\n"); | 5369 | printmsgerr("\n"); |
5370 | } else { | 5370 | } else { |
5371 | printmsgerr("Done\n"); | 5371 | printmsgerr("Done\n"); |
5372 | Print_Error(error); | 5372 | Print_Error(error); |
5373 | } | 5373 | } |
5374 | } | 5374 | } |
5375 | 5375 | ||
5376 | DoClear = false; | 5376 | DoClear = false; |
5377 | error = Phone->GetToDoStatus(&s,&ToDoStatus); | 5377 | error = Phone->GetToDoStatus(&s,&ToDoStatus); |
5378 | if (error == ERR_NONE && ToDoStatus.Used != 0) { | 5378 | if (error == ERR_NONE && ToDoStatus.Used != 0) { |
5379 | if (answer_yes("Delete ToDo")) DoClear = true; | 5379 | if (answer_yes("Delete ToDo")) DoClear = true; |
5380 | } | 5380 | } |
5381 | if (DoClear) { | 5381 | if (DoClear) { |
5382 | printmsgerr("Deleting: "); | 5382 | printmsgerr("Deleting: "); |
5383 | error=Phone->DeleteAllToDo(&s); | 5383 | error=Phone->DeleteAllToDo(&s); |
5384 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 5384 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
5385 | while (1) { | 5385 | while (1) { |
5386 | error = Phone->GetNextToDo(&s,&ToDo,true); | 5386 | error = Phone->GetNextToDo(&s,&ToDo,true); |
5387 | if (error != ERR_NONE) break; | 5387 | if (error != ERR_NONE) break; |
5388 | error = Phone->DeleteToDo(&s,&ToDo); | 5388 | error = Phone->DeleteToDo(&s,&ToDo); |
5389 | Print_Error(error); | 5389 | Print_Error(error); |
5390 | printmsgerr("*"); | 5390 | printmsgerr("*"); |
5391 | } | 5391 | } |
5392 | printmsgerr("\n"); | 5392 | printmsgerr("\n"); |
5393 | } else { | 5393 | } else { |
5394 | printmsgerr("Done\n"); | 5394 | printmsgerr("Done\n"); |
5395 | Print_Error(error); | 5395 | Print_Error(error); |
5396 | } | 5396 | } |
5397 | } | 5397 | } |
5398 | 5398 | ||
5399 | Bookmark.Location = 1; | 5399 | Bookmark.Location = 1; |
5400 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 5400 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
5401 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { | 5401 | if (error == ERR_NONE || error == ERR_INVALIDLOCATION) { |
5402 | if (answer_yes("Delete WAP bookmarks")) { | 5402 | if (answer_yes("Delete WAP bookmarks")) { |
5403 | printmsgerr("Deleting: "); | 5403 | printmsgerr("Deleting: "); |
5404 | /* One thing to explain: DCT4 phones seems to have bug here. | 5404 | /* One thing to explain: DCT4 phones seems to have bug here. |
5405 | * When delete for example first bookmark, phone change | 5405 | * When delete for example first bookmark, phone change |
5406 | * numeration for getting frame, not for deleting. So, we try to | 5406 | * numeration for getting frame, not for deleting. So, we try to |
5407 | * get 1'st bookmark. Inside frame is "correct" location. We use | 5407 | * get 1'st bookmark. Inside frame is "correct" location. We use |
5408 | * it later | 5408 | * it later |
5409 | */ | 5409 | */ |
5410 | while (error==ERR_NONE) { | 5410 | while (error==ERR_NONE) { |
5411 | error = Phone->DeleteWAPBookmark(&s,&Bookmark); | 5411 | error = Phone->DeleteWAPBookmark(&s,&Bookmark); |
5412 | Bookmark.Location = 1; | 5412 | Bookmark.Location = 1; |
5413 | error = Phone->GetWAPBookmark(&s,&Bookmark); | 5413 | error = Phone->GetWAPBookmark(&s,&Bookmark); |
5414 | printmsgerr("*"); | 5414 | printmsgerr("*"); |
5415 | } | 5415 | } |
5416 | printmsgerr("\n"); | 5416 | printmsgerr("\n"); |
5417 | } | 5417 | } |
5418 | } | 5418 | } |
5419 | if (Phone->DeleteUserRingtones != NOTSUPPORTED) { | 5419 | if (Phone->DeleteUserRingtones != NOTSUPPORTED) { |
5420 | if (answer_yes("Delete all user ringtones")) { | 5420 | if (answer_yes("Delete all user ringtones")) { |
5421 | printmsgerr("Deleting: "); | 5421 | printmsgerr("Deleting: "); |
5422 | error=Phone->DeleteUserRingtones(&s); | 5422 | error=Phone->DeleteUserRingtones(&s); |
5423 | Print_Error(error); | 5423 | Print_Error(error); |
5424 | printmsgerr("Done\n"); | 5424 | printmsgerr("Done\n"); |
5425 | } | 5425 | } |
5426 | } | 5426 | } |
5427 | Station.Location=i; | 5427 | Station.Location=i; |
5428 | error=Phone->GetFMStation(&s,&Station); | 5428 | error=Phone->GetFMStation(&s,&Station); |
5429 | if (error == ERR_NONE || error == ERR_EMPTY) { | 5429 | if (error == ERR_NONE || error == ERR_EMPTY) { |
5430 | if (answer_yes("Delete all FM station")) { | 5430 | if (answer_yes("Delete all FM station")) { |
5431 | error=Phone->ClearFMStations(&s); | 5431 | error=Phone->ClearFMStations(&s); |
5432 | Print_Error(error); | 5432 | Print_Error(error); |
5433 | } | 5433 | } |
5434 | } | 5434 | } |
5435 | 5435 | ||
5436 | GSM_Terminate(); | 5436 | GSM_Terminate(); |
5437 | } | 5437 | } |
5438 | 5438 | ||
5439 | static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) | 5439 | static void DisplayConnectionSettings(GSM_MultiWAPSettings *settings,int j) |
5440 | { | 5440 | { |
5441 | if (settings->Settings[j].IsContinuous) { | 5441 | if (settings->Settings[j].IsContinuous) { |
5442 | printmsg("Connection type : Continuous\n"); | 5442 | printmsg("Connection type : Continuous\n"); |
5443 | } else { | 5443 | } else { |
5444 | printmsg("Connection type : Temporary\n"); | 5444 | printmsg("Connection type : Temporary\n"); |
5445 | } | 5445 | } |
5446 | if (settings->Settings[j].IsSecurity) { | 5446 | if (settings->Settings[j].IsSecurity) { |
5447 | printmsg("Connection security : On\n"); | 5447 | printmsg("Connection security : On\n"); |
5448 | } else { | 5448 | } else { |
5449 | printmsg("Connection security : Off\n"); | 5449 | printmsg("Connection security : Off\n"); |
5450 | } | 5450 | } |
5451 | printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort); | 5451 | printmsg("Proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy),settings->ProxyPort); |
5452 | printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port); | 5452 | printmsg("2'nd proxy : address \"%s\", port %i\n",DecodeUnicodeConsole(settings->Proxy2),settings->Proxy2Port); |
5453 | switch (settings->Settings[j].Bearer) { | 5453 | switch (settings->Settings[j].Bearer) { |
5454 | case WAPSETTINGS_BEARER_SMS: | 5454 | case WAPSETTINGS_BEARER_SMS: |
5455 | printmsg("Bearer : SMS"); | 5455 | printmsg("Bearer : SMS"); |
5456 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)"); | 5456 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_SMS) printf(" (active)"); |
5457 | printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server)); | 5457 | printmsg("\nServer number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Server)); |
5458 | printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); | 5458 | printmsg("Service number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); |
5459 | break; | 5459 | break; |
5460 | case WAPSETTINGS_BEARER_DATA: | 5460 | case WAPSETTINGS_BEARER_DATA: |
5461 | printmsg("Bearer : Data (CSD)"); | 5461 | printmsg("Bearer : Data (CSD)"); |
5462 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)"); | 5462 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_DATA) printf(" (active)"); |
5463 | printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); | 5463 | printmsg("\nDial-up number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); |
5464 | printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); | 5464 | printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); |
5465 | if (settings->Settings[j].ManualLogin) { | 5465 | if (settings->Settings[j].ManualLogin) { |
5466 | printmsg("Login Type : Manual\n"); | 5466 | printmsg("Login Type : Manual\n"); |
5467 | } else { | 5467 | } else { |
5468 | printmsg("Login Type : Automatic\n"); | 5468 | printmsg("Login Type : Automatic\n"); |
5469 | } | 5469 | } |
5470 | if (settings->Settings[j].IsNormalAuthentication) { | 5470 | if (settings->Settings[j].IsNormalAuthentication) { |
5471 | printmsg("Authentication type : Normal\n"); | 5471 | printmsg("Authentication type : Normal\n"); |
5472 | } else { | 5472 | } else { |
5473 | printmsg("Authentication type : Secure\n"); | 5473 | printmsg("Authentication type : Secure\n"); |
5474 | } | 5474 | } |
5475 | if (settings->Settings[j].IsISDNCall) { | 5475 | if (settings->Settings[j].IsISDNCall) { |
5476 | printmsg("Data call type : ISDN\n"); | 5476 | printmsg("Data call type : ISDN\n"); |
5477 | } else { | 5477 | } else { |
5478 | printmsg("Data call type : Analogue\n"); | 5478 | printmsg("Data call type : Analogue\n"); |
5479 | } | 5479 | } |
5480 | switch (settings->Settings[j].Speed) { | 5480 | switch (settings->Settings[j].Speed) { |
5481 | case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break; | 5481 | case WAPSETTINGS_SPEED_9600 : printmsg("Data call speed : 9600\n"); break; |
5482 | case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break; | 5482 | case WAPSETTINGS_SPEED_14400 : printmsg("Data call speed : 14400\n"); break; |
5483 | case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break; | 5483 | case WAPSETTINGS_SPEED_AUTO : printmsg("Data call speed : Auto\n"); break; |
5484 | } | 5484 | } |
5485 | printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); | 5485 | printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); |
5486 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); | 5486 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); |
5487 | break; | 5487 | break; |
5488 | case WAPSETTINGS_BEARER_USSD: | 5488 | case WAPSETTINGS_BEARER_USSD: |
5489 | printmsg("Bearer : USSD"); | 5489 | printmsg("Bearer : USSD"); |
5490 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)"); | 5490 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_USSD) printf(" (active)"); |
5491 | printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code)); | 5491 | printmsg("\nService code : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Code)); |
5492 | if (settings->Settings[j].IsIP) { | 5492 | if (settings->Settings[j].IsIP) { |
5493 | printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); | 5493 | printmsg("Address type : IP address\nIPaddress : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); |
5494 | } else { | 5494 | } else { |
5495 | printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); | 5495 | printmsg("Address type : Service number\nService number : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Service)); |
5496 | } | 5496 | } |
5497 | break; | 5497 | break; |
5498 | case WAPSETTINGS_BEARER_GPRS: | 5498 | case WAPSETTINGS_BEARER_GPRS: |
5499 | printmsg("Bearer : GPRS"); | 5499 | printmsg("Bearer : GPRS"); |
5500 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)"); | 5500 | if (settings->ActiveBearer == WAPSETTINGS_BEARER_GPRS) printf(" (active)"); |
5501 | if (settings->Settings[j].ManualLogin) { | 5501 | if (settings->Settings[j].ManualLogin) { |
5502 | printmsg("\nLogin Type : Manual\n"); | 5502 | printmsg("\nLogin Type : Manual\n"); |
5503 | } else { | 5503 | } else { |
5504 | printmsg("\nLogin Type : Automatic\n"); | 5504 | printmsg("\nLogin Type : Automatic\n"); |
5505 | } | 5505 | } |
5506 | if (settings->Settings[j].IsNormalAuthentication) { | 5506 | if (settings->Settings[j].IsNormalAuthentication) { |
5507 | printmsg("Authentication type : Normal\n"); | 5507 | printmsg("Authentication type : Normal\n"); |
5508 | } else { | 5508 | } else { |
5509 | printmsg("Authentication type : Secure\n"); | 5509 | printmsg("Authentication type : Secure\n"); |
5510 | } | 5510 | } |
5511 | printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); | 5511 | printmsg("Access point : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].DialUp)); |
5512 | printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); | 5512 | printmsg("IP address : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].IPAddress)); |
5513 | printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); | 5513 | printmsg("User name : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].User)); |
5514 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); | 5514 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings->Settings[j].Password)); |
5515 | } | 5515 | } |
5516 | } | 5516 | } |
5517 | 5517 | ||
5518 | static void GetSyncMLSettings(int argc, char *argv[]) | 5518 | static void GetSyncMLSettings(int argc, char *argv[]) |
5519 | { | 5519 | { |
5520 | GSM_SyncMLSettingssettings; | 5520 | GSM_SyncMLSettingssettings; |
5521 | int start,stop,j; | 5521 | int start,stop,j; |
5522 | 5522 | ||
5523 | GetStartStop(&start, &stop, 2, argc, argv); | 5523 | GetStartStop(&start, &stop, 2, argc, argv); |
5524 | 5524 | ||
5525 | GSM_Init(true); | 5525 | GSM_Init(true); |
5526 | 5526 | ||
5527 | for (i=start;i<=stop;i++) { | 5527 | for (i=start;i<=stop;i++) { |
5528 | settings.Location=i; | 5528 | settings.Location=i; |
5529 | error=Phone->GetSyncMLSettings(&s,&settings); | 5529 | error=Phone->GetSyncMLSettings(&s,&settings); |
5530 | Print_Error(error); | 5530 | Print_Error(error); |
5531 | printmsg("%i. ",i); | 5531 | printmsg("%i. ",i); |
5532 | if (settings.Name[0]==0 && settings.Name[1]==0) { | 5532 | if (settings.Name[0]==0 && settings.Name[1]==0) { |
5533 | printmsg("Set %i",i); | 5533 | printmsg("Set %i",i); |
5534 | } else { | 5534 | } else { |
5535 | printmsg("%s",DecodeUnicodeConsole(settings.Name)); | 5535 | printmsg("%s",DecodeUnicodeConsole(settings.Name)); |
5536 | } | 5536 | } |
5537 | if (settings.Active) printmsg(" (active)"); | 5537 | if (settings.Active) printmsg(" (active)"); |
5538 | // if (settings.ReadOnly) printmsg("\nRead only : yes"); | 5538 | // if (settings.ReadOnly) printmsg("\nRead only : yes"); |
5539 | printmsg("\n"); | 5539 | printmsg("\n"); |
5540 | printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); | 5540 | printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); |
5541 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); | 5541 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); |
5542 | printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase)); | 5542 | printmsg("Phonebook database : \"%s\"\n",DecodeUnicodeConsole(settings.PhonebookDataBase)); |
5543 | printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase)); | 5543 | printmsg("Calendar database : \"%s\"\n",DecodeUnicodeConsole(settings.CalendarDataBase)); |
5544 | printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server)); | 5544 | printmsg("Server : \"%s\"\n",DecodeUnicodeConsole(settings.Server)); |
5545 | printmsg("Sync. phonebook : "); | 5545 | printmsg("Sync. phonebook : "); |
5546 | if (settings.SyncPhonebook) printmsg("yes\n"); | 5546 | if (settings.SyncPhonebook) printmsg("yes\n"); |
5547 | if (!settings.SyncPhonebook) printmsg("no\n"); | 5547 | if (!settings.SyncPhonebook) printmsg("no\n"); |
5548 | printmsg("Sync. calendar : "); | 5548 | printmsg("Sync. calendar : "); |
5549 | if (settings.SyncCalendar) printmsg("yes\n"); | 5549 | if (settings.SyncCalendar) printmsg("yes\n"); |
5550 | if (!settings.SyncCalendar) printmsg("no\n"); | 5550 | if (!settings.SyncCalendar) printmsg("no\n"); |
5551 | printmsg("\n"); | 5551 | printmsg("\n"); |
5552 | for (j=0;j<settings.Connection.Number;j++) { | 5552 | for (j=0;j<settings.Connection.Number;j++) { |
5553 | if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { | 5553 | if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { |
5554 | printmsg("Connection set name : Set %i\n",i); | 5554 | printmsg("Connection set name : Set %i\n",i); |
5555 | } else { | 5555 | } else { |
5556 | printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); | 5556 | printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); |
5557 | } | 5557 | } |
5558 | DisplayConnectionSettings(&settings.Connection,j); | 5558 | DisplayConnectionSettings(&settings.Connection,j); |
5559 | printf("\n"); | 5559 | printf("\n"); |
5560 | } | 5560 | } |
5561 | } | 5561 | } |
5562 | GSM_Terminate(); | 5562 | GSM_Terminate(); |
5563 | } | 5563 | } |
5564 | 5564 | ||
5565 | static void GetChatSettings(int argc, char *argv[]) | 5565 | static void GetChatSettings(int argc, char *argv[]) |
5566 | { | 5566 | { |
5567 | GSM_ChatSettingssettings; | 5567 | GSM_ChatSettingssettings; |
5568 | int start,stop,j; | 5568 | int start,stop,j; |
5569 | 5569 | ||
5570 | GetStartStop(&start, &stop, 2, argc, argv); | 5570 | GetStartStop(&start, &stop, 2, argc, argv); |
5571 | 5571 | ||
5572 | GSM_Init(true); | 5572 | GSM_Init(true); |
5573 | 5573 | ||
5574 | for (i=start;i<=stop;i++) { | 5574 | for (i=start;i<=stop;i++) { |
5575 | settings.Location=i; | 5575 | settings.Location=i; |
5576 | error=Phone->GetChatSettings(&s,&settings); | 5576 | error=Phone->GetChatSettings(&s,&settings); |
5577 | Print_Error(error); | 5577 | Print_Error(error); |
5578 | printmsg("%i. ",i); | 5578 | printmsg("%i. ",i); |
5579 | if (settings.Name[0]==0 && settings.Name[1]==0) { | 5579 | if (settings.Name[0]==0 && settings.Name[1]==0) { |
5580 | printmsg("Set %i",i); | 5580 | printmsg("Set %i",i); |
5581 | } else { | 5581 | } else { |
5582 | printmsg("%s",DecodeUnicodeConsole(settings.Name)); | 5582 | printmsg("%s",DecodeUnicodeConsole(settings.Name)); |
5583 | } | 5583 | } |
5584 | if (settings.Active) printmsg(" (active)"); | 5584 | if (settings.Active) printmsg(" (active)"); |
5585 | // if (settings.ReadOnly) printmsg("\nRead only : yes"); | 5585 | // if (settings.ReadOnly) printmsg("\nRead only : yes"); |
5586 | printmsg("\n"); | 5586 | printmsg("\n"); |
5587 | printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage)); | 5587 | printmsg("Homepage : \"%s\"\n",DecodeUnicodeConsole(settings.HomePage)); |
5588 | printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); | 5588 | printmsg("User : \"%s\"\n",DecodeUnicodeConsole(settings.User)); |
5589 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); | 5589 | printmsg("Password : \"%s\"\n",DecodeUnicodeConsole(settings.Password)); |
5590 | printmsg("\n"); | 5590 | printmsg("\n"); |
5591 | for (j=0;j<settings.Connection.Number;j++) { | 5591 | for (j=0;j<settings.Connection.Number;j++) { |
5592 | if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { | 5592 | if (settings.Connection.Settings[j].Title[0]==0 && settings.Connection.Settings[j].Title[1]==0) { |
5593 | printmsg("Connection set name : Set %i\n",i); | 5593 | printmsg("Connection set name : Set %i\n",i); |
5594 | } else { | 5594 | } else { |
5595 | printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); | 5595 | printmsg("Connection set name : %s\n",DecodeUnicodeConsole(settings.Connection.Settings[j].Title)); |
5596 | } | 5596 | } |
5597 | DisplayConnectionSettings(&settings.Connection,j); | 5597 | DisplayConnectionSettings(&settings.Connection,j); |
5598 | printf("\n"); | 5598 | printf("\n"); |
5599 | } | 5599 | } |
5600 | } | 5600 | } |
5601 | GSM_Terminate(); | 5601 | GSM_Terminate(); |
5602 | } | 5602 | } |
5603 | 5603 | ||
5604 | static void GetWAPMMSSettings(int argc, char *argv[]) | 5604 | static void GetWAPMMSSettings(int argc, char *argv[]) |
5605 | { | 5605 | { |
5606 | GSM_MultiWAPSettingssettings; | 5606 | GSM_MultiWAPSettingssettings; |
5607 | int start,stop,j; | 5607 | int start,stop,j; |
5608 | 5608 | ||
5609 | GetStartStop(&start, &stop, 2, argc, argv); | 5609 | GetStartStop(&start, &stop, 2, argc, argv); |
5610 | 5610 | ||
5611 | GSM_Init(true); | 5611 | GSM_Init(true); |
5612 | 5612 | ||
5613 | for (i=start;i<=stop;i++) { | 5613 | for (i=start;i<=stop;i++) { |
5614 | settings.Location=i; | 5614 | settings.Location=i; |
5615 | if (mystrncasecmp(argv[1],"--getwapsettings",0)) { | 5615 | if (mystrncasecmp(argv[1],"--getwapsettings",0)) { |
5616 | error=Phone->GetWAPSettings(&s,&settings); | 5616 | error=Phone->GetWAPSettings(&s,&settings); |
5617 | } else { | 5617 | } else { |
5618 | error=Phone->GetMMSSettings(&s,&settings); | 5618 | error=Phone->GetMMSSettings(&s,&settings); |
5619 | } | 5619 | } |
5620 | Print_Error(error); | 5620 | Print_Error(error); |
5621 | for (j=0;j<settings.Number;j++) { | 5621 | for (j=0;j<settings.Number;j++) { |
5622 | printmsg("%i. ",i); | 5622 | printmsg("%i. ",i); |
5623 | if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) { | 5623 | if (settings.Settings[j].Title[0]==0 && settings.Settings[j].Title[1]==0) { |
5624 | printmsg("Set %i",i); | 5624 | printmsg("Set %i",i); |
5625 | } else { | 5625 | } else { |
5626 | printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title)); | 5626 | printmsg("%s",DecodeUnicodeConsole(settings.Settings[j].Title)); |
5627 | } | 5627 | } |
5628 | if (settings.Active) printmsg(" (active)"); | 5628 | if (settings.Active) printmsg(" (active)"); |
5629 | if (settings.ReadOnly) printmsg("\nRead only : yes"); | 5629 | if (settings.ReadOnly) printmsg("\nRead only : yes"); |
5630 | printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage)); | 5630 | printmsg("\nHomepage : \"%s\"\n",DecodeUnicodeConsole(settings.Settings[j].HomePage)); |
5631 | DisplayConnectionSettings(&settings,j); | 5631 | DisplayConnectionSettings(&settings,j); |
5632 | printf("\n"); | 5632 | printf("\n"); |
5633 | } | 5633 | } |
5634 | } | 5634 | } |
5635 | GSM_Terminate(); | 5635 | GSM_Terminate(); |
5636 | } | 5636 | } |
5637 | 5637 | ||
5638 | #ifdef GSM_ENABLE_BACKUP | 5638 | #ifdef GSM_ENABLE_BACKUP |
5639 | static void BackupSMS(int argc, char *argv[]) | 5639 | static void BackupSMS(int argc, char *argv[]) |
5640 | { | 5640 | { |
5641 | GSM_SMS_Backup Backup; | 5641 | GSM_SMS_Backup Backup; |
5642 | GSM_MultiSMSMessage sms; | 5642 | GSM_MultiSMSMessage sms; |
5643 | GSM_SMSFolders folders; | 5643 | GSM_SMSFolders folders; |
5644 | bool BackupFromFolder[GSM_MAX_SMS_FOLDERS]; | 5644 | bool BackupFromFolder[GSM_MAX_SMS_FOLDERS]; |
5645 | bool start = true; | 5645 | bool start = true; |
5646 | bool DeleteAfter; | 5646 | bool DeleteAfter; |
5647 | int j, smsnum; | 5647 | int j, smsnum; |
5648 | char buffer[200]; | 5648 | char buffer[200]; |
5649 | 5649 | ||
5650 | /* We ignore return code, because (when file doesn't exist) we | 5650 | /* We ignore return code, because (when file doesn't exist) we |
5651 | * will create new later | 5651 | * will create new later |
5652 | */ | 5652 | */ |
5653 | GSM_ReadSMSBackupFile(argv[2], &Backup); | 5653 | GSM_ReadSMSBackupFile(argv[2], &Backup); |
5654 | smsnum = 0; | 5654 | smsnum = 0; |
5655 | while (Backup.SMS[smsnum]!=NULL) smsnum++; | 5655 | while (Backup.SMS[smsnum]!=NULL) smsnum++; |
5656 | 5656 | ||
5657 | GSM_Init(true); | 5657 | GSM_Init(true); |
5658 | 5658 | ||
5659 | error=Phone->GetSMSFolders(&s, &folders); | 5659 | error=Phone->GetSMSFolders(&s, &folders); |
5660 | Print_Error(error); | 5660 | Print_Error(error); |
5661 | 5661 | ||
5662 | DeleteAfter=answer_yes("Delete each sms after backup"); | 5662 | DeleteAfter=answer_yes("Delete each sms after backup"); |
5663 | 5663 | ||
5664 | for (j=0;j<folders.Number;j++) { | 5664 | for (j=0;j<folders.Number;j++) { |
5665 | BackupFromFolder[j] = false; | 5665 | BackupFromFolder[j] = false; |
5666 | sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name)); | 5666 | sprintf(buffer,"Backup sms from folder \"%s\"",DecodeUnicodeConsole(folders.Folder[j].Name)); |
5667 | if (answer_yes(buffer)) BackupFromFolder[j] = true; | 5667 | if (answer_yes(buffer)) BackupFromFolder[j] = true; |
5668 | } | 5668 | } |
5669 | 5669 | ||
5670 | while (error == ERR_NONE) { | 5670 | while (error == ERR_NONE) { |
5671 | sms.SMS[0].Folder=0x00; | 5671 | sms.SMS[0].Folder=0x00; |
5672 | error=Phone->GetNextSMS(&s, &sms, start); | 5672 | error=Phone->GetNextSMS(&s, &sms, start); |
5673 | switch (error) { | 5673 | switch (error) { |
5674 | case ERR_EMPTY: | 5674 | case ERR_EMPTY: |
5675 | break; | 5675 | break; |
5676 | default: | 5676 | default: |
5677 | Print_Error(error); | 5677 | Print_Error(error); |
5678 | for (j=0;j<sms.Number;j++) { | 5678 | for (j=0;j<sms.Number;j++) { |
5679 | if (BackupFromFolder[sms.SMS[j].Folder-1]) { | 5679 | if (BackupFromFolder[sms.SMS[j].Folder-1]) { |
5680 | switch (sms.SMS[j].PDU) { | 5680 | switch (sms.SMS[j].PDU) { |
5681 | case SMS_Status_Report: | 5681 | case SMS_Status_Report: |
5682 | break; | 5682 | break; |
5683 | case SMS_Submit: | 5683 | case SMS_Submit: |
5684 | case SMS_Deliver: | 5684 | case SMS_Deliver: |
5685 | if (sms.SMS[j].Length == 0) break; | 5685 | if (sms.SMS[j].Length == 0) break; |
5686 | if (smsnum < GSM_BACKUP_MAX_SMS) { | 5686 | if (smsnum < GSM_BACKUP_MAX_SMS) { |
5687 | Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage)); | 5687 | Backup.SMS[smsnum] = malloc(sizeof(GSM_SMSMessage)); |
5688 | if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY); | 5688 | if (Backup.SMS[smsnum] == NULL) Print_Error(ERR_MOREMEMORY); |
5689 | Backup.SMS[smsnum+1] = NULL; | 5689 | Backup.SMS[smsnum+1] = NULL; |
5690 | } else { | 5690 | } else { |
5691 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS"); | 5691 | printmsg(" Increase %s\n" , "GSM_BACKUP_MAX_SMS"); |
5692 | GSM_Terminate(); | 5692 | GSM_Terminate(); |
5693 | exit(-1); | 5693 | exit(-1); |
5694 | } | 5694 | } |
5695 | *Backup.SMS[smsnum] = sms.SMS[j]; | 5695 | *Backup.SMS[smsnum] = sms.SMS[j]; |
5696 | smsnum++; | 5696 | smsnum++; |
5697 | break; | 5697 | break; |
5698 | } | 5698 | } |
5699 | } | 5699 | } |
5700 | } | 5700 | } |
5701 | } | 5701 | } |
5702 | start=false; | 5702 | start=false; |
5703 | } | 5703 | } |
5704 | 5704 | ||
5705 | error = GSM_SaveSMSBackupFile(argv[2],&Backup); | 5705 | error = GSM_SaveSMSBackupFile(argv[2],&Backup); |
5706 | Print_Error(error); | 5706 | Print_Error(error); |
5707 | 5707 | ||
5708 | if (DeleteAfter) { | 5708 | if (DeleteAfter) { |
5709 | for (j=0;j<smsnum;j++) { | 5709 | for (j=0;j<smsnum;j++) { |
5710 | Backup.SMS[j]->Folder = 0; | 5710 | Backup.SMS[j]->Folder = 0; |
5711 | error=Phone->DeleteSMS(&s, Backup.SMS[j]); | 5711 | error=Phone->DeleteSMS(&s, Backup.SMS[j]); |
5712 | Print_Error(error); | 5712 | Print_Error(error); |
5713 | printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum); | 5713 | printmsgerr("%cDeleting: %i percent",13,(j+1)*100/smsnum); |
5714 | } | 5714 | } |
5715 | } | 5715 | } |
5716 | 5716 | ||
5717 | GSM_Terminate(); | 5717 | GSM_Terminate(); |
5718 | } | 5718 | } |
5719 | 5719 | ||
5720 | static void AddSMS(int argc, char *argv[]) | 5720 | static void AddSMS(int argc, char *argv[]) |
5721 | { | 5721 | { |
5722 | GSM_MultiSMSMessage SMS; | 5722 | GSM_MultiSMSMessage SMS; |
5723 | GSM_SMS_Backup Backup; | 5723 | GSM_SMS_Backup Backup; |
5724 | int smsnum = 0; | 5724 | int smsnum = 0; |
5725 | int folder; | 5725 | int folder; |
5726 | 5726 | ||
5727 | folder = atoi(argv[2]); | 5727 | folder = atoi(argv[2]); |
5728 | 5728 | ||
5729 | error = GSM_ReadSMSBackupFile(argv[3], &Backup); | 5729 | error = GSM_ReadSMSBackupFile(argv[3], &Backup); |
5730 | Print_Error(error); | 5730 | Print_Error(error); |
5731 | 5731 | ||
5732 | GSM_Init(true); | 5732 | GSM_Init(true); |
5733 | 5733 | ||
5734 | while (Backup.SMS[smsnum] != NULL) { | 5734 | while (Backup.SMS[smsnum] != NULL) { |
5735 | Backup.SMS[smsnum]->Folder = folder; | 5735 | Backup.SMS[smsnum]->Folder = folder; |
5736 | Backup.SMS[smsnum]->SMSC.Location = 1; | 5736 | Backup.SMS[smsnum]->SMSC.Location = 1; |
5737 | SMS.Number = 1; | 5737 | SMS.Number = 1; |
5738 | SMS.SMS[0] = *Backup.SMS[smsnum]; | 5738 | SMS.SMS[0] = *Backup.SMS[smsnum]; |
5739 | displaymultismsinfo(SMS,false,false); | 5739 | displaymultismsinfo(SMS,false,false); |
5740 | if (answer_yes("Restore sms")) { | 5740 | if (answer_yes("Restore sms")) { |
5741 | error=Phone->AddSMS(&s, Backup.SMS[smsnum]); | 5741 | error=Phone->AddSMS(&s, Backup.SMS[smsnum]); |
5742 | Print_Error(error); | 5742 | Print_Error(error); |
5743 | } | 5743 | } |
5744 | smsnum++; | 5744 | smsnum++; |
5745 | } | 5745 | } |
5746 | 5746 | ||
5747 | GSM_Terminate(); | 5747 | GSM_Terminate(); |
5748 | } | 5748 | } |
5749 | 5749 | ||
5750 | static void RestoreSMS(int argc, char *argv[]) | 5750 | static void RestoreSMS(int argc, char *argv[]) |
5751 | { | 5751 | { |
5752 | GSM_MultiSMSMessage SMS; | 5752 | GSM_MultiSMSMessage SMS; |
5753 | GSM_SMS_Backup Backup; | 5753 | GSM_SMS_Backup Backup; |
5754 | GSM_SMSFolders folders; | 5754 | GSM_SMSFolders folders; |
5755 | int smsnum = 0; | 5755 | int smsnum = 0; |
5756 | char buffer[200]; | 5756 | char buffer[200]; |
5757 | 5757 | ||
5758 | error=GSM_ReadSMSBackupFile(argv[2], &Backup); | 5758 | error=GSM_ReadSMSBackupFile(argv[2], &Backup); |
5759 | Print_Error(error); | 5759 | Print_Error(error); |
5760 | 5760 | ||
5761 | GSM_Init(true); | 5761 | GSM_Init(true); |
5762 | 5762 | ||
5763 | error=Phone->GetSMSFolders(&s, &folders); | 5763 | error=Phone->GetSMSFolders(&s, &folders); |
5764 | Print_Error(error); | 5764 | Print_Error(error); |
5765 | 5765 | ||
5766 | while (Backup.SMS[smsnum] != NULL) { | 5766 | while (Backup.SMS[smsnum] != NULL) { |
5767 | SMS.Number = 1; | 5767 | SMS.Number = 1; |
5768 | memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); | 5768 | memcpy(&SMS.SMS[0],Backup.SMS[smsnum],sizeof(GSM_SMSMessage)); |
5769 | displaymultismsinfo(SMS,false,false); | 5769 | displaymultismsinfo(SMS,false,false); |
5770 | sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); | 5770 | sprintf(buffer,"Restore sms to folder \"%s\"",DecodeUnicodeConsole(folders.Folder[Backup.SMS[smsnum]->Folder-1].Name)); |
5771 | if (answer_yes(buffer)) { | 5771 | if (answer_yes(buffer)) { |
5772 | error=Phone->AddSMS(&s, Backup.SMS[smsnum]); | 5772 | error=Phone->AddSMS(&s, Backup.SMS[smsnum]); |
5773 | Print_Error(error); | 5773 | Print_Error(error); |
5774 | } | 5774 | } |
5775 | smsnum++; | 5775 | smsnum++; |
5776 | } | 5776 | } |
5777 | 5777 | ||
5778 | GSM_Terminate(); | 5778 | GSM_Terminate(); |
5779 | } | 5779 | } |
5780 | #endif | 5780 | #endif |
5781 | 5781 | ||
5782 | static void CopyBitmap(int argc, char *argv[]) | 5782 | static void CopyBitmap(int argc, char *argv[]) |
5783 | { | 5783 | { |
5784 | GSM_MultiBitmap Bitmap; | 5784 | GSM_MultiBitmap Bitmap; |
5785 | int i; | 5785 | int i; |
5786 | 5786 | ||
5787 | Bitmap.Bitmap[0].Type = GSM_None; | 5787 | Bitmap.Bitmap[0].Type = GSM_None; |
5788 | 5788 | ||
5789 | error=GSM_ReadBitmapFile(argv[2],&Bitmap); | 5789 | error=GSM_ReadBitmapFile(argv[2],&Bitmap); |
5790 | Print_Error(error); | 5790 | Print_Error(error); |
5791 | 5791 | ||
5792 | if (argc==3) { | 5792 | if (argc==3) { |
5793 | for (i=0;i<Bitmap.Number;i++) { | 5793 | for (i=0;i<Bitmap.Number;i++) { |
5794 | switch (Bitmap.Bitmap[i].Type) { | 5794 | switch (Bitmap.Bitmap[i].Type) { |
5795 | case GSM_StartupLogo : printmsg("Startup logo"); break; | 5795 | case GSM_StartupLogo : printmsg("Startup logo"); break; |
5796 | case GSM_OperatorLogo: printmsg("Operator logo"); break; | 5796 | case GSM_OperatorLogo: printmsg("Operator logo"); break; |
5797 | case GSM_PictureImage: printmsg("Picture Image"); break; | 5797 | case GSM_PictureImage: printmsg("Picture Image"); break; |
5798 | case GSM_CallerGroupLogo : printmsg("Caller group logo"); break; | 5798 | case GSM_CallerGroupLogo : printmsg("Caller group logo"); break; |
5799 | default : break; | 5799 | default : break; |
5800 | } | 5800 | } |
5801 | printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight); | 5801 | printmsg(", width %i, height %i\n",Bitmap.Bitmap[i].BitmapWidth,Bitmap.Bitmap[i].BitmapHeight); |
5802 | GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]); | 5802 | GSM_PrintBitmap(stdout,&Bitmap.Bitmap[i]); |
5803 | } | 5803 | } |
5804 | } else { | 5804 | } else { |
5805 | if (argc == 5) { | 5805 | if (argc == 5) { |
5806 | for (i=0;i<Bitmap.Number;i++) { | 5806 | for (i=0;i<Bitmap.Number;i++) { |
5807 | if (mystrncasecmp(argv[4],"PICTURE",0)) { | 5807 | if (mystrncasecmp(argv[4],"PICTURE",0)) { |
5808 | Bitmap.Bitmap[i].Type = GSM_PictureImage; | 5808 | Bitmap.Bitmap[i].Type = GSM_PictureImage; |
5809 | } else if (mystrncasecmp(argv[4],"STARTUP",0)) { | 5809 | } else if (mystrncasecmp(argv[4],"STARTUP",0)) { |
5810 | Bitmap.Bitmap[i].Type = GSM_StartupLogo; | 5810 | Bitmap.Bitmap[i].Type = GSM_StartupLogo; |
5811 | } else if (mystrncasecmp(argv[4],"CALLER",0)) { | 5811 | } else if (mystrncasecmp(argv[4],"CALLER",0)) { |
5812 | Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo; | 5812 | Bitmap.Bitmap[i].Type = GSM_CallerGroupLogo; |
5813 | } else if (mystrncasecmp(argv[4],"OPERATOR",0)) { | 5813 | } else if (mystrncasecmp(argv[4],"OPERATOR",0)) { |
5814 | Bitmap.Bitmap[i].Type = GSM_OperatorLogo; | 5814 | Bitmap.Bitmap[i].Type = GSM_OperatorLogo; |
5815 | } else { | 5815 | } else { |
5816 | printmsg("What format of output file logo (\"%s\") ?\n",argv[4]); | 5816 | printmsg("What format of output file logo (\"%s\") ?\n",argv[4]); |
5817 | exit(-1); | 5817 | exit(-1); |
5818 | } | 5818 | } |
5819 | } | 5819 | } |
5820 | } | 5820 | } |
5821 | error=GSM_SaveBitmapFile(argv[3],&Bitmap); | 5821 | error=GSM_SaveBitmapFile(argv[3],&Bitmap); |
5822 | Print_Error(error); | 5822 | Print_Error(error); |
5823 | } | 5823 | } |
5824 | } | 5824 | } |
5825 | 5825 | ||
5826 | static void NokiaComposer(int argc, char *argv[]) | 5826 | static void NokiaComposer(int argc, char *argv[]) |
5827 | { | 5827 | { |
5828 | GSM_Ringtone ringtone; | 5828 | GSM_Ringtone ringtone; |
5829 | bool started; | 5829 | bool started; |
5830 | int i,j; | 5830 | int i,j; |
5831 | GSM_RingNote *Note; | 5831 | GSM_RingNote *Note; |
5832 | GSM_RingNoteDuration Duration; | 5832 | GSM_RingNoteDuration Duration; |
5833 | GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */ | 5833 | GSM_RingNoteDuration DefNoteDuration = 32; /* 32 = Duration_1_4 */ |
5834 | unsigned int DefNoteScale = Scale_880; | 5834 | unsigned int DefNoteScale = Scale_880; |
5835 | 5835 | ||
5836 | ringtone.Format= 0; | 5836 | ringtone.Format= 0; |
5837 | error=GSM_ReadRingtoneFile(argv[2],&ringtone); | 5837 | error=GSM_ReadRingtoneFile(argv[2],&ringtone); |
5838 | 5838 | ||
5839 | if (ringtone.Format != RING_NOTETONE) { | 5839 | if (ringtone.Format != RING_NOTETONE) { |
5840 | printmsg("It can be RTTL ringtone only used with this option\n"); | 5840 | printmsg("It can be RTTL ringtone only used with this option\n"); |
5841 | exit(-1); | 5841 | exit(-1); |
5842 | } | 5842 | } |
5843 | 5843 | ||
5844 | started = false; | 5844 | started = false; |
5845 | j= 0; | 5845 | j= 0; |
5846 | for (i=0;i<ringtone.NoteTone.NrCommands;i++) { | 5846 | for (i=0;i<ringtone.NoteTone.NrCommands;i++) { |
5847 | if (ringtone.NoteTone.Commands[i].Type == RING_Note) { | 5847 | if (ringtone.NoteTone.Commands[i].Type == RING_Note) { |
5848 | Note = &ringtone.NoteTone.Commands[i].Note; | 5848 | Note = &ringtone.NoteTone.Commands[i].Note; |
5849 | if (!started) { | 5849 | if (!started) { |
5850 | if (Note->Note != Note_Pause) { | 5850 | if (Note->Note != Note_Pause) { |
5851 | printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo)); | 5851 | printmsg("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n",DecodeUnicodeConsole(ringtone.Name),GSM_RTTLGetTempo(Note->Tempo)); |
5852 | started = true; | 5852 | started = true; |
5853 | } | 5853 | } |
5854 | } | 5854 | } |
5855 | if (started) j++; | 5855 | if (started) j++; |
5856 | } | 5856 | } |
5857 | } | 5857 | } |
5858 | if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j); | 5858 | if (j>50) printmsg("WARNING: LENGTH=%i NOTES, BUT YOU WILL ENTER ONLY FIRST 50 TONES.",j); |
5859 | 5859 | ||
5860 | printmsg("\n\nThis ringtone in Nokia Composer in phone should look: "); | 5860 | printmsg("\n\nThis ringtone in Nokia Composer in phone should look: "); |
5861 | started = false; | 5861 | started = false; |
5862 | for (i=0;i<ringtone.NoteTone.NrCommands;i++) { | 5862 | for (i=0;i<ringtone.NoteTone.NrCommands;i++) { |
5863 | if (ringtone.NoteTone.Commands[i].Type == RING_Note) { | 5863 | if (ringtone.NoteTone.Commands[i].Type == RING_Note) { |
5864 | Note = &ringtone.NoteTone.Commands[i].Note; | 5864 | Note = &ringtone.NoteTone.Commands[i].Note; |
5865 | if (!started) { | 5865 | if (!started) { |
5866 | if (Note->Note != Note_Pause) started = true; | 5866 | if (Note->Note != Note_Pause) started = true; |
5867 | } | 5867 | } |
5868 | if (started) { | 5868 | if (started) { |
5869 | switch (Note->Duration) { | 5869 | switch (Note->Duration) { |
5870 | case Duration_Full: printmsg("1"); break; | 5870 | case Duration_Full: printmsg("1"); break; |
5871 | case Duration_1_2 : printmsg("2"); break; | 5871 | case Duration_1_2 : printmsg("2"); break; |
5872 | case Duration_1_4 : printmsg("4"); break; | 5872 | case Duration_1_4 : printmsg("4"); break; |
5873 | case Duration_1_8 : printmsg("8"); break; | 5873 | case Duration_1_8 : printmsg("8"); break; |
5874 | case Duration_1_16: printmsg("16");break; | 5874 | case Duration_1_16: printmsg("16");break; |
5875 | case Duration_1_32: printmsg("32");break; | 5875 | case Duration_1_32: printmsg("32");break; |
5876 | } | 5876 | } |
5877 | if (Note->DurationSpec == DottedNote) printmsg("."); | 5877 | if (Note->DurationSpec == DottedNote) printmsg("."); |
5878 | switch (Note->Note) { | 5878 | switch (Note->Note) { |
5879 | case Note_C : printmsg("c");break; | 5879 | case Note_C : printmsg("c");break; |
5880 | case Note_Cis : printmsg("#c");break; | 5880 | case Note_Cis : printmsg("#c");break; |
5881 | case Note_D :printmsg("d");break; | 5881 | case Note_D :printmsg("d");break; |
5882 | case Note_Dis : printmsg("#d");break; | 5882 | case Note_Dis : printmsg("#d");break; |
5883 | case Note_E : printmsg("e");break; | 5883 | case Note_E : printmsg("e");break; |
5884 | case Note_F : printmsg("f");break; | 5884 | case Note_F : printmsg("f");break; |
5885 | case Note_Fis : printmsg("#f");break; | 5885 | case Note_Fis : printmsg("#f");break; |
5886 | case Note_G : printmsg("g");break; | 5886 | case Note_G : printmsg("g");break; |
5887 | case Note_Gis : printmsg("#g");break; | 5887 | case Note_Gis : printmsg("#g");break; |
5888 | case Note_A : printmsg("a");break; | 5888 | case Note_A : printmsg("a");break; |
5889 | case Note_Ais : printmsg("#a");break; | 5889 | case Note_Ais : printmsg("#a");break; |
5890 | case Note_H : printmsg("h");break; | 5890 | case Note_H : printmsg("h");break; |
5891 | case Note_Pause : printmsg("-");break; | 5891 | case Note_Pause : printmsg("-");break; |
5892 | } | 5892 | } |
5893 | if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4); | 5893 | if (Note->Note != Note_Pause) printmsg("%i",Note->Scale - 4); |
5894 | printmsg(" "); | 5894 | printmsg(" "); |
5895 | } | 5895 | } |
5896 | } | 5896 | } |
5897 | } | 5897 | } |
5898 | 5898 | ||
5899 | printmsg("\n\nTo enter it please press: "); | 5899 | printmsg("\n\nTo enter it please press: "); |
5900 | started = false; | 5900 | started = false; |
5901 | for (i=0;i<ringtone.NoteTone.NrCommands;i++) { | 5901 | for (i=0;i<ringtone.NoteTone.NrCommands;i++) { |
5902 | if (ringtone.NoteTone.Commands[i].Type == RING_Note) { | 5902 | if (ringtone.NoteTone.Commands[i].Type == RING_Note) { |
5903 | Note = &ringtone.NoteTone.Commands[i].Note; | 5903 | Note = &ringtone.NoteTone.Commands[i].Note; |
5904 | if (!started) { | 5904 | if (!started) { |
5905 | if (Note->Note != Note_Pause) started = true; | 5905 | if (Note->Note != Note_Pause) started = true; |
5906 | } | 5906 | } |
5907 | if (started) { | 5907 | if (started) { |
5908 | switch (Note->Note) { | 5908 | switch (Note->Note) { |
5909 | case Note_C : case Note_Cis:printmsg("1");break; | 5909 | case Note_C : case Note_Cis:printmsg("1");break; |
5910 | case Note_D : case Note_Dis:printmsg("2");break; | 5910 | case Note_D : case Note_Dis:printmsg("2");break; |
5911 | case Note_E : printmsg("3");break; | 5911 | case Note_E : printmsg("3");break; |
5912 | case Note_F : case Note_Fis:printmsg("4");break; | 5912 | case Note_F : case Note_Fis:printmsg("4");break; |
5913 | case Note_G : case Note_Gis:printmsg("5");break; | 5913 | case Note_G : case Note_Gis:printmsg("5");break; |
5914 | case Note_A : case Note_Ais:printmsg("6");break; | 5914 | case Note_A : case Note_Ais:printmsg("6");break; |
5915 | case Note_H : printmsg("7");break; | 5915 | case Note_H : printmsg("7");break; |
5916 | default : printmsg("0");break; | 5916 | default : printmsg("0");break; |
5917 | } | 5917 | } |
5918 | if (Note->DurationSpec == DottedNote) printmsg("(longer)"); | 5918 | if (Note->DurationSpec == DottedNote) printmsg("(longer)"); |
5919 | switch (Note->Note) { | 5919 | switch (Note->Note) { |
5920 | case Note_Cis: case Note_Dis: | 5920 | case Note_Cis: case Note_Dis: |
5921 | case Note_Fis: case Note_Gis: | 5921 | case Note_Fis: case Note_Gis: |
5922 | case Note_Ais: | 5922 | case Note_Ais: |
5923 | printmsg("#"); | 5923 | printmsg("#"); |
5924 | break; | 5924 | break; |
5925 | default : | 5925 | default : |
5926 | break; | 5926 | break; |
5927 | } | 5927 | } |
5928 | if (Note->Note != Note_Pause) { | 5928 | if (Note->Note != Note_Pause) { |
5929 | if ((unsigned int)Note->Scale != DefNoteScale) { | 5929 | if ((unsigned int)Note->Scale != DefNoteScale) { |
5930 | while (DefNoteScale != (unsigned int)Note->Scale) { | 5930 | while (DefNoteScale != (unsigned int)Note->Scale) { |
5931 | printmsg("*"); | 5931 | printmsg("*"); |
5932 | DefNoteScale++; | 5932 | DefNoteScale++; |
5933 | if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880; | 5933 | if (DefNoteScale==Scale_7040) DefNoteScale = Scale_880; |
5934 | } | 5934 | } |
5935 | } | 5935 | } |
5936 | } | 5936 | } |
5937 | Duration = 0; | 5937 | Duration = 0; |
5938 | switch (Note->Duration) { | 5938 | switch (Note->Duration) { |
5939 | case Duration_Full : Duration = 128;break; | 5939 | case Duration_Full : Duration = 128;break; |
5940 | case Duration_1_2 : Duration = 64;break; | 5940 | case Duration_1_2 : Duration = 64;break; |
5941 | case Duration_1_4 : Duration = 32;break; | 5941 | case Duration_1_4 : Duration = 32;break; |
5942 | case Duration_1_8 : Duration = 16;break; | 5942 | case Duration_1_8 : Duration = 16;break; |
5943 | case Duration_1_16 : Duration = 8;break; | 5943 | case Duration_1_16 : Duration = 8;break; |
5944 | case Duration_1_32 : Duration = 4;break; | 5944 | case Duration_1_32 : Duration = 4;break; |
5945 | default : dbgprintf("error\n");break; | 5945 | default : dbgprintf("error\n");break; |
5946 | } | 5946 | } |
5947 | if (Duration > DefNoteDuration) { | 5947 | if (Duration > DefNoteDuration) { |
5948 | while (DefNoteDuration != Duration) { | 5948 | while (DefNoteDuration != Duration) { |
5949 | printmsg("9"); | 5949 | printmsg("9"); |
5950 | DefNoteDuration = DefNoteDuration * 2; | 5950 | DefNoteDuration = DefNoteDuration * 2; |
5951 | } | 5951 | } |
5952 | } | 5952 | } |
5953 | if (Duration < DefNoteDuration) { | 5953 | if (Duration < DefNoteDuration) { |
5954 | while (DefNoteDuration != Duration) { | 5954 | while (DefNoteDuration != Duration) { |
5955 | printmsg("8"); | 5955 | printmsg("8"); |
5956 | DefNoteDuration = DefNoteDuration / 2; | 5956 | DefNoteDuration = DefNoteDuration / 2; |
5957 | } | 5957 | } |
5958 | } | 5958 | } |
5959 | printmsg(" "); | 5959 | printmsg(" "); |
5960 | } | 5960 | } |
5961 | } | 5961 | } |
5962 | } | 5962 | } |
5963 | 5963 | ||
5964 | printf("\n"); | 5964 | printf("\n"); |
5965 | } | 5965 | } |
5966 | 5966 | ||
5967 | static void CopyRingtone(int argc, char *argv[]) | 5967 | static void CopyRingtone(int argc, char *argv[]) |
5968 | { | 5968 | { |
5969 | GSM_Ringtone ringtone, ringtone2; | 5969 | GSM_Ringtone ringtone, ringtone2; |
5970 | GSM_RingtoneFormatFormat; | 5970 | GSM_RingtoneFormatFormat; |
5971 | 5971 | ||
5972 | ringtone.Format= 0; | 5972 | ringtone.Format= 0; |
5973 | error=GSM_ReadRingtoneFile(argv[2],&ringtone); | 5973 | error=GSM_ReadRingtoneFile(argv[2],&ringtone); |
5974 | Print_Error(error); | 5974 | Print_Error(error); |
5975 | 5975 | ||
5976 | Format = ringtone.Format; | 5976 | Format = ringtone.Format; |
5977 | if (argc == 5) { | 5977 | if (argc == 5) { |
5978 | if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE; | 5978 | if (mystrncasecmp(argv[4],"RTTL",0)) { Format = RING_NOTETONE; |
5979 | } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY; | 5979 | } else if (mystrncasecmp(argv[4],"BINARY",0)) {Format = RING_NOKIABINARY; |
5980 | } else { | 5980 | } else { |
5981 | printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]); | 5981 | printmsg("What format of output ringtone file (\"%s\") ?\n",argv[4]); |
5982 | exit(-1); | 5982 | exit(-1); |
5983 | } | 5983 | } |
5984 | } | 5984 | } |
5985 | 5985 | ||
5986 | error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format); | 5986 | error=GSM_RingtoneConvert(&ringtone2,&ringtone,Format); |
5987 | Print_Error(error); | 5987 | Print_Error(error); |
5988 | 5988 | ||
5989 | error=GSM_SaveRingtoneFile(argv[3],&ringtone2); | 5989 | error=GSM_SaveRingtoneFile(argv[3],&ringtone2); |
5990 | Print_Error(error); | 5990 | Print_Error(error); |
5991 | } | 5991 | } |
5992 | 5992 | ||
5993 | static void PressKeySequence(int argc, char *argv[]) | 5993 | static void PressKeySequence(int argc, char *argv[]) |
5994 | { | 5994 | { |
5995 | int i,Length; | 5995 | int i,Length; |
5996 | GSM_KeyCodeKeyCode[500]; | 5996 | GSM_KeyCodeKeyCode[500]; |
5997 | 5997 | ||
5998 | error = MakeKeySequence(argv[2], KeyCode, &Length); | 5998 | error = MakeKeySequence(argv[2], KeyCode, &Length); |
5999 | if (error == ERR_NOTSUPPORTED) { | 5999 | if (error == ERR_NOTSUPPORTED) { |
6000 | printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]); | 6000 | printmsg("Unknown key/function name: \"%c\"\n",argv[2][Length]); |
6001 | exit(-1); | 6001 | exit(-1); |
6002 | } | 6002 | } |
6003 | 6003 | ||
6004 | GSM_Init(true); | 6004 | GSM_Init(true); |
6005 | 6005 | ||
6006 | for (i=0;i<Length;i++) { | 6006 | for (i=0;i<Length;i++) { |
6007 | error=Phone->PressKey(&s, KeyCode[i], true); | 6007 | error=Phone->PressKey(&s, KeyCode[i], true); |
6008 | Print_Error(error); | 6008 | Print_Error(error); |
6009 | error=Phone->PressKey(&s, KeyCode[i], false); | 6009 | error=Phone->PressKey(&s, KeyCode[i], false); |
6010 | Print_Error(error); | 6010 | Print_Error(error); |
6011 | } | 6011 | } |
6012 | 6012 | ||
6013 | GSM_Terminate(); | 6013 | GSM_Terminate(); |
6014 | } | 6014 | } |
6015 | 6015 | ||
6016 | static void GetAllCategories(int argc, char *argv[]) | 6016 | static void GetAllCategories(int argc, char *argv[]) |
6017 | { | 6017 | { |
6018 | GSM_Category Category; | 6018 | GSM_Category Category; |
6019 | GSM_CategoryStatusStatus; | 6019 | GSM_CategoryStatusStatus; |
6020 | int j, count; | 6020 | int j, count; |
6021 | 6021 | ||
6022 | if (mystrncasecmp(argv[2],"TODO",0)) { | 6022 | if (mystrncasecmp(argv[2],"TODO",0)) { |
6023 | Category.Type = Category_ToDo; | 6023 | Category.Type = Category_ToDo; |
6024 | Status.Type = Category_ToDo; | 6024 | Status.Type = Category_ToDo; |
6025 | } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { | 6025 | } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { |
6026 | Category.Type = Category_Phonebook; | 6026 | Category.Type = Category_Phonebook; |
6027 | Status.Type = Category_Phonebook; | 6027 | Status.Type = Category_Phonebook; |
6028 | } else { | 6028 | } else { |
6029 | printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); | 6029 | printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); |
6030 | exit(-1); | 6030 | exit(-1); |
6031 | } | 6031 | } |
6032 | 6032 | ||
6033 | GSM_Init(true); | 6033 | GSM_Init(true); |
6034 | 6034 | ||
6035 | error=Phone->GetCategoryStatus(&s, &Status); | 6035 | error=Phone->GetCategoryStatus(&s, &Status); |
6036 | Print_Error(error); | 6036 | Print_Error(error); |
6037 | 6037 | ||
6038 | for (count=0,j=1;count<Status.Used;j++) | 6038 | for (count=0,j=1;count<Status.Used;j++) |
6039 | { | 6039 | { |
6040 | Category.Location=j; | 6040 | Category.Location=j; |
6041 | error=Phone->GetCategory(&s, &Category); | 6041 | error=Phone->GetCategory(&s, &Category); |
6042 | 6042 | ||
6043 | if (error != ERR_EMPTY) { | 6043 | if (error != ERR_EMPTY) { |
6044 | printmsg("Location: %i\n",j); | 6044 | printmsg("Location: %i\n",j); |
6045 | 6045 | ||
6046 | Print_Error(error); | 6046 | Print_Error(error); |
6047 | 6047 | ||
6048 | printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); | 6048 | printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); |
6049 | count++; | 6049 | count++; |
6050 | } | 6050 | } |
6051 | } | 6051 | } |
6052 | 6052 | ||
6053 | GSM_Terminate(); | 6053 | GSM_Terminate(); |
6054 | } | 6054 | } |
6055 | 6055 | ||
6056 | static void GetCategory(int argc, char *argv[]) | 6056 | static void GetCategory(int argc, char *argv[]) |
6057 | { | 6057 | { |
6058 | GSM_CategoryCategory; | 6058 | GSM_CategoryCategory; |
6059 | int start,stop,j; | 6059 | int start,stop,j; |
6060 | 6060 | ||
6061 | if (mystrncasecmp(argv[2],"TODO",0)) { | 6061 | if (mystrncasecmp(argv[2],"TODO",0)) { |
6062 | Category.Type = Category_ToDo; | 6062 | Category.Type = Category_ToDo; |
6063 | } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { | 6063 | } else if (mystrncasecmp(argv[2],"PHONEBOOK",0)) { |
6064 | Category.Type = Category_Phonebook; | 6064 | Category.Type = Category_Phonebook; |
6065 | } else { | 6065 | } else { |
6066 | printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); | 6066 | printmsg("What type of categories do you want to get (\"%s\") ?\n",argv[2]); |
6067 | exit(-1); | 6067 | exit(-1); |
6068 | } | 6068 | } |
6069 | 6069 | ||
6070 | GetStartStop(&start, &stop, 2, argc - 1, argv + 1); | 6070 | GetStartStop(&start, &stop, 2, argc - 1, argv + 1); |
6071 | 6071 | ||
6072 | GSM_Init(true); | 6072 | GSM_Init(true); |
6073 | 6073 | ||
6074 | for (j=start;j<=stop;j++) | 6074 | for (j=start;j<=stop;j++) |
6075 | { | 6075 | { |
6076 | printmsg("Location: %i\n",j); | 6076 | printmsg("Location: %i\n",j); |
6077 | 6077 | ||
6078 | Category.Location=j; | 6078 | Category.Location=j; |
6079 | 6079 | ||
6080 | error=Phone->GetCategory(&s, &Category); | 6080 | error=Phone->GetCategory(&s, &Category); |
6081 | if (error != ERR_EMPTY) Print_Error(error); | 6081 | if (error != ERR_EMPTY) Print_Error(error); |
6082 | 6082 | ||
6083 | if (error == ERR_EMPTY) { | 6083 | if (error == ERR_EMPTY) { |
6084 | printmsg("Entry is empty\n\n"); | 6084 | printmsg("Entry is empty\n\n"); |
6085 | } else { | 6085 | } else { |
6086 | printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); | 6086 | printmsg("Name : \"%s\"\n\n",DecodeUnicodeConsole(Category.Name)); |
6087 | } | 6087 | } |
6088 | } | 6088 | } |
6089 | 6089 | ||
6090 | GSM_Terminate(); | 6090 | GSM_Terminate(); |
6091 | } | 6091 | } |
6092 | 6092 | ||
6093 | static void DeleteToDo(int argc, char *argv[]) | 6093 | static void DeleteToDo(int argc, char *argv[]) |
6094 | { | 6094 | { |
6095 | GSM_ToDoEntryToDo; | 6095 | GSM_ToDoEntryToDo; |
6096 | int i; | 6096 | int i; |
6097 | int start,stop; | 6097 | int start,stop; |
6098 | 6098 | ||
6099 | GetStartStop(&start, &stop, 2, argc, argv); | 6099 | GetStartStop(&start, &stop, 2, argc, argv); |
6100 | 6100 | ||
6101 | GSM_Init(true); | 6101 | GSM_Init(true); |
6102 | 6102 | ||
6103 | for (i=start;i<=stop;i++) { | 6103 | for (i=start;i<=stop;i++) { |
6104 | ToDo.Location=i; | 6104 | ToDo.Location=i; |
6105 | printmsg("Location : %i\n",i); | 6105 | printmsg("Location : %i\n",i); |
6106 | error=Phone->DeleteToDo(&s,&ToDo); | 6106 | error=Phone->DeleteToDo(&s,&ToDo); |
6107 | if (error != ERR_EMPTY) Print_Error(error); | 6107 | if (error != ERR_EMPTY) Print_Error(error); |
6108 | 6108 | ||
6109 | if (error == ERR_EMPTY) { | 6109 | if (error == ERR_EMPTY) { |
6110 | printmsg("Entry was empty\n"); | 6110 | printmsg("Entry was empty\n"); |
6111 | } else { | 6111 | } else { |
6112 | printmsg("Entry was deleted\n"); | 6112 | printmsg("Entry was deleted\n"); |
6113 | } | 6113 | } |
6114 | printf("\n"); | 6114 | printf("\n"); |
6115 | } | 6115 | } |
6116 | 6116 | ||
6117 | GSM_Terminate(); | 6117 | GSM_Terminate(); |
6118 | } | 6118 | } |
6119 | 6119 | ||
6120 | static void PrintToDo(GSM_ToDoEntry *ToDo) | 6120 | static void PrintToDo(GSM_ToDoEntry *ToDo) |
6121 | { | 6121 | { |
6122 | int j; | 6122 | int j; |
6123 | GSM_MemoryEntry entry; | 6123 | GSM_MemoryEntry entry; |
6124 | unsigned char *name; | 6124 | unsigned char *name; |
6125 | GSM_Category Category; | 6125 | GSM_Category Category; |
6126 | 6126 | ||
6127 | printmsg("Location : %i\n",ToDo->Location); | 6127 | printmsg("Location : %i\n",ToDo->Location); |
6128 | printmsg("Priority : "); | 6128 | printmsg("Priority : "); |
6129 | switch (ToDo->Priority) { | 6129 | switch (ToDo->Priority) { |
6130 | case GSM_Priority_Low : printmsg("Low\n"); break; | 6130 | case GSM_Priority_Low : printmsg("Low\n"); break; |
6131 | case GSM_Priority_Medium : printmsg("Medium\n"); break; | 6131 | case GSM_Priority_Medium : printmsg("Medium\n"); break; |
6132 | case GSM_Priority_High : printmsg("High\n"); break; | 6132 | case GSM_Priority_High : printmsg("High\n"); break; |
6133 | default : printmsg("Unknown\n");break; | 6133 | default : printmsg("Unknown\n");break; |
6134 | } | 6134 | } |
6135 | for (j=0;j<ToDo->EntriesNum;j++) { | 6135 | for (j=0;j<ToDo->EntriesNum;j++) { |
6136 | switch (ToDo->Entries[j].EntryType) { | 6136 | switch (ToDo->Entries[j].EntryType) { |
6137 | case TODO_END_DATETIME: | 6137 | case TODO_END_DATETIME: |
6138 | printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); | 6138 | printmsg("DueTime : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); |
6139 | break; | 6139 | break; |
6140 | case TODO_COMPLETED: | 6140 | case TODO_COMPLETED: |
6141 | printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); | 6141 | printmsg("Completed : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); |
6142 | break; | 6142 | break; |
6143 | case TODO_ALARM_DATETIME: | 6143 | case TODO_ALARM_DATETIME: |
6144 | printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); | 6144 | printmsg("Alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); |
6145 | break; | 6145 | break; |
6146 | case TODO_SILENT_ALARM_DATETIME: | 6146 | case TODO_SILENT_ALARM_DATETIME: |
6147 | printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); | 6147 | printmsg("Silent alarm : %s\n",OSDateTime(ToDo->Entries[j].Date,false)); |
6148 | break; | 6148 | break; |
6149 | case TODO_TEXT: | 6149 | case TODO_TEXT: |
6150 | printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); | 6150 | printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); |
6151 | break; | 6151 | break; |
6152 | case TODO_PRIVATE: | 6152 | case TODO_PRIVATE: |
6153 | printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); | 6153 | printmsg("Private : %s\n",ToDo->Entries[j].Number == 1 ? "Yes" : "No"); |
6154 | break; | 6154 | break; |
6155 | case TODO_CATEGORY: | 6155 | case TODO_CATEGORY: |
6156 | Category.Location = ToDo->Entries[j].Number; | 6156 | Category.Location = ToDo->Entries[j].Number; |
6157 | Category.Type = Category_ToDo; | 6157 | Category.Type = Category_ToDo; |
6158 | error=Phone->GetCategory(&s, &Category); | 6158 | error=Phone->GetCategory(&s, &Category); |
6159 | if (error == ERR_NONE) { | 6159 | if (error == ERR_NONE) { |
6160 | printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number); | 6160 | printmsg("Category : \"%s\" (%i)\n", DecodeUnicodeConsole(Category.Name), ToDo->Entries[j].Number); |
6161 | } else { | 6161 | } else { |
6162 | printmsg("Category : %i\n", ToDo->Entries[j].Number); | 6162 | printmsg("Category : %i\n", ToDo->Entries[j].Number); |
6163 | } | 6163 | } |
6164 | break; | 6164 | break; |
6165 | case TODO_CONTACTID: | 6165 | case TODO_CONTACTID: |
6166 | entry.Location = ToDo->Entries[j].Number; | 6166 | entry.Location = ToDo->Entries[j].Number; |
6167 | entry.MemoryType = MEM_ME; | 6167 | entry.MemoryType = MEM_ME; |
6168 | error=Phone->GetMemory(&s, &entry); | 6168 | error=Phone->GetMemory(&s, &entry); |
6169 | if (error == ERR_NONE) { | 6169 | if (error == ERR_NONE) { |
6170 | name = GSM_PhonebookGetEntryName(&entry); | 6170 | name = GSM_PhonebookGetEntryName(&entry); |
6171 | if (name != NULL) { | 6171 | if (name != NULL) { |
6172 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); | 6172 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); |
6173 | } else { | 6173 | } else { |
6174 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); | 6174 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); |
6175 | } | 6175 | } |
6176 | } else { | 6176 | } else { |
6177 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); | 6177 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); |
6178 | } | 6178 | } |
6179 | break; | 6179 | break; |
6180 | case TODO_PHONE: | 6180 | case TODO_PHONE: |
6181 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); | 6181 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); |
6182 | break; | 6182 | break; |
6183 | } | 6183 | } |
6184 | } | 6184 | } |
6185 | printf("\n"); | 6185 | printf("\n"); |
6186 | } | 6186 | } |
6187 | 6187 | ||
6188 | static void ListToDoCategoryEntries(int Category) | 6188 | static void ListToDoCategoryEntries(int Category) |
6189 | { | 6189 | { |
6190 | GSM_ToDoEntry Entry; | 6190 | GSM_ToDoEntry Entry; |
6191 | bool start = true; | 6191 | bool start = true; |
6192 | int j; | 6192 | int j; |
6193 | 6193 | ||
6194 | while (!gshutdown) { | 6194 | while (!gshutdown) { |
6195 | error = Phone->GetNextToDo(&s, &Entry, start); | 6195 | error = Phone->GetNextToDo(&s, &Entry, start); |
6196 | if (error == ERR_EMPTY) break; | 6196 | if (error == ERR_EMPTY) break; |
6197 | Print_Error(error); | 6197 | Print_Error(error); |
6198 | for (j=0;j<Entry.EntriesNum;j++) { | 6198 | for (j=0;j<Entry.EntriesNum;j++) { |
6199 | if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category) | 6199 | if (Entry.Entries[j].EntryType == TODO_CATEGORY && Entry.Entries[j].Number == (unsigned int)Category) |
6200 | PrintToDo(&Entry); | 6200 | PrintToDo(&Entry); |
6201 | } | 6201 | } |
6202 | start = false; | 6202 | start = false; |
6203 | } | 6203 | } |
6204 | } | 6204 | } |
6205 | 6205 | ||
6206 | static void ListToDoCategory(int argc, char *argv[]) | 6206 | static void ListToDoCategory(int argc, char *argv[]) |
6207 | { | 6207 | { |
6208 | GSM_Category Category; | 6208 | GSM_Category Category; |
6209 | GSM_CategoryStatusStatus; | 6209 | GSM_CategoryStatusStatus; |
6210 | int j, count; | 6210 | int j, count; |
6211 | 6211 | ||
6212 | unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; | 6212 | unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH+1)*2]; |
6213 | int Length; | 6213 | int Length; |
6214 | bool Number = true;; | 6214 | bool Number = true;; |
6215 | 6215 | ||
6216 | GSM_Init(true); | 6216 | GSM_Init(true); |
6217 | 6217 | ||
6218 | signal(SIGINT, interrupt); | 6218 | signal(SIGINT, interrupt); |
6219 | printmsgerr("Press Ctrl+C to break...\n"); | 6219 | printmsgerr("Press Ctrl+C to break...\n"); |
6220 | 6220 | ||
6221 | Length = strlen(argv[2]); | 6221 | Length = strlen(argv[2]); |
6222 | for (j = 0; j < Length; j++) { | 6222 | for (j = 0; j < Length; j++) { |
6223 | if (!isdigit(argv[2][j])) { | 6223 | if (!isdigit(argv[2][j])) { |
6224 | Number = false; | 6224 | Number = false; |
6225 | break; | 6225 | break; |
6226 | } | 6226 | } |
6227 | } | 6227 | } |
6228 | 6228 | ||
6229 | if (Number) { | 6229 | if (Number) { |
6230 | j = atoi(argv[2]); | 6230 | j = atoi(argv[2]); |
6231 | if (j > 0) { | 6231 | if (j > 0) { |
6232 | ListToDoCategoryEntries(j); | 6232 | ListToDoCategoryEntries(j); |
6233 | } | 6233 | } |
6234 | } else { | 6234 | } else { |
6235 | if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) { | 6235 | if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) { |
6236 | printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH); | 6236 | printmsg("Search text too long, truncating to %d chars!\n", GSM_MAX_CATEGORY_NAME_LENGTH); |
6237 | Length = GSM_MAX_CATEGORY_NAME_LENGTH; | 6237 | Length = GSM_MAX_CATEGORY_NAME_LENGTH; |
6238 | } | 6238 | } |
6239 | EncodeUnicode(Text, argv[2], Length); | 6239 | EncodeUnicode(Text, argv[2], Length); |
6240 | 6240 | ||
6241 | Category.Type = Category_ToDo; | 6241 | Category.Type = Category_ToDo; |
6242 | Status.Type = Category_ToDo; | 6242 | Status.Type = Category_ToDo; |
6243 | 6243 | ||
6244 | if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { | 6244 | if (Phone->GetCategoryStatus(&s, &Status) == ERR_NONE) { |
6245 | for (count=0,j=1;count<Status.Used;j++) { | 6245 | for (count=0,j=1;count<Status.Used;j++) { |
6246 | Category.Location=j; | 6246 | Category.Location=j; |
6247 | error=Phone->GetCategory(&s, &Category); | 6247 | error=Phone->GetCategory(&s, &Category); |
6248 | 6248 | ||
6249 | if (error != ERR_EMPTY) { | 6249 | if (error != ERR_EMPTY) { |
6250 | count++; | 6250 | count++; |
6251 | if (mywstrstr(Category.Name, Text) != NULL) { | 6251 | if (mywstrstr(Category.Name, Text) != NULL) { |
6252 | ListToDoCategoryEntries(j); | 6252 | ListToDoCategoryEntries(j); |
6253 | } | 6253 | } |
6254 | } | 6254 | } |
6255 | } | 6255 | } |
6256 | } | 6256 | } |
6257 | } | 6257 | } |
6258 | GSM_Terminate(); | 6258 | GSM_Terminate(); |
6259 | } | 6259 | } |
6260 | 6260 | ||
6261 | 6261 | ||
6262 | static void GetToDo(int argc, char *argv[]) | 6262 | static void GetToDo(int argc, char *argv[]) |
6263 | { | 6263 | { |
6264 | GSM_ToDoEntryToDo; | 6264 | GSM_ToDoEntryToDo; |
6265 | int i; | 6265 | int i; |
6266 | int start,stop; | 6266 | int start,stop; |
6267 | 6267 | ||
6268 | GetStartStop(&start, &stop, 2, argc, argv); | 6268 | GetStartStop(&start, &stop, 2, argc, argv); |
6269 | 6269 | ||
6270 | GSM_Init(true); | 6270 | GSM_Init(true); |
6271 | 6271 | ||
6272 | for (i=start;i<=stop;i++) { | 6272 | for (i=start;i<=stop;i++) { |
6273 | ToDo.Location=i; | 6273 | ToDo.Location=i; |
6274 | error = Phone->GetToDo(&s,&ToDo); | 6274 | error = Phone->GetToDo(&s,&ToDo); |
6275 | if (error == ERR_EMPTY) continue; | 6275 | if (error == ERR_EMPTY) continue; |
6276 | Print_Error(error); | 6276 | Print_Error(error); |
6277 | PrintToDo(&ToDo); | 6277 | PrintToDo(&ToDo); |
6278 | } | 6278 | } |
6279 | 6279 | ||
6280 | GSM_Terminate(); | 6280 | GSM_Terminate(); |
6281 | } | 6281 | } |
6282 | 6282 | ||
6283 | static void GetAllToDo(int argc, char *argv[]) | 6283 | static void GetAllToDo(int argc, char *argv[]) |
6284 | { | 6284 | { |
6285 | GSM_ToDoEntry ToDo; | 6285 | GSM_ToDoEntry ToDo; |
6286 | bool start = true; | 6286 | bool start = true; |
6287 | 6287 | ||
6288 | signal(SIGINT, interrupt); | 6288 | signal(SIGINT, interrupt); |
6289 | printmsgerr("Press Ctrl+C to break...\n"); | 6289 | printmsgerr("Press Ctrl+C to break...\n"); |
6290 | 6290 | ||
6291 | GSM_Init(true); | 6291 | GSM_Init(true); |
6292 | 6292 | ||
6293 | while (!gshutdown) { | 6293 | while (!gshutdown) { |
6294 | error = Phone->GetNextToDo(&s, &ToDo, start); | 6294 | error = Phone->GetNextToDo(&s, &ToDo, start); |
6295 | if (error == ERR_EMPTY) break; | 6295 | if (error == ERR_EMPTY) break; |
6296 | Print_Error(error); | 6296 | Print_Error(error); |
6297 | PrintToDo(&ToDo); | 6297 | PrintToDo(&ToDo); |
6298 | start = false; | 6298 | start = false; |
6299 | } | 6299 | } |
6300 | 6300 | ||
6301 | GSM_Terminate(); | 6301 | GSM_Terminate(); |
6302 | } | 6302 | } |
6303 | 6303 | ||
6304 | static void GetAllNotes(int argc, char *argv[]) | 6304 | static void GetAllNotes(int argc, char *argv[]) |
6305 | { | 6305 | { |
6306 | GSM_NoteEntry Note; | 6306 | GSM_NoteEntry Note; |
6307 | bool start = true; | 6307 | bool start = true; |
6308 | 6308 | ||
6309 | signal(SIGINT, interrupt); | 6309 | signal(SIGINT, interrupt); |
6310 | printmsgerr("Press Ctrl+C to break...\n"); | 6310 | printmsgerr("Press Ctrl+C to break...\n"); |
6311 | 6311 | ||
6312 | GSM_Init(true); | 6312 | GSM_Init(true); |
6313 | 6313 | ||
6314 | while (!gshutdown) { | 6314 | while (!gshutdown) { |
6315 | error = Phone->GetNextNote(&s, &Note, start); | 6315 | error = Phone->GetNextNote(&s, &Note, start); |
6316 | if (error == ERR_EMPTY) break; | 6316 | if (error == ERR_EMPTY) break; |
6317 | Print_Error(error); | 6317 | Print_Error(error); |
6318 | printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text)); | 6318 | printmsg("Text : \"%s\"\n",DecodeUnicodeConsole(Note.Text)); |
6319 | printf("\n"); | 6319 | printf("\n"); |
6320 | start = false; | 6320 | start = false; |
6321 | } | 6321 | } |
6322 | GSM_Terminate(); | 6322 | GSM_Terminate(); |
6323 | } | 6323 | } |
6324 | 6324 | ||
6325 | static void GetSecurityStatus(int argc, char *argv[]) | 6325 | static void GetSecurityStatus(int argc, char *argv[]) |
6326 | { | 6326 | { |
6327 | GSM_Init(true); | 6327 | GSM_Init(true); |
6328 | 6328 | ||
6329 | PrintSecurityStatus(); | 6329 | PrintSecurityStatus(); |
6330 | 6330 | ||
6331 | GSM_Terminate(); | 6331 | GSM_Terminate(); |
6332 | } | 6332 | } |
6333 | 6333 | ||
6334 | static void EnterSecurityCode(int argc, char *argv[]) | 6334 | static void EnterSecurityCode(int argc, char *argv[]) |
6335 | { | 6335 | { |
6336 | GSM_SecurityCode Code; | 6336 | GSM_SecurityCode Code; |
6337 | 6337 | ||
6338 | if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin; | 6338 | if (mystrncasecmp(argv[2],"PIN",0)) { Code.Type = SEC_Pin; |
6339 | } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk; | 6339 | } else if (mystrncasecmp(argv[2],"PUK",0)) {Code.Type = SEC_Puk; |
6340 | } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2; | 6340 | } else if (mystrncasecmp(argv[2],"PIN2",0)) {Code.Type = SEC_Pin2; |
6341 | } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2; | 6341 | } else if (mystrncasecmp(argv[2],"PUK2",0)) {Code.Type = SEC_Puk2; |
6342 | } else { | 6342 | } else { |
6343 | printmsg("What security code (\"%s\") ?\n",argv[2]); | 6343 | printmsg("What security code (\"%s\") ?\n",argv[2]); |
6344 | exit(-1); | 6344 | exit(-1); |
6345 | } | 6345 | } |
6346 | 6346 | ||
6347 | strcpy(Code.Code,argv[3]); | 6347 | strcpy(Code.Code,argv[3]); |
6348 | 6348 | ||
6349 | GSM_Init(true); | 6349 | GSM_Init(true); |
6350 | 6350 | ||
6351 | error=Phone->EnterSecurityCode(&s,Code); | 6351 | error=Phone->EnterSecurityCode(&s,Code); |
6352 | Print_Error(error); | 6352 | Print_Error(error); |
6353 | 6353 | ||
6354 | GSM_Terminate(); | 6354 | GSM_Terminate(); |
6355 | } | 6355 | } |
6356 | 6356 | ||
6357 | static void GetProfile(int argc, char *argv[]) | 6357 | static void GetProfile(int argc, char *argv[]) |
6358 | { | 6358 | { |
6359 | GSM_Profile Profile; | 6359 | GSM_Profile Profile; |
6360 | int start,stop,j,k; | 6360 | int start,stop,j,k; |
6361 | GSM_Bitmap caller[5]; | 6361 | GSM_Bitmap caller[5]; |
6362 | bool callerinit[5],special; | 6362 | bool callerinit[5],special; |
6363 | GSM_AllRingtonesInfo Info; | 6363 | GSM_AllRingtonesInfo Info; |
6364 | 6364 | ||
6365 | GetStartStop(&start, &stop, 2, argc, argv); | 6365 | GetStartStop(&start, &stop, 2, argc, argv); |
6366 | 6366 | ||
6367 | for (i=0;i<5;i++) callerinit[i] = false; | 6367 | for (i=0;i<5;i++) callerinit[i] = false; |
6368 | 6368 | ||
6369 | GSM_Init(true); | 6369 | GSM_Init(true); |
6370 | 6370 | ||
6371 | error=Phone->GetRingtonesInfo(&s,&Info); | 6371 | error=Phone->GetRingtonesInfo(&s,&Info); |
6372 | if (error != ERR_NONE) Info.Number = 0; | 6372 | if (error != ERR_NONE) Info.Number = 0; |
6373 | 6373 | ||
6374 | for (i=start;i<=stop;i++) { | 6374 | for (i=start;i<=stop;i++) { |
6375 | Profile.Location=i; | 6375 | Profile.Location=i; |
6376 | error=Phone->GetProfile(&s,&Profile); | 6376 | error=Phone->GetProfile(&s,&Profile); |
6377 | Print_Error(error); | 6377 | Print_Error(error); |
6378 | 6378 | ||
6379 | printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name)); | 6379 | printmsg("%i. \"%s\"",i,DecodeUnicodeConsole(Profile.Name)); |
6380 | if (Profile.Active) printmsg(" (active)"); | 6380 | if (Profile.Active) printmsg(" (active)"); |
6381 | if (Profile.DefaultName) printmsg(" (default name)"); | 6381 | if (Profile.DefaultName) printmsg(" (default name)"); |
6382 | if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)"); | 6382 | if (Profile.HeadSetProfile) printmsg(" (HeadSet profile)"); |
6383 | if (Profile.CarKitProfile) printmsg(" (CarKit profile)"); | 6383 | if (Profile.CarKitProfile) printmsg(" (CarKit profile)"); |
6384 | printf("\n"); | 6384 | printf("\n"); |
6385 | for (j=0;j<Profile.FeaturesNumber;j++) { | 6385 | for (j=0;j<Profile.FeaturesNumber;j++) { |
6386 | special = false; | 6386 | special = false; |
6387 | switch (Profile.FeatureID[j]) { | 6387 | switch (Profile.FeatureID[j]) { |
6388 | case Profile_MessageToneID: | 6388 | case Profile_MessageToneID: |
6389 | case Profile_RingtoneID: | 6389 | case Profile_RingtoneID: |
6390 | special = true; | 6390 | special = true; |
6391 | if (Profile.FeatureID[j] == Profile_RingtoneID) { | 6391 | if (Profile.FeatureID[j] == Profile_RingtoneID) { |
6392 | printmsg("Ringtone ID : "); | 6392 | printmsg("Ringtone ID : "); |
6393 | } else { | 6393 | } else { |
6394 | printmsg("Message alert tone ID : "); | 6394 | printmsg("Message alert tone ID : "); |
6395 | } | 6395 | } |
6396 | if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) { | 6396 | if (UnicodeLength(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))!=0) { |
6397 | printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))); | 6397 | printmsg("\"%s\"\n",DecodeUnicodeConsole(GSM_GetRingtoneName(&Info,Profile.FeatureValue[j]))); |
6398 | } else { | 6398 | } else { |
6399 | printmsg("%i\n",Profile.FeatureValue[j]); | 6399 | printmsg("%i\n",Profile.FeatureValue[j]); |
6400 | } | 6400 | } |
6401 | break; | 6401 | break; |
6402 | case Profile_CallerGroups: | 6402 | case Profile_CallerGroups: |
6403 | special = true; | 6403 | special = true; |
6404 | printmsg("Call alert for :"); | 6404 | printmsg("Call alert for :"); |
6405 | for (k=0;k<5;k++) { | 6405 | for (k=0;k<5;k++) { |
6406 | if (Profile.CallerGroups[k]) { | 6406 | if (Profile.CallerGroups[k]) { |
6407 | if (!callerinit[k]) { | 6407 | if (!callerinit[k]) { |
6408 | caller[k].Type = GSM_CallerGroupLogo; | 6408 | caller[k].Type = GSM_CallerGroupLogo; |
6409 | caller[k].Location = k + 1; | 6409 | caller[k].Location = k + 1; |
6410 | error=Phone->GetBitmap(&s,&caller[k]); | 6410 | error=Phone->GetBitmap(&s,&caller[k]); |
6411 | if (error == ERR_SECURITYERROR) { | 6411 | if (error == ERR_SECURITYERROR) { |
6412 | NOKIA_GetDefaultCallerGroupName(&s,&caller[k]); | 6412 | NOKIA_GetDefaultCallerGroupName(&s,&caller[k]); |
6413 | } else { | 6413 | } else { |
6414 | Print_Error(error); | 6414 | Print_Error(error); |
6415 | } | 6415 | } |
6416 | callerinit[k]= true; | 6416 | callerinit[k]= true; |
6417 | } | 6417 | } |
6418 | printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text)); | 6418 | printmsg(" \"%s\"",DecodeUnicodeConsole(caller[k].Text)); |
6419 | } | 6419 | } |
6420 | } | 6420 | } |
6421 | printf("\n"); | 6421 | printf("\n"); |
6422 | break; | 6422 | break; |
6423 | case Profile_ScreenSaverNumber: | 6423 | case Profile_ScreenSaverNumber: |
6424 | special = true; | 6424 | special = true; |
6425 | printmsg("Screen saver number : "); | 6425 | printmsg("Screen saver number : "); |
6426 | printmsg("%i\n",Profile.FeatureValue[j]); | 6426 | printmsg("%i\n",Profile.FeatureValue[j]); |
6427 | break; | 6427 | break; |
6428 | case Profile_CallAlert : printmsg("Incoming call alert : "); break; | 6428 | case Profile_CallAlert : printmsg("Incoming call alert : "); break; |
6429 | case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break; | 6429 | case Profile_RingtoneVolume : printmsg("Ringtone volume : "); break; |
6430 | case Profile_Vibration : printmsg("Vibrating alert : "); break; | 6430 | case Profile_Vibration : printmsg("Vibrating alert : "); break; |
6431 | case Profile_MessageTone: printmsg("Message alert tone : "); break; | 6431 | case Profile_MessageTone: printmsg("Message alert tone : "); break; |
6432 | case Profile_KeypadTone : printmsg("Keypad tones : "); break; | 6432 | case Profile_KeypadTone : printmsg("Keypad tones : "); break; |
6433 | case Profile_WarningTone: printmsg("Warning (games) tones : "); break; | 6433 | case Profile_WarningTone: printmsg("Warning (games) tones : "); break; |
6434 | case Profile_ScreenSaver: printmsg("Screen saver : "); break; | 6434 | case Profile_ScreenSaver: printmsg("Screen saver : "); break; |
6435 | case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break; | 6435 | case Profile_ScreenSaverTime: printmsg("Screen saver timeout : "); break; |
6436 | case Profile_AutoAnswer : printmsg("Automatic answer : "); break; | 6436 | case Profile_AutoAnswer : printmsg("Automatic answer : "); break; |
6437 | case Profile_Lights : printmsg("Lights : "); break; | 6437 | case Profile_Lights : printmsg("Lights : "); break; |
6438 | default: | 6438 | default: |
6439 | printmsg("Unknown\n"); | 6439 | printmsg("Unknown\n"); |
6440 | special = true; | 6440 | special = true; |
6441 | } | 6441 | } |
6442 | if (!special) { | 6442 | if (!special) { |
6443 | switch (Profile.FeatureValue[j]) { | 6443 | switch (Profile.FeatureValue[j]) { |
6444 | case PROFILE_VOLUME_LEVEL1 : | 6444 | case PROFILE_VOLUME_LEVEL1 : |
6445 | case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break; | 6445 | case PROFILE_KEYPAD_LEVEL1 : printmsg("Level 1\n"); break; |
6446 | case PROFILE_VOLUME_LEVEL2 : | 6446 | case PROFILE_VOLUME_LEVEL2 : |
6447 | case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break; | 6447 | case PROFILE_KEYPAD_LEVEL2 : printmsg("Level 2\n"); break; |
6448 | case PROFILE_VOLUME_LEVEL3 : | 6448 | case PROFILE_VOLUME_LEVEL3 : |
6449 | case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break; | 6449 | case PROFILE_KEYPAD_LEVEL3 : printmsg("Level 3\n"); break; |
6450 | case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break; | 6450 | case PROFILE_VOLUME_LEVEL4 : printmsg("Level 4\n"); break; |
6451 | case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break; | 6451 | case PROFILE_VOLUME_LEVEL5 : printmsg("Level 5\n"); break; |
6452 | case PROFILE_MESSAGE_NOTONE : | 6452 | case PROFILE_MESSAGE_NOTONE : |
6453 | case PROFILE_AUTOANSWER_OFF : | 6453 | case PROFILE_AUTOANSWER_OFF : |
6454 | case PROFILE_LIGHTS_OFF : | 6454 | case PROFILE_LIGHTS_OFF : |
6455 | case PROFILE_SAVER_OFF : | 6455 | case PROFILE_SAVER_OFF : |
6456 | case PROFILE_WARNING_OFF : | 6456 | case PROFILE_WARNING_OFF : |
6457 | case PROFILE_CALLALERT_OFF : | 6457 | case PROFILE_CALLALERT_OFF : |
6458 | case PROFILE_VIBRATION_OFF : | 6458 | case PROFILE_VIBRATION_OFF : |
6459 | case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break; | 6459 | case PROFILE_KEYPAD_OFF : printmsg("Off\n"); break; |
6460 | case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break; | 6460 | case PROFILE_CALLALERT_RINGING : printmsg("Ringing\n"); break; |
6461 | case PROFILE_CALLALERT_BEEPONCE : | 6461 | case PROFILE_CALLALERT_BEEPONCE : |
6462 | case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break; | 6462 | case PROFILE_MESSAGE_BEEPONCE : printmsg("Beep once\n"); break; |
6463 | case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break; | 6463 | case PROFILE_CALLALERT_RINGONCE : printmsg("Ring once\n");break; |
6464 | case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break; | 6464 | case PROFILE_CALLALERT_ASCENDING : printmsg("Ascending\n"); break; |
6465 | case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break; | 6465 | case PROFILE_CALLALERT_CALLERGROUPS : printmsg("Caller groups\n");break; |
6466 | case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break; | 6466 | case PROFILE_MESSAGE_STANDARD : printmsg("Standard\n"); break; |
6467 | case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break; | 6467 | case PROFILE_MESSAGE_SPECIAL : printmsg("Special\n"); break; |
6468 | case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break; | 6468 | case PROFILE_MESSAGE_ASCENDING : printmsg("Ascending\n"); break; |
6469 | case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break; | 6469 | case PROFILE_MESSAGE_PERSONAL : printmsg("Personal\n"); break; |
6470 | case PROFILE_AUTOANSWER_ON : | 6470 | case PROFILE_AUTOANSWER_ON : |
6471 | case PROFILE_WARNING_ON : | 6471 | case PROFILE_WARNING_ON : |
6472 | case PROFILE_SAVER_ON : | 6472 | case PROFILE_SAVER_ON : |
6473 | case PROFILE_VIBRATION_ON : printmsg("On\n"); break; | 6473 | case PROFILE_VIBRATION_ON : printmsg("On\n"); break; |
6474 | case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break; | 6474 | case PROFILE_VIBRATION_FIRST : printmsg("Vibrate first\n");break; |
6475 | case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break; | 6475 | case PROFILE_LIGHTS_AUTO : printmsg("Auto\n"); break; |
6476 | case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break; | 6476 | case PROFILE_SAVER_TIMEOUT_5SEC : printmsg("5 seconds\n"); break; |
6477 | case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break; | 6477 | case PROFILE_SAVER_TIMEOUT_20SEC : printmsg("20 seconds\n"); break; |
6478 | case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break; | 6478 | case PROFILE_SAVER_TIMEOUT_1MIN : printmsg("1 minute\n"); break; |
6479 | case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break; | 6479 | case PROFILE_SAVER_TIMEOUT_2MIN : printmsg("2 minutes\n");break; |
6480 | case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break; | 6480 | case PROFILE_SAVER_TIMEOUT_5MIN : printmsg("5 minutes\n");break; |
6481 | case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break; | 6481 | case PROFILE_SAVER_TIMEOUT_10MIN : printmsg("10 minutes\n");break; |
6482 | default : printmsg("UNKNOWN\n"); | 6482 | default : printmsg("UNKNOWN\n"); |
6483 | } | 6483 | } |
6484 | } | 6484 | } |
6485 | } | 6485 | } |
6486 | printf("\n"); | 6486 | printf("\n"); |
6487 | } | 6487 | } |
6488 | 6488 | ||
6489 | GSM_Terminate(); | 6489 | GSM_Terminate(); |
6490 | } | 6490 | } |
6491 | 6491 | ||
6492 | static void GetSpeedDial(int argc, char *argv[]) | 6492 | static void GetSpeedDial(int argc, char *argv[]) |
6493 | { | 6493 | { |
6494 | GSM_SpeedDial SpeedDial; | 6494 | GSM_SpeedDial SpeedDial; |
6495 | GSM_MemoryEntry Phonebook; | 6495 | GSM_MemoryEntry Phonebook; |
6496 | int start,stop,Name,Number,Group; | 6496 | int start,stop,Name,Number,Group; |
6497 | 6497 | ||
6498 | GetStartStop(&start, &stop, 2, argc, argv); | 6498 | GetStartStop(&start, &stop, 2, argc, argv); |
6499 | 6499 | ||
6500 | GSM_Init(true); | 6500 | GSM_Init(true); |
6501 | 6501 | ||
6502 | for (i=start;i<=stop;i++) { | 6502 | for (i=start;i<=stop;i++) { |
6503 | SpeedDial.Location=i; | 6503 | SpeedDial.Location=i; |
6504 | error=Phone->GetSpeedDial(&s,&SpeedDial); | 6504 | error=Phone->GetSpeedDial(&s,&SpeedDial); |
6505 | printmsg("%i.",i); | 6505 | printmsg("%i.",i); |
6506 | switch (error) { | 6506 | switch (error) { |
6507 | case ERR_EMPTY: | 6507 | case ERR_EMPTY: |
6508 | printmsg(" speed dial not assigned\n"); | 6508 | printmsg(" speed dial not assigned\n"); |
6509 | break; | 6509 | break; |
6510 | default: | 6510 | default: |
6511 | Print_Error(error); | 6511 | Print_Error(error); |
6512 | 6512 | ||
6513 | Phonebook.Location= SpeedDial.MemoryLocation; | 6513 | Phonebook.Location= SpeedDial.MemoryLocation; |
6514 | Phonebook.MemoryType = SpeedDial.MemoryType; | 6514 | Phonebook.MemoryType = SpeedDial.MemoryType; |
6515 | error=Phone->GetMemory(&s,&Phonebook); | 6515 | error=Phone->GetMemory(&s,&Phonebook); |
6516 | 6516 | ||
6517 | GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group); | 6517 | GSM_PhonebookFindDefaultNameNumberGroup(&Phonebook, &Name, &Number, &Group); |
6518 | 6518 | ||
6519 | if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text)); | 6519 | if (Name != -1) printmsg(" Name \"%s\",",DecodeUnicodeConsole(Phonebook.Entries[Name].Text)); |
6520 | printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text)); | 6520 | printmsg(" Number \"%s\"",DecodeUnicodeConsole(Phonebook.Entries[SpeedDial.MemoryNumberID-1].Text)); |
6521 | } | 6521 | } |
6522 | printf("\n"); | 6522 | printf("\n"); |
6523 | } | 6523 | } |
6524 | 6524 | ||
6525 | GSM_Terminate(); | 6525 | GSM_Terminate(); |
6526 | } | 6526 | } |
6527 | 6527 | ||
6528 | static void ResetPhoneSettings(int argc, char *argv[]) | 6528 | static void ResetPhoneSettings(int argc, char *argv[]) |
6529 | { | 6529 | { |
6530 | GSM_ResetSettingsType Type; | 6530 | GSM_ResetSettingsType Type; |
6531 | 6531 | ||
6532 | if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS; | 6532 | if (mystrncasecmp(argv[2],"PHONE",0)) { Type = GSM_RESET_PHONESETTINGS; |
6533 | } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE; | 6533 | } else if (mystrncasecmp(argv[2],"UIF",0)) { Type = GSM_RESET_USERINTERFACE; |
6534 | } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS; | 6534 | } else if (mystrncasecmp(argv[2],"ALL",0)) { Type = GSM_RESET_USERINTERFACE_PHONESETTINGS; |
6535 | } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE; | 6535 | } else if (mystrncasecmp(argv[2],"DEV",0)) { Type = GSM_RESET_DEVICE; |
6536 | } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY; | 6536 | } else if (mystrncasecmp(argv[2],"FACTORY",0)) { Type = GSM_RESET_FULLFACTORY; |
6537 | } else { | 6537 | } else { |
6538 | printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]); | 6538 | printmsg("What type of reset phone settings (\"%s\") ?\n",argv[2]); |
6539 | exit(-1); | 6539 | exit(-1); |
6540 | } | 6540 | } |
6541 | 6541 | ||
6542 | GSM_Init(true); | 6542 | GSM_Init(true); |
6543 | 6543 | ||
6544 | error=Phone->ResetPhoneSettings(&s,Type); | 6544 | error=Phone->ResetPhoneSettings(&s,Type); |
6545 | Print_Error(error); | 6545 | Print_Error(error); |
6546 | 6546 | ||
6547 | GSM_Terminate(); | 6547 | GSM_Terminate(); |
6548 | } | 6548 | } |
6549 | 6549 | ||
6550 | #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) | 6550 | #if defined(GSM_ENABLE_NOKIA_DCT3) || defined(GSM_ENABLE_NOKIA_DCT4) |
6551 | static void NokiaSecurityCode(int argc, char *argv[]) | 6551 | static void NokiaSecurityCode(int argc, char *argv[]) |
6552 | { | 6552 | { |
6553 | GSM_Init(true); | 6553 | GSM_Init(true); |
6554 | 6554 | ||
6555 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 6555 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
6556 | DCT3GetSecurityCode(argc,argv); | 6556 | DCT3GetSecurityCode(argc,argv); |
6557 | #endif | 6557 | #endif |
6558 | #ifdef GSM_ENABLE_NOKIA_DCT4 | 6558 | #ifdef GSM_ENABLE_NOKIA_DCT4 |
6559 | //DCT4ResetSecurityCode(argc, argv); | 6559 | //DCT4ResetSecurityCode(argc, argv); |
6560 | DCT4GetSecurityCode(argc,argv); | 6560 | DCT4GetSecurityCode(argc,argv); |
6561 | #endif | 6561 | #endif |
6562 | 6562 | ||
6563 | GSM_Terminate(); | 6563 | GSM_Terminate(); |
6564 | } | 6564 | } |
6565 | 6565 | ||
6566 | static void NokiaSetPhoneMenus(int argc, char *argv[]) | 6566 | static void NokiaSetPhoneMenus(int argc, char *argv[]) |
6567 | { | 6567 | { |
6568 | GSM_Init(true); | 6568 | GSM_Init(true); |
6569 | 6569 | ||
6570 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 6570 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
6571 | DCT3SetPhoneMenus (argc, argv); | 6571 | DCT3SetPhoneMenus (argc, argv); |
6572 | #endif | 6572 | #endif |
6573 | #ifdef GSM_ENABLE_NOKIA_DCT4 | 6573 | #ifdef GSM_ENABLE_NOKIA_DCT4 |
6574 | DCT4SetPhoneMenus (argc, argv); | 6574 | DCT4SetPhoneMenus (argc, argv); |
6575 | #endif | 6575 | #endif |
6576 | 6576 | ||
6577 | GSM_Terminate(); | 6577 | GSM_Terminate(); |
6578 | } | 6578 | } |
6579 | 6579 | ||
6580 | static void NokiaSelfTests(int argc, char *argv[]) | 6580 | static void NokiaSelfTests(int argc, char *argv[]) |
6581 | { | 6581 | { |
6582 | GSM_Init(true); | 6582 | GSM_Init(true); |
6583 | 6583 | ||
6584 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 6584 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
6585 | DCT3SelfTests(argc, argv); | 6585 | DCT3SelfTests(argc, argv); |
6586 | #endif | 6586 | #endif |
6587 | #ifdef GSM_ENABLE_NOKIA_DCT4 | 6587 | #ifdef GSM_ENABLE_NOKIA_DCT4 |
6588 | DCT4SelfTests(argc, argv); | 6588 | DCT4SelfTests(argc, argv); |
6589 | #endif | 6589 | #endif |
6590 | 6590 | ||
6591 | GSM_Terminate(); | 6591 | GSM_Terminate(); |
6592 | } | 6592 | } |
6593 | #endif | 6593 | #endif |
6594 | 6594 | ||
6595 | static void DeleteAllSMS(int argc, char *argv[]) | 6595 | static void DeleteAllSMS(int argc, char *argv[]) |
6596 | { | 6596 | { |
6597 | GSM_MultiSMSMessage sms; | 6597 | GSM_MultiSMSMessage sms; |
6598 | GSM_SMSFolders folders; | 6598 | GSM_SMSFolders folders; |
6599 | int foldernum; | 6599 | int foldernum; |
6600 | bool start = true; | 6600 | bool start = true; |
6601 | 6601 | ||
6602 | GSM_Init(true); | 6602 | GSM_Init(true); |
6603 | 6603 | ||
6604 | error=Phone->GetSMSFolders(&s, &folders); | 6604 | error=Phone->GetSMSFolders(&s, &folders); |
6605 | Print_Error(error); | 6605 | Print_Error(error); |
6606 | 6606 | ||
6607 | GetStartStop(&foldernum, NULL, 2, argc, argv); | 6607 | GetStartStop(&foldernum, NULL, 2, argc, argv); |
6608 | if (foldernum > folders.Number) { | 6608 | if (foldernum > folders.Number) { |
6609 | printmsg("Too high folder number (max. %i)\n",folders.Number); | 6609 | printmsg("Too high folder number (max. %i)\n",folders.Number); |
6610 | GSM_Terminate(); | 6610 | GSM_Terminate(); |
6611 | exit(-1); | 6611 | exit(-1); |
6612 | } | 6612 | } |
6613 | 6613 | ||
6614 | printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name)); | 6614 | printmsg("Deleting SMS from \"%s\" folder: ",DecodeUnicodeConsole(folders.Folder[foldernum-1].Name)); |
6615 | 6615 | ||
6616 | while (error == ERR_NONE) { | 6616 | while (error == ERR_NONE) { |
6617 | sms.SMS[0].Folder=0x00; | 6617 | sms.SMS[0].Folder=0x00; |
6618 | error=Phone->GetNextSMS(&s, &sms, start); | 6618 | error=Phone->GetNextSMS(&s, &sms, start); |
6619 | switch (error) { | 6619 | switch (error) { |
6620 | case ERR_EMPTY: | 6620 | case ERR_EMPTY: |
6621 | break; | 6621 | break; |
6622 | default: | 6622 | default: |
6623 | Print_Error(error); | 6623 | Print_Error(error); |
6624 | if (sms.SMS[0].Folder == foldernum) { | 6624 | if (sms.SMS[0].Folder == foldernum) { |
6625 | sms.SMS[0].Folder=0x00; | 6625 | sms.SMS[0].Folder=0x00; |
6626 | error=Phone->DeleteSMS(&s, &sms.SMS[0]); | 6626 | error=Phone->DeleteSMS(&s, &sms.SMS[0]); |
6627 | Print_Error(error); | 6627 | Print_Error(error); |
6628 | printmsg("*"); | 6628 | printmsg("*"); |
6629 | } | 6629 | } |
6630 | } | 6630 | } |
6631 | start=false; | 6631 | start=false; |
6632 | } | 6632 | } |
6633 | 6633 | ||
6634 | printf("\n"); | 6634 | printf("\n"); |
6635 | 6635 | ||
6636 | GSM_Terminate(); | 6636 | GSM_Terminate(); |
6637 | } | 6637 | } |
6638 | 6638 | ||
6639 | static void SendDTMF(int argc, char *argv[]) | 6639 | static void SendDTMF(int argc, char *argv[]) |
6640 | { | 6640 | { |
6641 | GSM_Init(true); | 6641 | GSM_Init(true); |
6642 | 6642 | ||
6643 | error=Phone->SendDTMF(&s,argv[2]); | 6643 | error=Phone->SendDTMF(&s,argv[2]); |
6644 | Print_Error(error); | 6644 | Print_Error(error); |
6645 | 6645 | ||
6646 | GSM_Terminate(); | 6646 | GSM_Terminate(); |
6647 | } | 6647 | } |
6648 | 6648 | ||
6649 | static void GetDisplayStatus(int argc, char *argv[]) | 6649 | static void GetDisplayStatus(int argc, char *argv[]) |
6650 | { | 6650 | { |
6651 | GSM_DisplayFeatures Features; | 6651 | GSM_DisplayFeatures Features; |
6652 | int i; | 6652 | int i; |
6653 | 6653 | ||
6654 | GSM_Init(true); | 6654 | GSM_Init(true); |
6655 | 6655 | ||
6656 | error=Phone->GetDisplayStatus(&s,&Features); | 6656 | error=Phone->GetDisplayStatus(&s,&Features); |
6657 | Print_Error(error); | 6657 | Print_Error(error); |
6658 | 6658 | ||
6659 | printmsg("Current display features :\n"); | 6659 | printmsg("Current display features :\n"); |
6660 | 6660 | ||
6661 | for (i=0;i<Features.Number;i++) { | 6661 | for (i=0;i<Features.Number;i++) { |
6662 | switch(Features.Feature[i]) { | 6662 | switch(Features.Feature[i]) { |
6663 | case GSM_CallActive : printmsg("Call active\n");break; | 6663 | case GSM_CallActive : printmsg("Call active\n");break; |
6664 | case GSM_UnreadSMS : printmsg("Unread SMS\n");break; | 6664 | case GSM_UnreadSMS : printmsg("Unread SMS\n");break; |
6665 | case GSM_VoiceCall : printmsg("Voice call\n");break; | 6665 | case GSM_VoiceCall : printmsg("Voice call\n");break; |
6666 | case GSM_FaxCall : printmsg("Fax call\n");break; | 6666 | case GSM_FaxCall : printmsg("Fax call\n");break; |
6667 | case GSM_DataCall : printmsg("Data call\n");break; | 6667 | case GSM_DataCall : printmsg("Data call\n");break; |
6668 | case GSM_KeypadLocked : printmsg("Keypad locked\n");break; | 6668 | case GSM_KeypadLocked : printmsg("Keypad locked\n");break; |
6669 | case GSM_SMSMemoryFull: printmsg("SMS memory full\n"); | 6669 | case GSM_SMSMemoryFull: printmsg("SMS memory full\n"); |
6670 | } | 6670 | } |
6671 | } | 6671 | } |
6672 | 6672 | ||
6673 | GSM_Terminate(); | 6673 | GSM_Terminate(); |
6674 | } | 6674 | } |
6675 | 6675 | ||
6676 | static void SetAutoNetworkLogin(int argc, char *argv[]) | 6676 | static void SetAutoNetworkLogin(int argc, char *argv[]) |
6677 | { | 6677 | { |
6678 | GSM_Init(true); | 6678 | GSM_Init(true); |
6679 | 6679 | ||
6680 | error=Phone->SetAutoNetworkLogin(&s); | 6680 | error=Phone->SetAutoNetworkLogin(&s); |
6681 | Print_Error(error); | 6681 | Print_Error(error); |
6682 | 6682 | ||
6683 | GSM_Terminate(); | 6683 | GSM_Terminate(); |
6684 | } | 6684 | } |
6685 | 6685 | ||
6686 | #ifdef DEBUG | 6686 | #ifdef DEBUG |
6687 | static void MakeConvertTable(int argc, char *argv[]) | 6687 | static void MakeConvertTable(int argc, char *argv[]) |
6688 | { | 6688 | { |
6689 | unsigned char InputBuffer[10000], Buffer[10000]; | 6689 | unsigned char InputBuffer[10000], Buffer[10000]; |
6690 | FILE *file; | 6690 | FILE *file; |
6691 | int size,i,j=0; | 6691 | int size,i,j=0; |
6692 | 6692 | ||
6693 | file = fopen(argv[2], "rb"); | 6693 | file = fopen(argv[2], "rb"); |
6694 | if (file == NULL) Print_Error(ERR_CANTOPENFILE); | 6694 | if (file == NULL) Print_Error(ERR_CANTOPENFILE); |
6695 | size=fread(InputBuffer, 1, 10000-1, file); | 6695 | size=fread(InputBuffer, 1, 10000-1, file); |
6696 | fclose(file); | 6696 | fclose(file); |
6697 | InputBuffer[size] = 0; | 6697 | InputBuffer[size] = 0; |
6698 | InputBuffer[size+1] = 0; | 6698 | InputBuffer[size+1] = 0; |
6699 | 6699 | ||
6700 | ReadUnicodeFile(Buffer,InputBuffer); | 6700 | ReadUnicodeFile(Buffer,InputBuffer); |
6701 | 6701 | ||
6702 | for(i=0;i<((int)UnicodeLength(Buffer));i++) { | 6702 | for(i=0;i<((int)UnicodeLength(Buffer));i++) { |
6703 | j++; | 6703 | j++; |
6704 | if (j==100) { | 6704 | if (j==100) { |
6705 | printf("\"\\\n\""); | 6705 | printf("\"\\\n\""); |
6706 | j=0; | 6706 | j=0; |
6707 | } | 6707 | } |
6708 | printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]); | 6708 | printf("\\x%02x\\x%02x",Buffer[i*2],Buffer[i*2+1]); |
6709 | } | 6709 | } |
6710 | printf("\\x00\\x00"); | 6710 | printf("\\x00\\x00"); |
6711 | } | 6711 | } |
6712 | #endif | 6712 | #endif |
6713 | 6713 | ||
6714 | static void ListNetworks(int argc, char *argv[]) | 6714 | static void ListNetworks(int argc, char *argv[]) |
6715 | { | 6715 | { |
6716 | extern unsigned char *GSM_Networks[]; | 6716 | extern unsigned char *GSM_Networks[]; |
6717 | extern unsigned char *GSM_Countries[]; | 6717 | extern unsigned char *GSM_Countries[]; |
6718 | int i=0; | 6718 | int i=0; |
6719 | char country[4]=""; | 6719 | char country[4]=""; |
6720 | 6720 | ||
6721 | if (argc>2) { | 6721 | if (argc>2) { |
6722 | while (GSM_Countries[i*2]!=NULL) { | 6722 | while (GSM_Countries[i*2]!=NULL) { |
6723 | if (!strncmp(GSM_Countries[i*2+1],argv[2],strlen(argv[2]))) { | 6723 | if (!strncmp(GSM_Countries[i*2+1],argv[2],strlen(argv[2]))) { |
6724 | strcpy(country,GSM_Countries[i*2]); | 6724 | strcpy(country,GSM_Countries[i*2]); |
6725 | printmsg("Networks for %s:\n\n",GSM_Countries[i*2+1]); | 6725 | printmsg("Networks for %s:\n\n",GSM_Countries[i*2+1]); |
6726 | break; | 6726 | break; |
6727 | } | 6727 | } |
6728 | i++; | 6728 | i++; |
6729 | } | 6729 | } |
6730 | if (!*country) { | 6730 | if (!*country) { |
6731 | printmsg("Unknown country name."); | 6731 | printmsg("Unknown country name."); |
6732 | exit(-1); | 6732 | exit(-1); |
6733 | } | 6733 | } |
6734 | } | 6734 | } |
6735 | printmsg("Network Name\n"); | 6735 | printmsg("Network Name\n"); |
6736 | i=0; | 6736 | i=0; |
6737 | while (GSM_Networks[i*2]!=NULL) { | 6737 | while (GSM_Networks[i*2]!=NULL) { |
6738 | if (argc>2) { | 6738 | if (argc>2) { |
6739 | if (!strncmp(GSM_Networks[i*2],country,strlen(country))) { | 6739 | if (!strncmp(GSM_Networks[i*2],country,strlen(country))) { |
6740 | printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); | 6740 | printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); |
6741 | } | 6741 | } |
6742 | } else { | 6742 | } else { |
6743 | printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); | 6743 | printmsg("%s %s\n", GSM_Networks[i*2], GSM_Networks[i*2+1]); |
6744 | } | 6744 | } |
6745 | i++; | 6745 | i++; |
6746 | } | 6746 | } |
6747 | } | 6747 | } |
6748 | 6748 | ||
6749 | static void Version(int argc, char *argv[]) | 6749 | static void Version(int argc, char *argv[]) |
6750 | { | 6750 | { |
6751 | // unsigned char buff[10]; | 6751 | // unsigned char buff[10]; |
6752 | // int len; | 6752 | // int len; |
6753 | 6753 | ||
6754 | printmsg("[Gammu version %s built %s %s",VERSION,__TIME__,__DATE__); | 6754 | printmsg("[Gammu version %s built %s %s",VERSION,__TIME__,__DATE__); |
6755 | if (strlen(GetCompiler()) != 0) printmsg(" in %s",GetCompiler()); | 6755 | if (strlen(GetCompiler()) != 0) printmsg(" in %s",GetCompiler()); |
6756 | printmsg("]\n\n"); | 6756 | printmsg("]\n\n"); |
6757 | 6757 | ||
6758 | #ifdef DEBUG | 6758 | #ifdef DEBUG |
6759 | printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage)); | 6759 | printf("GSM_SMSMessage - %i\n",sizeof(GSM_SMSMessage)); |
6760 | printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC)); | 6760 | printf("GSM_SMSC - %i\n",sizeof(GSM_SMSC)); |
6761 | printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State)); | 6761 | printf("GSM_SMS_State - %i\n",sizeof(GSM_SMS_State)); |
6762 | printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader)); | 6762 | printf("GSM_UDHHeader - %i\n",sizeof(GSM_UDHHeader)); |
6763 | printf("bool - %i\n",sizeof(bool)); | 6763 | printf("bool - %i\n",sizeof(bool)); |
6764 | printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime)); | 6764 | printf("GSM_DateTime - %i\n",sizeof(GSM_DateTime)); |
6765 | printf("int - %i\n",sizeof(int)); | 6765 | printf("int - %i\n",sizeof(int)); |
6766 | printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo)); | 6766 | printf("GSM_NetworkInfo - %i\n",sizeof(GSM_NetworkInfo)); |
6767 | #endif | 6767 | #endif |
6768 | 6768 | ||
6769 | //len=DecodeBASE64("AXw", buff, 3); | 6769 | //len=DecodeBASE64("AXw", buff, 3); |
6770 | //DumpMessage(stdout, buff, len); | 6770 | //DumpMessage(stdout, buff, len); |
6771 | } | 6771 | } |
6772 | 6772 | ||
6773 | static void GetFMStation(int argc, char *argv[]) | 6773 | static void GetFMStation(int argc, char *argv[]) |
6774 | { | 6774 | { |
6775 | GSM_FMStation Station; | 6775 | GSM_FMStation Station; |
6776 | int start,stop; | 6776 | int start,stop; |
6777 | 6777 | ||
6778 | GetStartStop(&start, &stop, 2, argc, argv); | 6778 | GetStartStop(&start, &stop, 2, argc, argv); |
6779 | 6779 | ||
6780 | GSM_Init(true); | 6780 | GSM_Init(true); |
6781 | 6781 | ||
6782 | for (i=start;i<=stop;i++) { | 6782 | for (i=start;i<=stop;i++) { |
6783 | Station.Location=i; | 6783 | Station.Location=i; |
6784 | error=Phone->GetFMStation(&s,&Station); | 6784 | error=Phone->GetFMStation(&s,&Station); |
6785 | switch (error) { | 6785 | switch (error) { |
6786 | case ERR_EMPTY: | 6786 | case ERR_EMPTY: |
6787 | printmsg("Entry number %i is empty\n",i); | 6787 | printmsg("Entry number %i is empty\n",i); |
6788 | break; | 6788 | break; |
6789 | case ERR_NONE: | 6789 | case ERR_NONE: |
6790 | printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n", | 6790 | printmsg("Entry number %i\nStation name : \"%s\"\nFrequency : %.1f MHz\n", |
6791 | i,DecodeUnicodeConsole(Station.StationName), | 6791 | i,DecodeUnicodeConsole(Station.StationName), |
6792 | Station.Frequency); | 6792 | Station.Frequency); |
6793 | break; | 6793 | break; |
6794 | default: | 6794 | default: |
6795 | Print_Error(error); | 6795 | Print_Error(error); |
6796 | } | 6796 | } |
6797 | } | 6797 | } |
6798 | GSM_Terminate(); | 6798 | GSM_Terminate(); |
6799 | } | 6799 | } |
6800 | 6800 | ||
6801 | static void GetFileSystemStatus(int argc, char *argv[]) | 6801 | static void GetFileSystemStatus(int argc, char *argv[]) |
6802 | { | 6802 | { |
6803 | GSM_FileSystemStatusStatus; | 6803 | GSM_FileSystemStatusStatus; |
6804 | 6804 | ||
6805 | GSM_Init(true); | 6805 | GSM_Init(true); |
6806 | 6806 | ||
6807 | error = Phone->GetFileSystemStatus(&s,&Status); | 6807 | error = Phone->GetFileSystemStatus(&s,&Status); |
6808 | if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { | 6808 | if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { |
6809 | Print_Error(error); | 6809 | Print_Error(error); |
6810 | printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); | 6810 | printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); |
6811 | } | 6811 | } |
6812 | 6812 | ||
6813 | GSM_Terminate(); | 6813 | GSM_Terminate(); |
6814 | } | 6814 | } |
6815 | 6815 | ||
6816 | static void GetFileSystem(int argc, char *argv[]) | 6816 | static void GetFileSystem(int argc, char *argv[]) |
6817 | { | 6817 | { |
6818 | bool Start = true; | 6818 | bool Start = true; |
6819 | GSM_File Files; | 6819 | GSM_File Files; |
6820 | int j; | 6820 | int j; |
6821 | GSM_FileSystemStatusStatus; | 6821 | GSM_FileSystemStatusStatus; |
6822 | char FolderName[256]; | 6822 | char FolderName[256]; |
6823 | 6823 | ||
6824 | GSM_Init(true); | 6824 | GSM_Init(true); |
6825 | 6825 | ||
6826 | while (1) { | 6826 | while (1) { |
6827 | error = Phone->GetNextFileFolder(&s,&Files,Start); | 6827 | error = Phone->GetNextFileFolder(&s,&Files,Start); |
6828 | if (error == ERR_EMPTY) break; | 6828 | if (error == ERR_EMPTY) break; |
6829 | Print_Error(error); | 6829 | Print_Error(error); |
6830 | 6830 | ||
6831 | if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) { | 6831 | if (argc <= 2 || !mystrncasecmp(argv[2],"-flatall",0)) { |
6832 | if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) { | 6832 | if (strlen(Files.ID_FullName) < 5 && strlen(Files.ID_FullName) != 0) { |
6833 | printf("%5s.",Files.ID_FullName); | 6833 | printf("%5s.",Files.ID_FullName); |
6834 | } | 6834 | } |
6835 | if (Files.Protected) { | 6835 | if (Files.Protected) { |
6836 | printf("P"); | 6836 | printf("P"); |
6837 | } else { | 6837 | } else { |
6838 | printf(" "); | 6838 | printf(" "); |
6839 | } | 6839 | } |
6840 | if (Files.ReadOnly) { | 6840 | if (Files.ReadOnly) { |
6841 | printf("R"); | 6841 | printf("R"); |
6842 | } else { | 6842 | } else { |
6843 | printf(" "); | 6843 | printf(" "); |
6844 | } | 6844 | } |
6845 | if (Files.Hidden) { | 6845 | if (Files.Hidden) { |
6846 | printf("H"); | 6846 | printf("H"); |
6847 | } else { | 6847 | } else { |
6848 | printf(" "); | 6848 | printf(" "); |
6849 | } | 6849 | } |
6850 | if (Files.System) { | 6850 | if (Files.System) { |
6851 | printf("S"); | 6851 | printf("S"); |
6852 | } else { | 6852 | } else { |
6853 | printf(" "); | 6853 | printf(" "); |
6854 | } | 6854 | } |
6855 | if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) { | 6855 | if (argc > 2 && mystrncasecmp(argv[2],"-flat",0)) { |
6856 | if (!Files.Folder) { | 6856 | if (!Files.Folder) { |
6857 | if (mystrncasecmp(argv[2],"-flatall",0)) { | 6857 | if (mystrncasecmp(argv[2],"-flatall",0)) { |
6858 | if (!Files.ModifiedEmpty) { | 6858 | if (!Files.ModifiedEmpty) { |
6859 | printf(" %30s",OSDateTime(Files.Modified,false)); | 6859 | printf(" %30s",OSDateTime(Files.Modified,false)); |
6860 | } else printf(" %30c",0x20); | 6860 | } else printf(" %30c",0x20); |
6861 | printf(" %9i",Files.Used); | 6861 | printf(" %9i",Files.Used); |
6862 | printf(" "); | 6862 | printf(" "); |
6863 | } else printf("|-- "); | 6863 | } else printf("|-- "); |
6864 | } else printf("Folder "); | 6864 | } else printf("Folder "); |
6865 | } else { | 6865 | } else { |
6866 | if (Files.Level != 1) { | 6866 | if (Files.Level != 1) { |
6867 | for (j=0;j<Files.Level-2;j++) printf(" | "); | 6867 | for (j=0;j<Files.Level-2;j++) printf(" | "); |
6868 | printf(" |-- "); | 6868 | printf(" |-- "); |
6869 | } | 6869 | } |
6870 | if (Files.Folder) printf("Folder "); | 6870 | if (Files.Folder) printf("Folder "); |
6871 | } | 6871 | } |
6872 | printf("\"%s\"",DecodeUnicodeConsole(Files.Name)); | 6872 | printf("\"%s\"",DecodeUnicodeConsole(Files.Name)); |
6873 | } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) { | 6873 | } else if (argc > 2 && mystrncasecmp(argv[2],"-flatall",0)) { |
6874 | /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS] | 6874 | /* format for a folder ID;Folder;FOLDER_NAME;[FOLDER_PARAMETERS] |
6875 | * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */ | 6875 | * format for a file ID;File;FOLDER_NAME;FILE_NAME;DATESTAMP;FILE_SIZE;[FILE_PARAMETERS] */ |
6876 | if (!Files.Folder) { | 6876 | if (!Files.Folder) { |
6877 | printf("%s;File;",Files.ID_FullName); | 6877 | printf("%s;File;",Files.ID_FullName); |
6878 | printf("\"%s\";",FolderName); | 6878 | printf("\"%s\";",FolderName); |
6879 | printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); | 6879 | printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); |
6880 | if (!Files.ModifiedEmpty) { | 6880 | if (!Files.ModifiedEmpty) { |
6881 | printf("\"%s\";",OSDateTime(Files.Modified,false)); | 6881 | printf("\"%s\";",OSDateTime(Files.Modified,false)); |
6882 | } else printf("\"%c\";",0x20); | 6882 | } else printf("\"%c\";",0x20); |
6883 | printf("%i;",Files.Used); | 6883 | printf("%i;",Files.Used); |
6884 | } else { | 6884 | } else { |
6885 | printf("%s;Folder;",Files.ID_FullName); | 6885 | printf("%s;Folder;",Files.ID_FullName); |
6886 | printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); | 6886 | printf("\"%s\";",DecodeUnicodeConsole(Files.Name)); |
6887 | strcpy(FolderName,DecodeUnicodeConsole(Files.Name)); | 6887 | strcpy(FolderName,DecodeUnicodeConsole(Files.Name)); |
6888 | } | 6888 | } |
6889 | 6889 | ||
6890 | if (Files.Protected) printf("P"); | 6890 | if (Files.Protected) printf("P"); |
6891 | if (Files.ReadOnly) printf("R"); | 6891 | if (Files.ReadOnly) printf("R"); |
6892 | if (Files.Hidden) printf("H"); | 6892 | if (Files.Hidden) printf("H"); |
6893 | if (Files.System) printf("S"); | 6893 | if (Files.System) printf("S"); |
6894 | } | 6894 | } |
6895 | Start = false; | 6895 | Start = false; |
6896 | } | 6896 | } |
6897 | 6897 | ||
6898 | error = Phone->GetFileSystemStatus(&s,&Status); | 6898 | error = Phone->GetFileSystemStatus(&s,&Status); |
6899 | if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { | 6899 | if (error != ERR_NOTSUPPORTED && error != ERR_NOTIMPLEMENTED) { |
6900 | Print_Error(error); | 6900 | Print_Error(error); |
6901 | printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); | 6901 | printmsg("\nFree memory: %i, total memory: %i\n",Status.Free,Status.Free+Status.Used); |
6902 | } | 6902 | } |
6903 | 6903 | ||
6904 | GSM_Terminate(); | 6904 | GSM_Terminate(); |
6905 | } | 6905 | } |
6906 | 6906 | ||
6907 | static void GetOneFile(GSM_File *File, bool newtime, int i) | 6907 | static void GetOneFile(GSM_File *File, bool newtime, int i) |
6908 | { | 6908 | { |
6909 | FILE *file; | 6909 | FILE *file; |
6910 | bool start; | 6910 | bool start; |
6911 | unsigned char buffer[5000]; | 6911 | unsigned char buffer[5000]; |
6912 | struct utimbuf filedate; | 6912 | struct utimbuf filedate; |
6913 | 6913 | ||
6914 | if (File->Buffer != NULL) { | 6914 | if (File->Buffer != NULL) { |
6915 | free(File->Buffer); | 6915 | free(File->Buffer); |
6916 | File->Buffer = NULL; | 6916 | File->Buffer = NULL; |
6917 | } | 6917 | } |
6918 | File->Used = 0; | 6918 | File->Used = 0; |
6919 | start = true; | 6919 | start = true; |
6920 | 6920 | ||
6921 | error = ERR_NONE; | 6921 | error = ERR_NONE; |
6922 | while (error == ERR_NONE) { | 6922 | while (error == ERR_NONE) { |
6923 | error = Phone->GetFilePart(&s,File); | 6923 | error = Phone->GetFilePart(&s,File); |
6924 | if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) { | 6924 | if (error == ERR_NONE || error == ERR_EMPTY || error == ERR_WRONGCRC) { |
6925 | if (start) { | 6925 | if (start) { |
6926 | printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name)); | 6926 | printmsg("Getting \"%s\": ", DecodeUnicodeConsole(File->Name)); |
6927 | start = false; | 6927 | start = false; |
6928 | } | 6928 | } |
6929 | if (File->Folder) { | 6929 | if (File->Folder) { |
6930 | free(File->Buffer); | 6930 | free(File->Buffer); |
6931 | GSM_Terminate(); | 6931 | GSM_Terminate(); |
6932 | printmsg("it's folder. Please give only file names\n"); | 6932 | printmsg("it's folder. Please give only file names\n"); |
6933 | exit(-1); | 6933 | exit(-1); |
6934 | } | 6934 | } |
6935 | printmsg("*"); | 6935 | printmsg("*"); |
6936 | if (error == ERR_EMPTY) break; | 6936 | if (error == ERR_EMPTY) break; |
6937 | if (error == ERR_WRONGCRC) { | 6937 | if (error == ERR_WRONGCRC) { |
6938 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); | 6938 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); |
6939 | break; | 6939 | break; |
6940 | } | 6940 | } |
6941 | } | 6941 | } |
6942 | Print_Error(error); | 6942 | Print_Error(error); |
6943 | } | 6943 | } |
6944 | printf("\n"); | 6944 | printf("\n"); |
6945 | if (File->Used != 0) { | 6945 | if (File->Used != 0) { |
6946 | sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name)); | 6946 | sprintf(buffer,"%s",DecodeUnicodeConsole(File->Name)); |
6947 | file = fopen(buffer,"wb"); | 6947 | file = fopen(buffer,"wb"); |
6948 | if (file == NULL) { | 6948 | if (file == NULL) { |
6949 | sprintf(buffer,"file%s",File->ID_FullName); | 6949 | sprintf(buffer,"file%s",File->ID_FullName); |
6950 | file = fopen(buffer,"wb"); | 6950 | file = fopen(buffer,"wb"); |
6951 | } | 6951 | } |
6952 | if (file == NULL) { | 6952 | if (file == NULL) { |
6953 | sprintf(buffer,"file%i",i); | 6953 | sprintf(buffer,"file%i",i); |
6954 | file = fopen(buffer,"wb"); | 6954 | file = fopen(buffer,"wb"); |
6955 | } | 6955 | } |
6956 | printmsg(" Saving to %s\n",buffer); | 6956 | printmsg(" Saving to %s\n",buffer); |
6957 | if (!file) Print_Error(ERR_CANTOPENFILE); | 6957 | if (!file) Print_Error(ERR_CANTOPENFILE); |
6958 | fwrite(File->Buffer,1,File->Used,file); | 6958 | fwrite(File->Buffer,1,File->Used,file); |
6959 | fclose(file); | 6959 | fclose(file); |
6960 | if (!newtime && !File->ModifiedEmpty) { | 6960 | if (!newtime && !File->ModifiedEmpty) { |
6961 | /* access time */ | 6961 | /* access time */ |
6962 | filedate.actime = Fill_Time_T(File->Modified, 8); | 6962 | filedate.actime = Fill_Time_T(File->Modified, 8); |
6963 | /* modification time */ | 6963 | /* modification time */ |
6964 | filedate.modtime = Fill_Time_T(File->Modified, 8); | 6964 | filedate.modtime = Fill_Time_T(File->Modified, 8); |
6965 | dbgprintf("Setting date of %s\n",buffer); | 6965 | dbgprintf("Setting date of %s\n",buffer); |
6966 | utime(buffer,&filedate); | 6966 | utime(buffer,&filedate); |
6967 | } | 6967 | } |
6968 | } | 6968 | } |
6969 | } | 6969 | } |
6970 | 6970 | ||
6971 | static void GetFiles(int argc, char *argv[]) | 6971 | static void GetFiles(int argc, char *argv[]) |
6972 | { | 6972 | { |
6973 | GSM_File File; | 6973 | GSM_File File; |
6974 | int i; | 6974 | int i; |
6975 | bool newtime = false; | 6975 | bool newtime = false; |
6976 | 6976 | ||
6977 | File.Buffer = NULL; | 6977 | File.Buffer = NULL; |
6978 | 6978 | ||
6979 | GSM_Init(true); | 6979 | GSM_Init(true); |
6980 | 6980 | ||
6981 | for (i=2;i<argc;i++) { | 6981 | for (i=2;i<argc;i++) { |
6982 | if (mystrncasecmp(argv[i],"-newtime",0)) { | 6982 | if (mystrncasecmp(argv[i],"-newtime",0)) { |
6983 | newtime = true; | 6983 | newtime = true; |
6984 | continue; | 6984 | continue; |
6985 | } | 6985 | } |
6986 | 6986 | ||
6987 | strcpy(File.ID_FullName,argv[i]); | 6987 | strcpy(File.ID_FullName,argv[i]); |
6988 | GetOneFile(&File, newtime, i); | 6988 | GetOneFile(&File, newtime, i); |
6989 | } | 6989 | } |
6990 | 6990 | ||
6991 | free(File.Buffer); | 6991 | free(File.Buffer); |
6992 | GSM_Terminate(); | 6992 | GSM_Terminate(); |
6993 | } | 6993 | } |
6994 | 6994 | ||
6995 | static void GetFileFolder(int argc, char *argv[]) | 6995 | static void GetFileFolder(int argc, char *argv[]) |
6996 | { | 6996 | { |
6997 | bool Start = true; | 6997 | bool Start = true; |
6998 | GSM_File File; | 6998 | GSM_File File; |
6999 | int level=0,allnum=0,num=0,filelevel=0; | 6999 | int level=0,allnum=0,num=0,filelevel=0; |
7000 | bool newtime = false, found; | 7000 | bool newtime = false, found; |
7001 | 7001 | ||
7002 | File.Buffer = NULL; | 7002 | File.Buffer = NULL; |
7003 | 7003 | ||
7004 | GSM_Init(true); | 7004 | GSM_Init(true); |
7005 | 7005 | ||
7006 | for (i=2;i<argc;i++) { | 7006 | for (i=2;i<argc;i++) { |
7007 | if (mystrncasecmp(argv[i],"-newtime",0)) { | 7007 | if (mystrncasecmp(argv[i],"-newtime",0)) { |
7008 | newtime = true; | 7008 | newtime = true; |
7009 | continue; | 7009 | continue; |
7010 | } | 7010 | } |
7011 | allnum++; | 7011 | allnum++; |
7012 | } | 7012 | } |
7013 | 7013 | ||
7014 | while (allnum != num) { | 7014 | while (allnum != num) { |
7015 | error = Phone->GetNextFileFolder(&s,&File,Start); | 7015 | error = Phone->GetNextFileFolder(&s,&File,Start); |
7016 | if (error == ERR_EMPTY) break; | 7016 | if (error == ERR_EMPTY) break; |
7017 | Print_Error(error); | 7017 | Print_Error(error); |
7018 | 7018 | ||
7019 | if (level == 0) { | 7019 | if (level == 0) { |
7020 | /* We search for file or folder */ | 7020 | /* We search for file or folder */ |
7021 | found = false; | 7021 | found = false; |
7022 | for (i=2;i<argc;i++) { | 7022 | for (i=2;i<argc;i++) { |
7023 | if (mystrncasecmp(argv[i],"-newtime",0)) { | 7023 | if (mystrncasecmp(argv[i],"-newtime",0)) { |
7024 | continue; | 7024 | continue; |
7025 | } | 7025 | } |
7026 | if (!strcmp(File.ID_FullName,argv[i])) { | 7026 | if (!strcmp(File.ID_FullName,argv[i])) { |
7027 | found = true; | 7027 | found = true; |
7028 | if (File.Folder) { | 7028 | if (File.Folder) { |
7029 | level = 1; | 7029 | level = 1; |
7030 | filelevel = File.Level + 1; | 7030 | filelevel = File.Level + 1; |
7031 | Start = false; | 7031 | Start = false; |
7032 | } else { | 7032 | } else { |
7033 | level = 2; | 7033 | level = 2; |
7034 | } | 7034 | } |
7035 | break; | 7035 | break; |
7036 | } | 7036 | } |
7037 | } | 7037 | } |
7038 | if (found && File.Folder) continue; | 7038 | if (found && File.Folder) continue; |
7039 | } | 7039 | } |
7040 | if (level == 1) { | 7040 | if (level == 1) { |
7041 | /* We have folder */ | 7041 | /* We have folder */ |
7042 | dbgprintf("%i %i\n",File.Level,filelevel); | 7042 | dbgprintf("%i %i\n",File.Level,filelevel); |
7043 | if (File.Level != filelevel) { | 7043 | if (File.Level != filelevel) { |
7044 | level = 0; | 7044 | level = 0; |
7045 | num++; | 7045 | num++; |
7046 | } | 7046 | } |
7047 | } | 7047 | } |
7048 | 7048 | ||
7049 | if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num); | 7049 | if (level != 0 && !File.Folder) GetOneFile(&File, newtime,num); |
7050 | 7050 | ||
7051 | if (level == 2) { | 7051 | if (level == 2) { |
7052 | level = 0; | 7052 | level = 0; |
7053 | num++; | 7053 | num++; |
7054 | } | 7054 | } |
7055 | 7055 | ||
7056 | Start = false; | 7056 | Start = false; |
7057 | } | 7057 | } |
7058 | 7058 | ||
7059 | free(File.Buffer); | 7059 | free(File.Buffer); |
7060 | GSM_Terminate(); | 7060 | GSM_Terminate(); |
7061 | } | 7061 | } |
7062 | 7062 | ||
7063 | static void AddFile(int argc, char *argv[]) | 7063 | static void AddFile(int argc, char *argv[]) |
7064 | { | 7064 | { |
7065 | GSM_File File; | 7065 | GSM_File File; |
7066 | int Pos = 0,i,nextlong; | 7066 | int Pos = 0,i,nextlong; |
7067 | 7067 | ||
7068 | File.Buffer = NULL; | 7068 | File.Buffer = NULL; |
7069 | strcpy(File.ID_FullName,argv[2]); | 7069 | strcpy(File.ID_FullName,argv[2]); |
7070 | error = GSM_ReadFile(argv[3], &File); | 7070 | error = GSM_ReadFile(argv[3], &File); |
7071 | Print_Error(error); | 7071 | Print_Error(error); |
7072 | EncodeUnicode(File.Name,argv[3],strlen(argv[3])); | 7072 | EncodeUnicode(File.Name,argv[3],strlen(argv[3])); |
7073 | GSM_IdentifyFileFormat(&File); | 7073 | GSM_IdentifyFileFormat(&File); |
7074 | 7074 | ||
7075 | File.Protected = false; | 7075 | File.Protected = false; |
7076 | File.ReadOnly= false; | 7076 | File.ReadOnly= false; |
7077 | File.Hidden= false; | 7077 | File.Hidden= false; |
7078 | File.System= false; | 7078 | File.System= false; |
7079 | 7079 | ||
7080 | if (argc > 4) { | 7080 | if (argc > 4) { |
7081 | nextlong = 0; | 7081 | nextlong = 0; |
7082 | for (i=4;i<argc;i++) { | 7082 | for (i=4;i<argc;i++) { |
7083 | switch(nextlong) { | 7083 | switch(nextlong) { |
7084 | case 0: | 7084 | case 0: |
7085 | if (mystrncasecmp(argv[i],"-type",0)) { | 7085 | if (mystrncasecmp(argv[i],"-type",0)) { |
7086 | nextlong = 1; | 7086 | nextlong = 1; |
7087 | continue; | 7087 | continue; |
7088 | } | 7088 | } |
7089 | if (mystrncasecmp(argv[i],"-protected",0)) { | 7089 | if (mystrncasecmp(argv[i],"-protected",0)) { |
7090 | File.Protected = true; | 7090 | File.Protected = true; |
7091 | continue; | 7091 | continue; |
7092 | } | 7092 | } |
7093 | if (mystrncasecmp(argv[i],"-readonly",0)) { | 7093 | if (mystrncasecmp(argv[i],"-readonly",0)) { |
7094 | File.ReadOnly = true; | 7094 | File.ReadOnly = true; |
7095 | continue; | 7095 | continue; |
7096 | } | 7096 | } |
7097 | if (mystrncasecmp(argv[i],"-hidden",0)) { | 7097 | if (mystrncasecmp(argv[i],"-hidden",0)) { |
7098 | File.Hidden = true; | 7098 | File.Hidden = true; |
7099 | continue; | 7099 | continue; |
7100 | } | 7100 | } |
7101 | if (mystrncasecmp(argv[i],"-system",0)) { | 7101 | if (mystrncasecmp(argv[i],"-system",0)) { |
7102 | File.System = true; | 7102 | File.System = true; |
7103 | continue; | 7103 | continue; |
7104 | } | 7104 | } |
7105 | if (mystrncasecmp(argv[i],"-newtime",0)) { | 7105 | if (mystrncasecmp(argv[i],"-newtime",0)) { |
7106 | File.ModifiedEmpty = true; | 7106 | File.ModifiedEmpty = true; |
7107 | continue; | 7107 | continue; |
7108 | } | 7108 | } |
7109 | printmsg("Parameter \"%s\" unknown\n",argv[i]); | 7109 | printmsg("Parameter \"%s\" unknown\n",argv[i]); |
7110 | exit(-1); | 7110 | exit(-1); |
7111 | case 1: | 7111 | case 1: |
7112 | if (mystrncasecmp(argv[i],"JAR",0)) { | 7112 | if (mystrncasecmp(argv[i],"JAR",0)) { |
7113 | File.Type = GSM_File_Java_JAR; | 7113 | File.Type = GSM_File_Java_JAR; |
7114 | } else if (mystrncasecmp(argv[i],"JPG",0)) { | 7114 | } else if (mystrncasecmp(argv[i],"JPG",0)) { |
7115 | File.Type = GSM_File_Image_JPG; | 7115 | File.Type = GSM_File_Image_JPG; |
7116 | } else if (mystrncasecmp(argv[i],"BMP",0)) { | 7116 | } else if (mystrncasecmp(argv[i],"BMP",0)) { |
7117 | File.Type = GSM_File_Image_BMP; | 7117 | File.Type = GSM_File_Image_BMP; |
7118 | } else if (mystrncasecmp(argv[i],"WBMP",0)) { | 7118 | } else if (mystrncasecmp(argv[i],"WBMP",0)) { |
7119 | File.Type = GSM_File_Image_WBMP; | 7119 | File.Type = GSM_File_Image_WBMP; |
7120 | } else if (mystrncasecmp(argv[i],"GIF",0)) { | 7120 | } else if (mystrncasecmp(argv[i],"GIF",0)) { |
7121 | File.Type = GSM_File_Image_GIF; | 7121 | File.Type = GSM_File_Image_GIF; |
7122 | } else if (mystrncasecmp(argv[i],"PNG",0)) { | 7122 | } else if (mystrncasecmp(argv[i],"PNG",0)) { |
7123 | File.Type = GSM_File_Image_PNG; | 7123 | File.Type = GSM_File_Image_PNG; |
7124 | } else if (mystrncasecmp(argv[i],"MIDI",0)) { | 7124 | } else if (mystrncasecmp(argv[i],"MIDI",0)) { |
7125 | File.Type = GSM_File_Sound_MIDI; | 7125 | File.Type = GSM_File_Sound_MIDI; |
7126 | } else if (mystrncasecmp(argv[i],"AMR",0)) { | 7126 | } else if (mystrncasecmp(argv[i],"AMR",0)) { |
7127 | File.Type = GSM_File_Sound_AMR; | 7127 | File.Type = GSM_File_Sound_AMR; |
7128 | } else if (mystrncasecmp(argv[i],"NRT",0)) { | 7128 | } else if (mystrncasecmp(argv[i],"NRT",0)) { |
7129 | File.Type = GSM_File_Sound_NRT; | 7129 | File.Type = GSM_File_Sound_NRT; |
7130 | } else if (mystrncasecmp(argv[i],"3GP",0)) { | 7130 | } else if (mystrncasecmp(argv[i],"3GP",0)) { |
7131 | File.Type = GSM_File_Video_3GP; | 7131 | File.Type = GSM_File_Video_3GP; |
7132 | } else { | 7132 | } else { |
7133 | printmsg("What file type (\"%s\") ?\n",argv[i]); | 7133 | printmsg("What file type (\"%s\") ?\n",argv[i]); |
7134 | exit(-1); | 7134 | exit(-1); |
7135 | } | 7135 | } |
7136 | nextlong = 0; | 7136 | nextlong = 0; |
7137 | break; | 7137 | break; |
7138 | } | 7138 | } |
7139 | } | 7139 | } |
7140 | if (nextlong!=0) { | 7140 | if (nextlong!=0) { |
7141 | printmsg("Parameter missed...\n"); | 7141 | printmsg("Parameter missed...\n"); |
7142 | exit(-1); | 7142 | exit(-1); |
7143 | } | 7143 | } |
7144 | } | 7144 | } |
7145 | 7145 | ||
7146 | GSM_Init(true); | 7146 | GSM_Init(true); |
7147 | 7147 | ||
7148 | error = ERR_NONE; | 7148 | error = ERR_NONE; |
7149 | while (error == ERR_NONE) { | 7149 | while (error == ERR_NONE) { |
7150 | error = Phone->AddFilePart(&s,&File,&Pos); | 7150 | error = Phone->AddFilePart(&s,&File,&Pos); |
7151 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); | 7151 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); |
7152 | printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used); | 7152 | printmsgerr("%cWriting: %i percent",13,Pos*100/File.Used); |
7153 | } | 7153 | } |
7154 | printmsgerr("\n"); | 7154 | printmsgerr("\n"); |
7155 | if (error == ERR_WRONGCRC) { | 7155 | if (error == ERR_WRONGCRC) { |
7156 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); | 7156 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); |
7157 | } | 7157 | } |
7158 | 7158 | ||
7159 | free(File.Buffer); | 7159 | free(File.Buffer); |
7160 | GSM_Terminate(); | 7160 | GSM_Terminate(); |
7161 | } | 7161 | } |
7162 | 7162 | ||
7163 | static void AddFolder(int argc, char *argv[]) | 7163 | static void AddFolder(int argc, char *argv[]) |
7164 | { | 7164 | { |
7165 | GSM_File File; | 7165 | GSM_File File; |
7166 | 7166 | ||
7167 | strcpy(File.ID_FullName,argv[2]); | 7167 | strcpy(File.ID_FullName,argv[2]); |
7168 | EncodeUnicode(File.Name,argv[3],strlen(argv[3])); | 7168 | EncodeUnicode(File.Name,argv[3],strlen(argv[3])); |
7169 | File.ReadOnly = false; | 7169 | File.ReadOnly = false; |
7170 | 7170 | ||
7171 | GSM_Init(true); | 7171 | GSM_Init(true); |
7172 | 7172 | ||
7173 | error = Phone->AddFolder(&s,&File); | 7173 | error = Phone->AddFolder(&s,&File); |
7174 | Print_Error(error); | 7174 | Print_Error(error); |
7175 | 7175 | ||
7176 | GSM_Terminate(); | 7176 | GSM_Terminate(); |
7177 | } | 7177 | } |
7178 | 7178 | ||
7179 | struct NokiaFolderInfo { | 7179 | struct NokiaFolderInfo { |
7180 | char*model; | 7180 | char*model; |
7181 | char *parameter; | 7181 | char *parameter; |
7182 | char*folder; | 7182 | char*folder; |
7183 | char *level; | 7183 | char *level; |
7184 | }; | 7184 | }; |
7185 | 7185 | ||
7186 | static struct NokiaFolderInfo Folder[] = { | 7186 | static struct NokiaFolderInfo Folder[] = { |
7187 | /* Language indepedent in DCT4 */ | 7187 | /* Language indepedent in DCT4 */ |
7188 | {"", "MMSUnreadInbox", "INBOX","3"}, | 7188 | {"", "MMSUnreadInbox", "INBOX","3"}, |
7189 | {"", "MMSReadInbox", "INBOX","3"}, | 7189 | {"", "MMSReadInbox", "INBOX","3"}, |
7190 | {"", "MMSOutbox", "OUTBOX","3"}, | 7190 | {"", "MMSOutbox", "OUTBOX","3"}, |
7191 | {"", "MMSSent", "SENT", "3"}, | 7191 | {"", "MMSSent", "SENT", "3"}, |
7192 | {"", "MMSDrafts", "DRAFTS","3"}, | 7192 | {"", "MMSDrafts", "DRAFTS","3"}, |
7193 | {"", "Application", "applications","3"}, | 7193 | {"", "Application", "applications","3"}, |
7194 | {"", "Game", "games","3"}, | 7194 | {"", "Game", "games","3"}, |
7195 | /* Language depedent in DCT4 */ | 7195 | /* Language depedent in DCT4 */ |
7196 | {"", "Gallery", "Pictures","2"}, /* 3510 */ | 7196 | {"", "Gallery", "Pictures","2"}, /* 3510 */ |
7197 | {"", "Gallery", "Graphics","3"}, /* 3510i */ | 7197 | {"", "Gallery", "Graphics","3"}, /* 3510i */ |
7198 | {"", "Gallery", "Images","3"}, /* 6610 */ | 7198 | {"", "Gallery", "Images","3"}, /* 6610 */ |
7199 | {"3510", "Gallery", "", "8"}, | 7199 | {"3510", "Gallery", "", "8"}, |
7200 | {"3510i","Gallery", "", "3"}, | 7200 | {"3510i","Gallery", "", "3"}, |
7201 | {"5100", "Gallery", "", "3"}, | 7201 | {"5100", "Gallery", "", "3"}, |
7202 | {"6220", "Gallery", "", "5"}, | 7202 | {"6220", "Gallery", "", "5"}, |
7203 | {"6610", "Gallery", "", "2"}, | 7203 | {"6610", "Gallery", "", "2"}, |
7204 | {"7210", "Gallery", "", "2"}, | 7204 | {"7210", "Gallery", "", "2"}, |
7205 | {"", "Tones", "Tones","3"}, | 7205 | {"", "Tones", "Tones","3"}, |
7206 | {"3510i","Tones", "", "4"}, | 7206 | {"3510i","Tones", "", "4"}, |
7207 | {"5100", "Tones", "", "4"}, | 7207 | {"5100", "Tones", "", "4"}, |
7208 | {"6220", "Tones", "", "6"}, | 7208 | {"6220", "Tones", "", "6"}, |
7209 | {"6610", "Tones", "", "4"}, | 7209 | {"6610", "Tones", "", "4"}, |
7210 | {"7210", "Tones", "", "4"}, | 7210 | {"7210", "Tones", "", "4"}, |
7211 | /* Language indepedent in OBEX */ | 7211 | /* Language indepedent in OBEX */ |
7212 | {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"}, | 7212 | {"obex", "MMSUnreadInbox", "", "predefMessages\\predefINBOX"}, |
7213 | {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"}, | 7213 | {"obex", "MMSReadInbox", "", "predefMessages\\predefINBOX"}, |
7214 | {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"}, | 7214 | {"obex", "MMSOutbox", "", "predefMessages\\predefOUTBOX"}, |
7215 | {"obex", "MMSSent", "", "predefMessages\\predefSENT" }, | 7215 | {"obex", "MMSSent", "", "predefMessages\\predefSENT" }, |
7216 | {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"}, | 7216 | {"obex", "MMSDrafts", "", "predefMessages\\predefDRAFTS"}, |
7217 | // {"obex", "Application, "", "predefjava\\predefapplications"}, | 7217 | // {"obex", "Application, "", "predefjava\\predefapplications"}, |
7218 | // {"obex", "Game", "", "predefjava\\predefgames"}, | 7218 | // {"obex", "Game", "", "predefjava\\predefgames"}, |
7219 | {"obex", "Gallery", "", "predefgallery\\predefgraphics"}, | 7219 | {"obex", "Gallery", "", "predefgallery\\predefgraphics"}, |
7220 | {"obex", "Tones", "", "predefgallery\\predeftones"}, | 7220 | {"obex", "Tones", "", "predefgallery\\predeftones"}, |
7221 | 7221 | ||
7222 | /* End of list */ | 7222 | /* End of list */ |
7223 | {"", "", "", ""} | 7223 | {"", "", "", ""} |
7224 | }; | 7224 | }; |
7225 | 7225 | ||
7226 | static void NokiaAddFile(int argc, char *argv[]) | 7226 | static void NokiaAddFile(int argc, char *argv[]) |
7227 | { | 7227 | { |
7228 | GSM_File File, Files; | 7228 | GSM_File File, Files; |
7229 | FILE *file; | 7229 | FILE *file; |
7230 | GSM_DateTime DT,DT2; | 7230 | GSM_DateTime DT,DT2; |
7231 | time_t t_time1,t_time2; | 7231 | time_t t_time1,t_time2; |
7232 | unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400]; | 7232 | unsigned char buffer[10000],JAR[500],Vendor[500],Name[500],Version[500],FileID[400]; |
7233 | bool Start = true, Found = false, wasclr; | 7233 | bool Start = true, Found = false, wasclr; |
7234 | bool ModEmpty = false; | 7234 | bool ModEmpty = false; |
7235 | int i = 0, Pos, Size, Size2, nextlong; | 7235 | int i = 0, Pos, Size, Size2, nextlong; |
7236 | 7236 | ||
7237 | while (Folder[i].level[0] != 0) { | 7237 | while (Folder[i].level[0] != 0) { |
7238 | if (mystrncasecmp(argv[2],Folder[i].parameter,0)) { | 7238 | if (mystrncasecmp(argv[2],Folder[i].parameter,0)) { |
7239 | Found = true; | 7239 | Found = true; |
7240 | break; | 7240 | break; |
7241 | } | 7241 | } |
7242 | i++; | 7242 | i++; |
7243 | } | 7243 | } |
7244 | if (!Found) { | 7244 | if (!Found) { |
7245 | printmsg("What folder type (\"%s\") ?\n",argv[2]); | 7245 | printmsg("What folder type (\"%s\") ?\n",argv[2]); |
7246 | exit(-1); | 7246 | exit(-1); |
7247 | } | 7247 | } |
7248 | 7248 | ||
7249 | GSM_Init(true); | 7249 | GSM_Init(true); |
7250 | 7250 | ||
7251 | if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) { | 7251 | if (s.ConnectionType == GCT_IRDAOBEX || s.ConnectionType == GCT_BLUEOBEX) { |
7252 | Found = false; | 7252 | Found = false; |
7253 | i = 0; | 7253 | i = 0; |
7254 | while (Folder[i].level[0] != 0) { | 7254 | while (Folder[i].level[0] != 0) { |
7255 | if (!strcmp("obex",Folder[i].model) && | 7255 | if (!strcmp("obex",Folder[i].model) && |
7256 | mystrncasecmp(argv[2],Folder[i].parameter,0)) { | 7256 | mystrncasecmp(argv[2],Folder[i].parameter,0)) { |
7257 | strcpy(Files.ID_FullName,Folder[i].level); | 7257 | strcpy(Files.ID_FullName,Folder[i].level); |
7258 | Found = true; | 7258 | Found = true; |
7259 | break; | 7259 | break; |
7260 | } | 7260 | } |
7261 | i++; | 7261 | i++; |
7262 | } | 7262 | } |
7263 | } else { | 7263 | } else { |
7264 | printmsgerr("Searching for phone folder: "); | 7264 | printmsgerr("Searching for phone folder: "); |
7265 | while (1) { | 7265 | while (1) { |
7266 | error = Phone->GetNextFileFolder(&s,&Files,Start); | 7266 | error = Phone->GetNextFileFolder(&s,&Files,Start); |
7267 | if (error == ERR_EMPTY) break; | 7267 | if (error == ERR_EMPTY) break; |
7268 | Print_Error(error); | 7268 | Print_Error(error); |
7269 | 7269 | ||
7270 | if (Files.Folder) { | 7270 | if (Files.Folder) { |
7271 | dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level); | 7271 | dbgprintf("folder %s level %i\n",DecodeUnicodeConsole(Files.Name),Files.Level); |
7272 | Found = false; | 7272 | Found = false; |
7273 | i = 0; | 7273 | i = 0; |
7274 | while (Folder[i].level[0] != 0) { | 7274 | while (Folder[i].level[0] != 0) { |
7275 | EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder)); | 7275 | EncodeUnicode(buffer,Folder[i].folder,strlen(Folder[i].folder)); |
7276 | dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level); | 7276 | dbgprintf("comparing \"%s\" \"%s\" \"%s\"\n",s.Phone.Data.ModelInfo->model,Files.ID_FullName,Folder[i].level); |
7277 | if (mystrncasecmp(argv[2],Folder[i].parameter,0) && | 7277 | if (mystrncasecmp(argv[2],Folder[i].parameter,0) && |
7278 | mywstrncasecmp(Files.Name,buffer,0) && | 7278 | mywstrncasecmp(Files.Name,buffer,0) && |
7279 | Files.Level == atoi(Folder[i].level)) { | 7279 | Files.Level == atoi(Folder[i].level)) { |
7280 | Found = true; | 7280 | Found = true; |
7281 | break; | 7281 | break; |
7282 | } | 7282 | } |
7283 | if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) && | 7283 | if (!strcmp(s.Phone.Data.ModelInfo->model,Folder[i].model) && |
7284 | mystrncasecmp(argv[2],Folder[i].parameter,0) && | 7284 | mystrncasecmp(argv[2],Folder[i].parameter,0) && |
7285 | !strcmp(Files.ID_FullName,Folder[i].level)) { | 7285 | !strcmp(Files.ID_FullName,Folder[i].level)) { |
7286 | Found = true; | 7286 | Found = true; |
7287 | break; | 7287 | break; |
7288 | } | 7288 | } |
7289 | i++; | 7289 | i++; |
7290 | } | 7290 | } |
7291 | if (Found) break; | 7291 | if (Found) break; |
7292 | } | 7292 | } |
7293 | printmsgerr("*"); | 7293 | printmsgerr("*"); |
7294 | 7294 | ||
7295 | Start = false; | 7295 | Start = false; |
7296 | } | 7296 | } |
7297 | printmsgerr("\n"); | 7297 | printmsgerr("\n"); |
7298 | } | 7298 | } |
7299 | if (!Found) { | 7299 | if (!Found) { |
7300 | printmsg("Folder not found. Probably function not supported !\n"); | 7300 | printmsg("Folder not found. Probably function not supported !\n"); |
7301 | GSM_Terminate(); | 7301 | GSM_Terminate(); |
7302 | exit(-1); | 7302 | exit(-1); |
7303 | } | 7303 | } |
7304 | File.Buffer = NULL; | 7304 | File.Buffer = NULL; |
7305 | File.Protected = false; | 7305 | File.Protected = false; |
7306 | File.ReadOnly = false; | 7306 | File.ReadOnly = false; |
7307 | File.Hidden= false; | 7307 | File.Hidden= false; |
7308 | File.System= false; | 7308 | File.System= false; |
7309 | 7309 | ||
7310 | if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) { | 7310 | if (mystrncasecmp(argv[2],"Application",0) || mystrncasecmp(argv[2],"Game",0)) { |
7311 | sprintf(buffer,"%s.jad",argv[3]); | 7311 | sprintf(buffer,"%s.jad",argv[3]); |
7312 | file = fopen(buffer,"rb"); | 7312 | file = fopen(buffer,"rb"); |
7313 | if (file == NULL) Print_Error(ERR_CANTOPENFILE); | 7313 | if (file == NULL) Print_Error(ERR_CANTOPENFILE); |
7314 | fclose(file); | 7314 | fclose(file); |
7315 | sprintf(buffer,"%s.jar",argv[3]); | 7315 | sprintf(buffer,"%s.jar",argv[3]); |
7316 | file = fopen(buffer,"rb"); | 7316 | file = fopen(buffer,"rb"); |
7317 | if (file == NULL) Print_Error(ERR_CANTOPENFILE); | 7317 | if (file == NULL) Print_Error(ERR_CANTOPENFILE); |
7318 | fclose(file); | 7318 | fclose(file); |
7319 | 7319 | ||
7320 | /* reading jar file */ | 7320 | /* reading jar file */ |
7321 | sprintf(buffer,"%s.jar",argv[3]); | 7321 | sprintf(buffer,"%s.jar",argv[3]); |
7322 | error = GSM_ReadFile(buffer, &File); | 7322 | error = GSM_ReadFile(buffer, &File); |
7323 | Print_Error(error); | 7323 | Print_Error(error); |
7324 | Size2 = File.Used; | 7324 | Size2 = File.Used; |
7325 | 7325 | ||
7326 | /* reading jad file */ | 7326 | /* reading jad file */ |
7327 | sprintf(buffer,"%s.jad",argv[3]); | 7327 | sprintf(buffer,"%s.jad",argv[3]); |
7328 | error = GSM_ReadFile(buffer, &File); | 7328 | error = GSM_ReadFile(buffer, &File); |
7329 | Print_Error(error); | 7329 | Print_Error(error); |
7330 | 7330 | ||
7331 | /* Getting values from JAD file */ | 7331 | /* Getting values from JAD file */ |
7332 | error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size); | 7332 | error = GSM_JADFindData(File, Vendor, Name, JAR, Version, &Size); |
7333 | if (error == ERR_FILENOTSUPPORTED) { | 7333 | if (error == ERR_FILENOTSUPPORTED) { |
7334 | if (Vendor[0] == 0x00) { | 7334 | if (Vendor[0] == 0x00) { |
7335 | printmsgerr("No vendor info in JAD file\n"); | 7335 | printmsgerr("No vendor info in JAD file\n"); |
7336 | GSM_Terminate(); | 7336 | GSM_Terminate(); |
7337 | return; | 7337 | return; |
7338 | } | 7338 | } |
7339 | if (Name[0] == 0x00) { | 7339 | if (Name[0] == 0x00) { |
7340 | printmsgerr("No name info in JAD file\n"); | 7340 | printmsgerr("No name info in JAD file\n"); |
7341 | GSM_Terminate(); | 7341 | GSM_Terminate(); |
7342 | return; | 7342 | return; |
7343 | } | 7343 | } |
7344 | if (JAR[0] == 0x00) { | 7344 | if (JAR[0] == 0x00) { |
7345 | printmsgerr("No JAR URL info in JAD file\n"); | 7345 | printmsgerr("No JAR URL info in JAD file\n"); |
7346 | GSM_Terminate(); | 7346 | GSM_Terminate(); |
7347 | return; | 7347 | return; |
7348 | } | 7348 | } |
7349 | if (Size == -1) { | 7349 | if (Size == -1) { |
7350 | printmsgerr("No JAR size info in JAD file\n"); | 7350 | printmsgerr("No JAR size info in JAD file\n"); |
7351 | GSM_Terminate(); | 7351 | GSM_Terminate(); |
7352 | return; | 7352 | return; |
7353 | } | 7353 | } |
7354 | } | 7354 | } |
7355 | if (Size != Size2) { | 7355 | if (Size != Size2) { |
7356 | printmsgerr("Declared JAR file size is different than real\n"); | 7356 | printmsgerr("Declared JAR file size is different than real\n"); |
7357 | GSM_Terminate(); | 7357 | GSM_Terminate(); |
7358 | return; | 7358 | return; |
7359 | } | 7359 | } |
7360 | printmsgerr("Adding \"%s\"",Name); | 7360 | printmsgerr("Adding \"%s\"",Name); |
7361 | if (Version[0] != 0x00) printmsgerr(" version %s",Version); | 7361 | if (Version[0] != 0x00) printmsgerr(" version %s",Version); |
7362 | printmsgerr(" created by %s\n",Vendor); | 7362 | printmsgerr(" created by %s\n",Vendor); |
7363 | 7363 | ||
7364 | /* Bostjan Muller 3200 RH-30 3.08 */ | 7364 | /* Bostjan Muller 3200 RH-30 3.08 */ |
7365 | if (strstr(JAR,"http://") != NULL) { | 7365 | if (strstr(JAR,"http://") != NULL) { |
7366 | i = strlen(JAR)-1; | 7366 | i = strlen(JAR)-1; |
7367 | while (JAR[i] != '/') i--; | 7367 | while (JAR[i] != '/') i--; |
7368 | strcpy(buffer,JAR+i+1); | 7368 | strcpy(buffer,JAR+i+1); |
7369 | strcpy(JAR,buffer); | 7369 | strcpy(JAR,buffer); |
7370 | dbgprintf("New file name is \"%s\"\n",JAR); | 7370 | dbgprintf("New file name is \"%s\"\n",JAR); |
7371 | } | 7371 | } |
7372 | 7372 | ||
7373 | /* Changing all #13 or #10 to #13#10 in JAD */ | 7373 | /* Changing all #13 or #10 to #13#10 in JAD */ |
7374 | Pos = 0; | 7374 | Pos = 0; |
7375 | wasclr = false; | 7375 | wasclr = false; |
7376 | for (i=0;i<File.Used;i++) { | 7376 | for (i=0;i<File.Used;i++) { |
7377 | switch (File.Buffer[i]) { | 7377 | switch (File.Buffer[i]) { |
7378 | case 0x0D: | 7378 | case 0x0D: |
7379 | case 0x0A: | 7379 | case 0x0A: |
7380 | if (!wasclr) { | 7380 | if (!wasclr) { |
7381 | buffer[Pos++] = 0x0D; | 7381 | buffer[Pos++] = 0x0D; |
7382 | buffer[Pos++] = 0x0A; | 7382 | buffer[Pos++] = 0x0A; |
7383 | wasclr = true; | 7383 | wasclr = true; |
7384 | } else wasclr = false; | 7384 | } else wasclr = false; |
7385 | break; | 7385 | break; |
7386 | default: | 7386 | default: |
7387 | buffer[Pos++] = File.Buffer[i]; | 7387 | buffer[Pos++] = File.Buffer[i]; |
7388 | wasclr = false; | 7388 | wasclr = false; |
7389 | } | 7389 | } |
7390 | } | 7390 | } |
7391 | File.Buffer = realloc(File.Buffer, Pos); | 7391 | File.Buffer = realloc(File.Buffer, Pos); |
7392 | File.Used = Pos; | 7392 | File.Used = Pos; |
7393 | memcpy(File.Buffer,buffer,Pos); | 7393 | memcpy(File.Buffer,buffer,Pos); |
7394 | 7394 | ||
7395 | /* adding folder */ | 7395 | /* adding folder */ |
7396 | strcpy(buffer,Vendor); | 7396 | strcpy(buffer,Vendor); |
7397 | strcat(buffer,Name); | 7397 | strcat(buffer,Name); |
7398 | EncodeUnicode(File.Name,buffer,strlen(buffer)); | 7398 | EncodeUnicode(File.Name,buffer,strlen(buffer)); |
7399 | strcpy(File.ID_FullName,Files.ID_FullName); | 7399 | strcpy(File.ID_FullName,Files.ID_FullName); |
7400 | error = Phone->AddFolder(&s,&File); | 7400 | error = Phone->AddFolder(&s,&File); |
7401 | Print_Error(error); | 7401 | Print_Error(error); |
7402 | strcpy(FileID,File.ID_FullName); | 7402 | strcpy(FileID,File.ID_FullName); |
7403 | 7403 | ||
7404 | /* adding jad file */ | 7404 | /* adding jad file */ |
7405 | strcpy(buffer,JAR); | 7405 | strcpy(buffer,JAR); |
7406 | buffer[strlen(buffer) - 1] = 'd'; | 7406 | buffer[strlen(buffer) - 1] = 'd'; |
7407 | EncodeUnicode(File.Name,buffer,strlen(buffer)); | 7407 | EncodeUnicode(File.Name,buffer,strlen(buffer)); |
7408 | File.Type = GSM_File_Other; | 7408 | File.Type = GSM_File_Other; |
7409 | File.ModifiedEmpty = true; | 7409 | File.ModifiedEmpty = true; |
7410 | error = ERR_NONE; | 7410 | error = ERR_NONE; |
7411 | Pos = 0; | 7411 | Pos = 0; |
7412 | while (error == ERR_NONE) { | 7412 | while (error == ERR_NONE) { |
7413 | error = Phone->AddFilePart(&s,&File,&Pos); | 7413 | error = Phone->AddFilePart(&s,&File,&Pos); |
7414 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); | 7414 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); |
7415 | printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used); | 7415 | printmsgerr("%cWriting JAD file: %i percent",13,Pos*100/File.Used); |
7416 | } | 7416 | } |
7417 | printmsgerr("\n"); | 7417 | printmsgerr("\n"); |
7418 | if (error == ERR_WRONGCRC) { | 7418 | if (error == ERR_WRONGCRC) { |
7419 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); | 7419 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); |
7420 | } | 7420 | } |
7421 | 7421 | ||
7422 | if (argc > 4) { | 7422 | if (argc > 4) { |
7423 | if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true; | 7423 | if (mystrncasecmp(argv[4],"-readonly",0)) File.ReadOnly = true; |
7424 | } | 7424 | } |
7425 | 7425 | ||
7426 | /* reading jar file */ | 7426 | /* reading jar file */ |
7427 | sprintf(buffer,"%s.jar",argv[3]); | 7427 | sprintf(buffer,"%s.jar",argv[3]); |
7428 | error = GSM_ReadFile(buffer, &File); | 7428 | error = GSM_ReadFile(buffer, &File); |
7429 | Print_Error(error); | 7429 | Print_Error(error); |
7430 | 7430 | ||
7431 | /* adding jar file */ | 7431 | /* adding jar file */ |
7432 | strcpy(File.ID_FullName,FileID); | 7432 | strcpy(File.ID_FullName,FileID); |
7433 | strcpy(buffer,JAR); | 7433 | strcpy(buffer,JAR); |
7434 | EncodeUnicode(File.Name,buffer,strlen(buffer)); | 7434 | EncodeUnicode(File.Name,buffer,strlen(buffer)); |
7435 | File.Type = GSM_File_Java_JAR; | 7435 | File.Type = GSM_File_Java_JAR; |
7436 | File.ModifiedEmpty = true; | 7436 | File.ModifiedEmpty = true; |
7437 | error = ERR_NONE; | 7437 | error = ERR_NONE; |
7438 | Pos = 0; | 7438 | Pos = 0; |
7439 | while (error == ERR_NONE) { | 7439 | while (error == ERR_NONE) { |
7440 | error = Phone->AddFilePart(&s,&File,&Pos); | 7440 | error = Phone->AddFilePart(&s,&File,&Pos); |
7441 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); | 7441 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); |
7442 | printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used); | 7442 | printmsgerr("%cWriting JAR file: %i percent",13,Pos*100/File.Used); |
7443 | } | 7443 | } |
7444 | printmsgerr("\n"); | 7444 | printmsgerr("\n"); |
7445 | if (error == ERR_WRONGCRC) { | 7445 | if (error == ERR_WRONGCRC) { |
7446 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); | 7446 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); |
7447 | } | 7447 | } |
7448 | 7448 | ||
7449 | free(File.Buffer); | 7449 | free(File.Buffer); |
7450 | GSM_Terminate(); | 7450 | GSM_Terminate(); |
7451 | return; | 7451 | return; |
7452 | } | 7452 | } |
7453 | 7453 | ||
7454 | if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { | 7454 | if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { |
7455 | strcpy(buffer,argv[3]); | 7455 | strcpy(buffer,argv[3]); |
7456 | if (argc > 4) { | 7456 | if (argc > 4) { |
7457 | nextlong = 0; | 7457 | nextlong = 0; |
7458 | for (i=4;i<argc;i++) { | 7458 | for (i=4;i<argc;i++) { |
7459 | switch(nextlong) { | 7459 | switch(nextlong) { |
7460 | case 0: | 7460 | case 0: |
7461 | if (mystrncasecmp(argv[i],"-name",0)) { | 7461 | if (mystrncasecmp(argv[i],"-name",0)) { |
7462 | nextlong = 1; | 7462 | nextlong = 1; |
7463 | continue; | 7463 | continue; |
7464 | } | 7464 | } |
7465 | if (mystrncasecmp(argv[i],"-protected",0)) { | 7465 | if (mystrncasecmp(argv[i],"-protected",0)) { |
7466 | File.Protected = true; | 7466 | File.Protected = true; |
7467 | continue; | 7467 | continue; |
7468 | } | 7468 | } |
7469 | if (mystrncasecmp(argv[i],"-readonly",0)) { | 7469 | if (mystrncasecmp(argv[i],"-readonly",0)) { |
7470 | File.ReadOnly = true; | 7470 | File.ReadOnly = true; |
7471 | continue; | 7471 | continue; |
7472 | } | 7472 | } |
7473 | if (mystrncasecmp(argv[i],"-hidden",0)) { | 7473 | if (mystrncasecmp(argv[i],"-hidden",0)) { |
7474 | File.Hidden = true; | 7474 | File.Hidden = true; |
7475 | continue; | 7475 | continue; |
7476 | } | 7476 | } |
7477 | if (mystrncasecmp(argv[i],"-system",0)) { | 7477 | if (mystrncasecmp(argv[i],"-system",0)) { |
7478 | File.System = true; | 7478 | File.System = true; |
7479 | continue; | 7479 | continue; |
7480 | } | 7480 | } |
7481 | if (mystrncasecmp(argv[i],"-newtime",0)) { | 7481 | if (mystrncasecmp(argv[i],"-newtime",0)) { |
7482 | ModEmpty = true; | 7482 | ModEmpty = true; |
7483 | continue; | 7483 | continue; |
7484 | } | 7484 | } |
7485 | printmsg("Parameter \"%s\" unknown\n",argv[i]); | 7485 | printmsg("Parameter \"%s\" unknown\n",argv[i]); |
7486 | exit(-1); | 7486 | exit(-1); |
7487 | case 1: | 7487 | case 1: |
7488 | strcpy(buffer,argv[i]); | 7488 | strcpy(buffer,argv[i]); |
7489 | nextlong = 0; | 7489 | nextlong = 0; |
7490 | break; | 7490 | break; |
7491 | } | 7491 | } |
7492 | } | 7492 | } |
7493 | if (nextlong!=0) { | 7493 | if (nextlong!=0) { |
7494 | printmsg("Parameter missed...\n"); | 7494 | printmsg("Parameter missed...\n"); |
7495 | exit(-1); | 7495 | exit(-1); |
7496 | } | 7496 | } |
7497 | } | 7497 | } |
7498 | } else { /* MMS things */ | 7498 | } else { /* MMS things */ |
7499 | DT2.Year = 2001; | 7499 | DT2.Year = 2001; |
7500 | DT2.Month = 12; | 7500 | DT2.Month = 12; |
7501 | DT2.Day = 31; | 7501 | DT2.Day = 31; |
7502 | DT2.Hour = 14; | 7502 | DT2.Hour = 14; |
7503 | DT2.Minute = 00; | 7503 | DT2.Minute = 00; |
7504 | DT2.Second = 00; | 7504 | DT2.Second = 00; |
7505 | t_time2 = Fill_Time_T(DT2,8); | 7505 | t_time2 = Fill_Time_T(DT2,8); |
7506 | 7506 | ||
7507 | GSM_GetCurrentDateTime(&DT); | 7507 | GSM_GetCurrentDateTime(&DT); |
7508 | t_time1 = Fill_Time_T(DT,8); | 7508 | t_time1 = Fill_Time_T(DT,8); |
7509 | 7509 | ||
7510 | sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40)); | 7510 | sprintf(buffer,"%07X %07X ",(int)(t_time1-t_time2-40),(int)(t_time1-t_time2-40)); |
7511 | #ifdef DEVELOP | 7511 | #ifdef DEVELOP |
7512 | sprintf(buffer,"2A947BD 2A947DB "); | 7512 | sprintf(buffer,"2A947BD 2A947DB "); |
7513 | #endif | 7513 | #endif |
7514 | /* 40 = inbox "multimedia message received" message */ | 7514 | /* 40 = inbox "multimedia message received" message */ |
7515 | /* 30 = outbox sending failed */ | 7515 | /* 30 = outbox sending failed */ |
7516 | if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 "); | 7516 | if (mystrncasecmp(argv[2],"MMSUnreadInbox",0)) strcat(buffer,"43 "); |
7517 | else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 "); | 7517 | else if (mystrncasecmp(argv[2],"MMSReadInbox",0)) strcat(buffer,"50 "); |
7518 | else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 "); | 7518 | else if (mystrncasecmp(argv[2],"MMSOutbox",0)) strcat(buffer,"10 "); |
7519 | else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 "); | 7519 | else if (mystrncasecmp(argv[2],"MMSSent",0)) strcat(buffer,"20 "); |
7520 | else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 "); | 7520 | else if (mystrncasecmp(argv[2],"MMSDrafts",0)) strcat(buffer,"61 "); |
7521 | if (argc > 4) { | 7521 | if (argc > 4) { |
7522 | if (!mystrncasecmp(argv[2],"MMSOutbox",0) && | 7522 | if (!mystrncasecmp(argv[2],"MMSOutbox",0) && |
7523 | !mystrncasecmp(argv[2],"MMSSent",0)) { | 7523 | !mystrncasecmp(argv[2],"MMSSent",0)) { |
7524 | sprintf(Name,"%s",argv[4]); | 7524 | sprintf(Name,"%s",argv[4]); |
7525 | strcat(buffer,Name); | 7525 | strcat(buffer,Name); |
7526 | } | 7526 | } |
7527 | if (argc > 5) { | 7527 | if (argc > 5) { |
7528 | sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]); | 7528 | sprintf(Name,"%zd%s/TYPE=PLMN",strlen(argv[5])+10,argv[5]); |
7529 | strcat(buffer,Name); | 7529 | strcat(buffer,Name); |
7530 | } | 7530 | } |
7531 | } | 7531 | } |
7532 | ModEmpty = true; | 7532 | ModEmpty = true; |
7533 | } | 7533 | } |
7534 | 7534 | ||
7535 | error = GSM_ReadFile(argv[3], &File); | 7535 | error = GSM_ReadFile(argv[3], &File); |
7536 | Print_Error(error); | 7536 | Print_Error(error); |
7537 | if (ModEmpty) File.ModifiedEmpty = true; | 7537 | if (ModEmpty) File.ModifiedEmpty = true; |
7538 | 7538 | ||
7539 | strcpy(File.ID_FullName,Files.ID_FullName); | 7539 | strcpy(File.ID_FullName,Files.ID_FullName); |
7540 | EncodeUnicode(File.Name,buffer,strlen(buffer)); | 7540 | EncodeUnicode(File.Name,buffer,strlen(buffer)); |
7541 | GSM_IdentifyFileFormat(&File); | 7541 | GSM_IdentifyFileFormat(&File); |
7542 | #ifdef DEVELOP | 7542 | #ifdef DEVELOP |
7543 | if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { | 7543 | if (mystrncasecmp(argv[2],"Gallery",0) || mystrncasecmp(argv[2],"Tones",0)) { |
7544 | } else { /* MMS things */ | 7544 | } else { /* MMS things */ |
7545 | File.Type = GSM_File_MMS; | 7545 | File.Type = GSM_File_MMS; |
7546 | } | 7546 | } |
7547 | #endif | 7547 | #endif |
7548 | 7548 | ||
7549 | dbgprintf("Adding file to filesystem now\n"); | 7549 | dbgprintf("Adding file to filesystem now\n"); |
7550 | error = ERR_NONE; | 7550 | error = ERR_NONE; |
7551 | Pos= 0; | 7551 | Pos= 0; |
7552 | while (error == ERR_NONE) { | 7552 | while (error == ERR_NONE) { |
7553 | error = Phone->AddFilePart(&s,&File,&Pos); | 7553 | error = Phone->AddFilePart(&s,&File,&Pos); |
7554 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); | 7554 | if (error != ERR_EMPTY && error != ERR_WRONGCRC) Print_Error(error); |
7555 | if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used); | 7555 | if (File.Used != 0) printmsgerr("%cWriting file: %i percent",13,Pos*100/File.Used); |
7556 | } | 7556 | } |
7557 | printmsgerr("\n"); | 7557 | printmsgerr("\n"); |
7558 | if (error == ERR_WRONGCRC) { | 7558 | if (error == ERR_WRONGCRC) { |
7559 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); | 7559 | printmsg("WARNING: File checksum calculated by phone doesn't match with value calculated by Gammu. File damaged or error in Gammu\n"); |
7560 | } | 7560 | } |
7561 | 7561 | ||
7562 | free(File.Buffer); | 7562 | free(File.Buffer); |
7563 | GSM_Terminate(); | 7563 | GSM_Terminate(); |
7564 | } | 7564 | } |
7565 | 7565 | ||
7566 | static void DeleteFiles(int argc, char *argv[]) | 7566 | static void DeleteFiles(int argc, char *argv[]) |
7567 | { | 7567 | { |
7568 | int i; | 7568 | int i; |
7569 | 7569 | ||
7570 | GSM_Init(true); | 7570 | GSM_Init(true); |
7571 | 7571 | ||
7572 | for (i=2;i<argc;i++) { | 7572 | for (i=2;i<argc;i++) { |
7573 | error = Phone->DeleteFile(&s,argv[i]); | 7573 | error = Phone->DeleteFile(&s,argv[i]); |
7574 | Print_Error(error); | 7574 | Print_Error(error); |
7575 | } | 7575 | } |
7576 | 7576 | ||
7577 | GSM_Terminate(); | 7577 | GSM_Terminate(); |
7578 | } | 7578 | } |
7579 | 7579 | ||
7580 | static void SaveMMSFile(int argc, char *argv[]) | 7580 | static void SaveMMSFile(int argc, char *argv[]) |
7581 | { | 7581 | { |
7582 | FILE *file; | 7582 | FILE *file; |
7583 | unsigned char Buffer[50000],Buffer2[20][2010]; | 7583 | unsigned char Buffer[50000],Buffer2[20][2010]; |
7584 | int i,nextlong = 0,len = 0; | 7584 | int i,nextlong = 0,len = 0; |
7585 | GSM_EncodeMultiPartMMSInfo Info; | 7585 | GSM_EncodeMultiPartMMSInfo Info; |
7586 | 7586 | ||
7587 | GSM_ClearMultiPartMMSInfo(&Info); | 7587 | GSM_ClearMultiPartMMSInfo(&Info); |
7588 | 7588 | ||
7589 | for (i=3;i<argc;i++) { | 7589 | for (i=3;i<argc;i++) { |
7590 | switch (nextlong) { | 7590 | switch (nextlong) { |
7591 | case 0: | 7591 | case 0: |
7592 | if (mystrncasecmp(argv[i],"-subject",0)) { | 7592 | if (mystrncasecmp(argv[i],"-subject",0)) { |
7593 | nextlong=1; | 7593 | nextlong=1; |
7594 | continue; | 7594 | continue; |
7595 | } | 7595 | } |
7596 | if (mystrncasecmp(argv[i],"-text",0)) { | 7596 | if (mystrncasecmp(argv[i],"-text",0)) { |
7597 | nextlong=2; | 7597 | nextlong=2; |
7598 | continue; | 7598 | continue; |
7599 | } | 7599 | } |
7600 | if (mystrncasecmp(argv[i],"-from",0)) { | 7600 | if (mystrncasecmp(argv[i],"-from",0)) { |
7601 | nextlong=3; | 7601 | nextlong=3; |
7602 | continue; | 7602 | continue; |
7603 | } | 7603 | } |
7604 | if (mystrncasecmp(argv[i],"-to",0)) { | 7604 | if (mystrncasecmp(argv[i],"-to",0)) { |
7605 | nextlong=4; | 7605 | nextlong=4; |
7606 | continue; | 7606 | continue; |
7607 | } | 7607 | } |
7608 | printmsg("Unknown parameter (\"%s\")\n",argv[i]); | 7608 | printmsg("Unknown parameter (\"%s\")\n",argv[i]); |
7609 | exit(-1); | 7609 | exit(-1); |
7610 | break; | 7610 | break; |
7611 | case 1: /* Subject */ | 7611 | case 1: /* Subject */ |
7612 | EncodeUnicode(Info.Subject,argv[i],strlen(argv[i])); | 7612 | EncodeUnicode(Info.Subject,argv[i],strlen(argv[i])); |
7613 | nextlong = 0; | 7613 | nextlong = 0; |
7614 | break; | 7614 | break; |
7615 | case 2: /* Text */ | 7615 | case 2: /* Text */ |
7616 | EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i])); | 7616 | EncodeUnicode(Buffer2[Info.EntriesNum],argv[i],strlen(argv[i])); |
7617 | Info.Entries[Info.EntriesNum].ID = MMS_Text; | 7617 | Info.Entries[Info.EntriesNum].ID = MMS_Text; |
7618 | Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum]; | 7618 | Info.Entries[Info.EntriesNum].Buffer = Buffer2[Info.EntriesNum]; |
7619 | Info.EntriesNum++; | 7619 | Info.EntriesNum++; |
7620 | nextlong = 0; | 7620 | nextlong = 0; |
7621 | break; | 7621 | break; |
7622 | case 3: /* From */ | 7622 | case 3: /* From */ |
7623 | EncodeUnicode(Info.Source,argv[i],strlen(argv[i])); | 7623 | EncodeUnicode(Info.Source,argv[i],strlen(argv[i])); |
7624 | nextlong = 0; | 7624 | nextlong = 0; |
7625 | break; | 7625 | break; |
7626 | case 4: /* To */ | 7626 | case 4: /* To */ |
7627 | EncodeUnicode(Info.Destination,argv[i],strlen(argv[i])); | 7627 | EncodeUnicode(Info.Destination,argv[i],strlen(argv[i])); |
7628 | nextlong = 0; | 7628 | nextlong = 0; |
7629 | break; | 7629 | break; |
7630 | } | 7630 | } |
7631 | } | 7631 | } |
7632 | if (nextlong!=0) { | 7632 | if (nextlong!=0) { |
7633 | printmsg("Parameter missed...\n"); | 7633 | printmsg("Parameter missed...\n"); |
7634 | exit(-1); | 7634 | exit(-1); |
7635 | } | 7635 | } |
7636 | 7636 | ||
7637 | GSM_EncodeMMSFile(&Info,Buffer,&len); | 7637 | GSM_EncodeMMSFile(&Info,Buffer,&len); |
7638 | 7638 | ||
7639 | file = fopen(argv[2],"wb"); | 7639 | file = fopen(argv[2],"wb"); |
7640 | if (file == NULL) Print_Error(ERR_CANTOPENFILE); | 7640 | if (file == NULL) Print_Error(ERR_CANTOPENFILE); |
7641 | fwrite(Buffer,1,len,file); | 7641 | fwrite(Buffer,1,len,file); |
7642 | fclose(file); | 7642 | fclose(file); |
7643 | } | 7643 | } |
7644 | 7644 | ||
7645 | static void CallDivert(int argc, char *argv[]) | 7645 | static void CallDivert(int argc, char *argv[]) |
7646 | { | 7646 | { |
7647 | GSM_MultiCallDivert cd; | 7647 | GSM_MultiCallDivert cd; |
7648 | 7648 | ||
7649 | if (mystrncasecmp("get",argv[2],0)) {} | 7649 | if (mystrncasecmp("get",argv[2],0)) {} |
7650 | else if (mystrncasecmp("set",argv[2],0)) {} | 7650 | else if (mystrncasecmp("set",argv[2],0)) {} |
7651 | else { | 7651 | else { |
7652 | printmsg("Unknown divert action (\"%s\")\n",argv[2]); | 7652 | printmsg("Unknown divert action (\"%s\")\n",argv[2]); |
7653 | exit(-1); | 7653 | exit(-1); |
7654 | } | 7654 | } |
7655 | 7655 | ||
7656 | if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;} | 7656 | if (mystrncasecmp("all" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;} |
7657 | else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;} | 7657 | else if (mystrncasecmp("busy" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_Busy ;} |
7658 | else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;} | 7658 | else if (mystrncasecmp("noans" , argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_NoAnswer ;} |
7659 | else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;} | 7659 | else if (mystrncasecmp("outofreach", argv[3],0)) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;} |
7660 | else { | 7660 | else { |
7661 | printmsg("Unknown divert type (\"%s\")\n",argv[3]); | 7661 | printmsg("Unknown divert type (\"%s\")\n",argv[3]); |
7662 | exit(-1); | 7662 | exit(-1); |
7663 | } | 7663 | } |
7664 | 7664 | ||
7665 | if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;} | 7665 | if (mystrncasecmp("all" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_AllCalls ;} |
7666 | else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;} | 7666 | else if (mystrncasecmp("voice", argv[4],0)) {cd.Request.CallType = GSM_DIVERT_VoiceCalls;} |
7667 | else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;} | 7667 | else if (mystrncasecmp("fax" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_FaxCalls ;} |
7668 | else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;} | 7668 | else if (mystrncasecmp("data" , argv[4],0)) {cd.Request.CallType = GSM_DIVERT_DataCalls ;} |
7669 | else { | 7669 | else { |
7670 | printmsg("Unknown call type (\"%s\")\n",argv[4]); | 7670 | printmsg("Unknown call type (\"%s\")\n",argv[4]); |
7671 | exit(-1); | 7671 | exit(-1); |
7672 | } | 7672 | } |
7673 | 7673 | ||
7674 | GSM_Init(true); | 7674 | GSM_Init(true); |
7675 | 7675 | ||
7676 | if (mystrncasecmp("get", argv[2],0)) { | 7676 | if (mystrncasecmp("get", argv[2],0)) { |
7677 | error = Phone->GetCallDivert(&s,&cd); | 7677 | error = Phone->GetCallDivert(&s,&cd); |
7678 | Print_Error(error); | 7678 | Print_Error(error); |
7679 | printmsg("Query:\n Divert type: "); | 7679 | printmsg("Query:\n Divert type: "); |
7680 | } else { | 7680 | } else { |
7681 | cd.Request.Number[0] = 0; | 7681 | cd.Request.Number[0] = 0; |
7682 | cd.Request.Number[1] = 0; | 7682 | cd.Request.Number[1] = 0; |
7683 | if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5])); | 7683 | if (argc > 5) EncodeUnicode(cd.Request.Number,argv[5],strlen(argv[5])); |
7684 | 7684 | ||
7685 | cd.Request.Timeout = 0; | 7685 | cd.Request.Timeout = 0; |
7686 | if (argc > 6) cd.Request.Timeout = atoi(argv[6]); | 7686 | if (argc > 6) cd.Request.Timeout = atoi(argv[6]); |
7687 | 7687 | ||
7688 | error = Phone->SetCallDivert(&s,&cd); | 7688 | error = Phone->SetCallDivert(&s,&cd); |
7689 | Print_Error(error); | 7689 | Print_Error(error); |
7690 | printmsg("Changed:\n Divert type: "); | 7690 | printmsg("Changed:\n Divert type: "); |
7691 | } | 7691 | } |
7692 | 7692 | ||
7693 | switch (cd.Request.DivertType) { | 7693 | switch (cd.Request.DivertType) { |
7694 | case GSM_DIVERT_Busy : printmsg("when busy"); break; | 7694 | case GSM_DIVERT_Busy : printmsg("when busy"); break; |
7695 | case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break; | 7695 | case GSM_DIVERT_NoAnswer : printmsg("when not answered"); break; |
7696 | case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break; | 7696 | case GSM_DIVERT_OutOfReach: printmsg("when phone off or no coverage");break; |
7697 | case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break; | 7697 | case GSM_DIVERT_AllTypes : printmsg("all types of diverts"); break; |
7698 | default : printmsg("unknown %i",cd.Request.DivertType); break; | 7698 | default : printmsg("unknown %i",cd.Request.DivertType); break; |
7699 | } | 7699 | } |
7700 | printmsg("\n Calls type : "); | 7700 | printmsg("\n Calls type : "); |
7701 | switch (cd.Request.CallType) { | 7701 | switch (cd.Request.CallType) { |
7702 | case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; | 7702 | case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; |
7703 | case GSM_DIVERT_FaxCalls : printmsg("fax"); break; | 7703 | case GSM_DIVERT_FaxCalls : printmsg("fax"); break; |
7704 | case GSM_DIVERT_DataCalls : printmsg("data"); break; | 7704 | case GSM_DIVERT_DataCalls : printmsg("data"); break; |
7705 | case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break; | 7705 | case GSM_DIVERT_AllCalls : printmsg("data & fax & voice"); break; |
7706 | default : printmsg("unknown %i",cd.Request.CallType); break; | 7706 | default : printmsg("unknown %i",cd.Request.CallType); break; |
7707 | } | 7707 | } |
7708 | printmsg("\nResponse:"); | 7708 | printmsg("\nResponse:"); |
7709 | 7709 | ||
7710 | for (i=0;i<cd.Response.EntriesNum;i++) { | 7710 | for (i=0;i<cd.Response.EntriesNum;i++) { |
7711 | printmsg("\n Calls type : "); | 7711 | printmsg("\n Calls type : "); |
7712 | switch (cd.Response.Entries[i].CallType) { | 7712 | switch (cd.Response.Entries[i].CallType) { |
7713 | case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; | 7713 | case GSM_DIVERT_VoiceCalls: printmsg("voice"); break; |
7714 | case GSM_DIVERT_FaxCalls : printmsg("fax"); break; | 7714 | case GSM_DIVERT_FaxCalls : printmsg("fax"); break; |
7715 | case GSM_DIVERT_DataCalls : printmsg("data"); break; | 7715 | case GSM_DIVERT_DataCalls : printmsg("data"); break; |
7716 | default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break; | 7716 | default : printmsg("unknown %i",cd.Response.Entries[i].CallType);break; |
7717 | } | 7717 | } |
7718 | printf("\n"); | 7718 | printf("\n"); |
7719 | printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout); | 7719 | printmsg(" Timeout : %i seconds\n",cd.Response.Entries[i].Timeout); |
7720 | printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number)); | 7720 | printmsg(" Number : %s\n",DecodeUnicodeString(cd.Response.Entries[i].Number)); |
7721 | } | 7721 | } |
7722 | printf("\n"); | 7722 | printf("\n"); |
7723 | 7723 | ||
7724 | GSM_Terminate(); | 7724 | GSM_Terminate(); |
7725 | } | 7725 | } |
7726 | 7726 | ||
7727 | static void CancelAllDiverts(int argc, char *argv[]) | 7727 | static void CancelAllDiverts(int argc, char *argv[]) |
7728 | { | 7728 | { |
7729 | GSM_Init(true); | 7729 | GSM_Init(true); |
7730 | 7730 | ||
7731 | error = Phone->CancelAllDiverts(&s); | 7731 | error = Phone->CancelAllDiverts(&s); |
7732 | Print_Error(error); | 7732 | Print_Error(error); |
7733 | 7733 | ||
7734 | GSM_Terminate(); | 7734 | GSM_Terminate(); |
7735 | } | 7735 | } |
7736 | 7736 | ||
7737 | typedef struct { | 7737 | typedef struct { |
7738 | unsigned char Connection[50]; | 7738 | unsigned char Connection[50]; |
7739 | } OneConnectionInfo; | 7739 | } OneConnectionInfo; |
7740 | 7740 | ||
7741 | typedef struct { | 7741 | typedef struct { |
7742 | unsigned char Device[50]; | 7742 | unsigned char Device[50]; |
7743 | OneConnectionInfo Connections[4]; | 7743 | OneConnectionInfo Connections[4]; |
7744 | } OneDeviceInfo; | 7744 | } OneDeviceInfo; |
7745 | 7745 | ||
7746 | int num; | 7746 | int num; |
7747 | bool SearchOutput; | 7747 | bool SearchOutput; |
7748 | 7748 | ||
7749 | void SearchPhoneThread(OneDeviceInfo *Info) | 7749 | void SearchPhoneThread(OneDeviceInfo *Info) |
7750 | { | 7750 | { |
7751 | //LR | 7751 | //LR |
7752 | #if 0 | 7752 | #if 0 |
7753 | int j; | 7753 | int j; |
7754 | GSM_Error error; | 7754 | GSM_Error error; |
7755 | GSM_StateMachiness; | 7755 | GSM_StateMachiness; |
7756 | 7756 | ||
7757 | j = 0; | 7757 | j = 0; |
7758 | while(strlen(Info->Connections[j].Connection) != 0) { | 7758 | while(strlen(Info->Connections[j].Connection) != 0) { |
7759 | memcpy(&ss.di,&s.di,sizeof(Debug_Info)); | 7759 | memcpy(&ss.di,&s.di,sizeof(Debug_Info)); |
7760 | ss.msg = s.msg; | 7760 | ss.msg = s.msg; |
7761 | ss.ConfigNum = 1; | 7761 | ss.ConfigNum = 1; |
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index d037d2f..ad0f702 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,1076 +1,1198 @@ | |||
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | #include <kglobal.h> | 45 | #include <kglobal.h> |
46 | #include <klocale.h> | 46 | #include <klocale.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include <libkdepim/phoneaccess.h> | 50 | #include <libkdepim/phoneaccess.h> |
51 | #include "addressbook.h" | 51 | #include "addressbook.h" |
52 | #include "resource.h" | 52 | #include "resource.h" |
53 | #include "vcardconverter.h" | 53 | #include "vcardconverter.h" |
54 | #include "vcardparser/vcardtool.h" | 54 | #include "vcardparser/vcardtool.h" |
55 | 55 | ||
56 | //US #include "addressbook.moc" | 56 | //US #include "addressbook.moc" |
57 | 57 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | 59 | ||
60 | struct AddressBook::AddressBookData | 60 | struct AddressBook::AddressBookData |
61 | { | 61 | { |
62 | Addressee::List mAddressees; | 62 | Addressee::List mAddressees; |
63 | Addressee::List mRemovedAddressees; | 63 | Addressee::List mRemovedAddressees; |
64 | Field::List mAllFields; | 64 | Field::List mAllFields; |
65 | KConfig *mConfig; | 65 | KConfig *mConfig; |
66 | KRES::Manager<Resource> *mManager; | 66 | KRES::Manager<Resource> *mManager; |
67 | //US ErrorHandler *mErrorHandler; | 67 | //US ErrorHandler *mErrorHandler; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct AddressBook::Iterator::IteratorData | 70 | struct AddressBook::Iterator::IteratorData |
71 | { | 71 | { |
72 | Addressee::List::Iterator mIt; | 72 | Addressee::List::Iterator mIt; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | struct AddressBook::ConstIterator::ConstIteratorData | 75 | struct AddressBook::ConstIterator::ConstIteratorData |
76 | { | 76 | { |
77 | Addressee::List::ConstIterator mIt; | 77 | Addressee::List::ConstIterator mIt; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | AddressBook::Iterator::Iterator() | 80 | AddressBook::Iterator::Iterator() |
81 | { | 81 | { |
82 | d = new IteratorData; | 82 | d = new IteratorData; |
83 | } | 83 | } |
84 | 84 | ||
85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 85 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
86 | { | 86 | { |
87 | d = new IteratorData; | 87 | d = new IteratorData; |
88 | d->mIt = i.d->mIt; | 88 | d->mIt = i.d->mIt; |
89 | } | 89 | } |
90 | 90 | ||
91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 91 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
92 | { | 92 | { |
93 | if( this == &i ) return *this; // guard against self assignment | 93 | if( this == &i ) return *this; // guard against self assignment |
94 | delete d; // delete the old data the Iterator was completely constructed before | 94 | delete d; // delete the old data the Iterator was completely constructed before |
95 | d = new IteratorData; | 95 | d = new IteratorData; |
96 | d->mIt = i.d->mIt; | 96 | d->mIt = i.d->mIt; |
97 | return *this; | 97 | return *this; |
98 | } | 98 | } |
99 | 99 | ||
100 | AddressBook::Iterator::~Iterator() | 100 | AddressBook::Iterator::~Iterator() |
101 | { | 101 | { |
102 | delete d; | 102 | delete d; |
103 | } | 103 | } |
104 | 104 | ||
105 | const Addressee &AddressBook::Iterator::operator*() const | 105 | const Addressee &AddressBook::Iterator::operator*() const |
106 | { | 106 | { |
107 | return *(d->mIt); | 107 | return *(d->mIt); |
108 | } | 108 | } |
109 | 109 | ||
110 | Addressee &AddressBook::Iterator::operator*() | 110 | Addressee &AddressBook::Iterator::operator*() |
111 | { | 111 | { |
112 | return *(d->mIt); | 112 | return *(d->mIt); |
113 | } | 113 | } |
114 | 114 | ||
115 | Addressee *AddressBook::Iterator::operator->() | 115 | Addressee *AddressBook::Iterator::operator->() |
116 | { | 116 | { |
117 | return &(*(d->mIt)); | 117 | return &(*(d->mIt)); |
118 | } | 118 | } |
119 | 119 | ||
120 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 120 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
121 | { | 121 | { |
122 | (d->mIt)++; | 122 | (d->mIt)++; |
123 | return *this; | 123 | return *this; |
124 | } | 124 | } |
125 | 125 | ||
126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 126 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
127 | { | 127 | { |
128 | (d->mIt)++; | 128 | (d->mIt)++; |
129 | return *this; | 129 | return *this; |
130 | } | 130 | } |
131 | 131 | ||
132 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 132 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
133 | { | 133 | { |
134 | (d->mIt)--; | 134 | (d->mIt)--; |
135 | return *this; | 135 | return *this; |
136 | } | 136 | } |
137 | 137 | ||
138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 138 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
139 | { | 139 | { |
140 | (d->mIt)--; | 140 | (d->mIt)--; |
141 | return *this; | 141 | return *this; |
142 | } | 142 | } |
143 | 143 | ||
144 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 144 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
145 | { | 145 | { |
146 | return ( d->mIt == it.d->mIt ); | 146 | return ( d->mIt == it.d->mIt ); |
147 | } | 147 | } |
148 | 148 | ||
149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 149 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
150 | { | 150 | { |
151 | return ( d->mIt != it.d->mIt ); | 151 | return ( d->mIt != it.d->mIt ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | AddressBook::ConstIterator::ConstIterator() | 155 | AddressBook::ConstIterator::ConstIterator() |
156 | { | 156 | { |
157 | d = new ConstIteratorData; | 157 | d = new ConstIteratorData; |
158 | } | 158 | } |
159 | 159 | ||
160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 160 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
161 | { | 161 | { |
162 | d = new ConstIteratorData; | 162 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 163 | d->mIt = i.d->mIt; |
164 | } | 164 | } |
165 | 165 | ||
166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 166 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
167 | { | 167 | { |
168 | if( this == &i ) return *this; // guard for self assignment | 168 | if( this == &i ) return *this; // guard for self assignment |
169 | delete d; // delete the old data because the Iterator was really constructed before | 169 | delete d; // delete the old data because the Iterator was really constructed before |
170 | d = new ConstIteratorData; | 170 | d = new ConstIteratorData; |
171 | d->mIt = i.d->mIt; | 171 | d->mIt = i.d->mIt; |
172 | return *this; | 172 | return *this; |
173 | } | 173 | } |
174 | 174 | ||
175 | AddressBook::ConstIterator::~ConstIterator() | 175 | AddressBook::ConstIterator::~ConstIterator() |
176 | { | 176 | { |
177 | delete d; | 177 | delete d; |
178 | } | 178 | } |
179 | 179 | ||
180 | const Addressee &AddressBook::ConstIterator::operator*() const | 180 | const Addressee &AddressBook::ConstIterator::operator*() const |
181 | { | 181 | { |
182 | return *(d->mIt); | 182 | return *(d->mIt); |
183 | } | 183 | } |
184 | 184 | ||
185 | const Addressee* AddressBook::ConstIterator::operator->() const | 185 | const Addressee* AddressBook::ConstIterator::operator->() const |
186 | { | 186 | { |
187 | return &(*(d->mIt)); | 187 | return &(*(d->mIt)); |
188 | } | 188 | } |
189 | 189 | ||
190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 190 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
191 | { | 191 | { |
192 | (d->mIt)++; | 192 | (d->mIt)++; |
193 | return *this; | 193 | return *this; |
194 | } | 194 | } |
195 | 195 | ||
196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 196 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
197 | { | 197 | { |
198 | (d->mIt)++; | 198 | (d->mIt)++; |
199 | return *this; | 199 | return *this; |
200 | } | 200 | } |
201 | 201 | ||
202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 202 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
203 | { | 203 | { |
204 | (d->mIt)--; | 204 | (d->mIt)--; |
205 | return *this; | 205 | return *this; |
206 | } | 206 | } |
207 | 207 | ||
208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 208 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
209 | { | 209 | { |
210 | (d->mIt)--; | 210 | (d->mIt)--; |
211 | return *this; | 211 | return *this; |
212 | } | 212 | } |
213 | 213 | ||
214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 214 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
215 | { | 215 | { |
216 | return ( d->mIt == it.d->mIt ); | 216 | return ( d->mIt == it.d->mIt ); |
217 | } | 217 | } |
218 | 218 | ||
219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 219 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
220 | { | 220 | { |
221 | return ( d->mIt != it.d->mIt ); | 221 | return ( d->mIt != it.d->mIt ); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | AddressBook::AddressBook() | 225 | AddressBook::AddressBook() |
226 | { | 226 | { |
227 | init(0, "contact"); | 227 | init(0, "contact"); |
228 | } | 228 | } |
229 | 229 | ||
230 | AddressBook::AddressBook( const QString &config ) | 230 | AddressBook::AddressBook( const QString &config ) |
231 | { | 231 | { |
232 | init(config, "contact"); | 232 | init(config, "contact"); |
233 | } | 233 | } |
234 | 234 | ||
235 | AddressBook::AddressBook( const QString &config, const QString &family ) | 235 | AddressBook::AddressBook( const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | init(config, family); | 237 | init(config, family); |
238 | 238 | ||
239 | } | 239 | } |
240 | 240 | ||
241 | // the default family is "contact" | 241 | // the default family is "contact" |
242 | void AddressBook::init(const QString &config, const QString &family ) | 242 | void AddressBook::init(const QString &config, const QString &family ) |
243 | { | 243 | { |
244 | blockLSEchange = false; | 244 | blockLSEchange = false; |
245 | d = new AddressBookData; | 245 | d = new AddressBookData; |
246 | QString fami = family; | 246 | QString fami = family; |
247 | if (config != 0) { | 247 | if (config != 0) { |
248 | if ( family == "syncContact" ) { | 248 | if ( family == "syncContact" ) { |
249 | qDebug("creating sync config "); | 249 | qDebug("creating sync config "); |
250 | fami = "contact"; | 250 | fami = "contact"; |
251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 251 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
252 | con->setGroup( "General" ); | 252 | con->setGroup( "General" ); |
253 | con->writeEntry( "ResourceKeys", QString("sync") ); | 253 | con->writeEntry( "ResourceKeys", QString("sync") ); |
254 | con->writeEntry( "Standard", QString("sync") ); | 254 | con->writeEntry( "Standard", QString("sync") ); |
255 | con->setGroup( "Resource_sync" ); | 255 | con->setGroup( "Resource_sync" ); |
256 | con->writeEntry( "FileName", config ); | 256 | con->writeEntry( "FileName", config ); |
257 | con->writeEntry( "FileFormat", QString("vcard") ); | 257 | con->writeEntry( "FileFormat", QString("vcard") ); |
258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 258 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
259 | con->writeEntry( "ResourceName", QString("sync_res") ); | 259 | con->writeEntry( "ResourceName", QString("sync_res") ); |
260 | if ( config.right(4) == ".xml" ) | 260 | if ( config.right(4) == ".xml" ) |
261 | con->writeEntry( "ResourceType", QString("qtopia") ); | 261 | con->writeEntry( "ResourceType", QString("qtopia") ); |
262 | else if ( config == "sharp" ) { | 262 | else if ( config == "sharp" ) { |
263 | con->writeEntry( "ResourceType", QString("sharp") ); | 263 | con->writeEntry( "ResourceType", QString("sharp") ); |
264 | } else { | 264 | } else { |
265 | con->writeEntry( "ResourceType", QString("file") ); | 265 | con->writeEntry( "ResourceType", QString("file") ); |
266 | } | 266 | } |
267 | //con->sync(); | 267 | //con->sync(); |
268 | d->mConfig = con; | 268 | d->mConfig = con; |
269 | } | 269 | } |
270 | else | 270 | else |
271 | d->mConfig = new KConfig( locateLocal("config", config) ); | 271 | d->mConfig = new KConfig( locateLocal("config", config) ); |
272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 272 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
273 | } | 273 | } |
274 | else { | 274 | else { |
275 | d->mConfig = 0; | 275 | d->mConfig = 0; |
276 | // qDebug("AddressBook::init 1 config=0"); | 276 | // qDebug("AddressBook::init 1 config=0"); |
277 | } | 277 | } |
278 | 278 | ||
279 | //US d->mErrorHandler = 0; | 279 | //US d->mErrorHandler = 0; |
280 | d->mManager = new KRES::Manager<Resource>( fami, 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 | ||
333 | AddressBook::~AddressBook() | 333 | AddressBook::~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 | ||
341 | bool AddressBook::load() | 341 | bool 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 | ||
369 | bool AddressBook::save( Ticket *ticket ) | 368 | bool 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 | } |
380 | void AddressBook::export2File( QString fileName ) | 379 | void 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 | ||
407 | bool 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 | } | ||
407 | void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) | 475 | void 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 | } |
438 | void AddressBook::setUntagged() | 509 | void 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 | } |
445 | void AddressBook::removeUntagged() | 516 | void 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 | } |
463 | void AddressBook::smplifyAddressees() | 534 | void 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 | } |
473 | void AddressBook::preparePhoneSync( QString currentSyncDevice, bool isPreSync ) | 544 | void 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 | } | ||
561 | void 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 | |||
487 | bool AddressBook::saveABphone( QString fileName ) | 602 | bool 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 | } |
506 | bool AddressBook::saveAB() | 618 | bool 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 | ||
541 | AddressBook::Iterator AddressBook::begin() | 663 | AddressBook::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 | ||
548 | AddressBook::ConstIterator AddressBook::begin() const | 670 | AddressBook::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 | ||
555 | AddressBook::Iterator AddressBook::end() | 677 | AddressBook::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 | ||
562 | AddressBook::ConstIterator AddressBook::end() const | 684 | AddressBook::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 | ||
569 | void AddressBook::clear() | 691 | void AddressBook::clear() |
570 | { | 692 | { |
571 | d->mAddressees.clear(); | 693 | d->mAddressees.clear(); |
572 | } | 694 | } |
573 | 695 | ||
574 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 696 | Ticket *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); | |
597 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 719 | void 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 | ||
663 | void AddressBook::removeAddressee( const Addressee &a ) | 785 | void 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 | } |
693 | 815 | ||
694 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 816 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
695 | { | 817 | { |
696 | Iterator it = begin(); | 818 | Iterator it = begin(); |
697 | Iterator it2 ; | 819 | Iterator it2 ; |
698 | QDateTime dt ( QDate( 2004,1,1) ); | 820 | QDateTime dt ( QDate( 2004,1,1) ); |
699 | while ( it != end() ) { | 821 | while ( it != end() ) { |
700 | (*it).setRevision( dt ); | 822 | (*it).setRevision( dt ); |
701 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 823 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
702 | (*it).setIDStr(""); | 824 | (*it).setIDStr(""); |
703 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 825 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
704 | it2 = it; | 826 | it2 = it; |
705 | //qDebug("removing %s ",(*it).uid().latin1() ); | 827 | //qDebug("removing %s ",(*it).uid().latin1() ); |
706 | ++it; | 828 | ++it; |
707 | removeAddressee( it2 ); | 829 | removeAddressee( it2 ); |
708 | } else { | 830 | } else { |
709 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 831 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
710 | ++it; | 832 | ++it; |
711 | } | 833 | } |
712 | } | 834 | } |
713 | deleteRemovedAddressees(); | 835 | deleteRemovedAddressees(); |
714 | } | 836 | } |
715 | 837 | ||
716 | void AddressBook::removeAddressee( const Iterator &it ) | 838 | void AddressBook::removeAddressee( const Iterator &it ) |
717 | { | 839 | { |
718 | d->mRemovedAddressees.append( (*it) ); | 840 | d->mRemovedAddressees.append( (*it) ); |
719 | d->mAddressees.remove( it.d->mIt ); | 841 | d->mAddressees.remove( it.d->mIt ); |
720 | } | 842 | } |
721 | 843 | ||
722 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 844 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
723 | { | 845 | { |
724 | Iterator it; | 846 | Iterator it; |
725 | for ( it = begin(); it != end(); ++it ) { | 847 | for ( it = begin(); it != end(); ++it ) { |
726 | if ( a.uid() == (*it).uid() ) { | 848 | if ( a.uid() == (*it).uid() ) { |
727 | return it; | 849 | return it; |
728 | } | 850 | } |
729 | } | 851 | } |
730 | return end(); | 852 | return end(); |
731 | } | 853 | } |
732 | 854 | ||
733 | Addressee AddressBook::findByUid( const QString &uid ) | 855 | Addressee AddressBook::findByUid( const QString &uid ) |
734 | { | 856 | { |
735 | Iterator it; | 857 | Iterator it; |
736 | for ( it = begin(); it != end(); ++it ) { | 858 | for ( it = begin(); it != end(); ++it ) { |
737 | if ( uid == (*it).uid() ) { | 859 | if ( uid == (*it).uid() ) { |
738 | return *it; | 860 | return *it; |
739 | } | 861 | } |
740 | } | 862 | } |
741 | return Addressee(); | 863 | return Addressee(); |
742 | } | 864 | } |
743 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) | 865 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) |
744 | { | 866 | { |
745 | //qDebug("AddressBook::preExternSync "); | 867 | //qDebug("AddressBook::preExternSync "); |
746 | AddressBook::Iterator it; | 868 | AddressBook::Iterator it; |
747 | for ( it = begin(); it != end(); ++it ) { | 869 | for ( it = begin(); it != end(); ++it ) { |
748 | (*it).setID( csd, (*it).externalUID() ); | 870 | (*it).setID( csd, (*it).externalUID() ); |
749 | (*it).computeCsum( csd ); | 871 | (*it).computeCsum( csd ); |
750 | } | 872 | } |
751 | mergeAB( aBook ,csd ); | 873 | mergeAB( aBook ,csd ); |
752 | } | 874 | } |
753 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 875 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
754 | { | 876 | { |
755 | //qDebug("AddressBook::postExternSync "); | 877 | //qDebug("AddressBook::postExternSync "); |
756 | AddressBook::Iterator it; | 878 | AddressBook::Iterator it; |
757 | for ( it = begin(); it != end(); ++it ) { | 879 | for ( it = begin(); it != end(); ++it ) { |
758 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 880 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
759 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 881 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
760 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 882 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
761 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 883 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
762 | if ( ad.isEmpty() ) { | 884 | if ( ad.isEmpty() ) { |
763 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 885 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
764 | } else { | 886 | } else { |
765 | (*it).computeCsum( csd ); | 887 | (*it).computeCsum( csd ); |
766 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 888 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
767 | ad.setID( csd, (*it).externalUID() ); | 889 | ad.setID( csd, (*it).externalUID() ); |
768 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 890 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
769 | aBook->insertAddressee( ad ); | 891 | aBook->insertAddressee( ad ); |
770 | } | 892 | } |
771 | } | 893 | } |
772 | } | 894 | } |
773 | } | 895 | } |
774 | 896 | ||
775 | bool AddressBook::containsExternalUid( const QString& uid ) | 897 | bool AddressBook::containsExternalUid( const QString& uid ) |
776 | { | 898 | { |
777 | Iterator it; | 899 | Iterator it; |
778 | for ( it = begin(); it != end(); ++it ) { | 900 | for ( it = begin(); it != end(); ++it ) { |
779 | if ( uid == (*it).externalUID( ) ) | 901 | if ( uid == (*it).externalUID( ) ) |
780 | return true; | 902 | return true; |
781 | } | 903 | } |
782 | return false; | 904 | return false; |
783 | } | 905 | } |
784 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 906 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
785 | { | 907 | { |
786 | Iterator it; | 908 | Iterator it; |
787 | for ( it = begin(); it != end(); ++it ) { | 909 | for ( it = begin(); it != end(); ++it ) { |
788 | if ( uid == (*it).getID( profile ) ) | 910 | if ( uid == (*it).getID( profile ) ) |
789 | return (*it); | 911 | return (*it); |
790 | } | 912 | } |
791 | return Addressee(); | 913 | return Addressee(); |
792 | } | 914 | } |
793 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | 915 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) |
794 | { | 916 | { |
795 | Iterator it; | 917 | Iterator it; |
796 | Addressee ad; | 918 | Addressee ad; |
797 | for ( it = begin(); it != end(); ++it ) { | 919 | for ( it = begin(); it != end(); ++it ) { |
798 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 920 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
799 | if ( !ad.isEmpty() ) { | 921 | if ( !ad.isEmpty() ) { |
800 | (*it).mergeContact( ad ); | 922 | (*it).mergeContact( ad ); |
801 | } | 923 | } |
802 | } | 924 | } |
803 | #if 0 | 925 | #if 0 |
804 | // test only | 926 | // test only |
805 | for ( it = begin(); it != end(); ++it ) { | 927 | for ( it = begin(); it != end(); ++it ) { |
806 | 928 | ||
807 | qDebug("uid %s ", (*it).uid().latin1()); | 929 | qDebug("uid %s ", (*it).uid().latin1()); |
808 | } | 930 | } |
809 | #endif | 931 | #endif |
810 | } | 932 | } |
811 | 933 | ||
812 | #if 0 | 934 | #if 0 |
813 | Addressee::List AddressBook::getExternLastSyncAddressees() | 935 | Addressee::List AddressBook::getExternLastSyncAddressees() |
814 | { | 936 | { |
815 | Addressee::List results; | 937 | Addressee::List results; |
816 | 938 | ||
817 | Iterator it; | 939 | Iterator it; |
818 | for ( it = begin(); it != end(); ++it ) { | 940 | for ( it = begin(); it != end(); ++it ) { |
819 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 941 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
820 | if ( (*it).familyName().left(4) == "!E: " ) | 942 | if ( (*it).familyName().left(4) == "!E: " ) |
821 | results.append( *it ); | 943 | results.append( *it ); |
822 | } | 944 | } |
823 | } | 945 | } |
824 | 946 | ||
825 | return results; | 947 | return results; |
826 | } | 948 | } |
827 | #endif | 949 | #endif |
828 | void AddressBook::resetTempSyncStat() | 950 | void AddressBook::resetTempSyncStat() |
829 | { | 951 | { |
830 | Iterator it; | 952 | Iterator it; |
831 | for ( it = begin(); it != end(); ++it ) { | 953 | for ( it = begin(); it != end(); ++it ) { |
832 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 954 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
833 | } | 955 | } |
834 | 956 | ||
835 | } | 957 | } |
836 | 958 | ||
837 | QStringList AddressBook:: uidList() | 959 | QStringList AddressBook:: uidList() |
838 | { | 960 | { |
839 | QStringList results; | 961 | QStringList results; |
840 | Iterator it; | 962 | Iterator it; |
841 | for ( it = begin(); it != end(); ++it ) { | 963 | for ( it = begin(); it != end(); ++it ) { |
842 | results.append( (*it).uid() ); | 964 | results.append( (*it).uid() ); |
843 | } | 965 | } |
844 | return results; | 966 | return results; |
845 | } | 967 | } |
846 | 968 | ||
847 | 969 | ||
848 | Addressee::List AddressBook::allAddressees() | 970 | Addressee::List AddressBook::allAddressees() |
849 | { | 971 | { |
850 | return d->mAddressees; | 972 | return d->mAddressees; |
851 | 973 | ||
852 | } | 974 | } |
853 | 975 | ||
854 | Addressee::List AddressBook::findByName( const QString &name ) | 976 | Addressee::List AddressBook::findByName( const QString &name ) |
855 | { | 977 | { |
856 | Addressee::List results; | 978 | Addressee::List results; |
857 | 979 | ||
858 | Iterator it; | 980 | Iterator it; |
859 | for ( it = begin(); it != end(); ++it ) { | 981 | for ( it = begin(); it != end(); ++it ) { |
860 | if ( name == (*it).realName() ) { | 982 | if ( name == (*it).realName() ) { |
861 | results.append( *it ); | 983 | results.append( *it ); |
862 | } | 984 | } |
863 | } | 985 | } |
864 | 986 | ||
865 | return results; | 987 | return results; |
866 | } | 988 | } |
867 | 989 | ||
868 | Addressee::List AddressBook::findByEmail( const QString &email ) | 990 | Addressee::List AddressBook::findByEmail( const QString &email ) |
869 | { | 991 | { |
870 | Addressee::List results; | 992 | Addressee::List results; |
871 | QStringList mailList; | 993 | QStringList mailList; |
872 | 994 | ||
873 | Iterator it; | 995 | Iterator it; |
874 | for ( it = begin(); it != end(); ++it ) { | 996 | for ( it = begin(); it != end(); ++it ) { |
875 | mailList = (*it).emails(); | 997 | mailList = (*it).emails(); |
876 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 998 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
877 | if ( email == (*ite) ) { | 999 | if ( email == (*ite) ) { |
878 | results.append( *it ); | 1000 | results.append( *it ); |
879 | } | 1001 | } |
880 | } | 1002 | } |
881 | } | 1003 | } |
882 | 1004 | ||
883 | return results; | 1005 | return results; |
884 | } | 1006 | } |
885 | 1007 | ||
886 | Addressee::List AddressBook::findByCategory( const QString &category ) | 1008 | Addressee::List AddressBook::findByCategory( const QString &category ) |
887 | { | 1009 | { |
888 | Addressee::List results; | 1010 | Addressee::List results; |
889 | 1011 | ||
890 | Iterator it; | 1012 | Iterator it; |
891 | for ( it = begin(); it != end(); ++it ) { | 1013 | for ( it = begin(); it != end(); ++it ) { |
892 | if ( (*it).hasCategory( category) ) { | 1014 | if ( (*it).hasCategory( category) ) { |
893 | results.append( *it ); | 1015 | results.append( *it ); |
894 | } | 1016 | } |
895 | } | 1017 | } |
896 | 1018 | ||
897 | return results; | 1019 | return results; |
898 | } | 1020 | } |
899 | 1021 | ||
900 | void AddressBook::dump() const | 1022 | void AddressBook::dump() const |
901 | { | 1023 | { |
902 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 1024 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
903 | 1025 | ||
904 | ConstIterator it; | 1026 | ConstIterator it; |
905 | for( it = begin(); it != end(); ++it ) { | 1027 | for( it = begin(); it != end(); ++it ) { |
906 | (*it).dump(); | 1028 | (*it).dump(); |
907 | } | 1029 | } |
908 | 1030 | ||
909 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 1031 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
910 | } | 1032 | } |
911 | 1033 | ||
912 | QString AddressBook::identifier() | 1034 | QString AddressBook::identifier() |
913 | { | 1035 | { |
914 | QStringList identifier; | 1036 | QStringList identifier; |
915 | 1037 | ||
916 | 1038 | ||
917 | KRES::Manager<Resource>::ActiveIterator it; | 1039 | KRES::Manager<Resource>::ActiveIterator it; |
918 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1040 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
919 | if ( !(*it)->identifier().isEmpty() ) | 1041 | if ( !(*it)->identifier().isEmpty() ) |
920 | identifier.append( (*it)->identifier() ); | 1042 | identifier.append( (*it)->identifier() ); |
921 | } | 1043 | } |
922 | 1044 | ||
923 | return identifier.join( ":" ); | 1045 | return identifier.join( ":" ); |
924 | } | 1046 | } |
925 | 1047 | ||
926 | Field::List AddressBook::fields( int category ) | 1048 | Field::List AddressBook::fields( int category ) |
927 | { | 1049 | { |
928 | if ( d->mAllFields.isEmpty() ) { | 1050 | if ( d->mAllFields.isEmpty() ) { |
929 | d->mAllFields = Field::allFields(); | 1051 | d->mAllFields = Field::allFields(); |
930 | } | 1052 | } |
931 | 1053 | ||
932 | if ( category == Field::All ) return d->mAllFields; | 1054 | if ( category == Field::All ) return d->mAllFields; |
933 | 1055 | ||
934 | Field::List result; | 1056 | Field::List result; |
935 | Field::List::ConstIterator it; | 1057 | Field::List::ConstIterator it; |
936 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 1058 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
937 | if ( (*it)->category() & category ) result.append( *it ); | 1059 | if ( (*it)->category() & category ) result.append( *it ); |
938 | } | 1060 | } |
939 | 1061 | ||
940 | return result; | 1062 | return result; |
941 | } | 1063 | } |
942 | 1064 | ||
943 | bool AddressBook::addCustomField( const QString &label, int category, | 1065 | bool AddressBook::addCustomField( const QString &label, int category, |
944 | const QString &key, const QString &app ) | 1066 | const QString &key, const QString &app ) |
945 | { | 1067 | { |
946 | if ( d->mAllFields.isEmpty() ) { | 1068 | if ( d->mAllFields.isEmpty() ) { |
947 | d->mAllFields = Field::allFields(); | 1069 | d->mAllFields = Field::allFields(); |
948 | } | 1070 | } |
949 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 1071 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
950 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 1072 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
951 | 1073 | ||
952 | QString k = key.isNull() ? label : key; | 1074 | QString k = key.isNull() ? label : key; |
953 | 1075 | ||
954 | Field *field = Field::createCustomField( label, category, k, a ); | 1076 | Field *field = Field::createCustomField( label, category, k, a ); |
955 | 1077 | ||
956 | if ( !field ) return false; | 1078 | if ( !field ) return false; |
957 | 1079 | ||
958 | d->mAllFields.append( field ); | 1080 | d->mAllFields.append( field ); |
959 | 1081 | ||
960 | return true; | 1082 | return true; |
961 | } | 1083 | } |
962 | 1084 | ||
963 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 1085 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
964 | { | 1086 | { |
965 | if (!ab.d) return s; | 1087 | if (!ab.d) return s; |
966 | 1088 | ||
967 | return s << ab.d->mAddressees; | 1089 | return s << ab.d->mAddressees; |
968 | } | 1090 | } |
969 | 1091 | ||
970 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 1092 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
971 | { | 1093 | { |
972 | if (!ab.d) return s; | 1094 | if (!ab.d) return s; |
973 | 1095 | ||
974 | s >> ab.d->mAddressees; | 1096 | s >> ab.d->mAddressees; |
975 | 1097 | ||
976 | return s; | 1098 | return s; |
977 | } | 1099 | } |
978 | 1100 | ||
979 | bool AddressBook::addResource( Resource *resource ) | 1101 | bool AddressBook::addResource( Resource *resource ) |
980 | { | 1102 | { |
981 | if ( !resource->open() ) { | 1103 | if ( !resource->open() ) { |
982 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 1104 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
983 | return false; | 1105 | return false; |
984 | } | 1106 | } |
985 | 1107 | ||
986 | resource->setAddressBook( this ); | 1108 | resource->setAddressBook( this ); |
987 | 1109 | ||
988 | d->mManager->add( resource ); | 1110 | d->mManager->add( resource ); |
989 | return true; | 1111 | return true; |
990 | } | 1112 | } |
991 | 1113 | ||
992 | bool AddressBook::removeResource( Resource *resource ) | 1114 | bool AddressBook::removeResource( Resource *resource ) |
993 | { | 1115 | { |
994 | resource->close(); | 1116 | resource->close(); |
995 | 1117 | ||
996 | if ( resource == standardResource() ) | 1118 | if ( resource == standardResource() ) |
997 | d->mManager->setStandardResource( 0 ); | 1119 | d->mManager->setStandardResource( 0 ); |
998 | 1120 | ||
999 | resource->setAddressBook( 0 ); | 1121 | resource->setAddressBook( 0 ); |
1000 | 1122 | ||
1001 | d->mManager->remove( resource ); | 1123 | d->mManager->remove( resource ); |
1002 | return true; | 1124 | return true; |
1003 | } | 1125 | } |
1004 | 1126 | ||
1005 | QPtrList<Resource> AddressBook::resources() | 1127 | QPtrList<Resource> AddressBook::resources() |
1006 | { | 1128 | { |
1007 | QPtrList<Resource> list; | 1129 | QPtrList<Resource> list; |
1008 | 1130 | ||
1009 | // qDebug("AddressBook::resources() 1"); | 1131 | // qDebug("AddressBook::resources() 1"); |
1010 | 1132 | ||
1011 | KRES::Manager<Resource>::ActiveIterator it; | 1133 | KRES::Manager<Resource>::ActiveIterator it; |
1012 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 1134 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
1013 | list.append( *it ); | 1135 | list.append( *it ); |
1014 | 1136 | ||
1015 | return list; | 1137 | return list; |
1016 | } | 1138 | } |
1017 | 1139 | ||
1018 | /*US | 1140 | /*US |
1019 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 1141 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
1020 | { | 1142 | { |
1021 | delete d->mErrorHandler; | 1143 | delete d->mErrorHandler; |
1022 | d->mErrorHandler = handler; | 1144 | d->mErrorHandler = handler; |
1023 | } | 1145 | } |
1024 | */ | 1146 | */ |
1025 | 1147 | ||
1026 | void AddressBook::error( const QString& msg ) | 1148 | void AddressBook::error( const QString& msg ) |
1027 | { | 1149 | { |
1028 | /*US | 1150 | /*US |
1029 | if ( !d->mErrorHandler ) // create default error handler | 1151 | if ( !d->mErrorHandler ) // create default error handler |
1030 | d->mErrorHandler = new ConsoleErrorHandler; | 1152 | d->mErrorHandler = new ConsoleErrorHandler; |
1031 | 1153 | ||
1032 | if ( d->mErrorHandler ) | 1154 | if ( d->mErrorHandler ) |
1033 | d->mErrorHandler->error( msg ); | 1155 | d->mErrorHandler->error( msg ); |
1034 | else | 1156 | else |
1035 | kdError(5700) << "no error handler defined" << endl; | 1157 | kdError(5700) << "no error handler defined" << endl; |
1036 | */ | 1158 | */ |
1037 | kdDebug(5700) << "msg" << endl; | 1159 | kdDebug(5700) << "msg" << endl; |
1038 | qDebug(msg); | 1160 | qDebug(msg); |
1039 | } | 1161 | } |
1040 | 1162 | ||
1041 | void AddressBook::deleteRemovedAddressees() | 1163 | void AddressBook::deleteRemovedAddressees() |
1042 | { | 1164 | { |
1043 | Addressee::List::Iterator it; | 1165 | Addressee::List::Iterator it; |
1044 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 1166 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
1045 | Resource *resource = (*it).resource(); | 1167 | Resource *resource = (*it).resource(); |
1046 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 1168 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
1047 | resource->removeAddressee( *it ); | 1169 | resource->removeAddressee( *it ); |
1048 | } | 1170 | } |
1049 | 1171 | ||
1050 | d->mRemovedAddressees.clear(); | 1172 | d->mRemovedAddressees.clear(); |
1051 | } | 1173 | } |
1052 | 1174 | ||
1053 | void AddressBook::setStandardResource( Resource *resource ) | 1175 | void AddressBook::setStandardResource( Resource *resource ) |
1054 | { | 1176 | { |
1055 | // qDebug("AddressBook::setStandardResource 1"); | 1177 | // qDebug("AddressBook::setStandardResource 1"); |
1056 | d->mManager->setStandardResource( resource ); | 1178 | d->mManager->setStandardResource( resource ); |
1057 | } | 1179 | } |
1058 | 1180 | ||
1059 | Resource *AddressBook::standardResource() | 1181 | Resource *AddressBook::standardResource() |
1060 | { | 1182 | { |
1061 | return d->mManager->standardResource(); | 1183 | return d->mManager->standardResource(); |
1062 | } | 1184 | } |
1063 | 1185 | ||
1064 | KRES::Manager<Resource> *AddressBook::resourceManager() | 1186 | KRES::Manager<Resource> *AddressBook::resourceManager() |
1065 | { | 1187 | { |
1066 | return d->mManager; | 1188 | return d->mManager; |
1067 | } | 1189 | } |
1068 | 1190 | ||
1069 | void AddressBook::cleanUp() | 1191 | void AddressBook::cleanUp() |
1070 | { | 1192 | { |
1071 | KRES::Manager<Resource>::ActiveIterator it; | 1193 | KRES::Manager<Resource>::ActiveIterator it; |
1072 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1194 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1073 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 1195 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
1074 | (*it)->cleanUp(); | 1196 | (*it)->cleanUp(); |
1075 | } | 1197 | } |
1076 | } | 1198 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index cc755d1..df9048b 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,346 +1,348 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_ADDRESSBOOK_H | 28 | #ifndef KABC_ADDRESSBOOK_H |
29 | #define KABC_ADDRESSBOOK_H | 29 | #define KABC_ADDRESSBOOK_H |
30 | 30 | ||
31 | #include <qobject.h> | 31 | #include <qobject.h> |
32 | 32 | ||
33 | #include <kresources/manager.h> | 33 | #include <kresources/manager.h> |
34 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
35 | 35 | ||
36 | #include "addressee.h" | 36 | #include "addressee.h" |
37 | #include "field.h" | 37 | #include "field.h" |
38 | 38 | ||
39 | namespace KABC { | 39 | namespace KABC { |
40 | 40 | ||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
48 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
80 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
81 | 81 | ||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
104 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
107 | 107 | ||
108 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
109 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Constructs a address book object. | 113 | Constructs a address book object. |
114 | 114 | ||
115 | @param format File format class. | 115 | @param format File format class. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | 119 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
125 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
129 | */ | 129 | */ |
130 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | Load address book from file. | 133 | Load address book from file. |
134 | */ | 134 | */ |
135 | bool load(); | 135 | bool load(); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | bool saveABphone( QString fileName ); | 145 | bool saveABphone( QString fileName ); |
146 | void smplifyAddressees(); | 146 | void smplifyAddressees(); |
147 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); | 147 | void preparePhoneSync( QString currentSyncDevice, bool isPreSync ); |
148 | void export2File( QString fileName ); | 148 | void export2File( QString fileName ); |
149 | bool export2PhoneFormat( QStringList uids ,QString fileName ); | ||
149 | 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 |
248 | with the given field category. | 250 | with the given field category. |
249 | */ | 251 | */ |
250 | Field::List fields( int category = Field::All ); | 252 | Field::List fields( int category = Field::All ); |
251 | 253 | ||
252 | /** | 254 | /** |
253 | Add custom field to address book. | 255 | Add custom field to address book. |
254 | 256 | ||
255 | @param label User visible label of the field. | 257 | @param label User visible label of the field. |
256 | @param category Ored list of field categories. | 258 | @param category Ored list of field categories. |
257 | @param key Identifier used as key for reading and writing the field. | 259 | @param key Identifier used as key for reading and writing the field. |
258 | @param app String used as application key for reading and writing | 260 | @param app String used as application key for reading and writing |
259 | the field. | 261 | the field. |
260 | */ | 262 | */ |
261 | bool addCustomField( const QString &label, int category = Field::All, | 263 | bool addCustomField( const QString &label, int category = Field::All, |
262 | const QString &key = QString::null, | 264 | const QString &key = QString::null, |
263 | const QString &app = QString::null ); | 265 | const QString &app = QString::null ); |
264 | 266 | ||
265 | 267 | ||
266 | /** | 268 | /** |
267 | Add address book resource. | 269 | Add address book resource. |
268 | */ | 270 | */ |
269 | bool addResource( Resource * ); | 271 | bool addResource( Resource * ); |
270 | 272 | ||
271 | /** | 273 | /** |
272 | Remove address book resource. | 274 | Remove address book resource. |
273 | */ | 275 | */ |
274 | bool removeResource( Resource * ); | 276 | bool removeResource( Resource * ); |
275 | 277 | ||
276 | /** | 278 | /** |
277 | Return pointer list of all resources. | 279 | Return pointer list of all resources. |
278 | */ | 280 | */ |
279 | QPtrList<Resource> resources(); | 281 | QPtrList<Resource> resources(); |
280 | 282 | ||
281 | /** | 283 | /** |
282 | Set the @p ErrorHandler, that is used by @ref error() to | 284 | Set the @p ErrorHandler, that is used by @ref error() to |
283 | provide gui-independend error messages. | 285 | provide gui-independend error messages. |
284 | */ | 286 | */ |
285 | void setErrorHandler( ErrorHandler * ); | 287 | void setErrorHandler( ErrorHandler * ); |
286 | 288 | ||
287 | /** | 289 | /** |
288 | Shows gui independend error messages. | 290 | Shows gui independend error messages. |
289 | */ | 291 | */ |
290 | void error( const QString& ); | 292 | void error( const QString& ); |
291 | 293 | ||
292 | /** | 294 | /** |
293 | Query all resources to clean up their lock files | 295 | Query all resources to clean up their lock files |
294 | */ | 296 | */ |
295 | void cleanUp(); | 297 | void cleanUp(); |
296 | 298 | ||
297 | // sync stuff | 299 | // sync stuff |
298 | //Addressee::List getExternLastSyncAddressees(); | 300 | //Addressee::List getExternLastSyncAddressees(); |
299 | void resetTempSyncStat(); | 301 | void resetTempSyncStat(); |
300 | QStringList uidList(); | 302 | QStringList uidList(); |
301 | void removeSyncAddressees( bool removeDeleted = false ); | 303 | void removeSyncAddressees( bool removeDeleted = false ); |
302 | void mergeAB( AddressBook *aBook, const QString& profile ); | 304 | void mergeAB( AddressBook *aBook, const QString& profile ); |
303 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 305 | Addressee findByExternUid( const QString& uid , const QString& profile ); |
304 | bool containsExternalUid( const QString& uid ); | 306 | bool containsExternalUid( const QString& uid ); |
305 | 307 | ||
306 | void preExternSync( AddressBook* aBook, const QString& csd ); | 308 | void preExternSync( AddressBook* aBook, const QString& csd ); |
307 | void postExternSync( AddressBook* aBook, const QString& csd ); | 309 | void postExternSync( AddressBook* aBook, const QString& csd ); |
308 | signals: | 310 | signals: |
309 | /** | 311 | /** |
310 | Emitted, when the address book has changed on disk. | 312 | Emitted, when the address book has changed on disk. |
311 | */ | 313 | */ |
312 | void addressBookChanged( AddressBook * ); | 314 | void addressBookChanged( AddressBook * ); |
313 | 315 | ||
314 | /** | 316 | /** |
315 | Emitted, when the address book has been locked for writing. | 317 | Emitted, when the address book has been locked for writing. |
316 | */ | 318 | */ |
317 | void addressBookLocked( AddressBook * ); | 319 | void addressBookLocked( AddressBook * ); |
318 | 320 | ||
319 | /** | 321 | /** |
320 | Emitted, when the address book has been unlocked. | 322 | Emitted, when the address book has been unlocked. |
321 | */ | 323 | */ |
322 | void addressBookUnlocked( AddressBook * ); | 324 | void addressBookUnlocked( AddressBook * ); |
323 | 325 | ||
324 | protected: | 326 | protected: |
325 | void deleteRemovedAddressees(); | 327 | void deleteRemovedAddressees(); |
326 | void setStandardResource( Resource * ); | 328 | void setStandardResource( Resource * ); |
327 | Resource *standardResource(); | 329 | Resource *standardResource(); |
328 | KRES::Manager<Resource> *resourceManager(); | 330 | KRES::Manager<Resource> *resourceManager(); |
329 | 331 | ||
330 | void init(const QString &config, const QString &family); | 332 | void init(const QString &config, const QString &family); |
331 | 333 | ||
332 | private: | 334 | private: |
333 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 335 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
334 | 336 | ||
335 | 337 | ||
336 | struct AddressBookData; | 338 | struct AddressBookData; |
337 | AddressBookData *d; | 339 | AddressBookData *d; |
338 | bool blockLSEchange; | 340 | bool blockLSEchange; |
339 | }; | 341 | }; |
340 | 342 | ||
341 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 343 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
342 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 344 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
343 | 345 | ||
344 | } | 346 | } |
345 | 347 | ||
346 | #endif | 348 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 607ae26..548305a 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1947 +1,1987 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | 91 | bool tagged :1; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | Addressee::Addressee() | 94 | Addressee::Addressee() |
95 | { | 95 | { |
96 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
97 | mData->empty = true; | 97 | mData->empty = true; |
98 | mData->changed = false; | 98 | mData->changed = false; |
99 | mData->resource = 0; | 99 | mData->resource = 0; |
100 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
101 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
103 | } | 103 | } |
104 | 104 | ||
105 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
106 | { | 106 | { |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
110 | { | 110 | { |
111 | mData = a.mData; | 111 | mData = a.mData; |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
115 | { | 115 | { |
116 | mData = a.mData; | 116 | mData = a.mData; |
117 | return (*this); | 117 | return (*this); |
118 | } | 118 | } |
119 | 119 | ||
120 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
121 | { | 121 | { |
122 | Addressee a; | 122 | Addressee a; |
123 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
124 | return a; | 124 | return a; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Addressee::detach() | 127 | void Addressee::detach() |
128 | { | 128 | { |
129 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
130 | *this = copy(); | 130 | *this = copy(); |
131 | } | 131 | } |
132 | 132 | ||
133 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
134 | { | 134 | { |
135 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
136 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
137 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
138 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
139 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
140 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
141 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
142 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
143 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
144 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
145 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
146 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
147 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
148 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
149 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
150 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
151 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
152 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
153 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
154 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
155 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
156 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
157 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
158 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
159 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
161 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
163 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
164 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
165 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
166 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
167 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
173 | { | 173 | { |
174 | return !( a == *this ); | 174 | return !( a == *this ); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
178 | { | 178 | { |
179 | return mData->empty; | 179 | return mData->empty; |
180 | } | 180 | } |
181 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
182 | { | 182 | { |
183 | int max = attList.count(); | 183 | int max = attList.count(); |
184 | ulong cSum = 0; | 184 | ulong cSum = 0; |
185 | int j,k,i; | 185 | int j,k,i; |
186 | int add; | 186 | int add; |
187 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
188 | QString s = attList[i]; | 188 | QString s = attList[i]; |
189 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
190 | j = s.length(); | 190 | j = s.length(); |
191 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
192 | int mul = k +1; | 192 | int mul = k +1; |
193 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
194 | if ( k < 16 ) | 194 | if ( k < 16 ) |
195 | mul = mul * mul; | 195 | mul = mul * mul; |
196 | int ii = i+1; | 196 | int ii = i+1; |
197 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
198 | cSum += add; | 198 | cSum += add; |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
204 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
205 | 205 | ||
206 | return cSum; | 206 | return cSum; |
207 | 207 | ||
208 | } | 208 | } |
209 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
210 | { | 210 | { |
211 | QStringList l; | 211 | QStringList l; |
212 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
216 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
231 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
232 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
233 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
234 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
235 | //if ( mData->url.isValid() ) 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 | ||
280 | void Addressee::mergeContact( const Addressee& ad ) | 280 | void 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 | ||
319 | bool Addressee::removeVoice() | 325 | bool 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 | |||
343 | bool 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 | } | ||
336 | void Addressee::simplifyAddresses() | 373 | void 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 |
354 | void Addressee::simplifyEmails() | 394 | void 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 | ||
363 | void Addressee::simplifyPhoneNumbers() | 403 | void 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 | } |
377 | void Addressee::simplifyPhoneNumberTypes() | 417 | void 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 | } |
384 | void Addressee::removeID(const QString &prof) | 424 | void 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 | } |
390 | void Addressee::setID( const QString & prof , const QString & id ) | 430 | void 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 | } |
396 | void Addressee::setTempSyncStat( int id ) | 436 | void 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 | } |
402 | int Addressee::tempSyncStat() const | 442 | int Addressee::tempSyncStat() const |
403 | { | 443 | { |
404 | return mData->mTempSyncStat; | 444 | return mData->mTempSyncStat; |
405 | } | 445 | } |
406 | 446 | ||
407 | QString Addressee::getID( const QString & prof) | 447 | QString 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 | ||
412 | void Addressee::setCsum( const QString & prof , const QString & id ) | 452 | void 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 | ||
420 | QString Addressee::getCsum( const QString & prof) | 460 | QString 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 | ||
425 | void Addressee::setIDStr( const QString & s ) | 465 | void Addressee::setIDStr( const QString & s ) |
426 | { | 466 | { |
427 | detach(); | 467 | detach(); |
428 | mData->mExternalId = s; | 468 | mData->mExternalId = s; |
429 | } | 469 | } |
430 | 470 | ||
431 | QString Addressee::IDStr() const | 471 | QString Addressee::IDStr() const |
432 | { | 472 | { |
433 | return mData->mExternalId; | 473 | return mData->mExternalId; |
434 | } | 474 | } |
435 | 475 | ||
436 | void Addressee::setExternalUID( const QString &id ) | 476 | void Addressee::setExternalUID( const QString &id ) |
437 | { | 477 | { |
438 | if ( id == mData->externalUID ) return; | 478 | if ( id == mData->externalUID ) return; |
439 | detach(); | 479 | detach(); |
440 | mData->empty = false; | 480 | mData->empty = false; |
441 | mData->externalUID = id; | 481 | mData->externalUID = id; |
442 | } | 482 | } |
443 | 483 | ||
444 | QString Addressee::externalUID() const | 484 | QString Addressee::externalUID() const |
445 | { | 485 | { |
446 | return mData->externalUID; | 486 | return mData->externalUID; |
447 | } | 487 | } |
448 | void Addressee::setOriginalExternalUID( const QString &id ) | 488 | void Addressee::setOriginalExternalUID( const QString &id ) |
449 | { | 489 | { |
450 | if ( id == mData->originalExternalUID ) return; | 490 | if ( id == mData->originalExternalUID ) return; |
451 | detach(); | 491 | detach(); |
452 | mData->empty = false; | 492 | mData->empty = false; |
453 | //qDebug("*******Set orig uid %s ", id.latin1()); | 493 | //qDebug("*******Set orig uid %s ", id.latin1()); |
454 | mData->originalExternalUID = id; | 494 | mData->originalExternalUID = id; |
455 | } | 495 | } |
456 | 496 | ||
457 | QString Addressee::originalExternalUID() const | 497 | QString Addressee::originalExternalUID() const |
458 | { | 498 | { |
459 | return mData->originalExternalUID; | 499 | return mData->originalExternalUID; |
460 | } | 500 | } |
461 | 501 | ||
462 | void Addressee::setUid( const QString &id ) | 502 | void Addressee::setUid( const QString &id ) |
463 | { | 503 | { |
464 | if ( id == mData->uid ) return; | 504 | if ( id == mData->uid ) return; |
465 | detach(); | 505 | detach(); |
466 | //qDebug("****setuid %s ", id.latin1()); | 506 | //qDebug("****setuid %s ", id.latin1()); |
467 | mData->empty = false; | 507 | mData->empty = false; |
468 | mData->uid = id; | 508 | mData->uid = id; |
469 | } | 509 | } |
470 | 510 | ||
471 | QString Addressee::uid() const | 511 | QString Addressee::uid() const |
472 | { | 512 | { |
473 | if ( mData->uid.isEmpty() ) | 513 | if ( mData->uid.isEmpty() ) |
474 | mData->uid = KApplication::randomString( 10 ); | 514 | mData->uid = KApplication::randomString( 10 ); |
475 | 515 | ||
476 | return mData->uid; | 516 | return mData->uid; |
477 | } | 517 | } |
478 | 518 | ||
479 | QString Addressee::uidLabel() | 519 | QString Addressee::uidLabel() |
480 | { | 520 | { |
481 | return i18n("Unique Identifier"); | 521 | return i18n("Unique Identifier"); |
482 | } | 522 | } |
483 | 523 | ||
484 | void Addressee::setName( const QString &name ) | 524 | void Addressee::setName( const QString &name ) |
485 | { | 525 | { |
486 | if ( name == mData->name ) return; | 526 | if ( name == mData->name ) return; |
487 | detach(); | 527 | detach(); |
488 | mData->empty = false; | 528 | mData->empty = false; |
489 | mData->name = name; | 529 | mData->name = name; |
490 | } | 530 | } |
491 | 531 | ||
492 | QString Addressee::name() const | 532 | QString Addressee::name() const |
493 | { | 533 | { |
494 | return mData->name; | 534 | return mData->name; |
495 | } | 535 | } |
496 | 536 | ||
497 | QString Addressee::nameLabel() | 537 | QString Addressee::nameLabel() |
498 | { | 538 | { |
499 | return i18n("Name"); | 539 | return i18n("Name"); |
500 | } | 540 | } |
501 | 541 | ||
502 | 542 | ||
503 | void Addressee::setFormattedName( const QString &formattedName ) | 543 | void Addressee::setFormattedName( const QString &formattedName ) |
504 | { | 544 | { |
505 | if ( formattedName == mData->formattedName ) return; | 545 | if ( formattedName == mData->formattedName ) return; |
506 | detach(); | 546 | detach(); |
507 | mData->empty = false; | 547 | mData->empty = false; |
508 | mData->formattedName = formattedName; | 548 | mData->formattedName = formattedName; |
509 | } | 549 | } |
510 | 550 | ||
511 | QString Addressee::formattedName() const | 551 | QString Addressee::formattedName() const |
512 | { | 552 | { |
513 | return mData->formattedName; | 553 | return mData->formattedName; |
514 | } | 554 | } |
515 | 555 | ||
516 | QString Addressee::formattedNameLabel() | 556 | QString Addressee::formattedNameLabel() |
517 | { | 557 | { |
518 | return i18n("Formatted Name"); | 558 | return i18n("Formatted Name"); |
519 | } | 559 | } |
520 | 560 | ||
521 | 561 | ||
522 | void Addressee::setFamilyName( const QString &familyName ) | 562 | void Addressee::setFamilyName( const QString &familyName ) |
523 | { | 563 | { |
524 | if ( familyName == mData->familyName ) return; | 564 | if ( familyName == mData->familyName ) return; |
525 | detach(); | 565 | detach(); |
526 | mData->empty = false; | 566 | mData->empty = false; |
527 | mData->familyName = familyName; | 567 | mData->familyName = familyName; |
528 | } | 568 | } |
529 | 569 | ||
530 | QString Addressee::familyName() const | 570 | QString Addressee::familyName() const |
531 | { | 571 | { |
532 | return mData->familyName; | 572 | return mData->familyName; |
533 | } | 573 | } |
534 | 574 | ||
535 | QString Addressee::familyNameLabel() | 575 | QString Addressee::familyNameLabel() |
536 | { | 576 | { |
537 | return i18n("Family Name"); | 577 | return i18n("Family Name"); |
538 | } | 578 | } |
539 | 579 | ||
540 | 580 | ||
541 | void Addressee::setGivenName( const QString &givenName ) | 581 | void Addressee::setGivenName( const QString &givenName ) |
542 | { | 582 | { |
543 | if ( givenName == mData->givenName ) return; | 583 | if ( givenName == mData->givenName ) return; |
544 | detach(); | 584 | detach(); |
545 | mData->empty = false; | 585 | mData->empty = false; |
546 | mData->givenName = givenName; | 586 | mData->givenName = givenName; |
547 | } | 587 | } |
548 | 588 | ||
549 | QString Addressee::givenName() const | 589 | QString Addressee::givenName() const |
550 | { | 590 | { |
551 | return mData->givenName; | 591 | return mData->givenName; |
552 | } | 592 | } |
553 | 593 | ||
554 | QString Addressee::givenNameLabel() | 594 | QString Addressee::givenNameLabel() |
555 | { | 595 | { |
556 | return i18n("Given Name"); | 596 | return i18n("Given Name"); |
557 | } | 597 | } |
558 | 598 | ||
559 | 599 | ||
560 | void Addressee::setAdditionalName( const QString &additionalName ) | 600 | void Addressee::setAdditionalName( const QString &additionalName ) |
561 | { | 601 | { |
562 | if ( additionalName == mData->additionalName ) return; | 602 | if ( additionalName == mData->additionalName ) return; |
563 | detach(); | 603 | detach(); |
564 | mData->empty = false; | 604 | mData->empty = false; |
565 | mData->additionalName = additionalName; | 605 | mData->additionalName = additionalName; |
566 | } | 606 | } |
567 | 607 | ||
568 | QString Addressee::additionalName() const | 608 | QString Addressee::additionalName() const |
569 | { | 609 | { |
570 | return mData->additionalName; | 610 | return mData->additionalName; |
571 | } | 611 | } |
572 | 612 | ||
573 | QString Addressee::additionalNameLabel() | 613 | QString Addressee::additionalNameLabel() |
574 | { | 614 | { |
575 | return i18n("Additional Names"); | 615 | return i18n("Additional Names"); |
576 | } | 616 | } |
577 | 617 | ||
578 | 618 | ||
579 | void Addressee::setPrefix( const QString &prefix ) | 619 | void Addressee::setPrefix( const QString &prefix ) |
580 | { | 620 | { |
581 | if ( prefix == mData->prefix ) return; | 621 | if ( prefix == mData->prefix ) return; |
582 | detach(); | 622 | detach(); |
583 | mData->empty = false; | 623 | mData->empty = false; |
584 | mData->prefix = prefix; | 624 | mData->prefix = prefix; |
585 | } | 625 | } |
586 | 626 | ||
587 | QString Addressee::prefix() const | 627 | QString Addressee::prefix() const |
588 | { | 628 | { |
589 | return mData->prefix; | 629 | return mData->prefix; |
590 | } | 630 | } |
591 | 631 | ||
592 | QString Addressee::prefixLabel() | 632 | QString Addressee::prefixLabel() |
593 | { | 633 | { |
594 | return i18n("Honorific Prefixes"); | 634 | return i18n("Honorific Prefixes"); |
595 | } | 635 | } |
596 | 636 | ||
597 | 637 | ||
598 | void Addressee::setSuffix( const QString &suffix ) | 638 | void Addressee::setSuffix( const QString &suffix ) |
599 | { | 639 | { |
600 | if ( suffix == mData->suffix ) return; | 640 | if ( suffix == mData->suffix ) return; |
601 | detach(); | 641 | detach(); |
602 | mData->empty = false; | 642 | mData->empty = false; |
603 | mData->suffix = suffix; | 643 | mData->suffix = suffix; |
604 | } | 644 | } |
605 | 645 | ||
606 | QString Addressee::suffix() const | 646 | QString Addressee::suffix() const |
607 | { | 647 | { |
608 | return mData->suffix; | 648 | return mData->suffix; |
609 | } | 649 | } |
610 | 650 | ||
611 | QString Addressee::suffixLabel() | 651 | QString Addressee::suffixLabel() |
612 | { | 652 | { |
613 | return i18n("Honorific Suffixes"); | 653 | return i18n("Honorific Suffixes"); |
614 | } | 654 | } |
615 | 655 | ||
616 | 656 | ||
617 | void Addressee::setNickName( const QString &nickName ) | 657 | void Addressee::setNickName( const QString &nickName ) |
618 | { | 658 | { |
619 | if ( nickName == mData->nickName ) return; | 659 | if ( nickName == mData->nickName ) return; |
620 | detach(); | 660 | detach(); |
621 | mData->empty = false; | 661 | mData->empty = false; |
622 | mData->nickName = nickName; | 662 | mData->nickName = nickName; |
623 | } | 663 | } |
624 | 664 | ||
625 | QString Addressee::nickName() const | 665 | QString Addressee::nickName() const |
626 | { | 666 | { |
627 | return mData->nickName; | 667 | return mData->nickName; |
628 | } | 668 | } |
629 | 669 | ||
630 | QString Addressee::nickNameLabel() | 670 | QString Addressee::nickNameLabel() |
631 | { | 671 | { |
632 | return i18n("Nick Name"); | 672 | return i18n("Nick Name"); |
633 | } | 673 | } |
634 | 674 | ||
635 | 675 | ||
636 | void Addressee::setBirthday( const QDateTime &birthday ) | 676 | void Addressee::setBirthday( const QDateTime &birthday ) |
637 | { | 677 | { |
638 | if ( birthday == mData->birthday ) return; | 678 | if ( birthday == mData->birthday ) return; |
639 | detach(); | 679 | detach(); |
640 | mData->empty = false; | 680 | mData->empty = false; |
641 | mData->birthday = birthday; | 681 | mData->birthday = birthday; |
642 | } | 682 | } |
643 | 683 | ||
644 | QDateTime Addressee::birthday() const | 684 | QDateTime Addressee::birthday() const |
645 | { | 685 | { |
646 | return mData->birthday; | 686 | return mData->birthday; |
647 | } | 687 | } |
648 | 688 | ||
649 | QString Addressee::birthdayLabel() | 689 | QString Addressee::birthdayLabel() |
650 | { | 690 | { |
651 | return i18n("Birthday"); | 691 | return i18n("Birthday"); |
652 | } | 692 | } |
653 | 693 | ||
654 | 694 | ||
655 | QString Addressee::homeAddressStreetLabel() | 695 | QString Addressee::homeAddressStreetLabel() |
656 | { | 696 | { |
657 | return i18n("Home Address Street"); | 697 | return i18n("Home Address Street"); |
658 | } | 698 | } |
659 | 699 | ||
660 | 700 | ||
661 | QString Addressee::homeAddressLocalityLabel() | 701 | QString Addressee::homeAddressLocalityLabel() |
662 | { | 702 | { |
663 | return i18n("Home Address Locality"); | 703 | return i18n("Home Address Locality"); |
664 | } | 704 | } |
665 | 705 | ||
666 | 706 | ||
667 | QString Addressee::homeAddressRegionLabel() | 707 | QString Addressee::homeAddressRegionLabel() |
668 | { | 708 | { |
669 | return i18n("Home Address Region"); | 709 | return i18n("Home Address Region"); |
670 | } | 710 | } |
671 | 711 | ||
672 | 712 | ||
673 | QString Addressee::homeAddressPostalCodeLabel() | 713 | QString Addressee::homeAddressPostalCodeLabel() |
674 | { | 714 | { |
675 | return i18n("Home Address Postal Code"); | 715 | return i18n("Home Address Postal Code"); |
676 | } | 716 | } |
677 | 717 | ||
678 | 718 | ||
679 | QString Addressee::homeAddressCountryLabel() | 719 | QString Addressee::homeAddressCountryLabel() |
680 | { | 720 | { |
681 | return i18n("Home Address Country"); | 721 | return i18n("Home Address Country"); |
682 | } | 722 | } |
683 | 723 | ||
684 | 724 | ||
685 | QString Addressee::homeAddressLabelLabel() | 725 | QString Addressee::homeAddressLabelLabel() |
686 | { | 726 | { |
687 | return i18n("Home Address Label"); | 727 | return i18n("Home Address Label"); |
688 | } | 728 | } |
689 | 729 | ||
690 | 730 | ||
691 | QString Addressee::businessAddressStreetLabel() | 731 | QString Addressee::businessAddressStreetLabel() |
692 | { | 732 | { |
693 | return i18n("Business Address Street"); | 733 | return i18n("Business Address Street"); |
694 | } | 734 | } |
695 | 735 | ||
696 | 736 | ||
697 | QString Addressee::businessAddressLocalityLabel() | 737 | QString Addressee::businessAddressLocalityLabel() |
698 | { | 738 | { |
699 | return i18n("Business Address Locality"); | 739 | return i18n("Business Address Locality"); |
700 | } | 740 | } |
701 | 741 | ||
702 | 742 | ||
703 | QString Addressee::businessAddressRegionLabel() | 743 | QString Addressee::businessAddressRegionLabel() |
704 | { | 744 | { |
705 | return i18n("Business Address Region"); | 745 | return i18n("Business Address Region"); |
706 | } | 746 | } |
707 | 747 | ||
708 | 748 | ||
709 | QString Addressee::businessAddressPostalCodeLabel() | 749 | QString Addressee::businessAddressPostalCodeLabel() |
710 | { | 750 | { |
711 | return i18n("Business Address Postal Code"); | 751 | return i18n("Business Address Postal Code"); |
712 | } | 752 | } |
713 | 753 | ||
714 | 754 | ||
715 | QString Addressee::businessAddressCountryLabel() | 755 | QString Addressee::businessAddressCountryLabel() |
716 | { | 756 | { |
717 | return i18n("Business Address Country"); | 757 | return i18n("Business Address Country"); |
718 | } | 758 | } |
719 | 759 | ||
720 | 760 | ||
721 | QString Addressee::businessAddressLabelLabel() | 761 | QString Addressee::businessAddressLabelLabel() |
722 | { | 762 | { |
723 | return i18n("Business Address Label"); | 763 | return i18n("Business Address Label"); |
724 | } | 764 | } |
725 | 765 | ||
726 | 766 | ||
727 | QString Addressee::homePhoneLabel() | 767 | QString Addressee::homePhoneLabel() |
728 | { | 768 | { |
729 | return i18n("Home Phone"); | 769 | return i18n("Home Phone"); |
730 | } | 770 | } |
731 | 771 | ||
732 | 772 | ||
733 | QString Addressee::businessPhoneLabel() | 773 | QString Addressee::businessPhoneLabel() |
734 | { | 774 | { |
735 | return i18n("Business Phone"); | 775 | return i18n("Business Phone"); |
736 | } | 776 | } |
737 | 777 | ||
738 | 778 | ||
739 | QString Addressee::mobilePhoneLabel() | 779 | QString Addressee::mobilePhoneLabel() |
740 | { | 780 | { |
741 | return i18n("Mobile Phone"); | 781 | return i18n("Mobile Phone"); |
742 | } | 782 | } |
743 | 783 | ||
744 | 784 | ||
745 | QString Addressee::homeFaxLabel() | 785 | QString Addressee::homeFaxLabel() |
746 | { | 786 | { |
747 | return i18n("Home Fax"); | 787 | return i18n("Home Fax"); |
748 | } | 788 | } |
749 | 789 | ||
750 | 790 | ||
751 | QString Addressee::businessFaxLabel() | 791 | QString Addressee::businessFaxLabel() |
752 | { | 792 | { |
753 | return i18n("Business Fax"); | 793 | return i18n("Business Fax"); |
754 | } | 794 | } |
755 | 795 | ||
756 | 796 | ||
757 | QString Addressee::carPhoneLabel() | 797 | QString Addressee::carPhoneLabel() |
758 | { | 798 | { |
759 | return i18n("Car Phone"); | 799 | return i18n("Car Phone"); |
760 | } | 800 | } |
761 | 801 | ||
762 | 802 | ||
763 | QString Addressee::isdnLabel() | 803 | QString Addressee::isdnLabel() |
764 | { | 804 | { |
765 | return i18n("ISDN"); | 805 | return i18n("ISDN"); |
766 | } | 806 | } |
767 | 807 | ||
768 | 808 | ||
769 | QString Addressee::pagerLabel() | 809 | QString Addressee::pagerLabel() |
770 | { | 810 | { |
771 | return i18n("Pager"); | 811 | return i18n("Pager"); |
772 | } | 812 | } |
773 | 813 | ||
774 | QString Addressee::sipLabel() | 814 | QString Addressee::sipLabel() |
775 | { | 815 | { |
776 | return i18n("SIP"); | 816 | return i18n("SIP"); |
777 | } | 817 | } |
778 | 818 | ||
779 | QString Addressee::emailLabel() | 819 | QString Addressee::emailLabel() |
780 | { | 820 | { |
781 | return i18n("Email Address"); | 821 | return i18n("Email Address"); |
782 | } | 822 | } |
783 | 823 | ||
784 | 824 | ||
785 | void Addressee::setMailer( const QString &mailer ) | 825 | void Addressee::setMailer( const QString &mailer ) |
786 | { | 826 | { |
787 | if ( mailer == mData->mailer ) return; | 827 | if ( mailer == mData->mailer ) return; |
788 | detach(); | 828 | detach(); |
789 | mData->empty = false; | 829 | mData->empty = false; |
790 | mData->mailer = mailer; | 830 | mData->mailer = mailer; |
791 | } | 831 | } |
792 | 832 | ||
793 | QString Addressee::mailer() const | 833 | QString Addressee::mailer() const |
794 | { | 834 | { |
795 | return mData->mailer; | 835 | return mData->mailer; |
796 | } | 836 | } |
797 | 837 | ||
798 | QString Addressee::mailerLabel() | 838 | QString Addressee::mailerLabel() |
799 | { | 839 | { |
800 | return i18n("Mail Client"); | 840 | return i18n("Mail Client"); |
801 | } | 841 | } |
802 | 842 | ||
803 | 843 | ||
804 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 844 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
805 | { | 845 | { |
806 | if ( timeZone == mData->timeZone ) return; | 846 | if ( timeZone == mData->timeZone ) return; |
807 | detach(); | 847 | detach(); |
808 | mData->empty = false; | 848 | mData->empty = false; |
809 | mData->timeZone = timeZone; | 849 | mData->timeZone = timeZone; |
810 | } | 850 | } |
811 | 851 | ||
812 | TimeZone Addressee::timeZone() const | 852 | TimeZone Addressee::timeZone() const |
813 | { | 853 | { |
814 | return mData->timeZone; | 854 | return mData->timeZone; |
815 | } | 855 | } |
816 | 856 | ||
817 | QString Addressee::timeZoneLabel() | 857 | QString Addressee::timeZoneLabel() |
818 | { | 858 | { |
819 | return i18n("Time Zone"); | 859 | return i18n("Time Zone"); |
820 | } | 860 | } |
821 | 861 | ||
822 | 862 | ||
823 | void Addressee::setGeo( const Geo &geo ) | 863 | void Addressee::setGeo( const Geo &geo ) |
824 | { | 864 | { |
825 | if ( geo == mData->geo ) return; | 865 | if ( geo == mData->geo ) return; |
826 | detach(); | 866 | detach(); |
827 | mData->empty = false; | 867 | mData->empty = false; |
828 | mData->geo = geo; | 868 | mData->geo = geo; |
829 | } | 869 | } |
830 | 870 | ||
831 | Geo Addressee::geo() const | 871 | Geo Addressee::geo() const |
832 | { | 872 | { |
833 | return mData->geo; | 873 | return mData->geo; |
834 | } | 874 | } |
835 | 875 | ||
836 | QString Addressee::geoLabel() | 876 | QString Addressee::geoLabel() |
837 | { | 877 | { |
838 | return i18n("Geographic Position"); | 878 | return i18n("Geographic Position"); |
839 | } | 879 | } |
840 | 880 | ||
841 | 881 | ||
842 | void Addressee::setTitle( const QString &title ) | 882 | void Addressee::setTitle( const QString &title ) |
843 | { | 883 | { |
844 | if ( title == mData->title ) return; | 884 | if ( title == mData->title ) return; |
845 | detach(); | 885 | detach(); |
846 | mData->empty = false; | 886 | mData->empty = false; |
847 | mData->title = title; | 887 | mData->title = title; |
848 | } | 888 | } |
849 | 889 | ||
850 | QString Addressee::title() const | 890 | QString Addressee::title() const |
851 | { | 891 | { |
852 | return mData->title; | 892 | return mData->title; |
853 | } | 893 | } |
854 | 894 | ||
855 | QString Addressee::titleLabel() | 895 | QString Addressee::titleLabel() |
856 | { | 896 | { |
857 | return i18n("Title"); | 897 | return i18n("Title"); |
858 | } | 898 | } |
859 | 899 | ||
860 | 900 | ||
861 | void Addressee::setRole( const QString &role ) | 901 | void Addressee::setRole( const QString &role ) |
862 | { | 902 | { |
863 | if ( role == mData->role ) return; | 903 | if ( role == mData->role ) return; |
864 | detach(); | 904 | detach(); |
865 | mData->empty = false; | 905 | mData->empty = false; |
866 | mData->role = role; | 906 | mData->role = role; |
867 | } | 907 | } |
868 | 908 | ||
869 | QString Addressee::role() const | 909 | QString Addressee::role() const |
870 | { | 910 | { |
871 | return mData->role; | 911 | return mData->role; |
872 | } | 912 | } |
873 | 913 | ||
874 | QString Addressee::roleLabel() | 914 | QString Addressee::roleLabel() |
875 | { | 915 | { |
876 | return i18n("Role"); | 916 | return i18n("Role"); |
877 | } | 917 | } |
878 | 918 | ||
879 | 919 | ||
880 | void Addressee::setOrganization( const QString &organization ) | 920 | void Addressee::setOrganization( const QString &organization ) |
881 | { | 921 | { |
882 | if ( organization == mData->organization ) return; | 922 | if ( organization == mData->organization ) return; |
883 | detach(); | 923 | detach(); |
884 | mData->empty = false; | 924 | mData->empty = false; |
885 | mData->organization = organization; | 925 | mData->organization = organization; |
886 | } | 926 | } |
887 | 927 | ||
888 | QString Addressee::organization() const | 928 | QString Addressee::organization() const |
889 | { | 929 | { |
890 | return mData->organization; | 930 | return mData->organization; |
891 | } | 931 | } |
892 | 932 | ||
893 | QString Addressee::organizationLabel() | 933 | QString Addressee::organizationLabel() |
894 | { | 934 | { |
895 | return i18n("Organization"); | 935 | return i18n("Organization"); |
896 | } | 936 | } |
897 | 937 | ||
898 | 938 | ||
899 | void Addressee::setNote( const QString ¬e ) | 939 | void Addressee::setNote( const QString ¬e ) |
900 | { | 940 | { |
901 | if ( note == mData->note ) return; | 941 | if ( note == mData->note ) return; |
902 | detach(); | 942 | detach(); |
903 | mData->empty = false; | 943 | mData->empty = false; |
904 | mData->note = note; | 944 | mData->note = note; |
905 | } | 945 | } |
906 | 946 | ||
907 | QString Addressee::note() const | 947 | QString Addressee::note() const |
908 | { | 948 | { |
909 | return mData->note; | 949 | return mData->note; |
910 | } | 950 | } |
911 | 951 | ||
912 | QString Addressee::noteLabel() | 952 | QString Addressee::noteLabel() |
913 | { | 953 | { |
914 | return i18n("Note"); | 954 | return i18n("Note"); |
915 | } | 955 | } |
916 | 956 | ||
917 | 957 | ||
918 | void Addressee::setProductId( const QString &productId ) | 958 | void Addressee::setProductId( const QString &productId ) |
919 | { | 959 | { |
920 | if ( productId == mData->productId ) return; | 960 | if ( productId == mData->productId ) return; |
921 | detach(); | 961 | detach(); |
922 | mData->empty = false; | 962 | mData->empty = false; |
923 | mData->productId = productId; | 963 | mData->productId = productId; |
924 | } | 964 | } |
925 | 965 | ||
926 | QString Addressee::productId() const | 966 | QString Addressee::productId() const |
927 | { | 967 | { |
928 | return mData->productId; | 968 | return mData->productId; |
929 | } | 969 | } |
930 | 970 | ||
931 | QString Addressee::productIdLabel() | 971 | QString Addressee::productIdLabel() |
932 | { | 972 | { |
933 | return i18n("Product Identifier"); | 973 | return i18n("Product Identifier"); |
934 | } | 974 | } |
935 | 975 | ||
936 | 976 | ||
937 | void Addressee::setRevision( const QDateTime &revision ) | 977 | void Addressee::setRevision( const QDateTime &revision ) |
938 | { | 978 | { |
939 | if ( revision == mData->revision ) return; | 979 | if ( revision == mData->revision ) return; |
940 | detach(); | 980 | detach(); |
941 | mData->empty = false; | 981 | mData->empty = false; |
942 | mData->revision = revision; | 982 | mData->revision = revision; |
943 | } | 983 | } |
944 | 984 | ||
945 | QDateTime Addressee::revision() const | 985 | QDateTime Addressee::revision() const |
946 | { | 986 | { |
947 | return mData->revision; | 987 | return mData->revision; |
948 | } | 988 | } |
949 | 989 | ||
950 | QString Addressee::revisionLabel() | 990 | QString Addressee::revisionLabel() |
951 | { | 991 | { |
952 | return i18n("Revision Date"); | 992 | return i18n("Revision Date"); |
953 | } | 993 | } |
954 | 994 | ||
955 | 995 | ||
956 | void Addressee::setSortString( const QString &sortString ) | 996 | void Addressee::setSortString( const QString &sortString ) |
957 | { | 997 | { |
958 | if ( sortString == mData->sortString ) return; | 998 | if ( sortString == mData->sortString ) return; |
959 | detach(); | 999 | detach(); |
960 | mData->empty = false; | 1000 | mData->empty = false; |
961 | mData->sortString = sortString; | 1001 | mData->sortString = sortString; |
962 | } | 1002 | } |
963 | 1003 | ||
964 | QString Addressee::sortString() const | 1004 | QString Addressee::sortString() const |
965 | { | 1005 | { |
966 | return mData->sortString; | 1006 | return mData->sortString; |
967 | } | 1007 | } |
968 | 1008 | ||
969 | QString Addressee::sortStringLabel() | 1009 | QString Addressee::sortStringLabel() |
970 | { | 1010 | { |
971 | return i18n("Sort String"); | 1011 | return i18n("Sort String"); |
972 | } | 1012 | } |
973 | 1013 | ||
974 | 1014 | ||
975 | void Addressee::setUrl( const KURL &url ) | 1015 | void Addressee::setUrl( const KURL &url ) |
976 | { | 1016 | { |
977 | if ( url == mData->url ) return; | 1017 | if ( url == mData->url ) return; |
978 | detach(); | 1018 | detach(); |
979 | mData->empty = false; | 1019 | mData->empty = false; |
980 | mData->url = url; | 1020 | mData->url = url; |
981 | } | 1021 | } |
982 | 1022 | ||
983 | KURL Addressee::url() const | 1023 | KURL Addressee::url() const |
984 | { | 1024 | { |
985 | return mData->url; | 1025 | return mData->url; |
986 | } | 1026 | } |
987 | 1027 | ||
988 | QString Addressee::urlLabel() | 1028 | QString Addressee::urlLabel() |
989 | { | 1029 | { |
990 | return i18n("URL"); | 1030 | return i18n("URL"); |
991 | } | 1031 | } |
992 | 1032 | ||
993 | 1033 | ||
994 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 1034 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
995 | { | 1035 | { |
996 | if ( secrecy == mData->secrecy ) return; | 1036 | if ( secrecy == mData->secrecy ) return; |
997 | detach(); | 1037 | detach(); |
998 | mData->empty = false; | 1038 | mData->empty = false; |
999 | mData->secrecy = secrecy; | 1039 | mData->secrecy = secrecy; |
1000 | } | 1040 | } |
1001 | 1041 | ||
1002 | Secrecy Addressee::secrecy() const | 1042 | Secrecy Addressee::secrecy() const |
1003 | { | 1043 | { |
1004 | return mData->secrecy; | 1044 | return mData->secrecy; |
1005 | } | 1045 | } |
1006 | 1046 | ||
1007 | QString Addressee::secrecyLabel() | 1047 | QString Addressee::secrecyLabel() |
1008 | { | 1048 | { |
1009 | return i18n("Security Class"); | 1049 | return i18n("Security Class"); |
1010 | } | 1050 | } |
1011 | 1051 | ||
1012 | 1052 | ||
1013 | void Addressee::setLogo( const Picture &logo ) | 1053 | void Addressee::setLogo( const Picture &logo ) |
1014 | { | 1054 | { |
1015 | if ( logo == mData->logo ) return; | 1055 | if ( logo == mData->logo ) return; |
1016 | detach(); | 1056 | detach(); |
1017 | mData->empty = false; | 1057 | mData->empty = false; |
1018 | mData->logo = logo; | 1058 | mData->logo = logo; |
1019 | } | 1059 | } |
1020 | 1060 | ||
1021 | Picture Addressee::logo() const | 1061 | Picture Addressee::logo() const |
1022 | { | 1062 | { |
1023 | return mData->logo; | 1063 | return mData->logo; |
1024 | } | 1064 | } |
1025 | 1065 | ||
1026 | QString Addressee::logoLabel() | 1066 | QString Addressee::logoLabel() |
1027 | { | 1067 | { |
1028 | return i18n("Logo"); | 1068 | return i18n("Logo"); |
1029 | } | 1069 | } |
1030 | 1070 | ||
1031 | 1071 | ||
1032 | void Addressee::setPhoto( const Picture &photo ) | 1072 | void Addressee::setPhoto( const Picture &photo ) |
1033 | { | 1073 | { |
1034 | if ( photo == mData->photo ) return; | 1074 | if ( photo == mData->photo ) return; |
1035 | detach(); | 1075 | detach(); |
1036 | mData->empty = false; | 1076 | mData->empty = false; |
1037 | mData->photo = photo; | 1077 | mData->photo = photo; |
1038 | } | 1078 | } |
1039 | 1079 | ||
1040 | Picture Addressee::photo() const | 1080 | Picture Addressee::photo() const |
1041 | { | 1081 | { |
1042 | return mData->photo; | 1082 | return mData->photo; |
1043 | } | 1083 | } |
1044 | 1084 | ||
1045 | QString Addressee::photoLabel() | 1085 | QString Addressee::photoLabel() |
1046 | { | 1086 | { |
1047 | return i18n("Photo"); | 1087 | return i18n("Photo"); |
1048 | } | 1088 | } |
1049 | 1089 | ||
1050 | 1090 | ||
1051 | void Addressee::setSound( const Sound &sound ) | 1091 | void Addressee::setSound( const Sound &sound ) |
1052 | { | 1092 | { |
1053 | if ( sound == mData->sound ) return; | 1093 | if ( sound == mData->sound ) return; |
1054 | detach(); | 1094 | detach(); |
1055 | mData->empty = false; | 1095 | mData->empty = false; |
1056 | mData->sound = sound; | 1096 | mData->sound = sound; |
1057 | } | 1097 | } |
1058 | 1098 | ||
1059 | Sound Addressee::sound() const | 1099 | Sound Addressee::sound() const |
1060 | { | 1100 | { |
1061 | return mData->sound; | 1101 | return mData->sound; |
1062 | } | 1102 | } |
1063 | 1103 | ||
1064 | QString Addressee::soundLabel() | 1104 | QString Addressee::soundLabel() |
1065 | { | 1105 | { |
1066 | return i18n("Sound"); | 1106 | return i18n("Sound"); |
1067 | } | 1107 | } |
1068 | 1108 | ||
1069 | 1109 | ||
1070 | void Addressee::setAgent( const Agent &agent ) | 1110 | void Addressee::setAgent( const Agent &agent ) |
1071 | { | 1111 | { |
1072 | if ( agent == mData->agent ) return; | 1112 | if ( agent == mData->agent ) return; |
1073 | detach(); | 1113 | detach(); |
1074 | mData->empty = false; | 1114 | mData->empty = false; |
1075 | mData->agent = agent; | 1115 | mData->agent = agent; |
1076 | } | 1116 | } |
1077 | 1117 | ||
1078 | Agent Addressee::agent() const | 1118 | Agent Addressee::agent() const |
1079 | { | 1119 | { |
1080 | return mData->agent; | 1120 | return mData->agent; |
1081 | } | 1121 | } |
1082 | 1122 | ||
1083 | QString Addressee::agentLabel() | 1123 | QString Addressee::agentLabel() |
1084 | { | 1124 | { |
1085 | return i18n("Agent"); | 1125 | return i18n("Agent"); |
1086 | } | 1126 | } |
1087 | 1127 | ||
1088 | 1128 | ||
1089 | 1129 | ||
1090 | void Addressee::setNameFromString( const QString &str ) | 1130 | void Addressee::setNameFromString( const QString &str ) |
1091 | { | 1131 | { |
1092 | setFormattedName( str ); | 1132 | setFormattedName( str ); |
1093 | setName( str ); | 1133 | setName( str ); |
1094 | 1134 | ||
1095 | static bool first = true; | 1135 | static bool first = true; |
1096 | static QStringList titles; | 1136 | static QStringList titles; |
1097 | static QStringList suffixes; | 1137 | static QStringList suffixes; |
1098 | static QStringList prefixes; | 1138 | static QStringList prefixes; |
1099 | 1139 | ||
1100 | if ( first ) { | 1140 | if ( first ) { |
1101 | first = false; | 1141 | first = false; |
1102 | titles += i18n( "Dr." ); | 1142 | titles += i18n( "Dr." ); |
1103 | titles += i18n( "Miss" ); | 1143 | titles += i18n( "Miss" ); |
1104 | titles += i18n( "Mr." ); | 1144 | titles += i18n( "Mr." ); |
1105 | titles += i18n( "Mrs." ); | 1145 | titles += i18n( "Mrs." ); |
1106 | titles += i18n( "Ms." ); | 1146 | titles += i18n( "Ms." ); |
1107 | titles += i18n( "Prof." ); | 1147 | titles += i18n( "Prof." ); |
1108 | 1148 | ||
1109 | suffixes += i18n( "I" ); | 1149 | suffixes += i18n( "I" ); |
1110 | suffixes += i18n( "II" ); | 1150 | suffixes += i18n( "II" ); |
1111 | suffixes += i18n( "III" ); | 1151 | suffixes += i18n( "III" ); |
1112 | suffixes += i18n( "Jr." ); | 1152 | suffixes += i18n( "Jr." ); |
1113 | suffixes += i18n( "Sr." ); | 1153 | suffixes += i18n( "Sr." ); |
1114 | 1154 | ||
1115 | prefixes += "van"; | 1155 | prefixes += "van"; |
1116 | prefixes += "von"; | 1156 | prefixes += "von"; |
1117 | prefixes += "de"; | 1157 | prefixes += "de"; |
1118 | 1158 | ||
1119 | KConfig config( locateLocal( "config", "kabcrc") ); | 1159 | KConfig config( locateLocal( "config", "kabcrc") ); |
1120 | config.setGroup( "General" ); | 1160 | config.setGroup( "General" ); |
1121 | titles += config.readListEntry( "Prefixes" ); | 1161 | titles += config.readListEntry( "Prefixes" ); |
1122 | titles.remove( "" ); | 1162 | titles.remove( "" ); |
1123 | prefixes += config.readListEntry( "Inclusions" ); | 1163 | prefixes += config.readListEntry( "Inclusions" ); |
1124 | prefixes.remove( "" ); | 1164 | prefixes.remove( "" ); |
1125 | suffixes += config.readListEntry( "Suffixes" ); | 1165 | suffixes += config.readListEntry( "Suffixes" ); |
1126 | suffixes.remove( "" ); | 1166 | suffixes.remove( "" ); |
1127 | } | 1167 | } |
1128 | 1168 | ||
1129 | // clear all name parts | 1169 | // clear all name parts |
1130 | setPrefix( "" ); | 1170 | setPrefix( "" ); |
1131 | setGivenName( "" ); | 1171 | setGivenName( "" ); |
1132 | setAdditionalName( "" ); | 1172 | setAdditionalName( "" ); |
1133 | setFamilyName( "" ); | 1173 | setFamilyName( "" ); |
1134 | setSuffix( "" ); | 1174 | setSuffix( "" ); |
1135 | 1175 | ||
1136 | if ( str.isEmpty() ) | 1176 | if ( str.isEmpty() ) |
1137 | return; | 1177 | return; |
1138 | 1178 | ||
1139 | int i = str.find(','); | 1179 | int i = str.find(','); |
1140 | if( i < 0 ) { | 1180 | if( i < 0 ) { |
1141 | QStringList parts = QStringList::split( " ", str ); | 1181 | QStringList parts = QStringList::split( " ", str ); |
1142 | int leftOffset = 0; | 1182 | int leftOffset = 0; |
1143 | int rightOffset = parts.count() - 1; | 1183 | int rightOffset = parts.count() - 1; |
1144 | 1184 | ||
1145 | QString suffix; | 1185 | QString suffix; |
1146 | while ( rightOffset >= 0 ) { | 1186 | while ( rightOffset >= 0 ) { |
1147 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1187 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1148 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1188 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1149 | rightOffset--; | 1189 | rightOffset--; |
1150 | } else | 1190 | } else |
1151 | break; | 1191 | break; |
1152 | } | 1192 | } |
1153 | setSuffix( suffix ); | 1193 | setSuffix( suffix ); |
1154 | 1194 | ||
1155 | if ( rightOffset < 0 ) | 1195 | if ( rightOffset < 0 ) |
1156 | return; | 1196 | return; |
1157 | 1197 | ||
1158 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1198 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1159 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1199 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1160 | rightOffset--; | 1200 | rightOffset--; |
1161 | } else | 1201 | } else |
1162 | setFamilyName( parts[ rightOffset ] ); | 1202 | setFamilyName( parts[ rightOffset ] ); |
1163 | 1203 | ||
1164 | QString prefix; | 1204 | QString prefix; |
1165 | while ( leftOffset < rightOffset ) { | 1205 | while ( leftOffset < rightOffset ) { |
1166 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1206 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1167 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1207 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1168 | leftOffset++; | 1208 | leftOffset++; |
1169 | } else | 1209 | } else |
1170 | break; | 1210 | break; |
1171 | } | 1211 | } |
1172 | setPrefix( prefix ); | 1212 | setPrefix( prefix ); |
1173 | 1213 | ||
1174 | if ( leftOffset < rightOffset ) { | 1214 | if ( leftOffset < rightOffset ) { |
1175 | setGivenName( parts[ leftOffset ] ); | 1215 | setGivenName( parts[ leftOffset ] ); |
1176 | leftOffset++; | 1216 | leftOffset++; |
1177 | } | 1217 | } |
1178 | 1218 | ||
1179 | QString additionalName; | 1219 | QString additionalName; |
1180 | while ( leftOffset < rightOffset ) { | 1220 | while ( leftOffset < rightOffset ) { |
1181 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1221 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1182 | leftOffset++; | 1222 | leftOffset++; |
1183 | } | 1223 | } |
1184 | setAdditionalName( additionalName ); | 1224 | setAdditionalName( additionalName ); |
1185 | } else { | 1225 | } else { |
1186 | QString part1 = str.left( i ); | 1226 | QString part1 = str.left( i ); |
1187 | QString part2 = str.mid( i + 1 ); | 1227 | QString part2 = str.mid( i + 1 ); |
1188 | 1228 | ||
1189 | QStringList parts = QStringList::split( " ", part1 ); | 1229 | QStringList parts = QStringList::split( " ", part1 ); |
1190 | int leftOffset = 0; | 1230 | int leftOffset = 0; |
1191 | int rightOffset = parts.count() - 1; | 1231 | int rightOffset = parts.count() - 1; |
1192 | 1232 | ||
1193 | QString suffix; | 1233 | QString suffix; |
1194 | while ( rightOffset >= 0 ) { | 1234 | while ( rightOffset >= 0 ) { |
1195 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1235 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1196 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1236 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1197 | rightOffset--; | 1237 | rightOffset--; |
1198 | } else | 1238 | } else |
1199 | break; | 1239 | break; |
1200 | } | 1240 | } |
1201 | setSuffix( suffix ); | 1241 | setSuffix( suffix ); |
1202 | 1242 | ||
1203 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1243 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1204 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1244 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1205 | rightOffset--; | 1245 | rightOffset--; |
1206 | } else | 1246 | } else |
1207 | setFamilyName( parts[ rightOffset ] ); | 1247 | setFamilyName( parts[ rightOffset ] ); |
1208 | 1248 | ||
1209 | QString prefix; | 1249 | QString prefix; |
1210 | while ( leftOffset < rightOffset ) { | 1250 | while ( leftOffset < rightOffset ) { |
1211 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1251 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1212 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1252 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1213 | leftOffset++; | 1253 | leftOffset++; |
1214 | } else | 1254 | } else |
1215 | break; | 1255 | break; |
1216 | } | 1256 | } |
1217 | 1257 | ||
1218 | parts = QStringList::split( " ", part2 ); | 1258 | parts = QStringList::split( " ", part2 ); |
1219 | 1259 | ||
1220 | leftOffset = 0; | 1260 | leftOffset = 0; |
1221 | rightOffset = parts.count(); | 1261 | rightOffset = parts.count(); |
1222 | 1262 | ||
1223 | while ( leftOffset < rightOffset ) { | 1263 | while ( leftOffset < rightOffset ) { |
1224 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1264 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1225 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1265 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1226 | leftOffset++; | 1266 | leftOffset++; |
1227 | } else | 1267 | } else |
1228 | break; | 1268 | break; |
1229 | } | 1269 | } |
1230 | setPrefix( prefix ); | 1270 | setPrefix( prefix ); |
1231 | 1271 | ||
1232 | if ( leftOffset < rightOffset ) { | 1272 | if ( leftOffset < rightOffset ) { |
1233 | setGivenName( parts[ leftOffset ] ); | 1273 | setGivenName( parts[ leftOffset ] ); |
1234 | leftOffset++; | 1274 | leftOffset++; |
1235 | } | 1275 | } |
1236 | 1276 | ||
1237 | QString additionalName; | 1277 | QString additionalName; |
1238 | while ( leftOffset < rightOffset ) { | 1278 | while ( leftOffset < rightOffset ) { |
1239 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1279 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1240 | leftOffset++; | 1280 | leftOffset++; |
1241 | } | 1281 | } |
1242 | setAdditionalName( additionalName ); | 1282 | setAdditionalName( additionalName ); |
1243 | } | 1283 | } |
1244 | } | 1284 | } |
1245 | 1285 | ||
1246 | QString Addressee::realName() const | 1286 | QString Addressee::realName() const |
1247 | { | 1287 | { |
1248 | if ( !formattedName().isEmpty() ) | 1288 | if ( !formattedName().isEmpty() ) |
1249 | return formattedName(); | 1289 | return formattedName(); |
1250 | 1290 | ||
1251 | QString n = assembledName(); | 1291 | QString n = assembledName(); |
1252 | 1292 | ||
1253 | if ( n.isEmpty() ) | 1293 | if ( n.isEmpty() ) |
1254 | n = name(); | 1294 | n = name(); |
1255 | 1295 | ||
1256 | return n; | 1296 | return n; |
1257 | } | 1297 | } |
1258 | 1298 | ||
1259 | QString Addressee::assembledName() const | 1299 | QString Addressee::assembledName() const |
1260 | { | 1300 | { |
1261 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1301 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1262 | familyName() + " " + suffix(); | 1302 | familyName() + " " + suffix(); |
1263 | 1303 | ||
1264 | return name.simplifyWhiteSpace(); | 1304 | return name.simplifyWhiteSpace(); |
1265 | } | 1305 | } |
1266 | 1306 | ||
1267 | QString Addressee::fullEmail( const QString &email ) const | 1307 | QString Addressee::fullEmail( const QString &email ) const |
1268 | { | 1308 | { |
1269 | QString e; | 1309 | QString e; |
1270 | if ( email.isNull() ) { | 1310 | if ( email.isNull() ) { |
1271 | e = preferredEmail(); | 1311 | e = preferredEmail(); |
1272 | } else { | 1312 | } else { |
1273 | e = email; | 1313 | e = email; |
1274 | } | 1314 | } |
1275 | if ( e.isEmpty() ) return QString::null; | 1315 | if ( e.isEmpty() ) return QString::null; |
1276 | 1316 | ||
1277 | QString text; | 1317 | QString text; |
1278 | if ( realName().isEmpty() ) | 1318 | if ( realName().isEmpty() ) |
1279 | text = e; | 1319 | text = e; |
1280 | else | 1320 | else |
1281 | text = assembledName() + " <" + e + ">"; | 1321 | text = assembledName() + " <" + e + ">"; |
1282 | 1322 | ||
1283 | return text; | 1323 | return text; |
1284 | } | 1324 | } |
1285 | 1325 | ||
1286 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1326 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1287 | { | 1327 | { |
1288 | detach(); | 1328 | detach(); |
1289 | 1329 | ||
1290 | QStringList::Iterator it = mData->emails.find( email ); | 1330 | QStringList::Iterator it = mData->emails.find( email ); |
1291 | 1331 | ||
1292 | if ( it != mData->emails.end() ) { | 1332 | if ( it != mData->emails.end() ) { |
1293 | if ( !preferred || it == mData->emails.begin() ) return; | 1333 | if ( !preferred || it == mData->emails.begin() ) return; |
1294 | mData->emails.remove( it ); | 1334 | mData->emails.remove( it ); |
1295 | mData->emails.prepend( email ); | 1335 | mData->emails.prepend( email ); |
1296 | } else { | 1336 | } else { |
1297 | if ( preferred ) { | 1337 | if ( preferred ) { |
1298 | mData->emails.prepend( email ); | 1338 | mData->emails.prepend( email ); |
1299 | } else { | 1339 | } else { |
1300 | mData->emails.append( email ); | 1340 | mData->emails.append( email ); |
1301 | } | 1341 | } |
1302 | } | 1342 | } |
1303 | } | 1343 | } |
1304 | 1344 | ||
1305 | void Addressee::removeEmail( const QString &email ) | 1345 | void Addressee::removeEmail( const QString &email ) |
1306 | { | 1346 | { |
1307 | detach(); | 1347 | detach(); |
1308 | 1348 | ||
1309 | QStringList::Iterator it = mData->emails.find( email ); | 1349 | QStringList::Iterator it = mData->emails.find( email ); |
1310 | if ( it == mData->emails.end() ) return; | 1350 | if ( it == mData->emails.end() ) return; |
1311 | 1351 | ||
1312 | mData->emails.remove( it ); | 1352 | mData->emails.remove( it ); |
1313 | } | 1353 | } |
1314 | 1354 | ||
1315 | QString Addressee::preferredEmail() const | 1355 | QString Addressee::preferredEmail() const |
1316 | { | 1356 | { |
1317 | if ( mData->emails.count() == 0 ) return QString::null; | 1357 | if ( mData->emails.count() == 0 ) return QString::null; |
1318 | else return mData->emails.first(); | 1358 | else return mData->emails.first(); |
1319 | } | 1359 | } |
1320 | 1360 | ||
1321 | QStringList Addressee::emails() const | 1361 | QStringList Addressee::emails() const |
1322 | { | 1362 | { |
1323 | return mData->emails; | 1363 | return mData->emails; |
1324 | } | 1364 | } |
1325 | void Addressee::setEmails( const QStringList& emails ) { | 1365 | void Addressee::setEmails( const QStringList& emails ) { |
1326 | detach(); | 1366 | detach(); |
1327 | mData->emails = emails; | 1367 | mData->emails = emails; |
1328 | } | 1368 | } |
1329 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1369 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1330 | { | 1370 | { |
1331 | detach(); | 1371 | detach(); |
1332 | mData->empty = false; | 1372 | mData->empty = false; |
1333 | 1373 | ||
1334 | PhoneNumber::List::Iterator it; | 1374 | PhoneNumber::List::Iterator it; |
1335 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1375 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1336 | if ( (*it).id() == phoneNumber.id() ) { | 1376 | if ( (*it).id() == phoneNumber.id() ) { |
1337 | *it = phoneNumber; | 1377 | *it = phoneNumber; |
1338 | return; | 1378 | return; |
1339 | } | 1379 | } |
1340 | } | 1380 | } |
1341 | mData->phoneNumbers.append( phoneNumber ); | 1381 | mData->phoneNumbers.append( phoneNumber ); |
1342 | } | 1382 | } |
1343 | 1383 | ||
1344 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1384 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1345 | { | 1385 | { |
1346 | detach(); | 1386 | detach(); |
1347 | 1387 | ||
1348 | PhoneNumber::List::Iterator it; | 1388 | PhoneNumber::List::Iterator it; |
1349 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1389 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1350 | if ( (*it).id() == phoneNumber.id() ) { | 1390 | if ( (*it).id() == phoneNumber.id() ) { |
1351 | mData->phoneNumbers.remove( it ); | 1391 | mData->phoneNumbers.remove( it ); |
1352 | return; | 1392 | return; |
1353 | } | 1393 | } |
1354 | } | 1394 | } |
1355 | } | 1395 | } |
1356 | 1396 | ||
1357 | PhoneNumber Addressee::phoneNumber( int type ) const | 1397 | PhoneNumber Addressee::phoneNumber( int type ) const |
1358 | { | 1398 | { |
1359 | PhoneNumber phoneNumber( "", type ); | 1399 | PhoneNumber phoneNumber( "", type ); |
1360 | PhoneNumber::List::ConstIterator it; | 1400 | PhoneNumber::List::ConstIterator it; |
1361 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1401 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1362 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1402 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1363 | if ( (*it).type() & PhoneNumber::Pref ) | 1403 | if ( (*it).type() & PhoneNumber::Pref ) |
1364 | return (*it); | 1404 | return (*it); |
1365 | else if ( phoneNumber.number().isEmpty() ) | 1405 | else if ( phoneNumber.number().isEmpty() ) |
1366 | phoneNumber = (*it); | 1406 | phoneNumber = (*it); |
1367 | } | 1407 | } |
1368 | } | 1408 | } |
1369 | 1409 | ||
1370 | return phoneNumber; | 1410 | return phoneNumber; |
1371 | } | 1411 | } |
1372 | 1412 | ||
1373 | PhoneNumber::List Addressee::phoneNumbers() const | 1413 | PhoneNumber::List Addressee::phoneNumbers() const |
1374 | { | 1414 | { |
1375 | return mData->phoneNumbers; | 1415 | return mData->phoneNumbers; |
1376 | } | 1416 | } |
1377 | 1417 | ||
1378 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1418 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1379 | { | 1419 | { |
1380 | PhoneNumber::List list; | 1420 | PhoneNumber::List list; |
1381 | 1421 | ||
1382 | PhoneNumber::List::ConstIterator it; | 1422 | PhoneNumber::List::ConstIterator it; |
1383 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1423 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1384 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1424 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1385 | list.append( *it ); | 1425 | list.append( *it ); |
1386 | } | 1426 | } |
1387 | } | 1427 | } |
1388 | return list; | 1428 | return list; |
1389 | } | 1429 | } |
1390 | 1430 | ||
1391 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1431 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1392 | { | 1432 | { |
1393 | PhoneNumber::List::ConstIterator it; | 1433 | PhoneNumber::List::ConstIterator it; |
1394 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1434 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1395 | if ( (*it).id() == id ) { | 1435 | if ( (*it).id() == id ) { |
1396 | return *it; | 1436 | return *it; |
1397 | } | 1437 | } |
1398 | } | 1438 | } |
1399 | return PhoneNumber(); | 1439 | return PhoneNumber(); |
1400 | } | 1440 | } |
1401 | 1441 | ||
1402 | void Addressee::insertKey( const Key &key ) | 1442 | void Addressee::insertKey( const Key &key ) |
1403 | { | 1443 | { |
1404 | detach(); | 1444 | detach(); |
1405 | mData->empty = false; | 1445 | mData->empty = false; |
1406 | 1446 | ||
1407 | Key::List::Iterator it; | 1447 | Key::List::Iterator it; |
1408 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1448 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1409 | if ( (*it).id() == key.id() ) { | 1449 | if ( (*it).id() == key.id() ) { |
1410 | *it = key; | 1450 | *it = key; |
1411 | return; | 1451 | return; |
1412 | } | 1452 | } |
1413 | } | 1453 | } |
1414 | mData->keys.append( key ); | 1454 | mData->keys.append( key ); |
1415 | } | 1455 | } |
1416 | 1456 | ||
1417 | void Addressee::removeKey( const Key &key ) | 1457 | void Addressee::removeKey( const Key &key ) |
1418 | { | 1458 | { |
1419 | detach(); | 1459 | detach(); |
1420 | 1460 | ||
1421 | Key::List::Iterator it; | 1461 | Key::List::Iterator it; |
1422 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1462 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1423 | if ( (*it).id() == key.id() ) { | 1463 | if ( (*it).id() == key.id() ) { |
1424 | mData->keys.remove( key ); | 1464 | mData->keys.remove( key ); |
1425 | return; | 1465 | return; |
1426 | } | 1466 | } |
1427 | } | 1467 | } |
1428 | } | 1468 | } |
1429 | 1469 | ||
1430 | Key Addressee::key( int type, QString customTypeString ) const | 1470 | Key Addressee::key( int type, QString customTypeString ) const |
1431 | { | 1471 | { |
1432 | Key::List::ConstIterator it; | 1472 | Key::List::ConstIterator it; |
1433 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1473 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1434 | if ( (*it).type() == type ) { | 1474 | if ( (*it).type() == type ) { |
1435 | if ( type == Key::Custom ) { | 1475 | if ( type == Key::Custom ) { |
1436 | if ( customTypeString.isEmpty() ) { | 1476 | if ( customTypeString.isEmpty() ) { |
1437 | return *it; | 1477 | return *it; |
1438 | } else { | 1478 | } else { |
1439 | if ( (*it).customTypeString() == customTypeString ) | 1479 | if ( (*it).customTypeString() == customTypeString ) |
1440 | return (*it); | 1480 | return (*it); |
1441 | } | 1481 | } |
1442 | } else { | 1482 | } else { |
1443 | return *it; | 1483 | return *it; |
1444 | } | 1484 | } |
1445 | } | 1485 | } |
1446 | } | 1486 | } |
1447 | return Key( QString(), type ); | 1487 | return Key( QString(), type ); |
1448 | } | 1488 | } |
1449 | void Addressee::setKeys( const Key::List& list ) { | 1489 | void Addressee::setKeys( const Key::List& list ) { |
1450 | detach(); | 1490 | detach(); |
1451 | mData->keys = list; | 1491 | mData->keys = list; |
1452 | } | 1492 | } |
1453 | 1493 | ||
1454 | Key::List Addressee::keys() const | 1494 | Key::List Addressee::keys() const |
1455 | { | 1495 | { |
1456 | return mData->keys; | 1496 | return mData->keys; |
1457 | } | 1497 | } |
1458 | 1498 | ||
1459 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1499 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1460 | { | 1500 | { |
1461 | Key::List list; | 1501 | Key::List list; |
1462 | 1502 | ||
1463 | Key::List::ConstIterator it; | 1503 | Key::List::ConstIterator it; |
1464 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1504 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1465 | if ( (*it).type() == type ) { | 1505 | if ( (*it).type() == type ) { |
1466 | if ( type == Key::Custom ) { | 1506 | if ( type == Key::Custom ) { |
1467 | if ( customTypeString.isEmpty() ) { | 1507 | if ( customTypeString.isEmpty() ) { |
1468 | list.append(*it); | 1508 | list.append(*it); |
1469 | } else { | 1509 | } else { |
1470 | if ( (*it).customTypeString() == customTypeString ) | 1510 | if ( (*it).customTypeString() == customTypeString ) |
1471 | list.append(*it); | 1511 | list.append(*it); |
1472 | } | 1512 | } |
1473 | } else { | 1513 | } else { |
1474 | list.append(*it); | 1514 | list.append(*it); |
1475 | } | 1515 | } |
1476 | } | 1516 | } |
1477 | } | 1517 | } |
1478 | return list; | 1518 | return list; |
1479 | } | 1519 | } |
1480 | 1520 | ||
1481 | Key Addressee::findKey( const QString &id ) const | 1521 | Key Addressee::findKey( const QString &id ) const |
1482 | { | 1522 | { |
1483 | Key::List::ConstIterator it; | 1523 | Key::List::ConstIterator it; |
1484 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1524 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1485 | if ( (*it).id() == id ) { | 1525 | if ( (*it).id() == id ) { |
1486 | return *it; | 1526 | return *it; |
1487 | } | 1527 | } |
1488 | } | 1528 | } |
1489 | return Key(); | 1529 | return Key(); |
1490 | } | 1530 | } |
1491 | 1531 | ||
1492 | QString Addressee::asString() const | 1532 | QString Addressee::asString() const |
1493 | { | 1533 | { |
1494 | return "Smith, agent Smith..."; | 1534 | return "Smith, agent Smith..."; |
1495 | } | 1535 | } |
1496 | 1536 | ||
1497 | void Addressee::dump() const | 1537 | void Addressee::dump() const |
1498 | { | 1538 | { |
1499 | return; | 1539 | return; |
1500 | kdDebug(5700) << "Addressee {" << endl; | 1540 | kdDebug(5700) << "Addressee {" << endl; |
1501 | 1541 | ||
1502 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1542 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1503 | 1543 | ||
1504 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1544 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1505 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1545 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1506 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1546 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1507 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1547 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1508 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1548 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1509 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1549 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1510 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1550 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1511 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1551 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1512 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1552 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1513 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1553 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1514 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1554 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1515 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1555 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1516 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1556 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1517 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1557 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1518 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1558 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1519 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1559 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1520 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1560 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1521 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1561 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1522 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1562 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1523 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1563 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1524 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1564 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1525 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1565 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1526 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1566 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1527 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1567 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1528 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1568 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1529 | 1569 | ||
1530 | kdDebug(5700) << " Emails {" << endl; | 1570 | kdDebug(5700) << " Emails {" << endl; |
1531 | QStringList e = emails(); | 1571 | QStringList e = emails(); |
1532 | QStringList::ConstIterator it; | 1572 | QStringList::ConstIterator it; |
1533 | for( it = e.begin(); it != e.end(); ++it ) { | 1573 | for( it = e.begin(); it != e.end(); ++it ) { |
1534 | kdDebug(5700) << " " << (*it) << endl; | 1574 | kdDebug(5700) << " " << (*it) << endl; |
1535 | } | 1575 | } |
1536 | kdDebug(5700) << " }" << endl; | 1576 | kdDebug(5700) << " }" << endl; |
1537 | 1577 | ||
1538 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1578 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1539 | PhoneNumber::List p = phoneNumbers(); | 1579 | PhoneNumber::List p = phoneNumbers(); |
1540 | PhoneNumber::List::ConstIterator it2; | 1580 | PhoneNumber::List::ConstIterator it2; |
1541 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1581 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1542 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1582 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1543 | } | 1583 | } |
1544 | kdDebug(5700) << " }" << endl; | 1584 | kdDebug(5700) << " }" << endl; |
1545 | 1585 | ||
1546 | Address::List a = addresses(); | 1586 | Address::List a = addresses(); |
1547 | Address::List::ConstIterator it3; | 1587 | Address::List::ConstIterator it3; |
1548 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1588 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1549 | (*it3).dump(); | 1589 | (*it3).dump(); |
1550 | } | 1590 | } |
1551 | 1591 | ||
1552 | kdDebug(5700) << " Keys {" << endl; | 1592 | kdDebug(5700) << " Keys {" << endl; |
1553 | Key::List k = keys(); | 1593 | Key::List k = keys(); |
1554 | Key::List::ConstIterator it4; | 1594 | Key::List::ConstIterator it4; |
1555 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1595 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1556 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1596 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1557 | " Key: " << (*it4).textData() << | 1597 | " Key: " << (*it4).textData() << |
1558 | " CustomString: " << (*it4).customTypeString() << endl; | 1598 | " CustomString: " << (*it4).customTypeString() << endl; |
1559 | } | 1599 | } |
1560 | kdDebug(5700) << " }" << endl; | 1600 | kdDebug(5700) << " }" << endl; |
1561 | 1601 | ||
1562 | kdDebug(5700) << "}" << endl; | 1602 | kdDebug(5700) << "}" << endl; |
1563 | } | 1603 | } |
1564 | 1604 | ||
1565 | 1605 | ||
1566 | void Addressee::insertAddress( const Address &address ) | 1606 | void Addressee::insertAddress( const Address &address ) |
1567 | { | 1607 | { |
1568 | detach(); | 1608 | detach(); |
1569 | mData->empty = false; | 1609 | mData->empty = false; |
1570 | 1610 | ||
1571 | Address::List::Iterator it; | 1611 | Address::List::Iterator it; |
1572 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1612 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1573 | if ( (*it).id() == address.id() ) { | 1613 | if ( (*it).id() == address.id() ) { |
1574 | *it = address; | 1614 | *it = address; |
1575 | return; | 1615 | return; |
1576 | } | 1616 | } |
1577 | } | 1617 | } |
1578 | mData->addresses.append( address ); | 1618 | mData->addresses.append( address ); |
1579 | } | 1619 | } |
1580 | 1620 | ||
1581 | void Addressee::removeAddress( const Address &address ) | 1621 | void Addressee::removeAddress( const Address &address ) |
1582 | { | 1622 | { |
1583 | detach(); | 1623 | detach(); |
1584 | 1624 | ||
1585 | Address::List::Iterator it; | 1625 | Address::List::Iterator it; |
1586 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1626 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1587 | if ( (*it).id() == address.id() ) { | 1627 | if ( (*it).id() == address.id() ) { |
1588 | mData->addresses.remove( it ); | 1628 | mData->addresses.remove( it ); |
1589 | return; | 1629 | return; |
1590 | } | 1630 | } |
1591 | } | 1631 | } |
1592 | } | 1632 | } |
1593 | 1633 | ||
1594 | Address Addressee::address( int type ) const | 1634 | Address Addressee::address( int type ) const |
1595 | { | 1635 | { |
1596 | Address address( type ); | 1636 | Address address( type ); |
1597 | Address::List::ConstIterator it; | 1637 | Address::List::ConstIterator it; |
1598 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1638 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1599 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1639 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1600 | if ( (*it).type() & Address::Pref ) | 1640 | if ( (*it).type() & Address::Pref ) |
1601 | return (*it); | 1641 | return (*it); |
1602 | else if ( address.isEmpty() ) | 1642 | else if ( address.isEmpty() ) |
1603 | address = (*it); | 1643 | address = (*it); |
1604 | } | 1644 | } |
1605 | } | 1645 | } |
1606 | 1646 | ||
1607 | return address; | 1647 | return address; |
1608 | } | 1648 | } |
1609 | 1649 | ||
1610 | Address::List Addressee::addresses() const | 1650 | Address::List Addressee::addresses() const |
1611 | { | 1651 | { |
1612 | return mData->addresses; | 1652 | return mData->addresses; |
1613 | } | 1653 | } |
1614 | 1654 | ||
1615 | Address::List Addressee::addresses( int type ) const | 1655 | Address::List Addressee::addresses( int type ) const |
1616 | { | 1656 | { |
1617 | Address::List list; | 1657 | Address::List list; |
1618 | 1658 | ||
1619 | Address::List::ConstIterator it; | 1659 | Address::List::ConstIterator it; |
1620 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1660 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1621 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1661 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1622 | list.append( *it ); | 1662 | list.append( *it ); |
1623 | } | 1663 | } |
1624 | } | 1664 | } |
1625 | 1665 | ||
1626 | return list; | 1666 | return list; |
1627 | } | 1667 | } |
1628 | 1668 | ||
1629 | Address Addressee::findAddress( const QString &id ) const | 1669 | Address Addressee::findAddress( const QString &id ) const |
1630 | { | 1670 | { |
1631 | Address::List::ConstIterator it; | 1671 | Address::List::ConstIterator it; |
1632 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1672 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1633 | if ( (*it).id() == id ) { | 1673 | if ( (*it).id() == id ) { |
1634 | return *it; | 1674 | return *it; |
1635 | } | 1675 | } |
1636 | } | 1676 | } |
1637 | return Address(); | 1677 | return Address(); |
1638 | } | 1678 | } |
1639 | 1679 | ||
1640 | void Addressee::insertCategory( const QString &c ) | 1680 | void Addressee::insertCategory( const QString &c ) |
1641 | { | 1681 | { |
1642 | detach(); | 1682 | detach(); |
1643 | mData->empty = false; | 1683 | mData->empty = false; |
1644 | 1684 | ||
1645 | if ( mData->categories.contains( c ) ) return; | 1685 | if ( mData->categories.contains( c ) ) return; |
1646 | 1686 | ||
1647 | mData->categories.append( c ); | 1687 | mData->categories.append( c ); |
1648 | } | 1688 | } |
1649 | 1689 | ||
1650 | void Addressee::removeCategory( const QString &c ) | 1690 | void Addressee::removeCategory( const QString &c ) |
1651 | { | 1691 | { |
1652 | detach(); | 1692 | detach(); |
1653 | 1693 | ||
1654 | QStringList::Iterator it = mData->categories.find( c ); | 1694 | QStringList::Iterator it = mData->categories.find( c ); |
1655 | if ( it == mData->categories.end() ) return; | 1695 | if ( it == mData->categories.end() ) return; |
1656 | 1696 | ||
1657 | mData->categories.remove( it ); | 1697 | mData->categories.remove( it ); |
1658 | } | 1698 | } |
1659 | 1699 | ||
1660 | bool Addressee::hasCategory( const QString &c ) const | 1700 | bool Addressee::hasCategory( const QString &c ) const |
1661 | { | 1701 | { |
1662 | return ( mData->categories.contains( c ) ); | 1702 | return ( mData->categories.contains( c ) ); |
1663 | } | 1703 | } |
1664 | 1704 | ||
1665 | void Addressee::setCategories( const QStringList &c ) | 1705 | void Addressee::setCategories( const QStringList &c ) |
1666 | { | 1706 | { |
1667 | detach(); | 1707 | detach(); |
1668 | mData->empty = false; | 1708 | mData->empty = false; |
1669 | 1709 | ||
1670 | mData->categories = c; | 1710 | mData->categories = c; |
1671 | } | 1711 | } |
1672 | 1712 | ||
1673 | QStringList Addressee::categories() const | 1713 | QStringList Addressee::categories() const |
1674 | { | 1714 | { |
1675 | return mData->categories; | 1715 | return mData->categories; |
1676 | } | 1716 | } |
1677 | 1717 | ||
1678 | void Addressee::insertCustom( const QString &app, const QString &name, | 1718 | void Addressee::insertCustom( const QString &app, const QString &name, |
1679 | const QString &value ) | 1719 | const QString &value ) |
1680 | { | 1720 | { |
1681 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1721 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1682 | 1722 | ||
1683 | detach(); | 1723 | detach(); |
1684 | mData->empty = false; | 1724 | mData->empty = false; |
1685 | 1725 | ||
1686 | QString qualifiedName = app + "-" + name + ":"; | 1726 | QString qualifiedName = app + "-" + name + ":"; |
1687 | 1727 | ||
1688 | QStringList::Iterator it; | 1728 | QStringList::Iterator it; |
1689 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1729 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1690 | if ( (*it).startsWith( qualifiedName ) ) { | 1730 | if ( (*it).startsWith( qualifiedName ) ) { |
1691 | (*it) = qualifiedName + value; | 1731 | (*it) = qualifiedName + value; |
1692 | return; | 1732 | return; |
1693 | } | 1733 | } |
1694 | } | 1734 | } |
1695 | mData->custom.append( qualifiedName + value ); | 1735 | mData->custom.append( qualifiedName + value ); |
1696 | } | 1736 | } |
1697 | 1737 | ||
1698 | void Addressee::removeCustom( const QString &app, const QString &name) | 1738 | void Addressee::removeCustom( const QString &app, const QString &name) |
1699 | { | 1739 | { |
1700 | detach(); | 1740 | detach(); |
1701 | 1741 | ||
1702 | QString qualifiedName = app + "-" + name + ":"; | 1742 | QString qualifiedName = app + "-" + name + ":"; |
1703 | 1743 | ||
1704 | QStringList::Iterator it; | 1744 | QStringList::Iterator it; |
1705 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1745 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1706 | if ( (*it).startsWith( qualifiedName ) ) { | 1746 | if ( (*it).startsWith( qualifiedName ) ) { |
1707 | mData->custom.remove( it ); | 1747 | mData->custom.remove( it ); |
1708 | return; | 1748 | return; |
1709 | } | 1749 | } |
1710 | } | 1750 | } |
1711 | } | 1751 | } |
1712 | 1752 | ||
1713 | QString Addressee::custom( const QString &app, const QString &name ) const | 1753 | QString Addressee::custom( const QString &app, const QString &name ) const |
1714 | { | 1754 | { |
1715 | QString qualifiedName = app + "-" + name + ":"; | 1755 | QString qualifiedName = app + "-" + name + ":"; |
1716 | QString value; | 1756 | QString value; |
1717 | 1757 | ||
1718 | QStringList::ConstIterator it; | 1758 | QStringList::ConstIterator it; |
1719 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1759 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1720 | if ( (*it).startsWith( qualifiedName ) ) { | 1760 | if ( (*it).startsWith( qualifiedName ) ) { |
1721 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1761 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1722 | break; | 1762 | break; |
1723 | } | 1763 | } |
1724 | } | 1764 | } |
1725 | 1765 | ||
1726 | return value; | 1766 | return value; |
1727 | } | 1767 | } |
1728 | 1768 | ||
1729 | void Addressee::setCustoms( const QStringList &l ) | 1769 | void Addressee::setCustoms( const QStringList &l ) |
1730 | { | 1770 | { |
1731 | detach(); | 1771 | detach(); |
1732 | mData->empty = false; | 1772 | mData->empty = false; |
1733 | 1773 | ||
1734 | mData->custom = l; | 1774 | mData->custom = l; |
1735 | } | 1775 | } |
1736 | 1776 | ||
1737 | QStringList Addressee::customs() const | 1777 | QStringList Addressee::customs() const |
1738 | { | 1778 | { |
1739 | return mData->custom; | 1779 | return mData->custom; |
1740 | } | 1780 | } |
1741 | 1781 | ||
1742 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1782 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1743 | QString &email) | 1783 | QString &email) |
1744 | { | 1784 | { |
1745 | int startPos, endPos, len; | 1785 | int startPos, endPos, len; |
1746 | QString partA, partB, result; | 1786 | QString partA, partB, result; |
1747 | char endCh = '>'; | 1787 | char endCh = '>'; |
1748 | 1788 | ||
1749 | startPos = rawEmail.find('<'); | 1789 | startPos = rawEmail.find('<'); |
1750 | if (startPos < 0) | 1790 | if (startPos < 0) |
1751 | { | 1791 | { |
1752 | startPos = rawEmail.find('('); | 1792 | startPos = rawEmail.find('('); |
1753 | endCh = ')'; | 1793 | endCh = ')'; |
1754 | } | 1794 | } |
1755 | if (startPos < 0) | 1795 | if (startPos < 0) |
1756 | { | 1796 | { |
1757 | // We couldn't find any separators, so we assume the whole string | 1797 | // We couldn't find any separators, so we assume the whole string |
1758 | // is the email address | 1798 | // is the email address |
1759 | email = rawEmail; | 1799 | email = rawEmail; |
1760 | fullName = ""; | 1800 | fullName = ""; |
1761 | } | 1801 | } |
1762 | else | 1802 | else |
1763 | { | 1803 | { |
1764 | // We have a start position, try to find an end | 1804 | // We have a start position, try to find an end |
1765 | endPos = rawEmail.find(endCh, startPos+1); | 1805 | endPos = rawEmail.find(endCh, startPos+1); |
1766 | 1806 | ||
1767 | if (endPos < 0) | 1807 | if (endPos < 0) |
1768 | { | 1808 | { |
1769 | // We couldn't find the end of the email address. We can only | 1809 | // We couldn't find the end of the email address. We can only |
1770 | // assume the entire string is the email address. | 1810 | // assume the entire string is the email address. |
1771 | email = rawEmail; | 1811 | email = rawEmail; |
1772 | fullName = ""; | 1812 | fullName = ""; |
1773 | } | 1813 | } |
1774 | else | 1814 | else |
1775 | { | 1815 | { |
1776 | // We have a start and end to the email address | 1816 | // We have a start and end to the email address |
1777 | 1817 | ||
1778 | // Grab the name part | 1818 | // Grab the name part |
1779 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1819 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1780 | 1820 | ||
1781 | // grab the email part | 1821 | // grab the email part |
1782 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1822 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1783 | 1823 | ||
1784 | // Check that we do not have any extra characters on the end of the | 1824 | // Check that we do not have any extra characters on the end of the |
1785 | // strings | 1825 | // strings |
1786 | len = fullName.length(); | 1826 | len = fullName.length(); |
1787 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1827 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1788 | fullName = fullName.mid(1, len-2); | 1828 | fullName = fullName.mid(1, len-2); |
1789 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1829 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1790 | fullName = fullName.mid(1, len-2); | 1830 | fullName = fullName.mid(1, len-2); |
1791 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1831 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1792 | fullName = fullName.mid(1, len-2); | 1832 | fullName = fullName.mid(1, len-2); |
1793 | } | 1833 | } |
1794 | } | 1834 | } |
1795 | } | 1835 | } |
1796 | 1836 | ||
1797 | void Addressee::setResource( Resource *resource ) | 1837 | void Addressee::setResource( Resource *resource ) |
1798 | { | 1838 | { |
1799 | detach(); | 1839 | detach(); |
1800 | mData->resource = resource; | 1840 | mData->resource = resource; |
1801 | } | 1841 | } |
1802 | 1842 | ||
1803 | Resource *Addressee::resource() const | 1843 | Resource *Addressee::resource() const |
1804 | { | 1844 | { |
1805 | return mData->resource; | 1845 | return mData->resource; |
1806 | } | 1846 | } |
1807 | 1847 | ||
1808 | //US | 1848 | //US |
1809 | QString Addressee::resourceLabel() | 1849 | QString Addressee::resourceLabel() |
1810 | { | 1850 | { |
1811 | return i18n("Resource"); | 1851 | return i18n("Resource"); |
1812 | } | 1852 | } |
1813 | 1853 | ||
1814 | void Addressee::setChanged( bool value ) | 1854 | void Addressee::setChanged( bool value ) |
1815 | { | 1855 | { |
1816 | detach(); | 1856 | detach(); |
1817 | mData->changed = value; | 1857 | mData->changed = value; |
1818 | } | 1858 | } |
1819 | 1859 | ||
1820 | bool Addressee::changed() const | 1860 | bool Addressee::changed() const |
1821 | { | 1861 | { |
1822 | return mData->changed; | 1862 | return mData->changed; |
1823 | } | 1863 | } |
1824 | 1864 | ||
1825 | void Addressee::setTagged( bool value ) | 1865 | void Addressee::setTagged( bool value ) |
1826 | { | 1866 | { |
1827 | detach(); | 1867 | detach(); |
1828 | mData->tagged = value; | 1868 | mData->tagged = value; |
1829 | } | 1869 | } |
1830 | 1870 | ||
1831 | bool Addressee::tagged() const | 1871 | bool Addressee::tagged() const |
1832 | { | 1872 | { |
1833 | return mData->tagged; | 1873 | return mData->tagged; |
1834 | } | 1874 | } |
1835 | 1875 | ||
1836 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1876 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1837 | { | 1877 | { |
1838 | if (!a.mData) return s; | 1878 | if (!a.mData) return s; |
1839 | 1879 | ||
1840 | s << a.uid(); | 1880 | s << a.uid(); |
1841 | 1881 | ||
1842 | s << a.mData->name; | 1882 | s << a.mData->name; |
1843 | s << a.mData->formattedName; | 1883 | s << a.mData->formattedName; |
1844 | s << a.mData->familyName; | 1884 | s << a.mData->familyName; |
1845 | s << a.mData->givenName; | 1885 | s << a.mData->givenName; |
1846 | s << a.mData->additionalName; | 1886 | s << a.mData->additionalName; |
1847 | s << a.mData->prefix; | 1887 | s << a.mData->prefix; |
1848 | s << a.mData->suffix; | 1888 | s << a.mData->suffix; |
1849 | s << a.mData->nickName; | 1889 | s << a.mData->nickName; |
1850 | s << a.mData->birthday; | 1890 | s << a.mData->birthday; |
1851 | s << a.mData->mailer; | 1891 | s << a.mData->mailer; |
1852 | s << a.mData->timeZone; | 1892 | s << a.mData->timeZone; |
1853 | s << a.mData->geo; | 1893 | s << a.mData->geo; |
1854 | s << a.mData->title; | 1894 | s << a.mData->title; |
1855 | s << a.mData->role; | 1895 | s << a.mData->role; |
1856 | s << a.mData->organization; | 1896 | s << a.mData->organization; |
1857 | s << a.mData->note; | 1897 | s << a.mData->note; |
1858 | s << a.mData->productId; | 1898 | s << a.mData->productId; |
1859 | s << a.mData->revision; | 1899 | s << a.mData->revision; |
1860 | s << a.mData->sortString; | 1900 | s << a.mData->sortString; |
1861 | s << a.mData->url; | 1901 | s << a.mData->url; |
1862 | s << a.mData->secrecy; | 1902 | s << a.mData->secrecy; |
1863 | s << a.mData->logo; | 1903 | s << a.mData->logo; |
1864 | s << a.mData->photo; | 1904 | s << a.mData->photo; |
1865 | s << a.mData->sound; | 1905 | s << a.mData->sound; |
1866 | s << a.mData->agent; | 1906 | s << a.mData->agent; |
1867 | s << a.mData->phoneNumbers; | 1907 | s << a.mData->phoneNumbers; |
1868 | s << a.mData->addresses; | 1908 | s << a.mData->addresses; |
1869 | s << a.mData->emails; | 1909 | s << a.mData->emails; |
1870 | s << a.mData->categories; | 1910 | s << a.mData->categories; |
1871 | s << a.mData->custom; | 1911 | s << a.mData->custom; |
1872 | s << a.mData->keys; | 1912 | s << a.mData->keys; |
1873 | return s; | 1913 | return s; |
1874 | } | 1914 | } |
1875 | 1915 | ||
1876 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1916 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1877 | { | 1917 | { |
1878 | if (!a.mData) return s; | 1918 | if (!a.mData) return s; |
1879 | 1919 | ||
1880 | s >> a.mData->uid; | 1920 | s >> a.mData->uid; |
1881 | 1921 | ||
1882 | s >> a.mData->name; | 1922 | s >> a.mData->name; |
1883 | s >> a.mData->formattedName; | 1923 | s >> a.mData->formattedName; |
1884 | s >> a.mData->familyName; | 1924 | s >> a.mData->familyName; |
1885 | s >> a.mData->givenName; | 1925 | s >> a.mData->givenName; |
1886 | s >> a.mData->additionalName; | 1926 | s >> a.mData->additionalName; |
1887 | s >> a.mData->prefix; | 1927 | s >> a.mData->prefix; |
1888 | s >> a.mData->suffix; | 1928 | s >> a.mData->suffix; |
1889 | s >> a.mData->nickName; | 1929 | s >> a.mData->nickName; |
1890 | s >> a.mData->birthday; | 1930 | s >> a.mData->birthday; |
1891 | s >> a.mData->mailer; | 1931 | s >> a.mData->mailer; |
1892 | s >> a.mData->timeZone; | 1932 | s >> a.mData->timeZone; |
1893 | s >> a.mData->geo; | 1933 | s >> a.mData->geo; |
1894 | s >> a.mData->title; | 1934 | s >> a.mData->title; |
1895 | s >> a.mData->role; | 1935 | s >> a.mData->role; |
1896 | s >> a.mData->organization; | 1936 | s >> a.mData->organization; |
1897 | s >> a.mData->note; | 1937 | s >> a.mData->note; |
1898 | s >> a.mData->productId; | 1938 | s >> a.mData->productId; |
1899 | s >> a.mData->revision; | 1939 | s >> a.mData->revision; |
1900 | s >> a.mData->sortString; | 1940 | s >> a.mData->sortString; |
1901 | s >> a.mData->url; | 1941 | s >> a.mData->url; |
1902 | s >> a.mData->secrecy; | 1942 | s >> a.mData->secrecy; |
1903 | s >> a.mData->logo; | 1943 | s >> a.mData->logo; |
1904 | s >> a.mData->photo; | 1944 | s >> a.mData->photo; |
1905 | s >> a.mData->sound; | 1945 | s >> a.mData->sound; |
1906 | s >> a.mData->agent; | 1946 | s >> a.mData->agent; |
1907 | s >> a.mData->phoneNumbers; | 1947 | s >> a.mData->phoneNumbers; |
1908 | s >> a.mData->addresses; | 1948 | s >> a.mData->addresses; |
1909 | s >> a.mData->emails; | 1949 | s >> a.mData->emails; |
1910 | s >> a.mData->categories; | 1950 | s >> a.mData->categories; |
1911 | s >> a.mData->custom; | 1951 | s >> a.mData->custom; |
1912 | s >> a.mData->keys; | 1952 | s >> a.mData->keys; |
1913 | 1953 | ||
1914 | a.mData->empty = false; | 1954 | a.mData->empty = false; |
1915 | 1955 | ||
1916 | return s; | 1956 | return s; |
1917 | } | 1957 | } |
1918 | bool matchBinaryPattern( int value, int pattern ) | 1958 | bool matchBinaryPattern( int value, int pattern ) |
1919 | { | 1959 | { |
1920 | /** | 1960 | /** |
1921 | We want to match all telephonnumbers/addresses which have the bits in the | 1961 | We want to match all telephonnumbers/addresses which have the bits in the |
1922 | pattern set. More are allowed. | 1962 | pattern set. More are allowed. |
1923 | if pattern == 0 we have a special handling, then we want only those with | 1963 | if pattern == 0 we have a special handling, then we want only those with |
1924 | exactly no bit set. | 1964 | exactly no bit set. |
1925 | */ | 1965 | */ |
1926 | if ( pattern == 0 ) | 1966 | if ( pattern == 0 ) |
1927 | return ( value == 0 ); | 1967 | return ( value == 0 ); |
1928 | else | 1968 | else |
1929 | return ( pattern == ( pattern & value ) ); | 1969 | return ( pattern == ( pattern & value ) ); |
1930 | } | 1970 | } |
1931 | 1971 | ||
1932 | bool matchBinaryPatternP( int value, int pattern ) | 1972 | bool matchBinaryPatternP( int value, int pattern ) |
1933 | { | 1973 | { |
1934 | 1974 | ||
1935 | if ( pattern == 0 ) | 1975 | if ( pattern == 0 ) |
1936 | return ( value == 0 ); | 1976 | return ( value == 0 ); |
1937 | else | 1977 | else |
1938 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 1978 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
1939 | } | 1979 | } |
1940 | bool matchBinaryPatternA( int value, int pattern ) | 1980 | bool matchBinaryPatternA( int value, int pattern ) |
1941 | { | 1981 | { |
1942 | 1982 | ||
1943 | if ( pattern == 0 ) | 1983 | if ( pattern == 0 ) |
1944 | return ( value == 0 ); | 1984 | return ( value == 0 ); |
1945 | else | 1985 | else |
1946 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | 1986 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); |
1947 | } | 1987 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 0aa2c51..03138f6 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,852 +1,853 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #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 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class 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 | */ |
80 | class Addressee | 80 | class 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 ); |
221 | /** | 222 | /** |
222 | Return honorific suffixes. | 223 | Return honorific suffixes. |
223 | */ | 224 | */ |
224 | QString suffix() const; | 225 | QString suffix() const; |
225 | /** | 226 | /** |
226 | Return translated label for suffix field. | 227 | Return translated label for suffix field. |
227 | */ | 228 | */ |
228 | static QString suffixLabel(); | 229 | static QString suffixLabel(); |
229 | 230 | ||
230 | /** | 231 | /** |
231 | Set nick name. | 232 | Set nick name. |
232 | */ | 233 | */ |
233 | void setNickName( const QString &nickName ); | 234 | void setNickName( const QString &nickName ); |
234 | /** | 235 | /** |
235 | Return nick name. | 236 | Return nick name. |
236 | */ | 237 | */ |
237 | QString nickName() const; | 238 | QString nickName() const; |
238 | /** | 239 | /** |
239 | Return translated label for nickName field. | 240 | Return translated label for nickName field. |
240 | */ | 241 | */ |
241 | static QString nickNameLabel(); | 242 | static QString nickNameLabel(); |
242 | 243 | ||
243 | /** | 244 | /** |
244 | Set birthday. | 245 | Set birthday. |
245 | */ | 246 | */ |
246 | void setBirthday( const QDateTime &birthday ); | 247 | void setBirthday( const QDateTime &birthday ); |
247 | /** | 248 | /** |
248 | Return birthday. | 249 | Return birthday. |
249 | */ | 250 | */ |
250 | QDateTime birthday() const; | 251 | QDateTime birthday() const; |
251 | /** | 252 | /** |
252 | Return translated label for birthday field. | 253 | Return translated label for birthday field. |
253 | */ | 254 | */ |
254 | static QString birthdayLabel(); | 255 | static QString birthdayLabel(); |
255 | 256 | ||
256 | /** | 257 | /** |
257 | Return translated label for homeAddressStreet field. | 258 | Return translated label for homeAddressStreet field. |
258 | */ | 259 | */ |
259 | static QString homeAddressStreetLabel(); | 260 | static QString homeAddressStreetLabel(); |
260 | 261 | ||
261 | /** | 262 | /** |
262 | Return translated label for homeAddressLocality field. | 263 | Return translated label for homeAddressLocality field. |
263 | */ | 264 | */ |
264 | static QString homeAddressLocalityLabel(); | 265 | static QString homeAddressLocalityLabel(); |
265 | 266 | ||
266 | /** | 267 | /** |
267 | Return translated label for homeAddressRegion field. | 268 | Return translated label for homeAddressRegion field. |
268 | */ | 269 | */ |
269 | static QString homeAddressRegionLabel(); | 270 | static QString homeAddressRegionLabel(); |
270 | 271 | ||
271 | /** | 272 | /** |
272 | Return translated label for homeAddressPostalCode field. | 273 | Return translated label for homeAddressPostalCode field. |
273 | */ | 274 | */ |
274 | static QString homeAddressPostalCodeLabel(); | 275 | static QString homeAddressPostalCodeLabel(); |
275 | 276 | ||
276 | /** | 277 | /** |
277 | Return translated label for homeAddressCountry field. | 278 | Return translated label for homeAddressCountry field. |
278 | */ | 279 | */ |
279 | static QString homeAddressCountryLabel(); | 280 | static QString homeAddressCountryLabel(); |
280 | 281 | ||
281 | /** | 282 | /** |
282 | Return translated label for homeAddressLabel field. | 283 | Return translated label for homeAddressLabel field. |
283 | */ | 284 | */ |
284 | static QString homeAddressLabelLabel(); | 285 | static QString homeAddressLabelLabel(); |
285 | 286 | ||
286 | /** | 287 | /** |
287 | Return translated label for businessAddressStreet field. | 288 | Return translated label for businessAddressStreet field. |
288 | */ | 289 | */ |
289 | static QString businessAddressStreetLabel(); | 290 | static QString businessAddressStreetLabel(); |
290 | 291 | ||
291 | /** | 292 | /** |
292 | Return translated label for businessAddressLocality field. | 293 | Return translated label for businessAddressLocality field. |
293 | */ | 294 | */ |
294 | static QString businessAddressLocalityLabel(); | 295 | static QString businessAddressLocalityLabel(); |
295 | 296 | ||
296 | /** | 297 | /** |
297 | Return translated label for businessAddressRegion field. | 298 | Return translated label for businessAddressRegion field. |
298 | */ | 299 | */ |
299 | static QString businessAddressRegionLabel(); | 300 | static QString businessAddressRegionLabel(); |
300 | 301 | ||
301 | /** | 302 | /** |
302 | Return translated label for businessAddressPostalCode field. | 303 | Return translated label for businessAddressPostalCode field. |
303 | */ | 304 | */ |
304 | static QString businessAddressPostalCodeLabel(); | 305 | static QString businessAddressPostalCodeLabel(); |
305 | 306 | ||
306 | /** | 307 | /** |
307 | Return translated label for businessAddressCountry field. | 308 | Return translated label for businessAddressCountry field. |
308 | */ | 309 | */ |
309 | static QString businessAddressCountryLabel(); | 310 | static QString businessAddressCountryLabel(); |
310 | 311 | ||
311 | /** | 312 | /** |
312 | Return translated label for businessAddressLabel field. | 313 | Return translated label for businessAddressLabel field. |
313 | */ | 314 | */ |
314 | static QString businessAddressLabelLabel(); | 315 | static QString businessAddressLabelLabel(); |
315 | 316 | ||
316 | /** | 317 | /** |
317 | Return translated label for homePhone field. | 318 | Return translated label for homePhone field. |
318 | */ | 319 | */ |
319 | static QString homePhoneLabel(); | 320 | static QString homePhoneLabel(); |
320 | 321 | ||
321 | /** | 322 | /** |
322 | Return translated label for businessPhone field. | 323 | Return translated label for businessPhone field. |
323 | */ | 324 | */ |
324 | static QString businessPhoneLabel(); | 325 | static QString businessPhoneLabel(); |
325 | 326 | ||
326 | /** | 327 | /** |
327 | Return translated label for mobilePhone field. | 328 | Return translated label for mobilePhone field. |
328 | */ | 329 | */ |
329 | static QString mobilePhoneLabel(); | 330 | static QString mobilePhoneLabel(); |
330 | 331 | ||
331 | /** | 332 | /** |
332 | Return translated label for homeFax field. | 333 | Return translated label for homeFax field. |
333 | */ | 334 | */ |
334 | static QString homeFaxLabel(); | 335 | static QString homeFaxLabel(); |
335 | 336 | ||
336 | /** | 337 | /** |
337 | Return translated label for businessFax field. | 338 | Return translated label for businessFax field. |
338 | */ | 339 | */ |
339 | static QString businessFaxLabel(); | 340 | static QString businessFaxLabel(); |
340 | 341 | ||
341 | /** | 342 | /** |
342 | Return translated label for carPhone field. | 343 | Return translated label for carPhone field. |
343 | */ | 344 | */ |
344 | static QString carPhoneLabel(); | 345 | static QString carPhoneLabel(); |
345 | 346 | ||
346 | /** | 347 | /** |
347 | Return translated label for isdn field. | 348 | Return translated label for isdn field. |
348 | */ | 349 | */ |
349 | static QString isdnLabel(); | 350 | static QString isdnLabel(); |
350 | 351 | ||
351 | /** | 352 | /** |
352 | Return translated label for pager field. | 353 | Return translated label for pager field. |
353 | */ | 354 | */ |
354 | static QString pagerLabel(); | 355 | static QString pagerLabel(); |
355 | 356 | ||
356 | /** | 357 | /** |
357 | Return translated label for sip field. | 358 | Return translated label for sip field. |
358 | */ | 359 | */ |
359 | static QString sipLabel(); | 360 | static QString sipLabel(); |
360 | 361 | ||
361 | /** | 362 | /** |
362 | Return translated label for email field. | 363 | Return translated label for email field. |
363 | */ | 364 | */ |
364 | static QString emailLabel(); | 365 | static QString emailLabel(); |
365 | 366 | ||
366 | /** | 367 | /** |
367 | Set mail client. | 368 | Set mail client. |
368 | */ | 369 | */ |
369 | void setMailer( const QString &mailer ); | 370 | void setMailer( const QString &mailer ); |
370 | /** | 371 | /** |
371 | Return mail client. | 372 | Return mail client. |
372 | */ | 373 | */ |
373 | QString mailer() const; | 374 | QString mailer() const; |
374 | /** | 375 | /** |
375 | Return translated label for mailer field. | 376 | Return translated label for mailer field. |
376 | */ | 377 | */ |
377 | static QString mailerLabel(); | 378 | static QString mailerLabel(); |
378 | 379 | ||
379 | /** | 380 | /** |
380 | Set time zone. | 381 | Set time zone. |
381 | */ | 382 | */ |
382 | void setTimeZone( const TimeZone &timeZone ); | 383 | void setTimeZone( const TimeZone &timeZone ); |
383 | /** | 384 | /** |
384 | Return time zone. | 385 | Return time zone. |
385 | */ | 386 | */ |
386 | TimeZone timeZone() const; | 387 | TimeZone timeZone() const; |
387 | /** | 388 | /** |
388 | Return translated label for timeZone field. | 389 | Return translated label for timeZone field. |
389 | */ | 390 | */ |
390 | static QString timeZoneLabel(); | 391 | static QString timeZoneLabel(); |
391 | 392 | ||
392 | /** | 393 | /** |
393 | Set geographic position. | 394 | Set geographic position. |
394 | */ | 395 | */ |
395 | void setGeo( const Geo &geo ); | 396 | void setGeo( const Geo &geo ); |
396 | /** | 397 | /** |
397 | Return geographic position. | 398 | Return geographic position. |
398 | */ | 399 | */ |
399 | Geo geo() const; | 400 | Geo geo() const; |
400 | /** | 401 | /** |
401 | Return translated label for geo field. | 402 | Return translated label for geo field. |
402 | */ | 403 | */ |
403 | static QString geoLabel(); | 404 | static QString geoLabel(); |
404 | 405 | ||
405 | /** | 406 | /** |
406 | Set title. | 407 | Set title. |
407 | */ | 408 | */ |
408 | void setTitle( const QString &title ); | 409 | void setTitle( const QString &title ); |
409 | /** | 410 | /** |
410 | Return title. | 411 | Return title. |
411 | */ | 412 | */ |
412 | QString title() const; | 413 | QString title() const; |
413 | /** | 414 | /** |
414 | Return translated label for title field. | 415 | Return translated label for title field. |
415 | */ | 416 | */ |
416 | static QString titleLabel(); | 417 | static QString titleLabel(); |
417 | 418 | ||
418 | /** | 419 | /** |
419 | Set role. | 420 | Set role. |
420 | */ | 421 | */ |
421 | void setRole( const QString &role ); | 422 | void setRole( const QString &role ); |
422 | /** | 423 | /** |
423 | Return role. | 424 | Return role. |
424 | */ | 425 | */ |
425 | QString role() const; | 426 | QString role() const; |
426 | /** | 427 | /** |
427 | Return translated label for role field. | 428 | Return translated label for role field. |
428 | */ | 429 | */ |
429 | static QString roleLabel(); | 430 | static QString roleLabel(); |
430 | 431 | ||
431 | /** | 432 | /** |
432 | Set organization. | 433 | Set organization. |
433 | */ | 434 | */ |
434 | void setOrganization( const QString &organization ); | 435 | void setOrganization( const QString &organization ); |
435 | /** | 436 | /** |
436 | Return organization. | 437 | Return organization. |
437 | */ | 438 | */ |
438 | QString organization() const; | 439 | QString organization() const; |
439 | /** | 440 | /** |
440 | Return translated label for organization field. | 441 | Return translated label for organization field. |
441 | */ | 442 | */ |
442 | static QString organizationLabel(); | 443 | static QString organizationLabel(); |
443 | 444 | ||
444 | /** | 445 | /** |
445 | Set note. | 446 | Set note. |
446 | */ | 447 | */ |
447 | void setNote( const QString ¬e ); | 448 | void setNote( const QString ¬e ); |
448 | /** | 449 | /** |
449 | Return note. | 450 | Return note. |
450 | */ | 451 | */ |
451 | QString note() const; | 452 | QString note() const; |
452 | /** | 453 | /** |
453 | Return translated label for note field. | 454 | Return translated label for note field. |
454 | */ | 455 | */ |
455 | static QString noteLabel(); | 456 | static QString noteLabel(); |
456 | 457 | ||
457 | /** | 458 | /** |
458 | Set product identifier. | 459 | Set product identifier. |
459 | */ | 460 | */ |
460 | void setProductId( const QString &productId ); | 461 | void setProductId( const QString &productId ); |
461 | /** | 462 | /** |
462 | Return product identifier. | 463 | Return product identifier. |
463 | */ | 464 | */ |
464 | QString productId() const; | 465 | QString productId() const; |
465 | /** | 466 | /** |
466 | Return translated label for productId field. | 467 | Return translated label for productId field. |
467 | */ | 468 | */ |
468 | static QString productIdLabel(); | 469 | static QString productIdLabel(); |
469 | 470 | ||
470 | /** | 471 | /** |
471 | Set revision date. | 472 | Set revision date. |
472 | */ | 473 | */ |
473 | void setRevision( const QDateTime &revision ); | 474 | void setRevision( const QDateTime &revision ); |
474 | /** | 475 | /** |
475 | Return revision date. | 476 | Return revision date. |
476 | */ | 477 | */ |
477 | QDateTime revision() const; | 478 | QDateTime revision() const; |
478 | /** | 479 | /** |
479 | Return translated label for revision field. | 480 | Return translated label for revision field. |
480 | */ | 481 | */ |
481 | static QString revisionLabel(); | 482 | static QString revisionLabel(); |
482 | 483 | ||
483 | /** | 484 | /** |
484 | Set sort string. | 485 | Set sort string. |
485 | */ | 486 | */ |
486 | void setSortString( const QString &sortString ); | 487 | void setSortString( const QString &sortString ); |
487 | /** | 488 | /** |
488 | Return sort string. | 489 | Return sort string. |
489 | */ | 490 | */ |
490 | QString sortString() const; | 491 | QString sortString() const; |
491 | /** | 492 | /** |
492 | Return translated label for sortString field. | 493 | Return translated label for sortString field. |
493 | */ | 494 | */ |
494 | static QString sortStringLabel(); | 495 | static QString sortStringLabel(); |
495 | 496 | ||
496 | /** | 497 | /** |
497 | Set URL. | 498 | Set URL. |
498 | */ | 499 | */ |
499 | void setUrl( const KURL &url ); | 500 | void setUrl( const KURL &url ); |
500 | /** | 501 | /** |
501 | Return URL. | 502 | Return URL. |
502 | */ | 503 | */ |
503 | KURL url() const; | 504 | KURL url() const; |
504 | /** | 505 | /** |
505 | Return translated label for url field. | 506 | Return translated label for url field. |
506 | */ | 507 | */ |
507 | static QString urlLabel(); | 508 | static QString urlLabel(); |
508 | 509 | ||
509 | /** | 510 | /** |
510 | Set security class. | 511 | Set security class. |
511 | */ | 512 | */ |
512 | void setSecrecy( const Secrecy &secrecy ); | 513 | void setSecrecy( const Secrecy &secrecy ); |
513 | /** | 514 | /** |
514 | Return security class. | 515 | Return security class. |
515 | */ | 516 | */ |
516 | Secrecy secrecy() const; | 517 | Secrecy secrecy() const; |
517 | /** | 518 | /** |
518 | Return translated label for secrecy field. | 519 | Return translated label for secrecy field. |
519 | */ | 520 | */ |
520 | static QString secrecyLabel(); | 521 | static QString secrecyLabel(); |
521 | 522 | ||
522 | /** | 523 | /** |
523 | Set logo. | 524 | Set logo. |
524 | */ | 525 | */ |
525 | void setLogo( const Picture &logo ); | 526 | void setLogo( const Picture &logo ); |
526 | /** | 527 | /** |
527 | Return logo. | 528 | Return logo. |
528 | */ | 529 | */ |
529 | Picture logo() const; | 530 | Picture logo() const; |
530 | /** | 531 | /** |
531 | Return translated label for logo field. | 532 | Return translated label for logo field. |
532 | */ | 533 | */ |
533 | static QString logoLabel(); | 534 | static QString logoLabel(); |
534 | 535 | ||
535 | /** | 536 | /** |
536 | Set photo. | 537 | Set photo. |
537 | */ | 538 | */ |
538 | void setPhoto( const Picture &photo ); | 539 | void setPhoto( const Picture &photo ); |
539 | /** | 540 | /** |
540 | Return photo. | 541 | Return photo. |
541 | */ | 542 | */ |
542 | Picture photo() const; | 543 | Picture photo() const; |
543 | /** | 544 | /** |
544 | Return translated label for photo field. | 545 | Return translated label for photo field. |
545 | */ | 546 | */ |
546 | static QString photoLabel(); | 547 | static QString photoLabel(); |
547 | 548 | ||
548 | /** | 549 | /** |
549 | Set sound. | 550 | Set sound. |
550 | */ | 551 | */ |
551 | void setSound( const Sound &sound ); | 552 | void setSound( const Sound &sound ); |
552 | /** | 553 | /** |
553 | Return sound. | 554 | Return sound. |
554 | */ | 555 | */ |
555 | Sound sound() const; | 556 | Sound sound() const; |
556 | /** | 557 | /** |
557 | Return translated label for sound field. | 558 | Return translated label for sound field. |
558 | */ | 559 | */ |
559 | static QString soundLabel(); | 560 | static QString soundLabel(); |
560 | 561 | ||
561 | /** | 562 | /** |
562 | Set agent. | 563 | Set agent. |
563 | */ | 564 | */ |
564 | void setAgent( const Agent &agent ); | 565 | void setAgent( const Agent &agent ); |
565 | /** | 566 | /** |
566 | Return agent. | 567 | Return agent. |
567 | */ | 568 | */ |
568 | Agent agent() const; | 569 | Agent agent() const; |
569 | /** | 570 | /** |
570 | Return translated label for agent field. | 571 | Return translated label for agent field. |
571 | */ | 572 | */ |
572 | static QString agentLabel(); | 573 | static QString agentLabel(); |
573 | 574 | ||
574 | /** | 575 | /** |
575 | Set name fields by parsing the given string and trying to associate the | 576 | Set name fields by parsing the given string and trying to associate the |
576 | parts of the string with according fields. This function should probably | 577 | parts of the string with according fields. This function should probably |
577 | be a bit more clever. | 578 | be a bit more clever. |
578 | */ | 579 | */ |
579 | void setNameFromString( const QString & ); | 580 | void setNameFromString( const QString & ); |
580 | 581 | ||
581 | /** | 582 | /** |
582 | Return the name of the addressee. This is calculated from all the name | 583 | Return the name of the addressee. This is calculated from all the name |
583 | fields. | 584 | fields. |
584 | */ | 585 | */ |
585 | QString realName() const; | 586 | QString realName() const; |
586 | 587 | ||
587 | /** | 588 | /** |
588 | Return the name that consists of all name parts. | 589 | Return the name that consists of all name parts. |
589 | */ | 590 | */ |
590 | QString assembledName() const; | 591 | QString assembledName() const; |
591 | 592 | ||
592 | /** | 593 | /** |
593 | Return email address including real name. | 594 | Return email address including real name. |
594 | 595 | ||
595 | @param email Email address to be used to construct the full email string. | 596 | @param email Email address to be used to construct the full email string. |
596 | If this is QString::null the preferred email address is used. | 597 | If this is QString::null the preferred email address is used. |
597 | */ | 598 | */ |
598 | QString fullEmail( const QString &email=QString::null ) const; | 599 | QString fullEmail( const QString &email=QString::null ) const; |
599 | 600 | ||
600 | /** | 601 | /** |
601 | Insert an email address. If the email address already exists in this | 602 | Insert an email address. If the email address already exists in this |
602 | addressee it is not duplicated. | 603 | addressee it is not duplicated. |
603 | 604 | ||
604 | @param email Email address | 605 | @param email Email address |
605 | @param preferred Set to true, if this is the preferred email address of | 606 | @param preferred Set to true, if this is the preferred email address of |
606 | the addressee. | 607 | the addressee. |
607 | */ | 608 | */ |
608 | void insertEmail( const QString &email, bool preferred=false ); | 609 | void insertEmail( const QString &email, bool preferred=false ); |
609 | 610 | ||
610 | /** | 611 | /** |
611 | Remove email address. If the email address doesn't exist, nothing happens. | 612 | Remove email address. If the email address doesn't exist, nothing happens. |
612 | */ | 613 | */ |
613 | void removeEmail( const QString &email ); | 614 | void removeEmail( const QString &email ); |
614 | 615 | ||
615 | /** | 616 | /** |
616 | Return preferred email address. This is the first email address or the | 617 | Return preferred email address. This is the first email address or the |
617 | last one added with @ref insertEmail() with a set preferred parameter. | 618 | last one added with @ref insertEmail() with a set preferred parameter. |
618 | */ | 619 | */ |
619 | QString preferredEmail() const; | 620 | QString preferredEmail() const; |
620 | 621 | ||
621 | /** | 622 | /** |
622 | Return list of all email addresses. | 623 | Return list of all email addresses. |
623 | */ | 624 | */ |
624 | QStringList emails() const; | 625 | QStringList emails() const; |
625 | 626 | ||
626 | /** | 627 | /** |
627 | Set the emails to @param. | 628 | Set the emails to @param. |
628 | The first email address gets the preferred one! | 629 | The first email address gets the preferred one! |
629 | @param list The list of email addresses. | 630 | @param list The list of email addresses. |
630 | */ | 631 | */ |
631 | void setEmails( const QStringList& list); | 632 | void setEmails( const QStringList& list); |
632 | 633 | ||
633 | /** | 634 | /** |
634 | Insert a phone number. If a phone number with the same id already exists | 635 | Insert a phone number. If a phone number with the same id already exists |
635 | in this addressee it is not duplicated. | 636 | in this addressee it is not duplicated. |
636 | */ | 637 | */ |
637 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 638 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
638 | 639 | ||
639 | /** | 640 | /** |
640 | Remove phone number. If no phone number with the given id exists for this | 641 | Remove phone number. If no phone number with the given id exists for this |
641 | addresse nothing happens. | 642 | addresse nothing happens. |
642 | */ | 643 | */ |
643 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 644 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
644 | 645 | ||
645 | /** | 646 | /** |
646 | Return phone number, which matches the given type. | 647 | Return phone number, which matches the given type. |
647 | */ | 648 | */ |
648 | PhoneNumber phoneNumber( int type ) const; | 649 | PhoneNumber phoneNumber( int type ) const; |
649 | 650 | ||
650 | /** | 651 | /** |
651 | Return list of all phone numbers. | 652 | Return list of all phone numbers. |
652 | */ | 653 | */ |
653 | PhoneNumber::List phoneNumbers() const; | 654 | PhoneNumber::List phoneNumbers() const; |
654 | 655 | ||
655 | /** | 656 | /** |
656 | Return list of phone numbers with a special type. | 657 | Return list of phone numbers with a special type. |
657 | */ | 658 | */ |
658 | PhoneNumber::List phoneNumbers( int type ) const; | 659 | PhoneNumber::List phoneNumbers( int type ) const; |
659 | 660 | ||
660 | /** | 661 | /** |
661 | Return phone number with the given id. | 662 | Return phone number with the given id. |
662 | */ | 663 | */ |
663 | PhoneNumber findPhoneNumber( const QString &id ) const; | 664 | PhoneNumber findPhoneNumber( const QString &id ) const; |
664 | 665 | ||
665 | /** | 666 | /** |
666 | Insert a key. If a key with the same id already exists | 667 | Insert a key. If a key with the same id already exists |
667 | in this addressee it is not duplicated. | 668 | in this addressee it is not duplicated. |
668 | */ | 669 | */ |
669 | void insertKey( const Key &key ); | 670 | void insertKey( const Key &key ); |
670 | 671 | ||
671 | /** | 672 | /** |
672 | Remove a key. If no key with the given id exists for this | 673 | Remove a key. If no key with the given id exists for this |
673 | addresse nothing happens. | 674 | addresse nothing happens. |
674 | */ | 675 | */ |
675 | void removeKey( const Key &key ); | 676 | void removeKey( const Key &key ); |
676 | 677 | ||
677 | /** | 678 | /** |
678 | Return key, which matches the given type. | 679 | Return key, which matches the given type. |
679 | If @p type == Key::Custom you can specify a string | 680 | If @p type == Key::Custom you can specify a string |
680 | that should match. If you leave the string empty, the first | 681 | that should match. If you leave the string empty, the first |
681 | key with a custom value is returned. | 682 | key with a custom value is returned. |
682 | */ | 683 | */ |
683 | Key key( int type, QString customTypeString = QString::null ) const; | 684 | Key key( int type, QString customTypeString = QString::null ) const; |
684 | 685 | ||
685 | /** | 686 | /** |
686 | Return list of all keys. | 687 | Return list of all keys. |
687 | */ | 688 | */ |
688 | Key::List keys() const; | 689 | Key::List keys() const; |
689 | 690 | ||
690 | /** | 691 | /** |
691 | Set the list of keys | 692 | Set the list of keys |
692 | @param keys The keys to be set. | 693 | @param keys The keys to be set. |
693 | */ | 694 | */ |
694 | void setKeys( const Key::List& keys); | 695 | void setKeys( const Key::List& keys); |
695 | 696 | ||
696 | /** | 697 | /** |
697 | Return list of keys with a special type. | 698 | Return list of keys with a special type. |
698 | If @p type == Key::Custom you can specify a string | 699 | If @p type == Key::Custom you can specify a string |
699 | that should match. If you leave the string empty, all custom | 700 | that should match. If you leave the string empty, all custom |
700 | keys will be returned. | 701 | keys will be returned. |
701 | */ | 702 | */ |
702 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 703 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
703 | 704 | ||
704 | /** | 705 | /** |
705 | Return key with the given id. | 706 | Return key with the given id. |
706 | */ | 707 | */ |
707 | Key findKey( const QString &id ) const; | 708 | Key findKey( const QString &id ) const; |
708 | 709 | ||
709 | /** | 710 | /** |
710 | Insert an address. If an address with the same id already exists | 711 | Insert an address. If an address with the same id already exists |
711 | in this addressee it is not duplicated. | 712 | in this addressee it is not duplicated. |
712 | */ | 713 | */ |
713 | void insertAddress( const Address &address ); | 714 | void insertAddress( const Address &address ); |
714 | 715 | ||
715 | /** | 716 | /** |
716 | Remove address. If no address with the given id exists for this | 717 | Remove address. If no address with the given id exists for this |
717 | addresse nothing happens. | 718 | addresse nothing happens. |
718 | */ | 719 | */ |
719 | void removeAddress( const Address &address ); | 720 | void removeAddress( const Address &address ); |
720 | 721 | ||
721 | /** | 722 | /** |
722 | Return address, which matches the given type. | 723 | Return address, which matches the given type. |
723 | */ | 724 | */ |
724 | Address address( int type ) const; | 725 | Address address( int type ) const; |
725 | 726 | ||
726 | /** | 727 | /** |
727 | Return list of all addresses. | 728 | Return list of all addresses. |
728 | */ | 729 | */ |
729 | Address::List addresses() const; | 730 | Address::List addresses() const; |
730 | 731 | ||
731 | /** | 732 | /** |
732 | Return list of addresses with a special type. | 733 | Return list of addresses with a special type. |
733 | */ | 734 | */ |
734 | Address::List addresses( int type ) const; | 735 | Address::List addresses( int type ) const; |
735 | 736 | ||
736 | /** | 737 | /** |
737 | Return address with the given id. | 738 | Return address with the given id. |
738 | */ | 739 | */ |
739 | Address findAddress( const QString &id ) const; | 740 | Address findAddress( const QString &id ) const; |
740 | 741 | ||
741 | /** | 742 | /** |
742 | Insert category. If the category already exists it is not duplicated. | 743 | Insert category. If the category already exists it is not duplicated. |
743 | */ | 744 | */ |
744 | void insertCategory( const QString & ); | 745 | void insertCategory( const QString & ); |
745 | 746 | ||
746 | /** | 747 | /** |
747 | Remove category. | 748 | Remove category. |
748 | */ | 749 | */ |
749 | void removeCategory( const QString & ); | 750 | void removeCategory( const QString & ); |
750 | 751 | ||
751 | /** | 752 | /** |
752 | Return, if addressee has the given category. | 753 | Return, if addressee has the given category. |
753 | */ | 754 | */ |
754 | bool hasCategory( const QString & ) const; | 755 | bool hasCategory( const QString & ) const; |
755 | 756 | ||
756 | /** | 757 | /** |
757 | Set categories to given value. | 758 | Set categories to given value. |
758 | */ | 759 | */ |
759 | void setCategories( const QStringList & ); | 760 | void setCategories( const QStringList & ); |
760 | 761 | ||
761 | /** | 762 | /** |
762 | Return list of all set categories. | 763 | Return list of all set categories. |
763 | */ | 764 | */ |
764 | QStringList categories() const; | 765 | QStringList categories() const; |
765 | 766 | ||
766 | /** | 767 | /** |
767 | Insert custom entry. The entry is identified by the name of the inserting | 768 | Insert custom entry. The entry is identified by the name of the inserting |
768 | application and a unique name. If an entry with the given app and name | 769 | application and a unique name. If an entry with the given app and name |
769 | already exists its value is replaced with the new given value. | 770 | already exists its value is replaced with the new given value. |
770 | */ | 771 | */ |
771 | void insertCustom( const QString &app, const QString &name, | 772 | void insertCustom( const QString &app, const QString &name, |
772 | const QString &value ); | 773 | const QString &value ); |
773 | 774 | ||
774 | /** | 775 | /** |
775 | Remove custom entry. | 776 | Remove custom entry. |
776 | */ | 777 | */ |
777 | void removeCustom( const QString &app, const QString &name ); | 778 | void removeCustom( const QString &app, const QString &name ); |
778 | 779 | ||
779 | /** | 780 | /** |
780 | Return value of custom entry, identified by app and entry name. | 781 | Return value of custom entry, identified by app and entry name. |
781 | */ | 782 | */ |
782 | QString custom( const QString &app, const QString &name ) const; | 783 | QString custom( const QString &app, const QString &name ) const; |
783 | 784 | ||
784 | /** | 785 | /** |
785 | Set all custom entries. | 786 | Set all custom entries. |
786 | */ | 787 | */ |
787 | void setCustoms( const QStringList & ); | 788 | void setCustoms( const QStringList & ); |
788 | 789 | ||
789 | /** | 790 | /** |
790 | Return list of all custom entries. | 791 | Return list of all custom entries. |
791 | */ | 792 | */ |
792 | QStringList customs() const; | 793 | QStringList customs() const; |
793 | 794 | ||
794 | /** | 795 | /** |
795 | Parse full email address. The result is given back in fullName and email. | 796 | Parse full email address. The result is given back in fullName and email. |
796 | */ | 797 | */ |
797 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 798 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
798 | QString &email ); | 799 | QString &email ); |
799 | 800 | ||
800 | /** | 801 | /** |
801 | Debug output. | 802 | Debug output. |
802 | */ | 803 | */ |
803 | void dump() const; | 804 | void dump() const; |
804 | 805 | ||
805 | /** | 806 | /** |
806 | Returns string representation of the addressee. | 807 | Returns string representation of the addressee. |
807 | */ | 808 | */ |
808 | QString asString() const; | 809 | QString asString() const; |
809 | 810 | ||
810 | /** | 811 | /** |
811 | Set resource where the addressee is from. | 812 | Set resource where the addressee is from. |
812 | */ | 813 | */ |
813 | void setResource( Resource *resource ); | 814 | void setResource( Resource *resource ); |
814 | 815 | ||
815 | /** | 816 | /** |
816 | Return pointer to resource. | 817 | Return pointer to resource. |
817 | */ | 818 | */ |
818 | Resource *resource() const; | 819 | Resource *resource() const; |
819 | 820 | ||
820 | /** | 821 | /** |
821 | Return resourcelabel. | 822 | Return resourcelabel. |
822 | */ | 823 | */ |
823 | //US | 824 | //US |
824 | static QString resourceLabel(); | 825 | static QString resourceLabel(); |
825 | 826 | ||
826 | /** | 827 | /** |
827 | Mark addressee as changed. | 828 | Mark addressee as changed. |
828 | */ | 829 | */ |
829 | void setChanged( bool value ); | 830 | void setChanged( bool value ); |
830 | 831 | ||
831 | /** | 832 | /** |
832 | Return whether the addressee is changed. | 833 | Return whether the addressee is changed. |
833 | */ | 834 | */ |
834 | bool changed() const; | 835 | bool changed() const; |
835 | 836 | ||
836 | void setTagged( bool value ); | 837 | void setTagged( bool value ); |
837 | bool tagged() const; | 838 | bool tagged() const; |
838 | 839 | ||
839 | private: | 840 | private: |
840 | Addressee copy(); | 841 | Addressee copy(); |
841 | void detach(); | 842 | void detach(); |
842 | 843 | ||
843 | struct AddresseeData; | 844 | struct AddresseeData; |
844 | mutable KSharedPtr<AddresseeData> mData; | 845 | mutable KSharedPtr<AddresseeData> mData; |
845 | }; | 846 | }; |
846 | 847 | ||
847 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 848 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
848 | QDataStream &operator>>( QDataStream &, Addressee & ); | 849 | QDataStream &operator>>( QDataStream &, Addressee & ); |
849 | 850 | ||
850 | } | 851 | } |
851 | 852 | ||
852 | #endif | 853 | #endif |
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp index e5abc0e..6e94c7e 100644 --- a/kabc/phonenumber.cpp +++ b/kabc/phonenumber.cpp | |||
@@ -1,225 +1,223 @@ | |||
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 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <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 | ||
33 | using namespace KABC; | 33 | using namespace KABC; |
34 | 34 | ||
35 | PhoneNumber::PhoneNumber() : | 35 | PhoneNumber::PhoneNumber() : |
36 | mType( Home ) | 36 | mType( Home ) |
37 | { | 37 | { |
38 | init(); | 38 | init(); |
39 | } | 39 | } |
40 | 40 | ||
41 | PhoneNumber::PhoneNumber( const QString &number, int type ) : | 41 | PhoneNumber::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 | ||
47 | PhoneNumber::~PhoneNumber() | 47 | PhoneNumber::~PhoneNumber() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | void PhoneNumber::init() | 51 | void PhoneNumber::init() |
52 | { | 52 | { |
53 | mId = KApplication::randomString( 8 ); | 53 | mId = KApplication::randomString( 8 ); |
54 | } | 54 | } |
55 | 55 | ||
56 | bool PhoneNumber::operator==( const PhoneNumber &p ) const | 56 | bool 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 | ||
64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const | 64 | bool PhoneNumber::operator!=( const PhoneNumber &p ) const |
65 | { | 65 | { |
66 | return !( p == *this ); | 66 | return !( p == *this ); |
67 | } | 67 | } |
68 | 68 | ||
69 | bool PhoneNumber::simplifyNumber() | 69 | bool 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 |
84 | void PhoneNumber::simplifyType() | 82 | void 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 | } |
92 | void PhoneNumber::setId( const QString &id ) | 90 | void PhoneNumber::setId( const QString &id ) |
93 | { | 91 | { |
94 | mId = id; | 92 | mId = id; |
95 | } | 93 | } |
96 | 94 | ||
97 | QString PhoneNumber::id() const | 95 | QString PhoneNumber::id() const |
98 | { | 96 | { |
99 | return mId; | 97 | return mId; |
100 | } | 98 | } |
101 | 99 | ||
102 | void PhoneNumber::setNumber( const QString &number ) | 100 | void PhoneNumber::setNumber( const QString &number ) |
103 | { | 101 | { |
104 | mNumber = number; | 102 | mNumber = number; |
105 | } | 103 | } |
106 | 104 | ||
107 | QString PhoneNumber::number() const | 105 | QString PhoneNumber::number() const |
108 | { | 106 | { |
109 | return mNumber; | 107 | return mNumber; |
110 | } | 108 | } |
111 | 109 | ||
112 | void PhoneNumber::setType( int type ) | 110 | void PhoneNumber::setType( int type ) |
113 | { | 111 | { |
114 | mType = type; | 112 | mType = type; |
115 | } | 113 | } |
116 | 114 | ||
117 | int PhoneNumber::type() const | 115 | int PhoneNumber::type() const |
118 | { | 116 | { |
119 | return mType; | 117 | return mType; |
120 | } | 118 | } |
121 | 119 | ||
122 | QString PhoneNumber::typeLabel() const | 120 | QString 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 | ||
141 | QString PhoneNumber::label() const | 139 | QString PhoneNumber::label() const |
142 | { | 140 | { |
143 | return typeLabel( type() ); | 141 | return typeLabel( type() ); |
144 | } | 142 | } |
145 | 143 | ||
146 | PhoneNumber::TypeList PhoneNumber::typeList() | 144 | PhoneNumber::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 | ||
156 | QString PhoneNumber::label( int type ) | 154 | QString PhoneNumber::label( int type ) |
157 | { | 155 | { |
158 | return typeLabel( type ); | 156 | return typeLabel( type ); |
159 | } | 157 | } |
160 | 158 | ||
161 | QString PhoneNumber::typeLabel( int type ) | 159 | QString 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"); |
175 | else if ((type & Fax) == Fax) | 173 | else if ((type & Fax) == Fax) |
176 | typeString += i18n("Fax"); | 174 | typeString += i18n("Fax"); |
177 | else if ((type & Msg) == Msg) | 175 | else if ((type & Msg) == Msg) |
178 | typeString += i18n("Messenger"); | 176 | typeString += i18n("Messenger"); |
179 | else if ((type & Voice) == Voice) { | 177 | else if ((type & Voice) == Voice) { |
180 | // add nothing in case of the Voice flag | 178 | // add nothing in case of the Voice flag |
181 | // typeString += i18n("Voice"); | 179 | // typeString += i18n("Voice"); |
182 | } | 180 | } |
183 | else if ((type & Video) == Video) | 181 | else if ((type & Video) == Video) |
184 | typeString += i18n("Video"); | 182 | typeString += i18n("Video"); |
185 | else if ((type & Bbs) == Bbs) | 183 | else if ((type & Bbs) == Bbs) |
186 | typeString += i18n("Mailbox"); | 184 | typeString += i18n("Mailbox"); |
187 | else if ((type & Modem) == Modem) | 185 | else if ((type & Modem) == Modem) |
188 | typeString += i18n("Modem"); | 186 | typeString += i18n("Modem"); |
189 | else if ((type & Car) == Car) | 187 | else if ((type & Car) == Car) |
190 | typeString += i18n("Car"); | 188 | typeString += i18n("Car"); |
191 | else if ((type & Isdn) == Isdn) | 189 | else if ((type & Isdn) == Isdn) |
192 | typeString += i18n("ISDN"); | 190 | typeString += i18n("ISDN"); |
193 | else if ((type & Pcs) == Pcs) | 191 | else if ((type & Pcs) == Pcs) |
194 | typeString += i18n("PCS"); | 192 | typeString += i18n("PCS"); |
195 | else if ((type & Pager) == Pager) | 193 | else if ((type & Pager) == Pager) |
196 | typeString += i18n("Pager"); | 194 | typeString += i18n("Pager"); |
197 | else if ((type & Sip) == Sip) | 195 | else if ((type & Sip) == Sip) |
198 | typeString += i18n("SIP"); | 196 | typeString += i18n("SIP"); |
199 | 197 | ||
200 | // add the prefered flag | 198 | // add the prefered flag |
201 | if (!typeString.isEmpty()) | 199 | if (!typeString.isEmpty()) |
202 | typeString += " "; | 200 | typeString += " "; |
203 | 201 | ||
204 | if ((type & Pref) == Pref) | 202 | if ((type & Pref) == Pref) |
205 | typeString += i18n("(p)"); | 203 | typeString += i18n("(p)"); |
206 | 204 | ||
207 | //if we still have no match, return "other" | 205 | //if we still have no match, return "other" |
208 | if (typeString.isEmpty()) | 206 | if (typeString.isEmpty()) |
209 | return i18n("Other"); | 207 | return i18n("Other"); |
210 | 208 | ||
211 | 209 | ||
212 | return typeString; | 210 | return typeString; |
213 | } | 211 | } |
214 | 212 | ||
215 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) | 213 | QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) |
216 | { | 214 | { |
217 | return s << phone.mId << phone.mType << phone.mNumber; | 215 | return s << phone.mId << phone.mType << phone.mNumber; |
218 | } | 216 | } |
219 | 217 | ||
220 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) | 218 | QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) |
221 | { | 219 | { |
222 | s >> phone.mId >> phone.mType >> phone.mNumber; | 220 | s >> phone.mId >> phone.mType >> phone.mNumber; |
223 | 221 | ||
224 | return s; | 222 | return s; |
225 | } | 223 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index a7967cb..cd261f6 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2924 +1,2872 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | 134 | ||
135 | #include <libkdepim/categoryselectdialog.h> | 135 | #include <libkdepim/categoryselectdialog.h> |
136 | #include <kabc/vcardconverter.h> | 136 | #include <kabc/vcardconverter.h> |
137 | 137 | ||
138 | 138 | ||
139 | #include "addresseeutil.h" | 139 | #include "addresseeutil.h" |
140 | #include "undocmds.h" | 140 | #include "undocmds.h" |
141 | #include "addresseeeditordialog.h" | 141 | #include "addresseeeditordialog.h" |
142 | #include "viewmanager.h" | 142 | #include "viewmanager.h" |
143 | #include "details/detailsviewcontainer.h" | 143 | #include "details/detailsviewcontainer.h" |
144 | #include "kabprefs.h" | 144 | #include "kabprefs.h" |
145 | #include "xxportmanager.h" | 145 | #include "xxportmanager.h" |
146 | #include "incsearchwidget.h" | 146 | #include "incsearchwidget.h" |
147 | #include "jumpbuttonbar.h" | 147 | #include "jumpbuttonbar.h" |
148 | #include "extensionmanager.h" | 148 | #include "extensionmanager.h" |
149 | #include "addresseeconfig.h" | 149 | #include "addresseeconfig.h" |
150 | #include <kcmultidialog.h> | 150 | #include <kcmultidialog.h> |
151 | 151 | ||
152 | #ifdef _WIN32_ | 152 | #ifdef _WIN32_ |
153 | 153 | ||
154 | #include "kaimportoldialog.h" | 154 | #include "kaimportoldialog.h" |
155 | #else | 155 | #else |
156 | #include <unistd.h> | 156 | #include <unistd.h> |
157 | #endif | 157 | #endif |
158 | // sync includes | 158 | // sync includes |
159 | #include <libkdepim/ksyncprofile.h> | 159 | #include <libkdepim/ksyncprofile.h> |
160 | #include <libkdepim/ksyncprefsdialog.h> | 160 | #include <libkdepim/ksyncprefsdialog.h> |
161 | 161 | ||
162 | class KAex2phonePrefs : public QDialog | 162 | class 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 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | bool pasteWithNewUid = true; | 207 | bool pasteWithNewUid = true; |
208 | 208 | ||
209 | #ifdef KAB_EMBEDDED | 209 | #ifdef KAB_EMBEDDED |
210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
214 | #else //KAB_EMBEDDED | 214 | #else //KAB_EMBEDDED |
215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
218 | mReadWrite( readWrite ), mModified( false ) | 218 | mReadWrite( readWrite ), mModified( false ) |
219 | #endif //KAB_EMBEDDED | 219 | #endif //KAB_EMBEDDED |
220 | { | 220 | { |
221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
222 | // syncManager->setBlockSave(false); | 222 | // syncManager->setBlockSave(false); |
223 | mExtensionBarSplitter = 0; | 223 | mExtensionBarSplitter = 0; |
224 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 224 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
225 | 225 | ||
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | 323 | ||
324 | delete syncManager; | 324 | delete syncManager; |
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | void KABCore::recieve( QString fn ) | 328 | void KABCore::recieve( QString fn ) |
329 | { | 329 | { |
330 | //qDebug("KABCore::recieve "); | 330 | //qDebug("KABCore::recieve "); |
331 | mAddressBook->importFromFile( fn, true ); | 331 | mAddressBook->importFromFile( fn, true ); |
332 | mViewManager->refreshView(); | 332 | mViewManager->refreshView(); |
333 | topLevelWidget()->raise(); | 333 | topLevelWidget()->raise(); |
334 | } | 334 | } |
335 | void KABCore::restoreSettings() | 335 | void KABCore::restoreSettings() |
336 | { | 336 | { |
337 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 337 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
338 | 338 | ||
339 | bool state; | 339 | bool state; |
340 | 340 | ||
341 | if (mMultipleViewsAtOnce) | 341 | if (mMultipleViewsAtOnce) |
342 | state = KABPrefs::instance()->mDetailsPageVisible; | 342 | state = KABPrefs::instance()->mDetailsPageVisible; |
343 | else | 343 | else |
344 | state = false; | 344 | state = false; |
345 | 345 | ||
346 | mActionDetails->setChecked( state ); | 346 | mActionDetails->setChecked( state ); |
347 | setDetailsVisible( state ); | 347 | setDetailsVisible( state ); |
348 | 348 | ||
349 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 349 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
350 | 350 | ||
351 | mActionJumpBar->setChecked( state ); | 351 | mActionJumpBar->setChecked( state ); |
352 | setJumpButtonBarVisible( state ); | 352 | setJumpButtonBarVisible( state ); |
353 | /*US | 353 | /*US |
354 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 354 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
355 | if ( splitterSize.count() == 0 ) { | 355 | if ( splitterSize.count() == 0 ) { |
356 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
357 | splitterSize.append( width() / 2 ); | 357 | splitterSize.append( width() / 2 ); |
358 | } | 358 | } |
359 | mMiniSplitter->setSizes( splitterSize ); | 359 | mMiniSplitter->setSizes( splitterSize ); |
360 | if ( mExtensionBarSplitter ) { | 360 | if ( mExtensionBarSplitter ) { |
361 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 361 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
362 | if ( splitterSize.count() == 0 ) { | 362 | if ( splitterSize.count() == 0 ) { |
363 | splitterSize.append( width() / 2 ); | 363 | splitterSize.append( width() / 2 ); |
364 | splitterSize.append( width() / 2 ); | 364 | splitterSize.append( width() / 2 ); |
365 | } | 365 | } |
366 | mExtensionBarSplitter->setSizes( splitterSize ); | 366 | mExtensionBarSplitter->setSizes( splitterSize ); |
367 | 367 | ||
368 | } | 368 | } |
369 | */ | 369 | */ |
370 | mViewManager->restoreSettings(); | 370 | mViewManager->restoreSettings(); |
371 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 371 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
372 | mExtensionManager->restoreSettings(); | 372 | mExtensionManager->restoreSettings(); |
373 | #ifdef DESKTOP_VERSION | 373 | #ifdef DESKTOP_VERSION |
374 | int wid = width(); | 374 | int wid = width(); |
375 | if ( wid < 10 ) | 375 | if ( wid < 10 ) |
376 | wid = 400; | 376 | wid = 400; |
377 | #else | 377 | #else |
378 | int wid = QApplication::desktop()->width(); | 378 | int wid = QApplication::desktop()->width(); |
379 | if ( wid < 640 ) | 379 | if ( wid < 640 ) |
380 | wid = QApplication::desktop()->height(); | 380 | wid = QApplication::desktop()->height(); |
381 | #endif | 381 | #endif |
382 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 382 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
383 | if ( true /*splitterSize.count() == 0*/ ) { | 383 | if ( true /*splitterSize.count() == 0*/ ) { |
384 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
385 | splitterSize.append( wid / 2 ); | 385 | splitterSize.append( wid / 2 ); |
386 | } | 386 | } |
387 | mMiniSplitter->setSizes( splitterSize ); | 387 | mMiniSplitter->setSizes( splitterSize ); |
388 | if ( mExtensionBarSplitter ) { | 388 | if ( mExtensionBarSplitter ) { |
389 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 389 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
390 | if ( true /*splitterSize.count() == 0*/ ) { | 390 | if ( true /*splitterSize.count() == 0*/ ) { |
391 | splitterSize.append( wid / 2 ); | 391 | splitterSize.append( wid / 2 ); |
392 | splitterSize.append( wid / 2 ); | 392 | splitterSize.append( wid / 2 ); |
393 | } | 393 | } |
394 | mExtensionBarSplitter->setSizes( splitterSize ); | 394 | mExtensionBarSplitter->setSizes( splitterSize ); |
395 | 395 | ||
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | void KABCore::saveSettings() | 401 | void KABCore::saveSettings() |
402 | { | 402 | { |
403 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 403 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
404 | if ( mExtensionBarSplitter ) | 404 | if ( mExtensionBarSplitter ) |
405 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 405 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
406 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 406 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
407 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 407 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
408 | #ifndef KAB_EMBEDDED | 408 | #ifndef KAB_EMBEDDED |
409 | 409 | ||
410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
411 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 411 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
412 | #endif //KAB_EMBEDDED | 412 | #endif //KAB_EMBEDDED |
413 | mExtensionManager->saveSettings(); | 413 | mExtensionManager->saveSettings(); |
414 | mViewManager->saveSettings(); | 414 | mViewManager->saveSettings(); |
415 | 415 | ||
416 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 416 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
417 | } | 417 | } |
418 | 418 | ||
419 | KABC::AddressBook *KABCore::addressBook() const | 419 | KABC::AddressBook *KABCore::addressBook() const |
420 | { | 420 | { |
421 | return mAddressBook; | 421 | return mAddressBook; |
422 | } | 422 | } |
423 | 423 | ||
424 | KConfig *KABCore::config() | 424 | KConfig *KABCore::config() |
425 | { | 425 | { |
426 | #ifndef KAB_EMBEDDED | 426 | #ifndef KAB_EMBEDDED |
427 | return KABPrefs::instance()->config(); | 427 | return KABPrefs::instance()->config(); |
428 | #else //KAB_EMBEDDED | 428 | #else //KAB_EMBEDDED |
429 | return KABPrefs::instance()->getConfig(); | 429 | return KABPrefs::instance()->getConfig(); |
430 | #endif //KAB_EMBEDDED | 430 | #endif //KAB_EMBEDDED |
431 | } | 431 | } |
432 | 432 | ||
433 | KActionCollection *KABCore::actionCollection() const | 433 | KActionCollection *KABCore::actionCollection() const |
434 | { | 434 | { |
435 | return mGUIClient->actionCollection(); | 435 | return mGUIClient->actionCollection(); |
436 | } | 436 | } |
437 | 437 | ||
438 | KABC::Field *KABCore::currentSearchField() const | 438 | KABC::Field *KABCore::currentSearchField() const |
439 | { | 439 | { |
440 | if (mIncSearchWidget) | 440 | if (mIncSearchWidget) |
441 | return mIncSearchWidget->currentField(); | 441 | return mIncSearchWidget->currentField(); |
442 | else | 442 | else |
443 | return 0; | 443 | return 0; |
444 | } | 444 | } |
445 | 445 | ||
446 | QStringList KABCore::selectedUIDs() const | 446 | QStringList KABCore::selectedUIDs() const |
447 | { | 447 | { |
448 | return mViewManager->selectedUids(); | 448 | return mViewManager->selectedUids(); |
449 | } | 449 | } |
450 | 450 | ||
451 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 451 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
452 | { | 452 | { |
453 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 453 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
454 | 454 | ||
455 | QPtrList<KRES::Resource> kresResources; | 455 | QPtrList<KRES::Resource> kresResources; |
456 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 456 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
457 | KABC::Resource *resource; | 457 | KABC::Resource *resource; |
458 | while ( ( resource = resIt.current() ) != 0 ) { | 458 | while ( ( resource = resIt.current() ) != 0 ) { |
459 | ++resIt; | 459 | ++resIt; |
460 | if ( !resource->readOnly() ) { | 460 | if ( !resource->readOnly() ) { |
461 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 461 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
462 | if ( res ) | 462 | if ( res ) |
463 | kresResources.append( res ); | 463 | kresResources.append( res ); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 467 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
468 | return static_cast<KABC::Resource*>( res ); | 468 | return static_cast<KABC::Resource*>( res ); |
469 | } | 469 | } |
470 | 470 | ||
471 | #ifndef KAB_EMBEDDED | 471 | #ifndef KAB_EMBEDDED |
472 | KAboutData *KABCore::createAboutData() | 472 | KAboutData *KABCore::createAboutData() |
473 | #else //KAB_EMBEDDED | 473 | #else //KAB_EMBEDDED |
474 | void KABCore::createAboutData() | 474 | void KABCore::createAboutData() |
475 | #endif //KAB_EMBEDDED | 475 | #endif //KAB_EMBEDDED |
476 | { | 476 | { |
477 | #ifndef KAB_EMBEDDED | 477 | #ifndef KAB_EMBEDDED |
478 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 478 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
479 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 479 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
480 | KAboutData::License_GPL_V2, | 480 | KAboutData::License_GPL_V2, |
481 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 481 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
482 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 482 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
483 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 483 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
484 | about->addAuthor( "Cornelius Schumacher", | 484 | about->addAuthor( "Cornelius Schumacher", |
485 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 485 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
486 | "schumacher@kde.org" ); | 486 | "schumacher@kde.org" ); |
487 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 487 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
488 | "mpilone@slac.com" ); | 488 | "mpilone@slac.com" ); |
489 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 489 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
490 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 490 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
491 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 491 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
492 | "michel@klaralvdalens-datakonsult.se" ); | 492 | "michel@klaralvdalens-datakonsult.se" ); |
493 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 493 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
494 | "hansen@kde.org" ); | 494 | "hansen@kde.org" ); |
495 | 495 | ||
496 | return about; | 496 | return about; |
497 | #endif //KAB_EMBEDDED | 497 | #endif //KAB_EMBEDDED |
498 | 498 | ||
499 | QString version; | 499 | QString version; |
500 | #include <../version> | 500 | #include <../version> |
501 | QMessageBox::about( this, "About KAddressbook/Pi", | 501 | QMessageBox::about( this, "About KAddressbook/Pi", |
502 | "KAddressbook/Platform-independent\n" | 502 | "KAddressbook/Platform-independent\n" |
503 | "(KA/Pi) " +version + " - " + | 503 | "(KA/Pi) " +version + " - " + |
504 | #ifdef DESKTOP_VERSION | 504 | #ifdef DESKTOP_VERSION |
505 | "Desktop Edition\n" | 505 | "Desktop Edition\n" |
506 | #else | 506 | #else |
507 | "PDA-Edition\n" | 507 | "PDA-Edition\n" |
508 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 508 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
509 | #endif | 509 | #endif |
510 | 510 | ||
511 | "(c) 2004 Ulf Schenk\n" | 511 | "(c) 2004 Ulf Schenk\n" |
512 | "(c) 2004 Lutz Rogowski\n" | 512 | "(c) 2004 Lutz Rogowski\n" |
513 | "(c) 1997-2003, The KDE PIM Team\n" | 513 | "(c) 1997-2003, The KDE PIM Team\n" |
514 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 514 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
515 | "Don Sanders Original author\n" | 515 | "Don Sanders Original author\n" |
516 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 516 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
517 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 517 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
518 | "Greg Stern DCOP interface\n" | 518 | "Greg Stern DCOP interface\n" |
519 | "Mark Westcot Contact pinning\n" | 519 | "Mark Westcot Contact pinning\n" |
520 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 520 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
521 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 521 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
522 | #ifdef _WIN32_ | 522 | #ifdef _WIN32_ |
523 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 523 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
524 | #endif | 524 | #endif |
525 | ); | 525 | ); |
526 | } | 526 | } |
527 | 527 | ||
528 | void KABCore::setContactSelected( const QString &uid ) | 528 | void KABCore::setContactSelected( const QString &uid ) |
529 | { | 529 | { |
530 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 530 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
531 | if ( !mDetails->isHidden() ) | 531 | if ( !mDetails->isHidden() ) |
532 | mDetails->setAddressee( addr ); | 532 | mDetails->setAddressee( addr ); |
533 | 533 | ||
534 | if ( !addr.isEmpty() ) { | 534 | if ( !addr.isEmpty() ) { |
535 | emit contactSelected( addr.formattedName() ); | 535 | emit contactSelected( addr.formattedName() ); |
536 | KABC::Picture pic = addr.photo(); | 536 | KABC::Picture pic = addr.photo(); |
537 | if ( pic.isIntern() ) { | 537 | if ( pic.isIntern() ) { |
538 | //US emit contactSelected( pic.data() ); | 538 | //US emit contactSelected( pic.data() ); |
539 | //US instead use: | 539 | //US instead use: |
540 | QPixmap px; | 540 | QPixmap px; |
541 | if (pic.data().isNull() != true) | 541 | if (pic.data().isNull() != true) |
542 | { | 542 | { |
543 | px.convertFromImage(pic.data()); | 543 | px.convertFromImage(pic.data()); |
544 | } | 544 | } |
545 | 545 | ||
546 | emit contactSelected( px ); | 546 | emit contactSelected( px ); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | mExtensionManager->setSelectionChanged(); | 551 | mExtensionManager->setSelectionChanged(); |
552 | 552 | ||
553 | // update the actions | 553 | // update the actions |
554 | bool selected = !uid.isEmpty(); | 554 | bool selected = !uid.isEmpty(); |
555 | 555 | ||
556 | if ( mReadWrite ) { | 556 | if ( mReadWrite ) { |
557 | mActionCut->setEnabled( selected ); | 557 | mActionCut->setEnabled( selected ); |
558 | mActionPaste->setEnabled( selected ); | 558 | mActionPaste->setEnabled( selected ); |
559 | } | 559 | } |
560 | 560 | ||
561 | mActionCopy->setEnabled( selected ); | 561 | mActionCopy->setEnabled( selected ); |
562 | mActionDelete->setEnabled( selected ); | 562 | mActionDelete->setEnabled( selected ); |
563 | mActionEditAddressee->setEnabled( selected ); | 563 | mActionEditAddressee->setEnabled( selected ); |
564 | mActionMail->setEnabled( selected ); | 564 | mActionMail->setEnabled( selected ); |
565 | mActionMailVCard->setEnabled( selected ); | 565 | mActionMailVCard->setEnabled( selected ); |
566 | //if (mActionBeam) | 566 | //if (mActionBeam) |
567 | //mActionBeam->setEnabled( selected ); | 567 | //mActionBeam->setEnabled( selected ); |
568 | 568 | ||
569 | if (mActionBeamVCard) | 569 | if (mActionBeamVCard) |
570 | mActionBeamVCard->setEnabled( selected ); | 570 | mActionBeamVCard->setEnabled( selected ); |
571 | 571 | ||
572 | mActionExport2phone->setEnabled( selected ); | 572 | mActionExport2phone->setEnabled( selected ); |
573 | mActionWhoAmI->setEnabled( selected ); | 573 | mActionWhoAmI->setEnabled( selected ); |
574 | mActionCategories->setEnabled( selected ); | 574 | mActionCategories->setEnabled( selected ); |
575 | } | 575 | } |
576 | 576 | ||
577 | void KABCore::sendMail() | 577 | void KABCore::sendMail() |
578 | { | 578 | { |
579 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 579 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
580 | } | 580 | } |
581 | 581 | ||
582 | void KABCore::sendMail( const QString& emaillist ) | 582 | void KABCore::sendMail( const QString& emaillist ) |
583 | { | 583 | { |
584 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 584 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
585 | if (emaillist.contains(",") > 0) | 585 | if (emaillist.contains(",") > 0) |
586 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 586 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
587 | else | 587 | else |
588 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 588 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
589 | } | 589 | } |
590 | 590 | ||
591 | 591 | ||
592 | 592 | ||
593 | void KABCore::mailVCard() | 593 | void KABCore::mailVCard() |
594 | { | 594 | { |
595 | QStringList uids = mViewManager->selectedUids(); | 595 | QStringList uids = mViewManager->selectedUids(); |
596 | if ( !uids.isEmpty() ) | 596 | if ( !uids.isEmpty() ) |
597 | mailVCard( uids ); | 597 | mailVCard( uids ); |
598 | } | 598 | } |
599 | 599 | ||
600 | void KABCore::mailVCard( const QStringList& uids ) | 600 | void KABCore::mailVCard( const QStringList& uids ) |
601 | { | 601 | { |
602 | QStringList urls; | 602 | QStringList urls; |
603 | 603 | ||
604 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 604 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
605 | 605 | ||
606 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 606 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
607 | 607 | ||
608 | 608 | ||
609 | 609 | ||
610 | QDir().mkdir( dirName, true ); | 610 | QDir().mkdir( dirName, true ); |
611 | 611 | ||
612 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 612 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
613 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 613 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
614 | 614 | ||
615 | if ( a.isEmpty() ) | 615 | if ( a.isEmpty() ) |
616 | continue; | 616 | continue; |
617 | 617 | ||
618 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 618 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
619 | 619 | ||
620 | QString fileName = dirName + "/" + name; | 620 | QString fileName = dirName + "/" + name; |
621 | 621 | ||
622 | QFile outFile(fileName); | 622 | QFile outFile(fileName); |
623 | 623 | ||
624 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 624 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
625 | KABC::VCardConverter converter; | 625 | KABC::VCardConverter converter; |
626 | QString vcard; | 626 | QString vcard; |
627 | 627 | ||
628 | converter.addresseeToVCard( a, vcard ); | 628 | converter.addresseeToVCard( a, vcard ); |
629 | 629 | ||
630 | QTextStream t( &outFile ); // use a text stream | 630 | QTextStream t( &outFile ); // use a text stream |
631 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 631 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
632 | t << vcard; | 632 | t << vcard; |
633 | 633 | ||
634 | outFile.close(); | 634 | outFile.close(); |
635 | 635 | ||
636 | urls.append( fileName ); | 636 | urls.append( fileName ); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | 639 | ||
640 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 640 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
641 | 641 | ||
642 | 642 | ||
643 | /*US | 643 | /*US |
644 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 644 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
645 | QString::null, // subject | 645 | QString::null, // subject |
646 | QString::null, // body | 646 | QString::null, // body |
647 | QString::null, | 647 | QString::null, |
648 | urls ); // attachments | 648 | urls ); // attachments |
649 | */ | 649 | */ |
650 | 650 | ||
651 | } | 651 | } |
652 | 652 | ||
653 | /** | 653 | /** |
654 | Beams the "WhoAmI contact. | 654 | Beams the "WhoAmI contact. |
655 | */ | 655 | */ |
656 | void KABCore::beamMySelf() | 656 | void KABCore::beamMySelf() |
657 | { | 657 | { |
658 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 658 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
659 | if (!a.isEmpty()) | 659 | if (!a.isEmpty()) |
660 | { | 660 | { |
661 | QStringList uids; | 661 | QStringList uids; |
662 | uids << a.uid(); | 662 | uids << a.uid(); |
663 | 663 | ||
664 | beamVCard(uids); | 664 | beamVCard(uids); |
665 | } else { | 665 | } else { |
666 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 666 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
667 | 667 | ||
668 | 668 | ||
669 | } | 669 | } |
670 | } | 670 | } |
671 | 671 | ||
672 | void KABCore::export2phone() | 672 | void KABCore::export2phone() |
673 | { | 673 | { |
674 | 674 | ||
675 | KAex2phonePrefs ex2phone; | 675 | KAex2phonePrefs ex2phone; |
676 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 676 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
677 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 677 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
678 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 678 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
679 | 679 | ||
680 | if ( !ex2phone.exec() ) { | 680 | if ( !ex2phone.exec() ) { |
681 | return; | 681 | return; |
682 | } | 682 | } |
683 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 683 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
684 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 684 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
685 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 685 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
686 | 686 | ||
687 | 687 | ||
688 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 688 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
689 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 689 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
690 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 690 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
691 | 691 | ||
692 | QStringList uids = mViewManager->selectedUids(); | 692 | QStringList uids = mViewManager->selectedUids(); |
693 | if ( uids.isEmpty() ) | 693 | if ( uids.isEmpty() ) |
694 | return; | 694 | return; |
695 | 695 | ||
696 | #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 | } |
777 | void KABCore::beamVCard() | 722 | void 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 | ||
785 | void KABCore::beamVCard(const QStringList& uids) | 730 | void 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); |
861 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 806 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
862 | start = sep; | 807 | start = sep; |
863 | } | 808 | } |
864 | datastream += vcard.mid( start,vcard.length() ); | 809 | datastream += vcard.mid( start,vcard.length() ); |
865 | } | 810 | } |
866 | #ifndef DESKTOP_VERSION | 811 | #ifndef DESKTOP_VERSION |
867 | QFile outFile(fileName); | 812 | QFile outFile(fileName); |
868 | if ( outFile.open(IO_WriteOnly) ) { | 813 | if ( outFile.open(IO_WriteOnly) ) { |
869 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 814 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
870 | QTextStream t( &outFile ); // use a text stream | 815 | QTextStream t( &outFile ); // use a text stream |
871 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 816 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
872 | t <<datastream; | 817 | t <<datastream; |
873 | outFile.close(); | 818 | outFile.close(); |
874 | Ir *ir = new Ir( this ); | 819 | Ir *ir = new Ir( this ); |
875 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 820 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
876 | ir->send( fileName, description, "text/x-vCard" ); | 821 | ir->send( fileName, description, "text/x-vCard" ); |
877 | } else { | 822 | } else { |
878 | qDebug("Error open temp beam file "); | 823 | qDebug("Error open temp beam file "); |
879 | return; | 824 | return; |
880 | } | 825 | } |
881 | #endif | 826 | #endif |
882 | 827 | ||
883 | } | 828 | } |
884 | 829 | ||
885 | void KABCore::beamDone( Ir *ir ) | 830 | void KABCore::beamDone( Ir *ir ) |
886 | { | 831 | { |
887 | #ifndef DESKTOP_VERSION | 832 | #ifndef DESKTOP_VERSION |
888 | delete ir; | 833 | delete ir; |
889 | #endif | 834 | #endif |
890 | } | 835 | } |
891 | 836 | ||
892 | 837 | ||
893 | void KABCore::browse( const QString& url ) | 838 | void KABCore::browse( const QString& url ) |
894 | { | 839 | { |
895 | #ifndef KAB_EMBEDDED | 840 | #ifndef KAB_EMBEDDED |
896 | kapp->invokeBrowser( url ); | 841 | kapp->invokeBrowser( url ); |
897 | #else //KAB_EMBEDDED | 842 | #else //KAB_EMBEDDED |
898 | qDebug("KABCore::browse must be fixed"); | 843 | qDebug("KABCore::browse must be fixed"); |
899 | #endif //KAB_EMBEDDED | 844 | #endif //KAB_EMBEDDED |
900 | } | 845 | } |
901 | 846 | ||
902 | void KABCore::selectAllContacts() | 847 | void KABCore::selectAllContacts() |
903 | { | 848 | { |
904 | mViewManager->setSelected( QString::null, true ); | 849 | mViewManager->setSelected( QString::null, true ); |
905 | } | 850 | } |
906 | 851 | ||
907 | void KABCore::deleteContacts() | 852 | void KABCore::deleteContacts() |
908 | { | 853 | { |
909 | QStringList uidList = mViewManager->selectedUids(); | 854 | QStringList uidList = mViewManager->selectedUids(); |
910 | deleteContacts( uidList ); | 855 | deleteContacts( uidList ); |
911 | } | 856 | } |
912 | 857 | ||
913 | void KABCore::deleteContacts( const QStringList &uids ) | 858 | void KABCore::deleteContacts( const QStringList &uids ) |
914 | { | 859 | { |
915 | if ( uids.count() > 0 ) { | 860 | if ( uids.count() > 0 ) { |
916 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 861 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
917 | UndoStack::instance()->push( command ); | 862 | UndoStack::instance()->push( command ); |
918 | RedoStack::instance()->clear(); | 863 | RedoStack::instance()->clear(); |
919 | 864 | ||
920 | // now if we deleted anything, refresh | 865 | // now if we deleted anything, refresh |
921 | setContactSelected( QString::null ); | 866 | setContactSelected( QString::null ); |
922 | setModified( true ); | 867 | setModified( true ); |
923 | } | 868 | } |
924 | } | 869 | } |
925 | 870 | ||
926 | void KABCore::copyContacts() | 871 | void KABCore::copyContacts() |
927 | { | 872 | { |
928 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 873 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
929 | 874 | ||
930 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 875 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
931 | 876 | ||
932 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 877 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
933 | 878 | ||
934 | QClipboard *cb = QApplication::clipboard(); | 879 | QClipboard *cb = QApplication::clipboard(); |
935 | cb->setText( clipText ); | 880 | cb->setText( clipText ); |
936 | } | 881 | } |
937 | 882 | ||
938 | void KABCore::cutContacts() | 883 | void KABCore::cutContacts() |
939 | { | 884 | { |
940 | QStringList uidList = mViewManager->selectedUids(); | 885 | QStringList uidList = mViewManager->selectedUids(); |
941 | 886 | ||
942 | //US if ( uidList.size() > 0 ) { | 887 | //US if ( uidList.size() > 0 ) { |
943 | if ( uidList.count() > 0 ) { | 888 | if ( uidList.count() > 0 ) { |
944 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 889 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
945 | UndoStack::instance()->push( command ); | 890 | UndoStack::instance()->push( command ); |
946 | RedoStack::instance()->clear(); | 891 | RedoStack::instance()->clear(); |
947 | 892 | ||
948 | setModified( true ); | 893 | setModified( true ); |
949 | } | 894 | } |
950 | } | 895 | } |
951 | 896 | ||
952 | void KABCore::pasteContacts() | 897 | void KABCore::pasteContacts() |
953 | { | 898 | { |
954 | QClipboard *cb = QApplication::clipboard(); | 899 | QClipboard *cb = QApplication::clipboard(); |
955 | 900 | ||
956 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 901 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
957 | 902 | ||
958 | pasteContacts( list ); | 903 | pasteContacts( list ); |
959 | } | 904 | } |
960 | 905 | ||
961 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 906 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
962 | { | 907 | { |
963 | KABC::Resource *resource = requestResource( this ); | 908 | KABC::Resource *resource = requestResource( this ); |
964 | KABC::Addressee::List::Iterator it; | 909 | KABC::Addressee::List::Iterator it; |
965 | for ( it = list.begin(); it != list.end(); ++it ) | 910 | for ( it = list.begin(); it != list.end(); ++it ) |
966 | (*it).setResource( resource ); | 911 | (*it).setResource( resource ); |
967 | 912 | ||
968 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 913 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
969 | UndoStack::instance()->push( command ); | 914 | UndoStack::instance()->push( command ); |
970 | RedoStack::instance()->clear(); | 915 | RedoStack::instance()->clear(); |
971 | 916 | ||
972 | setModified( true ); | 917 | setModified( true ); |
973 | } | 918 | } |
974 | 919 | ||
975 | void KABCore::setWhoAmI() | 920 | void KABCore::setWhoAmI() |
976 | { | 921 | { |
977 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 922 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
978 | 923 | ||
979 | if ( addrList.count() > 1 ) { | 924 | if ( addrList.count() > 1 ) { |
980 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 925 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
981 | return; | 926 | return; |
982 | } | 927 | } |
983 | 928 | ||
984 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 929 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
985 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 930 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
986 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 931 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
987 | } | 932 | } |
988 | 933 | ||
989 | void KABCore::setCategories() | 934 | void KABCore::setCategories() |
990 | { | 935 | { |
991 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 936 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
992 | if ( !dlg.exec() ) | 937 | if ( !dlg.exec() ) |
993 | return; | 938 | return; |
994 | 939 | ||
995 | bool merge = false; | 940 | bool merge = false; |
996 | QString msg = i18n( "Merge with existing categories?" ); | 941 | QString msg = i18n( "Merge with existing categories?" ); |
997 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 942 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
998 | merge = true; | 943 | merge = true; |
999 | 944 | ||
1000 | QStringList categories = dlg.selectedCategories(); | 945 | QStringList categories = dlg.selectedCategories(); |
1001 | 946 | ||
1002 | QStringList uids = mViewManager->selectedUids(); | 947 | QStringList uids = mViewManager->selectedUids(); |
1003 | QStringList::Iterator it; | 948 | QStringList::Iterator it; |
1004 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 949 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1005 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 950 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1006 | if ( !addr.isEmpty() ) { | 951 | if ( !addr.isEmpty() ) { |
1007 | if ( !merge ) | 952 | if ( !merge ) |
1008 | addr.setCategories( categories ); | 953 | addr.setCategories( categories ); |
1009 | else { | 954 | else { |
1010 | QStringList addrCategories = addr.categories(); | 955 | QStringList addrCategories = addr.categories(); |
1011 | QStringList::Iterator catIt; | 956 | QStringList::Iterator catIt; |
1012 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 957 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1013 | if ( !addrCategories.contains( *catIt ) ) | 958 | if ( !addrCategories.contains( *catIt ) ) |
1014 | addrCategories.append( *catIt ); | 959 | addrCategories.append( *catIt ); |
1015 | } | 960 | } |
1016 | addr.setCategories( addrCategories ); | 961 | addr.setCategories( addrCategories ); |
1017 | } | 962 | } |
1018 | 963 | ||
1019 | mAddressBook->insertAddressee( addr ); | 964 | mAddressBook->insertAddressee( addr ); |
1020 | } | 965 | } |
1021 | } | 966 | } |
1022 | 967 | ||
1023 | if ( uids.count() > 0 ) | 968 | if ( uids.count() > 0 ) |
1024 | setModified( true ); | 969 | setModified( true ); |
1025 | } | 970 | } |
1026 | 971 | ||
1027 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 972 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1028 | { | 973 | { |
1029 | mIncSearchWidget->setFields( fields ); | 974 | mIncSearchWidget->setFields( fields ); |
1030 | } | 975 | } |
1031 | 976 | ||
1032 | void KABCore::incrementalSearch( const QString& text ) | 977 | void KABCore::incrementalSearch( const QString& text ) |
1033 | { | 978 | { |
1034 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 979 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1035 | } | 980 | } |
1036 | 981 | ||
1037 | void KABCore::setModified() | 982 | void KABCore::setModified() |
1038 | { | 983 | { |
1039 | setModified( true ); | 984 | setModified( true ); |
1040 | } | 985 | } |
1041 | 986 | ||
1042 | void KABCore::setModifiedWOrefresh() | 987 | void KABCore::setModifiedWOrefresh() |
1043 | { | 988 | { |
1044 | // qDebug("KABCore::setModifiedWOrefresh() "); | 989 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1045 | mModified = true; | 990 | mModified = true; |
1046 | mActionSave->setEnabled( mModified ); | 991 | mActionSave->setEnabled( mModified ); |
1047 | #ifdef DESKTOP_VERSION | 992 | #ifdef DESKTOP_VERSION |
1048 | mDetails->refreshView(); | 993 | mDetails->refreshView(); |
1049 | #endif | 994 | #endif |
1050 | 995 | ||
1051 | } | 996 | } |
1052 | void KABCore::setModified( bool modified ) | 997 | void KABCore::setModified( bool modified ) |
1053 | { | 998 | { |
1054 | mModified = modified; | 999 | mModified = modified; |
1055 | mActionSave->setEnabled( mModified ); | 1000 | mActionSave->setEnabled( mModified ); |
1056 | 1001 | ||
1057 | if ( modified ) | 1002 | if ( modified ) |
1058 | mJumpButtonBar->recreateButtons(); | 1003 | mJumpButtonBar->recreateButtons(); |
1059 | 1004 | ||
1060 | mViewManager->refreshView(); | 1005 | mViewManager->refreshView(); |
1061 | mDetails->refreshView(); | 1006 | mDetails->refreshView(); |
1062 | 1007 | ||
1063 | } | 1008 | } |
1064 | 1009 | ||
1065 | bool KABCore::modified() const | 1010 | bool KABCore::modified() const |
1066 | { | 1011 | { |
1067 | return mModified; | 1012 | return mModified; |
1068 | } | 1013 | } |
1069 | 1014 | ||
1070 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1015 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1071 | { | 1016 | { |
1072 | 1017 | ||
1073 | Command *command = 0; | 1018 | Command *command = 0; |
1074 | QString uid; | 1019 | QString uid; |
1075 | 1020 | ||
1076 | // check if it exists already | 1021 | // check if it exists already |
1077 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1022 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1078 | if ( origAddr.isEmpty() ) | 1023 | if ( origAddr.isEmpty() ) |
1079 | command = new PwNewCommand( mAddressBook, addr ); | 1024 | command = new PwNewCommand( mAddressBook, addr ); |
1080 | else { | 1025 | else { |
1081 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1026 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1082 | uid = addr.uid(); | 1027 | uid = addr.uid(); |
1083 | } | 1028 | } |
1084 | 1029 | ||
1085 | UndoStack::instance()->push( command ); | 1030 | UndoStack::instance()->push( command ); |
1086 | RedoStack::instance()->clear(); | 1031 | RedoStack::instance()->clear(); |
1087 | 1032 | ||
1088 | setModified( true ); | 1033 | setModified( true ); |
1089 | } | 1034 | } |
1090 | 1035 | ||
1091 | void KABCore::newContact() | 1036 | void KABCore::newContact() |
1092 | { | 1037 | { |
1093 | 1038 | ||
1094 | 1039 | ||
1095 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1040 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1096 | 1041 | ||
1097 | QPtrList<KRES::Resource> kresResources; | 1042 | QPtrList<KRES::Resource> kresResources; |
1098 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1043 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1099 | KABC::Resource *resource; | 1044 | KABC::Resource *resource; |
1100 | while ( ( resource = it.current() ) != 0 ) { | 1045 | while ( ( resource = it.current() ) != 0 ) { |
1101 | ++it; | 1046 | ++it; |
1102 | if ( !resource->readOnly() ) { | 1047 | if ( !resource->readOnly() ) { |
1103 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1048 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1104 | if ( res ) | 1049 | if ( res ) |
1105 | kresResources.append( res ); | 1050 | kresResources.append( res ); |
1106 | } | 1051 | } |
1107 | } | 1052 | } |
1108 | 1053 | ||
1109 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1054 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1110 | resource = static_cast<KABC::Resource*>( res ); | 1055 | resource = static_cast<KABC::Resource*>( res ); |
1111 | 1056 | ||
1112 | if ( resource ) { | 1057 | if ( resource ) { |
1113 | KABC::Addressee addr; | 1058 | KABC::Addressee addr; |
1114 | addr.setResource( resource ); | 1059 | addr.setResource( resource ); |
1115 | mEditorDialog->setAddressee( addr ); | 1060 | mEditorDialog->setAddressee( addr ); |
1116 | KApplication::execDialog ( mEditorDialog ); | 1061 | KApplication::execDialog ( mEditorDialog ); |
1117 | 1062 | ||
1118 | } else | 1063 | } else |
1119 | return; | 1064 | return; |
1120 | 1065 | ||
1121 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1066 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1122 | 1067 | ||
1123 | 1068 | ||
1124 | } | 1069 | } |
1125 | 1070 | ||
1126 | void KABCore::addEmail( QString aStr ) | 1071 | void KABCore::addEmail( QString aStr ) |
1127 | { | 1072 | { |
1128 | #ifndef KAB_EMBEDDED | 1073 | #ifndef KAB_EMBEDDED |
1129 | QString fullName, email; | 1074 | QString fullName, email; |
1130 | 1075 | ||
1131 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1076 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1132 | 1077 | ||
1133 | // Try to lookup the addressee matching the email address | 1078 | // Try to lookup the addressee matching the email address |
1134 | bool found = false; | 1079 | bool found = false; |
1135 | QStringList emailList; | 1080 | QStringList emailList; |
1136 | KABC::AddressBook::Iterator it; | 1081 | KABC::AddressBook::Iterator it; |
1137 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1082 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1138 | emailList = (*it).emails(); | 1083 | emailList = (*it).emails(); |
1139 | if ( emailList.contains( email ) > 0 ) { | 1084 | if ( emailList.contains( email ) > 0 ) { |
1140 | found = true; | 1085 | found = true; |
1141 | (*it).setNameFromString( fullName ); | 1086 | (*it).setNameFromString( fullName ); |
1142 | editContact( (*it).uid() ); | 1087 | editContact( (*it).uid() ); |
1143 | } | 1088 | } |
1144 | } | 1089 | } |
1145 | 1090 | ||
1146 | if ( !found ) { | 1091 | if ( !found ) { |
1147 | KABC::Addressee addr; | 1092 | KABC::Addressee addr; |
1148 | addr.setNameFromString( fullName ); | 1093 | addr.setNameFromString( fullName ); |
1149 | addr.insertEmail( email, true ); | 1094 | addr.insertEmail( email, true ); |
1150 | 1095 | ||
1151 | mAddressBook->insertAddressee( addr ); | 1096 | mAddressBook->insertAddressee( addr ); |
1152 | mViewManager->refreshView( addr.uid() ); | 1097 | mViewManager->refreshView( addr.uid() ); |
1153 | editContact( addr.uid() ); | 1098 | editContact( addr.uid() ); |
1154 | } | 1099 | } |
1155 | #else //KAB_EMBEDDED | 1100 | #else //KAB_EMBEDDED |
1156 | qDebug("KABCore::addEmail finsih method"); | 1101 | qDebug("KABCore::addEmail finsih method"); |
1157 | #endif //KAB_EMBEDDED | 1102 | #endif //KAB_EMBEDDED |
1158 | } | 1103 | } |
1159 | 1104 | ||
1160 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1105 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1161 | { | 1106 | { |
1162 | mXXPortManager->importVCard( url, showPreview ); | 1107 | mXXPortManager->importVCard( url, showPreview ); |
1163 | } | 1108 | } |
1164 | void KABCore::importFromOL() | 1109 | void KABCore::importFromOL() |
1165 | { | 1110 | { |
1166 | #ifdef _WIN32_ | 1111 | #ifdef _WIN32_ |
1167 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1112 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1168 | idgl->exec(); | 1113 | idgl->exec(); |
1169 | KABC::Addressee::List list = idgl->getAddressList(); | 1114 | KABC::Addressee::List list = idgl->getAddressList(); |
1170 | if ( list.count() > 0 ) { | 1115 | if ( list.count() > 0 ) { |
1171 | KABC::Addressee::List listNew; | 1116 | KABC::Addressee::List listNew; |
1172 | KABC::Addressee::List listExisting; | 1117 | KABC::Addressee::List listExisting; |
1173 | KABC::Addressee::List::Iterator it; | 1118 | KABC::Addressee::List::Iterator it; |
1174 | KABC::AddressBook::Iterator iter; | 1119 | KABC::AddressBook::Iterator iter; |
1175 | for ( it = list.begin(); it != list.end(); ++it ) { | 1120 | for ( it = list.begin(); it != list.end(); ++it ) { |
1176 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1121 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1177 | listNew.append( (*it) ); | 1122 | listNew.append( (*it) ); |
1178 | else | 1123 | else |
1179 | listExisting.append( (*it) ); | 1124 | listExisting.append( (*it) ); |
1180 | } | 1125 | } |
1181 | if ( listExisting.count() > 0 ) | 1126 | if ( listExisting.count() > 0 ) |
1182 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1127 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1183 | if ( listNew.count() > 0 ) { | 1128 | if ( listNew.count() > 0 ) { |
1184 | pasteWithNewUid = false; | 1129 | pasteWithNewUid = false; |
1185 | pasteContacts( listNew ); | 1130 | pasteContacts( listNew ); |
1186 | pasteWithNewUid = true; | 1131 | pasteWithNewUid = true; |
1187 | } | 1132 | } |
1188 | } | 1133 | } |
1189 | delete idgl; | 1134 | delete idgl; |
1190 | #endif | 1135 | #endif |
1191 | } | 1136 | } |
1192 | 1137 | ||
1193 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1138 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1194 | { | 1139 | { |
1195 | mXXPortManager->importVCard( vCard, showPreview ); | 1140 | mXXPortManager->importVCard( vCard, showPreview ); |
1196 | } | 1141 | } |
1197 | 1142 | ||
1198 | //US added a second method without defaultparameter | 1143 | //US added a second method without defaultparameter |
1199 | void KABCore::editContact2() { | 1144 | void KABCore::editContact2() { |
1200 | editContact( QString::null ); | 1145 | editContact( QString::null ); |
1201 | } | 1146 | } |
1202 | 1147 | ||
1203 | void KABCore::editContact( const QString &uid ) | 1148 | void KABCore::editContact( const QString &uid ) |
1204 | { | 1149 | { |
1205 | 1150 | ||
1206 | if ( mExtensionManager->isQuickEditVisible() ) | 1151 | if ( mExtensionManager->isQuickEditVisible() ) |
1207 | return; | 1152 | return; |
1208 | 1153 | ||
1209 | // First, locate the contact entry | 1154 | // First, locate the contact entry |
1210 | QString localUID = uid; | 1155 | QString localUID = uid; |
1211 | if ( localUID.isNull() ) { | 1156 | if ( localUID.isNull() ) { |
1212 | QStringList uidList = mViewManager->selectedUids(); | 1157 | QStringList uidList = mViewManager->selectedUids(); |
1213 | if ( uidList.count() > 0 ) | 1158 | if ( uidList.count() > 0 ) |
1214 | localUID = *( uidList.at( 0 ) ); | 1159 | localUID = *( uidList.at( 0 ) ); |
1215 | } | 1160 | } |
1216 | 1161 | ||
1217 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1162 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1218 | if ( !addr.isEmpty() ) { | 1163 | if ( !addr.isEmpty() ) { |
1219 | mEditorDialog->setAddressee( addr ); | 1164 | mEditorDialog->setAddressee( addr ); |
1220 | KApplication::execDialog ( mEditorDialog ); | 1165 | KApplication::execDialog ( mEditorDialog ); |
1221 | } | 1166 | } |
1222 | } | 1167 | } |
1223 | 1168 | ||
1224 | /** | 1169 | /** |
1225 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1170 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1226 | the method will try to find a selected addressee in the view. | 1171 | the method will try to find a selected addressee in the view. |
1227 | */ | 1172 | */ |
1228 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1173 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1229 | { | 1174 | { |
1230 | if ( mMultipleViewsAtOnce ) | 1175 | if ( mMultipleViewsAtOnce ) |
1231 | { | 1176 | { |
1232 | editContact( uid ); | 1177 | editContact( uid ); |
1233 | } | 1178 | } |
1234 | else | 1179 | else |
1235 | { | 1180 | { |
1236 | setDetailsVisible( true ); | 1181 | setDetailsVisible( true ); |
1237 | mActionDetails->setChecked(true); | 1182 | mActionDetails->setChecked(true); |
1238 | } | 1183 | } |
1239 | 1184 | ||
1240 | } | 1185 | } |
1241 | 1186 | ||
1242 | void KABCore::save() | 1187 | void KABCore::save() |
1243 | { | 1188 | { |
1244 | if (syncManager->blockSave()) | 1189 | if (syncManager->blockSave()) |
1245 | return; | 1190 | return; |
1246 | if ( !mModified ) | 1191 | if ( !mModified ) |
1247 | return; | 1192 | return; |
1248 | 1193 | ||
1249 | syncManager->setBlockSave(true); | 1194 | syncManager->setBlockSave(true); |
1250 | QString text = i18n( "There was an error while attempting to save\n the " | 1195 | QString text = i18n( "There was an error while attempting to save\n the " |
1251 | "address book. Please check that some \nother application is " | 1196 | "address book. Please check that some \nother application is " |
1252 | "not using it. " ); | 1197 | "not using it. " ); |
1253 | statusMessage(i18n("Saving addressbook ... ")); | 1198 | statusMessage(i18n("Saving addressbook ... ")); |
1254 | #ifndef KAB_EMBEDDED | 1199 | #ifndef KAB_EMBEDDED |
1255 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1200 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1256 | if ( !b || !b->save() ) { | 1201 | if ( !b || !b->save() ) { |
1257 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1202 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1258 | } | 1203 | } |
1259 | #else //KAB_EMBEDDED | 1204 | #else //KAB_EMBEDDED |
1260 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1205 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1261 | if ( !b || !b->save() ) { | 1206 | if ( !b || !b->save() ) { |
1262 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1207 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1263 | } | 1208 | } |
1264 | #endif //KAB_EMBEDDED | 1209 | #endif //KAB_EMBEDDED |
1265 | 1210 | ||
1266 | statusMessage(i18n("Addressbook saved!")); | 1211 | statusMessage(i18n("Addressbook saved!")); |
1267 | setModified( false ); | 1212 | setModified( false ); |
1268 | syncManager->setBlockSave(false); | 1213 | syncManager->setBlockSave(false); |
1269 | } | 1214 | } |
1270 | 1215 | ||
1271 | void KABCore::statusMessage(QString mess , int time ) | 1216 | void KABCore::statusMessage(QString mess , int time ) |
1272 | { | 1217 | { |
1273 | //topLevelWidget()->setCaption( mess ); | 1218 | //topLevelWidget()->setCaption( mess ); |
1274 | // pending setting timer to revome message | 1219 | // pending setting timer to revome message |
1275 | } | 1220 | } |
1276 | void KABCore::undo() | 1221 | void KABCore::undo() |
1277 | { | 1222 | { |
1278 | UndoStack::instance()->undo(); | 1223 | UndoStack::instance()->undo(); |
1279 | 1224 | ||
1280 | // Refresh the view | 1225 | // Refresh the view |
1281 | mViewManager->refreshView(); | 1226 | mViewManager->refreshView(); |
1282 | } | 1227 | } |
1283 | 1228 | ||
1284 | void KABCore::redo() | 1229 | void KABCore::redo() |
1285 | { | 1230 | { |
1286 | RedoStack::instance()->redo(); | 1231 | RedoStack::instance()->redo(); |
1287 | 1232 | ||
1288 | // Refresh the view | 1233 | // Refresh the view |
1289 | mViewManager->refreshView(); | 1234 | mViewManager->refreshView(); |
1290 | } | 1235 | } |
1291 | 1236 | ||
1292 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1237 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1293 | { | 1238 | { |
1294 | if (mMultipleViewsAtOnce) | 1239 | if (mMultipleViewsAtOnce) |
1295 | { | 1240 | { |
1296 | if ( visible ) | 1241 | if ( visible ) |
1297 | mJumpButtonBar->show(); | 1242 | mJumpButtonBar->show(); |
1298 | else | 1243 | else |
1299 | mJumpButtonBar->hide(); | 1244 | mJumpButtonBar->hide(); |
1300 | } | 1245 | } |
1301 | else | 1246 | else |
1302 | { | 1247 | { |
1303 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1248 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1304 | if (mViewManager->isVisible()) | 1249 | if (mViewManager->isVisible()) |
1305 | { | 1250 | { |
1306 | if ( visible ) | 1251 | if ( visible ) |
1307 | mJumpButtonBar->show(); | 1252 | mJumpButtonBar->show(); |
1308 | else | 1253 | else |
1309 | mJumpButtonBar->hide(); | 1254 | mJumpButtonBar->hide(); |
1310 | } | 1255 | } |
1311 | else | 1256 | else |
1312 | { | 1257 | { |
1313 | mJumpButtonBar->hide(); | 1258 | mJumpButtonBar->hide(); |
1314 | } | 1259 | } |
1315 | } | 1260 | } |
1316 | } | 1261 | } |
1317 | 1262 | ||
1318 | 1263 | ||
1319 | void KABCore::setDetailsToState() | 1264 | void KABCore::setDetailsToState() |
1320 | { | 1265 | { |
1321 | setDetailsVisible( mActionDetails->isChecked() ); | 1266 | setDetailsVisible( mActionDetails->isChecked() ); |
1322 | } | 1267 | } |
1323 | 1268 | ||
1324 | 1269 | ||
1325 | 1270 | ||
1326 | void KABCore::setDetailsVisible( bool visible ) | 1271 | void KABCore::setDetailsVisible( bool visible ) |
1327 | { | 1272 | { |
1328 | if (visible && mDetails->isHidden()) | 1273 | if (visible && mDetails->isHidden()) |
1329 | { | 1274 | { |
1330 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1275 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1331 | if ( addrList.count() > 0 ) | 1276 | if ( addrList.count() > 0 ) |
1332 | mDetails->setAddressee( addrList[ 0 ] ); | 1277 | mDetails->setAddressee( addrList[ 0 ] ); |
1333 | } | 1278 | } |
1334 | 1279 | ||
1335 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1280 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1336 | // the listview and the detailview. We do that by changing the splitbar size. | 1281 | // the listview and the detailview. We do that by changing the splitbar size. |
1337 | if (mMultipleViewsAtOnce) | 1282 | if (mMultipleViewsAtOnce) |
1338 | { | 1283 | { |
1339 | if ( visible ) | 1284 | if ( visible ) |
1340 | mDetails->show(); | 1285 | mDetails->show(); |
1341 | else | 1286 | else |
1342 | mDetails->hide(); | 1287 | mDetails->hide(); |
1343 | } | 1288 | } |
1344 | else | 1289 | else |
1345 | { | 1290 | { |
1346 | if ( visible ) { | 1291 | if ( visible ) { |
1347 | mViewManager->hide(); | 1292 | mViewManager->hide(); |
1348 | mDetails->show(); | 1293 | mDetails->show(); |
1349 | } | 1294 | } |
1350 | else { | 1295 | else { |
1351 | mViewManager->show(); | 1296 | mViewManager->show(); |
1352 | mDetails->hide(); | 1297 | mDetails->hide(); |
1353 | } | 1298 | } |
1354 | setJumpButtonBarVisible( !visible ); | 1299 | setJumpButtonBarVisible( !visible ); |
1355 | } | 1300 | } |
1356 | 1301 | ||
1357 | } | 1302 | } |
1358 | 1303 | ||
1359 | void KABCore::extensionChanged( int id ) | 1304 | void KABCore::extensionChanged( int id ) |
1360 | { | 1305 | { |
1361 | //change the details view only for non desktop systems | 1306 | //change the details view only for non desktop systems |
1362 | #ifndef DESKTOP_VERSION | 1307 | #ifndef DESKTOP_VERSION |
1363 | 1308 | ||
1364 | if (id == 0) | 1309 | if (id == 0) |
1365 | { | 1310 | { |
1366 | //the user disabled the extension. | 1311 | //the user disabled the extension. |
1367 | 1312 | ||
1368 | if (mMultipleViewsAtOnce) | 1313 | if (mMultipleViewsAtOnce) |
1369 | { // enable detailsview again | 1314 | { // enable detailsview again |
1370 | setDetailsVisible( true ); | 1315 | setDetailsVisible( true ); |
1371 | mActionDetails->setChecked( true ); | 1316 | mActionDetails->setChecked( true ); |
1372 | } | 1317 | } |
1373 | else | 1318 | else |
1374 | { //go back to the listview | 1319 | { //go back to the listview |
1375 | setDetailsVisible( false ); | 1320 | setDetailsVisible( false ); |
1376 | mActionDetails->setChecked( false ); | 1321 | mActionDetails->setChecked( false ); |
1377 | mActionDetails->setEnabled(true); | 1322 | mActionDetails->setEnabled(true); |
1378 | } | 1323 | } |
1379 | 1324 | ||
1380 | } | 1325 | } |
1381 | else | 1326 | else |
1382 | { | 1327 | { |
1383 | //the user enabled the extension. | 1328 | //the user enabled the extension. |
1384 | setDetailsVisible( false ); | 1329 | setDetailsVisible( false ); |
1385 | mActionDetails->setChecked( false ); | 1330 | mActionDetails->setChecked( false ); |
1386 | 1331 | ||
1387 | if (!mMultipleViewsAtOnce) | 1332 | if (!mMultipleViewsAtOnce) |
1388 | { | 1333 | { |
1389 | mActionDetails->setEnabled(false); | 1334 | mActionDetails->setEnabled(false); |
1390 | } | 1335 | } |
1391 | 1336 | ||
1392 | mExtensionManager->setSelectionChanged(); | 1337 | mExtensionManager->setSelectionChanged(); |
1393 | 1338 | ||
1394 | } | 1339 | } |
1395 | 1340 | ||
1396 | #endif// DESKTOP_VERSION | 1341 | #endif// DESKTOP_VERSION |
1397 | 1342 | ||
1398 | } | 1343 | } |
1399 | 1344 | ||
1400 | 1345 | ||
1401 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1346 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1402 | { | 1347 | { |
1403 | 1348 | ||
1404 | if ( list.count() != 0 ) { | 1349 | if ( list.count() != 0 ) { |
1405 | KABC::Addressee::List::ConstIterator it; | 1350 | KABC::Addressee::List::ConstIterator it; |
1406 | for ( it = list.begin(); it != list.end(); ++it ) | 1351 | for ( it = list.begin(); it != list.end(); ++it ) |
1407 | mAddressBook->insertAddressee( *it ); | 1352 | mAddressBook->insertAddressee( *it ); |
1408 | if ( list.count() > 1 ) | 1353 | if ( list.count() > 1 ) |
1409 | setModified(); | 1354 | setModified(); |
1410 | else | 1355 | else |
1411 | setModifiedWOrefresh(); | 1356 | setModifiedWOrefresh(); |
1412 | } | 1357 | } |
1413 | if ( list.count() == 0 ) | 1358 | if ( list.count() == 0 ) |
1414 | mViewManager->refreshView(); | 1359 | mViewManager->refreshView(); |
1415 | else | 1360 | else |
1416 | mViewManager->refreshView( list[ 0 ].uid() ); | 1361 | mViewManager->refreshView( list[ 0 ].uid() ); |
1417 | 1362 | ||
1418 | 1363 | ||
1419 | 1364 | ||
1420 | } | 1365 | } |
1421 | 1366 | ||
1422 | QString KABCore::getNameByPhone( const QString &phone ) | 1367 | QString KABCore::getNameByPhone( const QString &phone ) |
1423 | { | 1368 | { |
1424 | #ifndef KAB_EMBEDDED | 1369 | #ifndef KAB_EMBEDDED |
1425 | QRegExp r( "[/*/-/ ]" ); | 1370 | QRegExp r( "[/*/-/ ]" ); |
1426 | QString localPhone( phone ); | 1371 | QString localPhone( phone ); |
1427 | 1372 | ||
1428 | bool found = false; | 1373 | bool found = false; |
1429 | QString ownerName = ""; | 1374 | QString ownerName = ""; |
1430 | KABC::AddressBook::Iterator iter; | 1375 | KABC::AddressBook::Iterator iter; |
1431 | KABC::PhoneNumber::List::Iterator phoneIter; | 1376 | KABC::PhoneNumber::List::Iterator phoneIter; |
1432 | KABC::PhoneNumber::List phoneList; | 1377 | KABC::PhoneNumber::List phoneList; |
1433 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1378 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1434 | phoneList = (*iter).phoneNumbers(); | 1379 | phoneList = (*iter).phoneNumbers(); |
1435 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1380 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1436 | ++phoneIter) { | 1381 | ++phoneIter) { |
1437 | // Get rid of separator chars so just the numbers are compared. | 1382 | // Get rid of separator chars so just the numbers are compared. |
1438 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1383 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1439 | ownerName = (*iter).formattedName(); | 1384 | ownerName = (*iter).formattedName(); |
1440 | found = true; | 1385 | found = true; |
1441 | } | 1386 | } |
1442 | } | 1387 | } |
1443 | } | 1388 | } |
1444 | 1389 | ||
1445 | return ownerName; | 1390 | return ownerName; |
1446 | #else //KAB_EMBEDDED | 1391 | #else //KAB_EMBEDDED |
1447 | qDebug("KABCore::getNameByPhone finsih method"); | 1392 | qDebug("KABCore::getNameByPhone finsih method"); |
1448 | return ""; | 1393 | return ""; |
1449 | #endif //KAB_EMBEDDED | 1394 | #endif //KAB_EMBEDDED |
1450 | 1395 | ||
1451 | } | 1396 | } |
1452 | 1397 | ||
1453 | void KABCore::openConfigDialog() | 1398 | void KABCore::openConfigDialog() |
1454 | { | 1399 | { |
1455 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1400 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1456 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1401 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1457 | ConfigureDialog->addModule(kabcfg ); | 1402 | ConfigureDialog->addModule(kabcfg ); |
1458 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1403 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1459 | ConfigureDialog->addModule(kdelibcfg ); | 1404 | ConfigureDialog->addModule(kdelibcfg ); |
1460 | 1405 | ||
1461 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1406 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1462 | this, SLOT( configurationChanged() ) ); | 1407 | this, SLOT( configurationChanged() ) ); |
1463 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1408 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1464 | this, SLOT( configurationChanged() ) ); | 1409 | this, SLOT( configurationChanged() ) ); |
1465 | saveSettings(); | 1410 | saveSettings(); |
1466 | #ifndef DESKTOP_VERSION | 1411 | #ifndef DESKTOP_VERSION |
1467 | ConfigureDialog->showMaximized(); | 1412 | ConfigureDialog->showMaximized(); |
1468 | #endif | 1413 | #endif |
1469 | if ( ConfigureDialog->exec() ) | 1414 | if ( ConfigureDialog->exec() ) |
1470 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1415 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1471 | delete ConfigureDialog; | 1416 | delete ConfigureDialog; |
1472 | } | 1417 | } |
1473 | 1418 | ||
1474 | void KABCore::openLDAPDialog() | 1419 | void KABCore::openLDAPDialog() |
1475 | { | 1420 | { |
1476 | #ifndef KAB_EMBEDDED | 1421 | #ifndef KAB_EMBEDDED |
1477 | if ( !mLdapSearchDialog ) { | 1422 | if ( !mLdapSearchDialog ) { |
1478 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1423 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1479 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1424 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1480 | SLOT( refreshView() ) ); | 1425 | SLOT( refreshView() ) ); |
1481 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1426 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1482 | SLOT( setModified() ) ); | 1427 | SLOT( setModified() ) ); |
1483 | } else | 1428 | } else |
1484 | mLdapSearchDialog->restoreSettings(); | 1429 | mLdapSearchDialog->restoreSettings(); |
1485 | 1430 | ||
1486 | if ( mLdapSearchDialog->isOK() ) | 1431 | if ( mLdapSearchDialog->isOK() ) |
1487 | mLdapSearchDialog->exec(); | 1432 | mLdapSearchDialog->exec(); |
1488 | #else //KAB_EMBEDDED | 1433 | #else //KAB_EMBEDDED |
1489 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1434 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1490 | #endif //KAB_EMBEDDED | 1435 | #endif //KAB_EMBEDDED |
1491 | } | 1436 | } |
1492 | 1437 | ||
1493 | void KABCore::print() | 1438 | void KABCore::print() |
1494 | { | 1439 | { |
1495 | #ifndef KAB_EMBEDDED | 1440 | #ifndef KAB_EMBEDDED |
1496 | KPrinter printer; | 1441 | KPrinter printer; |
1497 | if ( !printer.setup( this ) ) | 1442 | if ( !printer.setup( this ) ) |
1498 | return; | 1443 | return; |
1499 | 1444 | ||
1500 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1445 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1501 | mViewManager->selectedUids(), this ); | 1446 | mViewManager->selectedUids(), this ); |
1502 | 1447 | ||
1503 | wizard.exec(); | 1448 | wizard.exec(); |
1504 | #else //KAB_EMBEDDED | 1449 | #else //KAB_EMBEDDED |
1505 | qDebug("KABCore::print() finsih method"); | 1450 | qDebug("KABCore::print() finsih method"); |
1506 | #endif //KAB_EMBEDDED | 1451 | #endif //KAB_EMBEDDED |
1507 | 1452 | ||
1508 | } | 1453 | } |
1509 | 1454 | ||
1510 | 1455 | ||
1511 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1456 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1512 | { | 1457 | { |
1513 | if ( mGUIClient ) | 1458 | if ( mGUIClient ) |
1514 | mGUIClient->insertChildClient( client ); | 1459 | mGUIClient->insertChildClient( client ); |
1515 | else | 1460 | else |
1516 | KMessageBox::error( this, "no KXMLGUICLient"); | 1461 | KMessageBox::error( this, "no KXMLGUICLient"); |
1517 | } | 1462 | } |
1518 | 1463 | ||
1519 | 1464 | ||
1520 | void KABCore::configurationChanged() | 1465 | void KABCore::configurationChanged() |
1521 | { | 1466 | { |
1522 | mExtensionManager->reconfigure(); | 1467 | mExtensionManager->reconfigure(); |
1523 | } | 1468 | } |
1524 | 1469 | ||
1525 | void KABCore::addressBookChanged() | 1470 | void KABCore::addressBookChanged() |
1526 | { | 1471 | { |
1527 | /*US | 1472 | /*US |
1528 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1473 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1529 | while ( it.current() ) { | 1474 | while ( it.current() ) { |
1530 | if ( it.current()->dirty() ) { | 1475 | if ( it.current()->dirty() ) { |
1531 | QString text = i18n( "Data has been changed externally. Unsaved " | 1476 | QString text = i18n( "Data has been changed externally. Unsaved " |
1532 | "changes will be lost." ); | 1477 | "changes will be lost." ); |
1533 | KMessageBox::information( this, text ); | 1478 | KMessageBox::information( this, text ); |
1534 | } | 1479 | } |
1535 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1480 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1536 | ++it; | 1481 | ++it; |
1537 | } | 1482 | } |
1538 | */ | 1483 | */ |
1539 | if (mEditorDialog) | 1484 | if (mEditorDialog) |
1540 | { | 1485 | { |
1541 | if (mEditorDialog->dirty()) | 1486 | if (mEditorDialog->dirty()) |
1542 | { | 1487 | { |
1543 | QString text = i18n( "Data has been changed externally. Unsaved " | 1488 | QString text = i18n( "Data has been changed externally. Unsaved " |
1544 | "changes will be lost." ); | 1489 | "changes will be lost." ); |
1545 | KMessageBox::information( this, text ); | 1490 | KMessageBox::information( this, text ); |
1546 | } | 1491 | } |
1547 | QString currentuid = mEditorDialog->addressee().uid(); | 1492 | QString currentuid = mEditorDialog->addressee().uid(); |
1548 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1493 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1549 | } | 1494 | } |
1550 | mViewManager->refreshView(); | 1495 | mViewManager->refreshView(); |
1551 | // mDetails->refreshView(); | 1496 | // mDetails->refreshView(); |
1552 | 1497 | ||
1553 | 1498 | ||
1554 | } | 1499 | } |
1555 | 1500 | ||
1556 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1501 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1557 | const char *name ) | 1502 | const char *name ) |
1558 | { | 1503 | { |
1559 | 1504 | ||
1560 | if ( mEditorDialog == 0 ) { | 1505 | if ( mEditorDialog == 0 ) { |
1561 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1506 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1562 | name ? name : "editorDialog" ); | 1507 | name ? name : "editorDialog" ); |
1563 | 1508 | ||
1564 | 1509 | ||
1565 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1510 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1566 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1511 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1567 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1512 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1568 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1513 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1569 | } | 1514 | } |
1570 | 1515 | ||
1571 | return mEditorDialog; | 1516 | return mEditorDialog; |
1572 | } | 1517 | } |
1573 | 1518 | ||
1574 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1519 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1575 | { | 1520 | { |
1576 | //mEditorDict.remove( uid ); | 1521 | //mEditorDict.remove( uid ); |
1577 | } | 1522 | } |
1578 | 1523 | ||
1579 | void KABCore::initGUI() | 1524 | void KABCore::initGUI() |
1580 | { | 1525 | { |
1581 | #ifndef KAB_EMBEDDED | 1526 | #ifndef KAB_EMBEDDED |
1582 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1527 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1583 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1528 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1584 | 1529 | ||
1585 | mExtensionBarSplitter = new QSplitter( this ); | 1530 | mExtensionBarSplitter = new QSplitter( this ); |
1586 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1531 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1587 | 1532 | ||
1588 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1533 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1589 | 1534 | ||
1590 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1535 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1591 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1536 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1592 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1537 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1593 | SLOT( incrementalSearch( const QString& ) ) ); | 1538 | SLOT( incrementalSearch( const QString& ) ) ); |
1594 | 1539 | ||
1595 | mViewManager = new ViewManager( this, viewSpace ); | 1540 | mViewManager = new ViewManager( this, viewSpace ); |
1596 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1541 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1597 | 1542 | ||
1598 | mDetails = new ViewContainer( mDetailsSplitter ); | 1543 | mDetails = new ViewContainer( mDetailsSplitter ); |
1599 | 1544 | ||
1600 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1545 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1601 | 1546 | ||
1602 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1547 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1603 | 1548 | ||
1604 | topLayout->addWidget( mExtensionBarSplitter ); | 1549 | topLayout->addWidget( mExtensionBarSplitter ); |
1605 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1550 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1606 | topLayout->addWidget( mJumpButtonBar ); | 1551 | topLayout->addWidget( mJumpButtonBar ); |
1607 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1552 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1608 | 1553 | ||
1609 | mXXPortManager = new XXPortManager( this, this ); | 1554 | mXXPortManager = new XXPortManager( this, this ); |
1610 | 1555 | ||
1611 | #else //KAB_EMBEDDED | 1556 | #else //KAB_EMBEDDED |
1612 | //US initialize viewMenu before settingup viewmanager. | 1557 | //US initialize viewMenu before settingup viewmanager. |
1613 | // Viewmanager needs this menu to plugin submenues. | 1558 | // Viewmanager needs this menu to plugin submenues. |
1614 | viewMenu = new QPopupMenu( this ); | 1559 | viewMenu = new QPopupMenu( this ); |
1615 | settingsMenu = new QPopupMenu( this ); | 1560 | settingsMenu = new QPopupMenu( this ); |
1616 | //filterMenu = new QPopupMenu( this ); | 1561 | //filterMenu = new QPopupMenu( this ); |
1617 | ImportMenu = new QPopupMenu( this ); | 1562 | ImportMenu = new QPopupMenu( this ); |
1618 | ExportMenu = new QPopupMenu( this ); | 1563 | ExportMenu = new QPopupMenu( this ); |
1619 | syncMenu = new QPopupMenu( this ); | 1564 | syncMenu = new QPopupMenu( this ); |
1620 | changeMenu= new QPopupMenu( this ); | 1565 | changeMenu= new QPopupMenu( this ); |
1621 | 1566 | ||
1622 | //US since we have no splitter for the embedded system, setup | 1567 | //US since we have no splitter for the embedded system, setup |
1623 | // a layout with two frames. One left and one right. | 1568 | // a layout with two frames. One left and one right. |
1624 | 1569 | ||
1625 | QBoxLayout *topLayout; | 1570 | QBoxLayout *topLayout; |
1626 | 1571 | ||
1627 | // = new QHBoxLayout( this ); | 1572 | // = new QHBoxLayout( this ); |
1628 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1573 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1629 | 1574 | ||
1630 | // QWidget *mainBox = new QWidget( this ); | 1575 | // QWidget *mainBox = new QWidget( this ); |
1631 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1576 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1632 | 1577 | ||
1633 | #ifdef DESKTOP_VERSION | 1578 | #ifdef DESKTOP_VERSION |
1634 | topLayout = new QHBoxLayout( this ); | 1579 | topLayout = new QHBoxLayout( this ); |
1635 | 1580 | ||
1636 | 1581 | ||
1637 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1582 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1638 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1583 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1639 | 1584 | ||
1640 | topLayout->addWidget(mMiniSplitter ); | 1585 | topLayout->addWidget(mMiniSplitter ); |
1641 | 1586 | ||
1642 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1587 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1643 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1588 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1644 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1589 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1645 | mDetails = new ViewContainer( mMiniSplitter ); | 1590 | mDetails = new ViewContainer( mMiniSplitter ); |
1646 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1591 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1647 | #else | 1592 | #else |
1648 | if ( QApplication::desktop()->width() > 480 ) { | 1593 | if ( QApplication::desktop()->width() > 480 ) { |
1649 | topLayout = new QHBoxLayout( this ); | 1594 | topLayout = new QHBoxLayout( this ); |
1650 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1595 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1651 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1596 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1652 | } else { | 1597 | } else { |
1653 | 1598 | ||
1654 | topLayout = new QHBoxLayout( this ); | 1599 | topLayout = new QHBoxLayout( this ); |
1655 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1600 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1656 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1601 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1657 | } | 1602 | } |
1658 | 1603 | ||
1659 | topLayout->addWidget(mMiniSplitter ); | 1604 | topLayout->addWidget(mMiniSplitter ); |
1660 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1605 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1661 | mDetails = new ViewContainer( mMiniSplitter ); | 1606 | mDetails = new ViewContainer( mMiniSplitter ); |
1662 | 1607 | ||
1663 | 1608 | ||
1664 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1609 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1665 | #endif | 1610 | #endif |
1666 | //eh->hide(); | 1611 | //eh->hide(); |
1667 | // topLayout->addWidget(mExtensionManager ); | 1612 | // topLayout->addWidget(mExtensionManager ); |
1668 | 1613 | ||
1669 | 1614 | ||
1670 | /*US | 1615 | /*US |
1671 | #ifndef KAB_NOSPLITTER | 1616 | #ifndef KAB_NOSPLITTER |
1672 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1617 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1673 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1618 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1674 | topLayout->setSpacing( 10 ); | 1619 | topLayout->setSpacing( 10 ); |
1675 | 1620 | ||
1676 | mDetailsSplitter = new QSplitter( this ); | 1621 | mDetailsSplitter = new QSplitter( this ); |
1677 | 1622 | ||
1678 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1623 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1679 | 1624 | ||
1680 | mViewManager = new ViewManager( this, viewSpace ); | 1625 | mViewManager = new ViewManager( this, viewSpace ); |
1681 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1626 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1682 | 1627 | ||
1683 | mDetails = new ViewContainer( mDetailsSplitter ); | 1628 | mDetails = new ViewContainer( mDetailsSplitter ); |
1684 | 1629 | ||
1685 | topLayout->addWidget( mDetailsSplitter ); | 1630 | topLayout->addWidget( mDetailsSplitter ); |
1686 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1631 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1687 | #else //KAB_NOSPLITTER | 1632 | #else //KAB_NOSPLITTER |
1688 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1633 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1689 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1634 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1690 | topLayout->setSpacing( 10 ); | 1635 | topLayout->setSpacing( 10 ); |
1691 | 1636 | ||
1692 | // mDetailsSplitter = new QSplitter( this ); | 1637 | // mDetailsSplitter = new QSplitter( this ); |
1693 | 1638 | ||
1694 | QVBox *viewSpace = new QVBox( this ); | 1639 | QVBox *viewSpace = new QVBox( this ); |
1695 | 1640 | ||
1696 | mViewManager = new ViewManager( this, viewSpace ); | 1641 | mViewManager = new ViewManager( this, viewSpace ); |
1697 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1642 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1698 | 1643 | ||
1699 | mDetails = new ViewContainer( this ); | 1644 | mDetails = new ViewContainer( this ); |
1700 | 1645 | ||
1701 | topLayout->addWidget( viewSpace ); | 1646 | topLayout->addWidget( viewSpace ); |
1702 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1647 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1703 | topLayout->addWidget( mDetails ); | 1648 | topLayout->addWidget( mDetails ); |
1704 | #endif //KAB_NOSPLITTER | 1649 | #endif //KAB_NOSPLITTER |
1705 | */ | 1650 | */ |
1706 | 1651 | ||
1707 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1652 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1708 | syncManager->setBlockSave(false); | 1653 | syncManager->setBlockSave(false); |
1709 | 1654 | ||
1710 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1655 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1711 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1656 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1712 | syncManager->setDefaultFileName( sentSyncFile()); | 1657 | syncManager->setDefaultFileName( sentSyncFile()); |
1713 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1658 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1714 | 1659 | ||
1715 | #endif //KAB_EMBEDDED | 1660 | #endif //KAB_EMBEDDED |
1716 | initActions(); | 1661 | initActions(); |
1717 | 1662 | ||
1718 | #ifdef KAB_EMBEDDED | 1663 | #ifdef KAB_EMBEDDED |
1719 | addActionsManually(); | 1664 | addActionsManually(); |
1720 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1665 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1721 | mXXPortManager = new XXPortManager( this, this ); | 1666 | mXXPortManager = new XXPortManager( this, this ); |
1722 | 1667 | ||
1723 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1668 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1724 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1669 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1725 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1670 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1726 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1671 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1727 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1672 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1728 | // mIncSearchWidget->hide(); | 1673 | // mIncSearchWidget->hide(); |
1729 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1674 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1730 | SLOT( incrementalSearch( const QString& ) ) ); | 1675 | SLOT( incrementalSearch( const QString& ) ) ); |
1731 | 1676 | ||
1732 | 1677 | ||
1733 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1678 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1734 | 1679 | ||
1735 | topLayout->addWidget( mJumpButtonBar ); | 1680 | topLayout->addWidget( mJumpButtonBar ); |
1736 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1681 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1737 | 1682 | ||
1738 | // mMainWindow->getIconToolBar()->raise(); | 1683 | // mMainWindow->getIconToolBar()->raise(); |
1739 | 1684 | ||
1740 | #endif //KAB_EMBEDDED | 1685 | #endif //KAB_EMBEDDED |
1741 | 1686 | ||
1742 | } | 1687 | } |
1743 | void KABCore::initActions() | 1688 | void KABCore::initActions() |
1744 | { | 1689 | { |
1745 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1690 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1746 | 1691 | ||
1747 | #ifndef KAB_EMBEDDED | 1692 | #ifndef KAB_EMBEDDED |
1748 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1693 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1749 | SLOT( clipboardDataChanged() ) ); | 1694 | SLOT( clipboardDataChanged() ) ); |
1750 | #endif //KAB_EMBEDDED | 1695 | #endif //KAB_EMBEDDED |
1751 | 1696 | ||
1752 | // file menu | 1697 | // file menu |
1753 | if ( mIsPart ) { | 1698 | if ( mIsPart ) { |
1754 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1699 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1755 | SLOT( sendMail() ), actionCollection(), | 1700 | SLOT( sendMail() ), actionCollection(), |
1756 | "kaddressbook_mail" ); | 1701 | "kaddressbook_mail" ); |
1757 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1702 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1758 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1703 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1759 | 1704 | ||
1760 | } else { | 1705 | } else { |
1761 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1706 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1762 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1707 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1763 | } | 1708 | } |
1764 | 1709 | ||
1765 | 1710 | ||
1766 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1711 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1767 | SLOT( save() ), actionCollection(), "file_sync" ); | 1712 | SLOT( save() ), actionCollection(), "file_sync" ); |
1768 | 1713 | ||
1769 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1714 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1770 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1715 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1771 | 1716 | ||
1772 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1717 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1773 | this, SLOT( mailVCard() ), | 1718 | this, SLOT( mailVCard() ), |
1774 | actionCollection(), "file_mail_vcard"); | 1719 | actionCollection(), "file_mail_vcard"); |
1775 | 1720 | ||
1776 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1721 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1777 | SLOT( export2phone() ), actionCollection(), | 1722 | SLOT( export2phone() ), actionCollection(), |
1778 | "kaddressbook_ex2phone" ); | 1723 | "kaddressbook_ex2phone" ); |
1779 | 1724 | ||
1780 | mActionBeamVCard = 0; | 1725 | mActionBeamVCard = 0; |
1781 | mActionBeam = 0; | 1726 | mActionBeam = 0; |
1782 | 1727 | ||
1783 | #ifndef DESKTOP_VERSION | 1728 | #ifndef DESKTOP_VERSION |
1784 | if ( Ir::supported() ) { | 1729 | if ( Ir::supported() ) { |
1785 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1730 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1786 | SLOT( beamVCard() ), actionCollection(), | 1731 | SLOT( beamVCard() ), actionCollection(), |
1787 | "kaddressbook_beam_vcard" ); | 1732 | "kaddressbook_beam_vcard" ); |
1788 | 1733 | ||
1789 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1734 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1790 | SLOT( beamMySelf() ), actionCollection(), | 1735 | SLOT( beamMySelf() ), actionCollection(), |
1791 | "kaddressbook_beam_myself" ); | 1736 | "kaddressbook_beam_myself" ); |
1792 | } | 1737 | } |
1793 | #endif | 1738 | #endif |
1794 | 1739 | ||
1795 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1740 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1796 | this, SLOT( editContact2() ), | 1741 | this, SLOT( editContact2() ), |
1797 | actionCollection(), "file_properties" ); | 1742 | actionCollection(), "file_properties" ); |
1798 | 1743 | ||
1799 | #ifdef KAB_EMBEDDED | 1744 | #ifdef KAB_EMBEDDED |
1800 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1745 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1801 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1746 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1802 | mMainWindow, SLOT( exit() ), | 1747 | mMainWindow, SLOT( exit() ), |
1803 | actionCollection(), "quit" ); | 1748 | actionCollection(), "quit" ); |
1804 | #endif //KAB_EMBEDDED | 1749 | #endif //KAB_EMBEDDED |
1805 | 1750 | ||
1806 | // edit menu | 1751 | // edit menu |
1807 | if ( mIsPart ) { | 1752 | if ( mIsPart ) { |
1808 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1753 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1809 | SLOT( copyContacts() ), actionCollection(), | 1754 | SLOT( copyContacts() ), actionCollection(), |
1810 | "kaddressbook_copy" ); | 1755 | "kaddressbook_copy" ); |
1811 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1756 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1812 | SLOT( cutContacts() ), actionCollection(), | 1757 | SLOT( cutContacts() ), actionCollection(), |
1813 | "kaddressbook_cut" ); | 1758 | "kaddressbook_cut" ); |
1814 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1759 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1815 | SLOT( pasteContacts() ), actionCollection(), | 1760 | SLOT( pasteContacts() ), actionCollection(), |
1816 | "kaddressbook_paste" ); | 1761 | "kaddressbook_paste" ); |
1817 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1762 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1818 | SLOT( selectAllContacts() ), actionCollection(), | 1763 | SLOT( selectAllContacts() ), actionCollection(), |
1819 | "kaddressbook_select_all" ); | 1764 | "kaddressbook_select_all" ); |
1820 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1765 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1821 | SLOT( undo() ), actionCollection(), | 1766 | SLOT( undo() ), actionCollection(), |
1822 | "kaddressbook_undo" ); | 1767 | "kaddressbook_undo" ); |
1823 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1768 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1824 | this, SLOT( redo() ), actionCollection(), | 1769 | this, SLOT( redo() ), actionCollection(), |
1825 | "kaddressbook_redo" ); | 1770 | "kaddressbook_redo" ); |
1826 | } else { | 1771 | } else { |
1827 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1772 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1828 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1773 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1829 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1774 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1830 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1775 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1831 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1776 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1832 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1777 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1833 | } | 1778 | } |
1834 | 1779 | ||
1835 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1780 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1836 | Key_Delete, this, SLOT( deleteContacts() ), | 1781 | Key_Delete, this, SLOT( deleteContacts() ), |
1837 | actionCollection(), "edit_delete" ); | 1782 | actionCollection(), "edit_delete" ); |
1838 | 1783 | ||
1839 | mActionUndo->setEnabled( false ); | 1784 | mActionUndo->setEnabled( false ); |
1840 | mActionRedo->setEnabled( false ); | 1785 | mActionRedo->setEnabled( false ); |
1841 | 1786 | ||
1842 | // settings menu | 1787 | // settings menu |
1843 | #ifdef KAB_EMBEDDED | 1788 | #ifdef KAB_EMBEDDED |
1844 | //US special menuentry to configure the addressbook resources. On KDE | 1789 | //US special menuentry to configure the addressbook resources. On KDE |
1845 | // you do that through the control center !!! | 1790 | // you do that through the control center !!! |
1846 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1791 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1847 | SLOT( configureResources() ), actionCollection(), | 1792 | SLOT( configureResources() ), actionCollection(), |
1848 | "kaddressbook_configure_resources" ); | 1793 | "kaddressbook_configure_resources" ); |
1849 | #endif //KAB_EMBEDDED | 1794 | #endif //KAB_EMBEDDED |
1850 | 1795 | ||
1851 | if ( mIsPart ) { | 1796 | if ( mIsPart ) { |
1852 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1797 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1853 | SLOT( openConfigDialog() ), actionCollection(), | 1798 | SLOT( openConfigDialog() ), actionCollection(), |
1854 | "kaddressbook_configure" ); | 1799 | "kaddressbook_configure" ); |
1855 | 1800 | ||
1856 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1801 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1857 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1802 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1858 | "kaddressbook_configure_shortcuts" ); | 1803 | "kaddressbook_configure_shortcuts" ); |
1859 | #ifdef KAB_EMBEDDED | 1804 | #ifdef KAB_EMBEDDED |
1860 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1805 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1861 | mActionConfigureToolbars->setEnabled( false ); | 1806 | mActionConfigureToolbars->setEnabled( false ); |
1862 | #endif //KAB_EMBEDDED | 1807 | #endif //KAB_EMBEDDED |
1863 | 1808 | ||
1864 | } else { | 1809 | } else { |
1865 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1810 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1866 | 1811 | ||
1867 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1812 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1868 | } | 1813 | } |
1869 | 1814 | ||
1870 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1815 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1871 | actionCollection(), "options_show_jump_bar" ); | 1816 | actionCollection(), "options_show_jump_bar" ); |
1872 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1817 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1873 | 1818 | ||
1874 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1819 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1875 | actionCollection(), "options_show_details" ); | 1820 | actionCollection(), "options_show_details" ); |
1876 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1821 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1877 | 1822 | ||
1878 | // misc | 1823 | // misc |
1879 | // only enable LDAP lookup if we can handle the protocol | 1824 | // only enable LDAP lookup if we can handle the protocol |
1880 | #ifndef KAB_EMBEDDED | 1825 | #ifndef KAB_EMBEDDED |
1881 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1826 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1882 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1827 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1883 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1828 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1884 | "ldap_lookup" ); | 1829 | "ldap_lookup" ); |
1885 | } | 1830 | } |
1886 | #else //KAB_EMBEDDED | 1831 | #else //KAB_EMBEDDED |
1887 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1832 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1888 | #endif //KAB_EMBEDDED | 1833 | #endif //KAB_EMBEDDED |
1889 | 1834 | ||
1890 | 1835 | ||
1891 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1836 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1892 | SLOT( setWhoAmI() ), actionCollection(), | 1837 | SLOT( setWhoAmI() ), actionCollection(), |
1893 | "set_personal" ); | 1838 | "set_personal" ); |
1894 | 1839 | ||
1895 | 1840 | ||
1896 | 1841 | ||
1897 | 1842 | ||
1898 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1843 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1899 | SLOT( setCategories() ), actionCollection(), | 1844 | SLOT( setCategories() ), actionCollection(), |
1900 | "edit_set_categories" ); | 1845 | "edit_set_categories" ); |
1901 | 1846 | ||
1902 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1847 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1903 | SLOT( removeVoice() ), actionCollection(), | 1848 | SLOT( removeVoice() ), actionCollection(), |
1904 | "remove_voice" ); | 1849 | "remove_voice" ); |
1905 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1850 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1906 | SLOT( importFromOL() ), actionCollection(), | 1851 | SLOT( importFromOL() ), actionCollection(), |
1907 | "import_OL" ); | 1852 | "import_OL" ); |
1908 | #ifdef KAB_EMBEDDED | 1853 | #ifdef KAB_EMBEDDED |
1909 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1854 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1910 | this, SLOT( showLicence() ), actionCollection(), | 1855 | this, SLOT( showLicence() ), actionCollection(), |
1911 | "licence_about_data" ); | 1856 | "licence_about_data" ); |
1912 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1857 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1913 | this, SLOT( faq() ), actionCollection(), | 1858 | this, SLOT( faq() ), actionCollection(), |
1914 | "faq_about_data" ); | 1859 | "faq_about_data" ); |
1915 | 1860 | ||
1916 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1861 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1917 | this, SLOT( createAboutData() ), actionCollection(), | 1862 | this, SLOT( createAboutData() ), actionCollection(), |
1918 | "kaddressbook_about_data" ); | 1863 | "kaddressbook_about_data" ); |
1919 | #endif //KAB_EMBEDDED | 1864 | #endif //KAB_EMBEDDED |
1920 | 1865 | ||
1921 | clipboardDataChanged(); | 1866 | clipboardDataChanged(); |
1922 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1867 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1923 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1868 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1924 | } | 1869 | } |
1925 | 1870 | ||
1926 | //US we need this function, to plug all actions into the correct menues. | 1871 | //US we need this function, to plug all actions into the correct menues. |
1927 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1872 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1928 | void KABCore::addActionsManually() | 1873 | void KABCore::addActionsManually() |
1929 | { | 1874 | { |
1930 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1875 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1931 | 1876 | ||
1932 | #ifdef KAB_EMBEDDED | 1877 | #ifdef KAB_EMBEDDED |
1933 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1878 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1934 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1879 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1935 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1880 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1936 | 1881 | ||
1937 | KToolBar* tb = mMainWindow->toolBar(); | 1882 | KToolBar* tb = mMainWindow->toolBar(); |
1938 | 1883 | ||
1939 | #ifdef DESKTOP_VERSION | 1884 | #ifdef DESKTOP_VERSION |
1940 | QMenuBar* mb = mMainWindow->menuBar(); | 1885 | QMenuBar* mb = mMainWindow->menuBar(); |
1941 | 1886 | ||
1942 | //US setup menubar. | 1887 | //US setup menubar. |
1943 | //Disable the following block if you do not want to have a menubar. | 1888 | //Disable the following block if you do not want to have a menubar. |
1944 | mb->insertItem( "&File", fileMenu ); | 1889 | mb->insertItem( "&File", fileMenu ); |
1945 | mb->insertItem( "&Edit", editMenu ); | 1890 | mb->insertItem( "&Edit", editMenu ); |
1946 | mb->insertItem( "&View", viewMenu ); | 1891 | mb->insertItem( "&View", viewMenu ); |
1947 | mb->insertItem( "&Settings", settingsMenu ); | 1892 | mb->insertItem( "&Settings", settingsMenu ); |
1948 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1893 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1949 | mb->insertItem( "&Change selected", changeMenu ); | 1894 | mb->insertItem( "&Change selected", changeMenu ); |
1950 | mb->insertItem( "&Help", helpMenu ); | 1895 | mb->insertItem( "&Help", helpMenu ); |
1951 | mIncSearchWidget = new IncSearchWidget( tb ); | 1896 | mIncSearchWidget = new IncSearchWidget( tb ); |
1952 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1897 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1953 | 1898 | ||
1954 | #else | 1899 | #else |
1955 | //US setup toolbar | 1900 | //US setup toolbar |
1956 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1901 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1957 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1902 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1958 | menuBarTB->insertItem( "ME", popupBarTB); | 1903 | menuBarTB->insertItem( "ME", popupBarTB); |
1959 | tb->insertWidget(-1, 0, menuBarTB); | 1904 | tb->insertWidget(-1, 0, menuBarTB); |
1960 | mIncSearchWidget = new IncSearchWidget( tb ); | 1905 | mIncSearchWidget = new IncSearchWidget( tb ); |
1961 | 1906 | ||
1962 | tb->enableMoving(false); | 1907 | tb->enableMoving(false); |
1963 | popupBarTB->insertItem( "&File", fileMenu ); | 1908 | popupBarTB->insertItem( "&File", fileMenu ); |
1964 | popupBarTB->insertItem( "&Edit", editMenu ); | 1909 | popupBarTB->insertItem( "&Edit", editMenu ); |
1965 | popupBarTB->insertItem( "&View", viewMenu ); | 1910 | popupBarTB->insertItem( "&View", viewMenu ); |
1966 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1911 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1967 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1912 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1968 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1913 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1969 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1914 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1970 | popupBarTB->insertItem( "&Help", helpMenu ); | 1915 | popupBarTB->insertItem( "&Help", helpMenu ); |
1971 | if (QApplication::desktop()->width() > 320 ) { | 1916 | if (QApplication::desktop()->width() > 320 ) { |
1972 | // mViewManager->getFilterAction()->plug ( tb); | 1917 | // mViewManager->getFilterAction()->plug ( tb); |
1973 | } | 1918 | } |
1974 | #endif | 1919 | #endif |
1975 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1920 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1976 | 1921 | ||
1977 | 1922 | ||
1978 | 1923 | ||
1979 | //US Now connect the actions with the menue entries. | 1924 | //US Now connect the actions with the menue entries. |
1980 | mActionPrint->plug( fileMenu ); | 1925 | mActionPrint->plug( fileMenu ); |
1981 | mActionMail->plug( fileMenu ); | 1926 | mActionMail->plug( fileMenu ); |
1982 | fileMenu->insertSeparator(); | 1927 | fileMenu->insertSeparator(); |
1983 | 1928 | ||
1984 | mActionNewContact->plug( fileMenu ); | 1929 | mActionNewContact->plug( fileMenu ); |
1985 | mActionNewContact->plug( tb ); | 1930 | mActionNewContact->plug( tb ); |
1986 | 1931 | ||
1987 | mActionEditAddressee->plug( fileMenu ); | 1932 | mActionEditAddressee->plug( fileMenu ); |
1988 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1933 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1989 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1934 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1990 | mActionEditAddressee->plug( tb ); | 1935 | mActionEditAddressee->plug( tb ); |
1991 | 1936 | ||
1992 | fileMenu->insertSeparator(); | 1937 | fileMenu->insertSeparator(); |
1993 | mActionSave->plug( fileMenu ); | 1938 | mActionSave->plug( fileMenu ); |
1994 | fileMenu->insertItem( "&Import", ImportMenu ); | 1939 | fileMenu->insertItem( "&Import", ImportMenu ); |
1995 | fileMenu->insertItem( "&Export", ExportMenu ); | 1940 | fileMenu->insertItem( "&Export", ExportMenu ); |
1996 | fileMenu->insertSeparator(); | 1941 | fileMenu->insertSeparator(); |
1997 | mActionMailVCard->plug( fileMenu ); | 1942 | mActionMailVCard->plug( fileMenu ); |
1998 | #ifndef DESKTOP_VERSION | 1943 | #ifndef DESKTOP_VERSION |
1999 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1944 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
2000 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1945 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
2001 | #endif | 1946 | #endif |
2002 | fileMenu->insertSeparator(); | 1947 | fileMenu->insertSeparator(); |
2003 | mActionQuit->plug( fileMenu ); | 1948 | mActionQuit->plug( fileMenu ); |
2004 | #ifdef _WIN32_ | 1949 | #ifdef _WIN32_ |
2005 | mActionImportOL->plug( ImportMenu ); | 1950 | mActionImportOL->plug( ImportMenu ); |
2006 | #endif | 1951 | #endif |
2007 | // edit menu | 1952 | // edit menu |
2008 | mActionUndo->plug( editMenu ); | 1953 | mActionUndo->plug( editMenu ); |
2009 | mActionRedo->plug( editMenu ); | 1954 | mActionRedo->plug( editMenu ); |
2010 | editMenu->insertSeparator(); | 1955 | editMenu->insertSeparator(); |
2011 | mActionCut->plug( editMenu ); | 1956 | mActionCut->plug( editMenu ); |
2012 | mActionCopy->plug( editMenu ); | 1957 | mActionCopy->plug( editMenu ); |
2013 | mActionPaste->plug( editMenu ); | 1958 | mActionPaste->plug( editMenu ); |
2014 | mActionDelete->plug( editMenu ); | 1959 | mActionDelete->plug( editMenu ); |
2015 | editMenu->insertSeparator(); | 1960 | editMenu->insertSeparator(); |
2016 | mActionSelectAll->plug( editMenu ); | 1961 | mActionSelectAll->plug( editMenu ); |
2017 | 1962 | ||
2018 | mActionRemoveVoice->plug( changeMenu ); | 1963 | mActionRemoveVoice->plug( changeMenu ); |
2019 | // settings menu | 1964 | // settings menu |
2020 | //US special menuentry to configure the addressbook resources. On KDE | 1965 | //US special menuentry to configure the addressbook resources. On KDE |
2021 | // you do that through the control center !!! | 1966 | // you do that through the control center !!! |
2022 | mActionConfigResources->plug( settingsMenu ); | 1967 | mActionConfigResources->plug( settingsMenu ); |
2023 | settingsMenu->insertSeparator(); | 1968 | settingsMenu->insertSeparator(); |
2024 | 1969 | ||
2025 | mActionConfigKAddressbook->plug( settingsMenu ); | 1970 | mActionConfigKAddressbook->plug( settingsMenu ); |
2026 | 1971 | ||
2027 | if ( mIsPart ) { | 1972 | if ( mIsPart ) { |
2028 | mActionConfigShortcuts->plug( settingsMenu ); | 1973 | mActionConfigShortcuts->plug( settingsMenu ); |
2029 | mActionConfigureToolbars->plug( settingsMenu ); | 1974 | mActionConfigureToolbars->plug( settingsMenu ); |
2030 | 1975 | ||
2031 | } else { | 1976 | } else { |
2032 | mActionKeyBindings->plug( settingsMenu ); | 1977 | mActionKeyBindings->plug( settingsMenu ); |
2033 | } | 1978 | } |
2034 | 1979 | ||
2035 | settingsMenu->insertSeparator(); | 1980 | settingsMenu->insertSeparator(); |
2036 | 1981 | ||
2037 | mActionJumpBar->plug( settingsMenu ); | 1982 | mActionJumpBar->plug( settingsMenu ); |
2038 | mActionDetails->plug( settingsMenu ); | 1983 | mActionDetails->plug( settingsMenu ); |
2039 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1984 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2040 | mActionDetails->plug( tb ); | 1985 | mActionDetails->plug( tb ); |
2041 | settingsMenu->insertSeparator(); | 1986 | settingsMenu->insertSeparator(); |
2042 | 1987 | ||
2043 | mActionWhoAmI->plug( settingsMenu ); | 1988 | mActionWhoAmI->plug( settingsMenu ); |
2044 | mActionCategories->plug( settingsMenu ); | 1989 | mActionCategories->plug( settingsMenu ); |
2045 | 1990 | ||
2046 | mActionLicence->plug( helpMenu ); | 1991 | mActionLicence->plug( helpMenu ); |
2047 | mActionFaq->plug( helpMenu ); | 1992 | mActionFaq->plug( helpMenu ); |
2048 | mActionAboutKAddressbook->plug( helpMenu ); | 1993 | mActionAboutKAddressbook->plug( helpMenu ); |
2049 | 1994 | ||
2050 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1995 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2051 | 1996 | ||
2052 | mActionSave->plug( tb ); | 1997 | mActionSave->plug( tb ); |
2053 | mViewManager->getFilterAction()->plug ( tb); | 1998 | mViewManager->getFilterAction()->plug ( tb); |
2054 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1999 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2055 | mActionUndo->plug( tb ); | 2000 | mActionUndo->plug( tb ); |
2056 | mActionDelete->plug( tb ); | 2001 | mActionDelete->plug( tb ); |
2057 | mActionRedo->plug( tb ); | 2002 | mActionRedo->plug( tb ); |
2058 | } | 2003 | } |
2059 | } | 2004 | } |
2060 | //mActionQuit->plug ( tb ); | 2005 | //mActionQuit->plug ( tb ); |
2061 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2006 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2062 | 2007 | ||
2063 | //US link the searchwidget first to this. | 2008 | //US link the searchwidget first to this. |
2064 | // The real linkage to the toolbar happens later. | 2009 | // The real linkage to the toolbar happens later. |
2065 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2010 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2066 | //US tb->insertItem( mIncSearchWidget ); | 2011 | //US tb->insertItem( mIncSearchWidget ); |
2067 | /*US | 2012 | /*US |
2068 | mIncSearchWidget = new IncSearchWidget( tb ); | 2013 | mIncSearchWidget = new IncSearchWidget( tb ); |
2069 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2014 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2070 | SLOT( incrementalSearch( const QString& ) ) ); | 2015 | SLOT( incrementalSearch( const QString& ) ) ); |
2071 | 2016 | ||
2072 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2017 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2073 | 2018 | ||
2074 | //US topLayout->addWidget( mJumpButtonBar ); | 2019 | //US topLayout->addWidget( mJumpButtonBar ); |
2075 | this->layout()->add( mJumpButtonBar ); | 2020 | this->layout()->add( mJumpButtonBar ); |
2076 | */ | 2021 | */ |
2077 | 2022 | ||
2078 | #endif //KAB_EMBEDDED | 2023 | #endif //KAB_EMBEDDED |
2079 | 2024 | ||
2080 | mActionExport2phone->plug( ExportMenu ); | 2025 | mActionExport2phone->plug( ExportMenu ); |
2081 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2026 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2082 | syncManager->fillSyncMenu(); | 2027 | syncManager->fillSyncMenu(); |
2083 | 2028 | ||
2084 | } | 2029 | } |
2085 | void KABCore::showLicence() | 2030 | void KABCore::showLicence() |
2086 | { | 2031 | { |
2087 | KApplication::showLicence(); | 2032 | KApplication::showLicence(); |
2088 | } | 2033 | } |
2089 | void KABCore::removeVoice() | 2034 | void KABCore::removeVoice() |
2090 | { | 2035 | { |
2091 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 2036 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
2092 | return; | 2037 | return; |
2093 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2038 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2094 | KABC::Addressee::List::Iterator it; | 2039 | KABC::Addressee::List::Iterator it; |
2095 | for ( it = list.begin(); it != list.end(); ++it ) { | 2040 | for ( it = list.begin(); it != list.end(); ++it ) { |
2096 | 2041 | ||
2097 | if ( (*it).removeVoice() ) | 2042 | if ( (*it).removeVoice() ) |
2098 | contactModified((*it) ); | 2043 | contactModified((*it) ); |
2099 | } | 2044 | } |
2100 | } | 2045 | } |
2101 | 2046 | ||
2102 | 2047 | ||
2103 | 2048 | ||
2104 | void KABCore::clipboardDataChanged() | 2049 | void KABCore::clipboardDataChanged() |
2105 | { | 2050 | { |
2106 | 2051 | ||
2107 | if ( mReadWrite ) | 2052 | if ( mReadWrite ) |
2108 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2053 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2109 | 2054 | ||
2110 | } | 2055 | } |
2111 | 2056 | ||
2112 | void KABCore::updateActionMenu() | 2057 | void KABCore::updateActionMenu() |
2113 | { | 2058 | { |
2114 | UndoStack *undo = UndoStack::instance(); | 2059 | UndoStack *undo = UndoStack::instance(); |
2115 | RedoStack *redo = RedoStack::instance(); | 2060 | RedoStack *redo = RedoStack::instance(); |
2116 | 2061 | ||
2117 | if ( undo->isEmpty() ) | 2062 | if ( undo->isEmpty() ) |
2118 | mActionUndo->setText( i18n( "Undo" ) ); | 2063 | mActionUndo->setText( i18n( "Undo" ) ); |
2119 | else | 2064 | else |
2120 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2065 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2121 | 2066 | ||
2122 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2067 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2123 | 2068 | ||
2124 | if ( !redo->top() ) | 2069 | if ( !redo->top() ) |
2125 | mActionRedo->setText( i18n( "Redo" ) ); | 2070 | mActionRedo->setText( i18n( "Redo" ) ); |
2126 | else | 2071 | else |
2127 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2072 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2128 | 2073 | ||
2129 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2074 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2130 | } | 2075 | } |
2131 | 2076 | ||
2132 | void KABCore::configureKeyBindings() | 2077 | void KABCore::configureKeyBindings() |
2133 | { | 2078 | { |
2134 | #ifndef KAB_EMBEDDED | 2079 | #ifndef KAB_EMBEDDED |
2135 | KKeyDialog::configure( actionCollection(), true ); | 2080 | KKeyDialog::configure( actionCollection(), true ); |
2136 | #else //KAB_EMBEDDED | 2081 | #else //KAB_EMBEDDED |
2137 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2082 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2138 | #endif //KAB_EMBEDDED | 2083 | #endif //KAB_EMBEDDED |
2139 | } | 2084 | } |
2140 | 2085 | ||
2141 | #ifdef KAB_EMBEDDED | 2086 | #ifdef KAB_EMBEDDED |
2142 | void KABCore::configureResources() | 2087 | void KABCore::configureResources() |
2143 | { | 2088 | { |
2144 | KRES::KCMKResources dlg( this, "" , 0 ); | 2089 | KRES::KCMKResources dlg( this, "" , 0 ); |
2145 | 2090 | ||
2146 | if ( !dlg.exec() ) | 2091 | if ( !dlg.exec() ) |
2147 | return; | 2092 | return; |
2148 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2093 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2149 | } | 2094 | } |
2150 | #endif //KAB_EMBEDDED | 2095 | #endif //KAB_EMBEDDED |
2151 | 2096 | ||
2152 | 2097 | ||
2153 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2098 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2154 | * for the attendees list of an event. | 2099 | * for the attendees list of an event. |
2155 | */ | 2100 | */ |
2156 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2101 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2157 | { | 2102 | { |
2158 | QStringList nameList; | 2103 | QStringList nameList; |
2159 | QStringList emailList; | 2104 | QStringList emailList; |
2160 | QStringList uidList; | 2105 | QStringList uidList; |
2161 | 2106 | ||
2162 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2107 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2163 | uint i=0; | 2108 | uint i=0; |
2164 | for (i=0; i < list.count(); i++) | 2109 | for (i=0; i < list.count(); i++) |
2165 | { | 2110 | { |
2166 | nameList.append(list[i].realName()); | 2111 | nameList.append(list[i].realName()); |
2167 | emailList.append(list[i].preferredEmail()); | 2112 | emailList.append(list[i].preferredEmail()); |
2168 | uidList.append(list[i].uid()); | 2113 | uidList.append(list[i].uid()); |
2169 | } | 2114 | } |
2170 | 2115 | ||
2171 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2116 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2172 | 2117 | ||
2173 | } | 2118 | } |
2174 | 2119 | ||
2175 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2120 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2176 | * to put them into the calendar. | 2121 | * to put them into the calendar. |
2177 | */ | 2122 | */ |
2178 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2123 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2179 | { | 2124 | { |
2180 | // qDebug("KABCore::requestForBirthdayList"); | 2125 | // qDebug("KABCore::requestForBirthdayList"); |
2181 | QStringList birthdayList; | 2126 | QStringList birthdayList; |
2182 | QStringList anniversaryList; | 2127 | QStringList anniversaryList; |
2183 | QStringList realNameList; | 2128 | QStringList realNameList; |
2184 | QStringList preferredEmailList; | 2129 | QStringList preferredEmailList; |
2185 | QStringList assembledNameList; | 2130 | QStringList assembledNameList; |
2186 | QStringList uidList; | 2131 | QStringList uidList; |
2187 | 2132 | ||
2188 | KABC::AddressBook::Iterator it; | 2133 | KABC::AddressBook::Iterator it; |
2189 | 2134 | ||
2190 | int count = 0; | 2135 | int count = 0; |
2191 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2136 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2192 | ++count; | 2137 | ++count; |
2193 | } | 2138 | } |
2194 | QProgressBar bar(count,0 ); | 2139 | QProgressBar bar(count,0 ); |
2195 | int w = 300; | 2140 | int w = 300; |
2196 | if ( QApplication::desktop()->width() < 320 ) | 2141 | if ( QApplication::desktop()->width() < 320 ) |
2197 | w = 220; | 2142 | w = 220; |
2198 | int h = bar.sizeHint().height() ; | 2143 | int h = bar.sizeHint().height() ; |
2199 | int dw = QApplication::desktop()->width(); | 2144 | int dw = QApplication::desktop()->width(); |
2200 | int dh = QApplication::desktop()->height(); | 2145 | int dh = QApplication::desktop()->height(); |
2201 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2146 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2202 | bar.show(); | 2147 | bar.show(); |
2203 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); | 2148 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); |
2204 | qApp->processEvents(); | 2149 | qApp->processEvents(); |
2205 | 2150 | ||
2206 | QDate bday; | 2151 | QDate bday; |
2207 | QString anni; | 2152 | QString anni; |
2208 | QString formattedbday; | 2153 | QString formattedbday; |
2209 | 2154 | ||
2210 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2155 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2211 | { | 2156 | { |
2212 | if ( ! bar.isVisible() ) | 2157 | if ( ! bar.isVisible() ) |
2213 | return; | 2158 | return; |
2214 | bar.setProgress( count++ ); | 2159 | bar.setProgress( count++ ); |
2215 | qApp->processEvents(); | 2160 | qApp->processEvents(); |
2216 | bday = (*it).birthday().date(); | 2161 | bday = (*it).birthday().date(); |
2217 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2162 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2218 | 2163 | ||
2219 | if ( bday.isValid() || !anni.isEmpty()) | 2164 | if ( bday.isValid() || !anni.isEmpty()) |
2220 | { | 2165 | { |
2221 | if (bday.isValid()) | 2166 | if (bday.isValid()) |
2222 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2167 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2223 | else | 2168 | else |
2224 | formattedbday = "NOTVALID"; | 2169 | formattedbday = "NOTVALID"; |
2225 | if (anni.isEmpty()) | 2170 | if (anni.isEmpty()) |
2226 | anni = "INVALID"; | 2171 | anni = "INVALID"; |
2227 | 2172 | ||
2228 | birthdayList.append(formattedbday); | 2173 | birthdayList.append(formattedbday); |
2229 | anniversaryList.append(anni); //should be ISODate | 2174 | anniversaryList.append(anni); //should be ISODate |
2230 | realNameList.append((*it).realName()); | 2175 | realNameList.append((*it).realName()); |
2231 | preferredEmailList.append((*it).preferredEmail()); | 2176 | preferredEmailList.append((*it).preferredEmail()); |
2232 | assembledNameList.append((*it).assembledName()); | 2177 | assembledNameList.append((*it).assembledName()); |
2233 | uidList.append((*it).uid()); | 2178 | uidList.append((*it).uid()); |
2234 | 2179 | ||
2235 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2180 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2236 | } | 2181 | } |
2237 | } | 2182 | } |
2238 | 2183 | ||
2239 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2184 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2240 | 2185 | ||
2241 | } | 2186 | } |
2242 | 2187 | ||
2243 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2188 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2244 | */ | 2189 | */ |
2245 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2190 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2246 | { | 2191 | { |
2247 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2192 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2248 | 2193 | ||
2249 | QString foundUid = QString::null; | 2194 | QString foundUid = QString::null; |
2250 | if ( ! uid.isEmpty() ) { | 2195 | if ( ! uid.isEmpty() ) { |
2251 | Addressee adrr = mAddressBook->findByUid( uid ); | 2196 | Addressee adrr = mAddressBook->findByUid( uid ); |
2252 | if ( !adrr.isEmpty() ) { | 2197 | if ( !adrr.isEmpty() ) { |
2253 | foundUid = uid; | 2198 | foundUid = uid; |
2254 | } | 2199 | } |
2255 | if ( email == "sendbacklist" ) { | 2200 | if ( email == "sendbacklist" ) { |
2256 | //qDebug("ssssssssssssssssssssssend "); | 2201 | //qDebug("ssssssssssssssssssssssend "); |
2257 | QStringList nameList; | 2202 | QStringList nameList; |
2258 | QStringList emailList; | 2203 | QStringList emailList; |
2259 | QStringList uidList; | 2204 | QStringList uidList; |
2260 | nameList.append(adrr.realName()); | 2205 | nameList.append(adrr.realName()); |
2261 | emailList = adrr.emails(); | 2206 | emailList = adrr.emails(); |
2262 | uidList.append( adrr.preferredEmail()); | 2207 | uidList.append( adrr.preferredEmail()); |
2263 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2208 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2264 | return; | 2209 | return; |
2265 | } | 2210 | } |
2266 | 2211 | ||
2267 | } | 2212 | } |
2268 | 2213 | ||
2269 | if ( email == "sendbacklist" ) | 2214 | if ( email == "sendbacklist" ) |
2270 | return; | 2215 | return; |
2271 | if (foundUid.isEmpty()) | 2216 | if (foundUid.isEmpty()) |
2272 | { | 2217 | { |
2273 | //find the uid of the person first | 2218 | //find the uid of the person first |
2274 | Addressee::List namelist; | 2219 | Addressee::List namelist; |
2275 | Addressee::List emaillist; | 2220 | Addressee::List emaillist; |
2276 | 2221 | ||
2277 | if (!name.isEmpty()) | 2222 | if (!name.isEmpty()) |
2278 | namelist = mAddressBook->findByName( name ); | 2223 | namelist = mAddressBook->findByName( name ); |
2279 | 2224 | ||
2280 | if (!email.isEmpty()) | 2225 | if (!email.isEmpty()) |
2281 | emaillist = mAddressBook->findByEmail( email ); | 2226 | emaillist = mAddressBook->findByEmail( email ); |
2282 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2227 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2283 | //check if we have a match in Namelist and Emaillist | 2228 | //check if we have a match in Namelist and Emaillist |
2284 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2229 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2285 | foundUid = emaillist[0].uid(); | 2230 | foundUid = emaillist[0].uid(); |
2286 | } | 2231 | } |
2287 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2232 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2288 | foundUid = namelist[0].uid(); | 2233 | foundUid = namelist[0].uid(); |
2289 | else | 2234 | else |
2290 | { | 2235 | { |
2291 | for (int i = 0; i < namelist.count(); i++) | 2236 | for (int i = 0; i < namelist.count(); i++) |
2292 | { | 2237 | { |
2293 | for (int j = 0; j < emaillist.count(); j++) | 2238 | for (int j = 0; j < emaillist.count(); j++) |
2294 | { | 2239 | { |
2295 | if (namelist[i] == emaillist[j]) | 2240 | if (namelist[i] == emaillist[j]) |
2296 | { | 2241 | { |
2297 | foundUid = namelist[i].uid(); | 2242 | foundUid = namelist[i].uid(); |
2298 | } | 2243 | } |
2299 | } | 2244 | } |
2300 | } | 2245 | } |
2301 | } | 2246 | } |
2302 | } | 2247 | } |
2303 | else | 2248 | else |
2304 | { | 2249 | { |
2305 | foundUid = uid; | 2250 | foundUid = uid; |
2306 | } | 2251 | } |
2307 | 2252 | ||
2308 | if (!foundUid.isEmpty()) | 2253 | if (!foundUid.isEmpty()) |
2309 | { | 2254 | { |
2310 | 2255 | ||
2311 | // raise Ka/Pi if it is in the background | 2256 | // raise Ka/Pi if it is in the background |
2312 | #ifndef DESKTOP_VERSION | 2257 | #ifndef DESKTOP_VERSION |
2313 | #ifndef KORG_NODCOP | 2258 | #ifndef KORG_NODCOP |
2314 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2259 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2315 | #endif | 2260 | #endif |
2316 | #endif | 2261 | #endif |
2317 | 2262 | ||
2318 | mMainWindow->showMaximized(); | 2263 | mMainWindow->showMaximized(); |
2319 | mMainWindow-> raise(); | 2264 | mMainWindow-> raise(); |
2320 | 2265 | ||
2321 | mViewManager->setSelected( "", false); | 2266 | mViewManager->setSelected( "", false); |
2322 | mViewManager->refreshView( "" ); | 2267 | mViewManager->refreshView( "" ); |
2323 | mViewManager->setSelected( foundUid, true ); | 2268 | mViewManager->setSelected( foundUid, true ); |
2324 | mViewManager->refreshView( foundUid ); | 2269 | mViewManager->refreshView( foundUid ); |
2325 | 2270 | ||
2326 | if ( !mMultipleViewsAtOnce ) | 2271 | if ( !mMultipleViewsAtOnce ) |
2327 | { | 2272 | { |
2328 | setDetailsVisible( true ); | 2273 | setDetailsVisible( true ); |
2329 | mActionDetails->setChecked(true); | 2274 | mActionDetails->setChecked(true); |
2330 | } | 2275 | } |
2331 | } | 2276 | } |
2332 | } | 2277 | } |
2333 | 2278 | ||
2334 | 2279 | ||
2335 | void KABCore::faq() | 2280 | void KABCore::faq() |
2336 | { | 2281 | { |
2337 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2282 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2338 | } | 2283 | } |
2339 | 2284 | ||
2340 | #include <libkcal/syncdefines.h> | 2285 | #include <libkcal/syncdefines.h> |
2341 | 2286 | ||
2342 | KABC::Addressee KABCore::getLastSyncAddressee() | 2287 | KABC::Addressee KABCore::getLastSyncAddressee() |
2343 | { | 2288 | { |
2344 | Addressee lse; | 2289 | Addressee lse; |
2345 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2290 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2346 | 2291 | ||
2347 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2292 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2348 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2293 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2349 | if (lse.isEmpty()) { | 2294 | if (lse.isEmpty()) { |
2350 | qDebug("Creating new last-syncAddressee "); | 2295 | qDebug("Creating new last-syncAddressee "); |
2351 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2296 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2352 | QString sum = ""; | 2297 | QString sum = ""; |
2353 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2298 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2354 | sum = "E: "; | 2299 | sum = "E: "; |
2355 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2300 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2356 | lse.setRevision( mLastAddressbookSync ); | 2301 | lse.setRevision( mLastAddressbookSync ); |
2357 | lse.setCategories( i18n("SyncEvent") ); | 2302 | lse.setCategories( i18n("SyncEvent") ); |
2358 | mAddressBook->insertAddressee( lse ); | 2303 | mAddressBook->insertAddressee( lse ); |
2359 | } | 2304 | } |
2360 | return lse; | 2305 | return lse; |
2361 | } | 2306 | } |
2362 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2307 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2363 | { | 2308 | { |
2364 | 2309 | ||
2365 | //void setZaurusId(int id); | 2310 | //void setZaurusId(int id); |
2366 | // int zaurusId() const; | 2311 | // int zaurusId() const; |
2367 | // void setZaurusUid(int id); | 2312 | // void setZaurusUid(int id); |
2368 | // int zaurusUid() const; | 2313 | // int zaurusUid() const; |
2369 | // void setZaurusStat(int id); | 2314 | // void setZaurusStat(int id); |
2370 | // int zaurusStat() const; | 2315 | // int zaurusStat() const; |
2371 | // 0 equal | 2316 | // 0 equal |
2372 | // 1 take local | 2317 | // 1 take local |
2373 | // 2 take remote | 2318 | // 2 take remote |
2374 | // 3 cancel | 2319 | // 3 cancel |
2375 | QDateTime lastSync = mLastAddressbookSync; | 2320 | QDateTime lastSync = mLastAddressbookSync; |
2376 | QDateTime localMod = local->revision(); | 2321 | QDateTime localMod = local->revision(); |
2377 | QDateTime remoteMod = remote->revision(); | 2322 | QDateTime remoteMod = remote->revision(); |
2378 | 2323 | ||
2379 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2324 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2380 | 2325 | ||
2381 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2326 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2382 | bool remCh, locCh; | 2327 | bool remCh, locCh; |
2383 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2328 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2384 | 2329 | ||
2385 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2330 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2386 | locCh = ( localMod > mLastAddressbookSync ); | 2331 | locCh = ( localMod > mLastAddressbookSync ); |
2387 | if ( !remCh && ! locCh ) { | 2332 | if ( !remCh && ! locCh ) { |
2388 | //qDebug("both not changed "); | 2333 | //qDebug("both not changed "); |
2389 | lastSync = localMod.addDays(1); | 2334 | lastSync = localMod.addDays(1); |
2390 | if ( mode <= SYNC_PREF_ASK ) | 2335 | if ( mode <= SYNC_PREF_ASK ) |
2391 | return 0; | 2336 | return 0; |
2392 | } else { | 2337 | } else { |
2393 | if ( locCh ) { | 2338 | if ( locCh ) { |
2394 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2339 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2395 | lastSync = localMod.addDays( -1 ); | 2340 | lastSync = localMod.addDays( -1 ); |
2396 | if ( !remCh ) | 2341 | if ( !remCh ) |
2397 | remoteMod =( lastSync.addDays( -1 ) ); | 2342 | remoteMod =( lastSync.addDays( -1 ) ); |
2398 | } else { | 2343 | } else { |
2399 | //qDebug(" not loc changed "); | 2344 | //qDebug(" not loc changed "); |
2400 | lastSync = localMod.addDays( 1 ); | 2345 | lastSync = localMod.addDays( 1 ); |
2401 | if ( remCh ) | 2346 | if ( remCh ) |
2402 | remoteMod =( lastSync.addDays( 1 ) ); | 2347 | remoteMod =( lastSync.addDays( 1 ) ); |
2403 | 2348 | ||
2404 | } | 2349 | } |
2405 | } | 2350 | } |
2406 | full = true; | 2351 | full = true; |
2407 | if ( mode < SYNC_PREF_ASK ) | 2352 | if ( mode < SYNC_PREF_ASK ) |
2408 | mode = SYNC_PREF_ASK; | 2353 | mode = SYNC_PREF_ASK; |
2409 | } else { | 2354 | } else { |
2410 | if ( localMod == remoteMod ) | 2355 | if ( localMod == remoteMod ) |
2411 | return 0; | 2356 | return 0; |
2412 | 2357 | ||
2413 | } | 2358 | } |
2414 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2359 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2415 | 2360 | ||
2416 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2361 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2417 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2362 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2418 | //full = true; //debug only | 2363 | //full = true; //debug only |
2419 | if ( full ) { | 2364 | if ( full ) { |
2420 | bool equ = ( (*local) == (*remote) ); | 2365 | bool equ = ( (*local) == (*remote) ); |
2421 | if ( equ ) { | 2366 | if ( equ ) { |
2422 | //qDebug("equal "); | 2367 | //qDebug("equal "); |
2423 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2368 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2424 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2369 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2425 | } | 2370 | } |
2426 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2371 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2427 | return 0; | 2372 | return 0; |
2428 | 2373 | ||
2429 | }//else //debug only | 2374 | }//else //debug only |
2430 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2375 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2431 | } | 2376 | } |
2432 | int result; | 2377 | int result; |
2433 | bool localIsNew; | 2378 | bool localIsNew; |
2434 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2379 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2435 | 2380 | ||
2436 | if ( full && mode < SYNC_PREF_NEWEST ) | 2381 | if ( full && mode < SYNC_PREF_NEWEST ) |
2437 | mode = SYNC_PREF_ASK; | 2382 | mode = SYNC_PREF_ASK; |
2438 | 2383 | ||
2439 | switch( mode ) { | 2384 | switch( mode ) { |
2440 | case SYNC_PREF_LOCAL: | 2385 | case SYNC_PREF_LOCAL: |
2441 | if ( lastSync > remoteMod ) | 2386 | if ( lastSync > remoteMod ) |
2442 | return 1; | 2387 | return 1; |
2443 | if ( lastSync > localMod ) | 2388 | if ( lastSync > localMod ) |
2444 | return 2; | 2389 | return 2; |
2445 | return 1; | 2390 | return 1; |
2446 | break; | 2391 | break; |
2447 | case SYNC_PREF_REMOTE: | 2392 | case SYNC_PREF_REMOTE: |
2448 | if ( lastSync > remoteMod ) | 2393 | if ( lastSync > remoteMod ) |
2449 | return 1; | 2394 | return 1; |
2450 | if ( lastSync > localMod ) | 2395 | if ( lastSync > localMod ) |
2451 | return 2; | 2396 | return 2; |
2452 | return 2; | 2397 | return 2; |
2453 | break; | 2398 | break; |
2454 | case SYNC_PREF_NEWEST: | 2399 | case SYNC_PREF_NEWEST: |
2455 | if ( localMod > remoteMod ) | 2400 | if ( localMod > remoteMod ) |
2456 | return 1; | 2401 | return 1; |
2457 | else | 2402 | else |
2458 | return 2; | 2403 | return 2; |
2459 | break; | 2404 | break; |
2460 | case SYNC_PREF_ASK: | 2405 | case SYNC_PREF_ASK: |
2461 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2406 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2462 | if ( lastSync > remoteMod ) | 2407 | if ( lastSync > remoteMod ) |
2463 | return 1; | 2408 | return 1; |
2464 | if ( lastSync > localMod ) | 2409 | if ( lastSync > localMod ) |
2465 | return 2; | 2410 | return 2; |
2466 | localIsNew = localMod >= remoteMod; | 2411 | localIsNew = localMod >= remoteMod; |
2467 | //qDebug("conflict! ************************************** "); | 2412 | //qDebug("conflict! ************************************** "); |
2468 | { | 2413 | { |
2469 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2414 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2470 | result = acd.executeD(localIsNew); | 2415 | result = acd.executeD(localIsNew); |
2471 | return result; | 2416 | return result; |
2472 | } | 2417 | } |
2473 | break; | 2418 | break; |
2474 | case SYNC_PREF_FORCE_LOCAL: | 2419 | case SYNC_PREF_FORCE_LOCAL: |
2475 | return 1; | 2420 | return 1; |
2476 | break; | 2421 | break; |
2477 | case SYNC_PREF_FORCE_REMOTE: | 2422 | case SYNC_PREF_FORCE_REMOTE: |
2478 | return 2; | 2423 | return 2; |
2479 | break; | 2424 | break; |
2480 | 2425 | ||
2481 | default: | 2426 | default: |
2482 | // SYNC_PREF_TAKE_BOTH not implemented | 2427 | // SYNC_PREF_TAKE_BOTH not implemented |
2483 | break; | 2428 | break; |
2484 | } | 2429 | } |
2485 | return 0; | 2430 | return 0; |
2486 | } | 2431 | } |
2487 | 2432 | ||
2488 | 2433 | ||
2489 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2434 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2490 | { | 2435 | { |
2491 | bool syncOK = true; | 2436 | bool syncOK = true; |
2492 | int addedAddressee = 0; | 2437 | int addedAddressee = 0; |
2493 | int addedAddresseeR = 0; | 2438 | int addedAddresseeR = 0; |
2494 | int deletedAddresseeR = 0; | 2439 | int deletedAddresseeR = 0; |
2495 | int deletedAddresseeL = 0; | 2440 | int deletedAddresseeL = 0; |
2496 | int changedLocal = 0; | 2441 | int changedLocal = 0; |
2497 | int changedRemote = 0; | 2442 | int changedRemote = 0; |
2498 | 2443 | ||
2499 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2444 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2500 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2445 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2501 | 2446 | ||
2502 | //QPtrList<Addressee> el = local->rawAddressees(); | 2447 | //QPtrList<Addressee> el = local->rawAddressees(); |
2503 | Addressee addresseeR; | 2448 | Addressee addresseeR; |
2504 | QString uid; | 2449 | QString uid; |
2505 | int take; | 2450 | int take; |
2506 | Addressee addresseeL; | 2451 | Addressee addresseeL; |
2507 | Addressee addresseeRSync; | 2452 | Addressee addresseeRSync; |
2508 | Addressee addresseeLSync; | 2453 | Addressee addresseeLSync; |
2509 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2454 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2510 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2455 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2511 | bool fullDateRange = false; | 2456 | bool fullDateRange = false; |
2512 | local->resetTempSyncStat(); | 2457 | local->resetTempSyncStat(); |
2513 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2458 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2514 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2459 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2515 | addresseeLSync = getLastSyncAddressee(); | 2460 | addresseeLSync = getLastSyncAddressee(); |
2516 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2461 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2517 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2462 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2518 | if ( !addresseeR.isEmpty() ) { | 2463 | if ( !addresseeR.isEmpty() ) { |
2519 | addresseeRSync = addresseeR; | 2464 | addresseeRSync = addresseeR; |
2520 | remote->removeAddressee(addresseeR ); | 2465 | remote->removeAddressee(addresseeR ); |
2521 | 2466 | ||
2522 | } else { | 2467 | } else { |
2523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2468 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2524 | addresseeRSync = addresseeLSync ; | 2469 | addresseeRSync = addresseeLSync ; |
2525 | } else { | 2470 | } else { |
2526 | qDebug("FULLDATE 1"); | 2471 | qDebug("FULLDATE 1"); |
2527 | fullDateRange = true; | 2472 | fullDateRange = true; |
2528 | Addressee newAdd; | 2473 | Addressee newAdd; |
2529 | addresseeRSync = newAdd; | 2474 | addresseeRSync = newAdd; |
2530 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2475 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2531 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2476 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2532 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2477 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2533 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2478 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2534 | } | 2479 | } |
2535 | } | 2480 | } |
2536 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2481 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2537 | qDebug("FULLDATE 2"); | 2482 | qDebug("FULLDATE 2"); |
2538 | fullDateRange = true; | 2483 | fullDateRange = true; |
2539 | } | 2484 | } |
2540 | if ( ! fullDateRange ) { | 2485 | if ( ! fullDateRange ) { |
2541 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2486 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2542 | 2487 | ||
2543 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2488 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2544 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2489 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2545 | fullDateRange = true; | 2490 | fullDateRange = true; |
2546 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2491 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2547 | } | 2492 | } |
2548 | } | 2493 | } |
2549 | // fullDateRange = true; // debug only! | 2494 | // fullDateRange = true; // debug only! |
2550 | if ( fullDateRange ) | 2495 | if ( fullDateRange ) |
2551 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2496 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2552 | else | 2497 | else |
2553 | mLastAddressbookSync = addresseeLSync.revision(); | 2498 | mLastAddressbookSync = addresseeLSync.revision(); |
2554 | // for resyncing if own file has changed | 2499 | // for resyncing if own file has changed |
2555 | // PENDING fixme later when implemented | 2500 | // PENDING fixme later when implemented |
2556 | #if 0 | 2501 | #if 0 |
2557 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2502 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2558 | mLastAddressbookSync = loadedFileVersion; | 2503 | mLastAddressbookSync = loadedFileVersion; |
2559 | qDebug("setting mLastAddressbookSync "); | 2504 | qDebug("setting mLastAddressbookSync "); |
2560 | } | 2505 | } |
2561 | #endif | 2506 | #endif |
2562 | 2507 | ||
2563 | //qDebug("*************************** "); | 2508 | //qDebug("*************************** "); |
2564 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2509 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2565 | QStringList er = remote->uidList(); | 2510 | QStringList er = remote->uidList(); |
2566 | Addressee inR ;//= er.first(); | 2511 | Addressee inR ;//= er.first(); |
2567 | Addressee inL; | 2512 | Addressee inL; |
2568 | 2513 | ||
2569 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2514 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2570 | 2515 | ||
2571 | int modulo = (er.count()/10)+1; | 2516 | int modulo = (er.count()/10)+1; |
2572 | int incCounter = 0; | 2517 | int incCounter = 0; |
2573 | while ( incCounter < er.count()) { | 2518 | while ( incCounter < er.count()) { |
2574 | if (syncManager->isProgressBarCanceled()) | 2519 | if (syncManager->isProgressBarCanceled()) |
2575 | return false; | 2520 | return false; |
2576 | if ( incCounter % modulo == 0 ) | 2521 | if ( incCounter % modulo == 0 ) |
2577 | syncManager->showProgressBar(incCounter); | 2522 | syncManager->showProgressBar(incCounter); |
2578 | 2523 | ||
2579 | uid = er[ incCounter ]; | 2524 | uid = er[ incCounter ]; |
2580 | bool skipIncidence = false; | 2525 | bool skipIncidence = false; |
2581 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2526 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2582 | skipIncidence = true; | 2527 | skipIncidence = true; |
2583 | QString idS,OidS; | 2528 | QString idS,OidS; |
2584 | qApp->processEvents(); | 2529 | qApp->processEvents(); |
2585 | if ( !skipIncidence ) { | 2530 | if ( !skipIncidence ) { |
2586 | inL = local->findByUid( uid ); | 2531 | inL = local->findByUid( uid ); |
2587 | inR = remote->findByUid( uid ); | 2532 | inR = remote->findByUid( uid ); |
2588 | //inL.setResource( 0 ); | 2533 | //inL.setResource( 0 ); |
2589 | //inR.setResource( 0 ); | 2534 | //inR.setResource( 0 ); |
2590 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2535 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2591 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2536 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2592 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2537 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2593 | if ( take == 3 ) | 2538 | if ( take == 3 ) |
2594 | return false; | 2539 | return false; |
2595 | if ( take == 1 ) {// take local | 2540 | if ( take == 1 ) {// take local |
2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2541 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2597 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2542 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2598 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2543 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2599 | local->insertAddressee( inL, false ); | 2544 | local->insertAddressee( inL, false ); |
2600 | idS = inR.externalUID(); | 2545 | idS = inR.externalUID(); |
2601 | OidS = inR.originalExternalUID(); | 2546 | OidS = inR.originalExternalUID(); |
2602 | } | 2547 | } |
2603 | else | 2548 | else |
2604 | idS = inR.IDStr(); | 2549 | idS = inR.IDStr(); |
2605 | remote->removeAddressee( inR ); | 2550 | remote->removeAddressee( inR ); |
2606 | inR = inL; | 2551 | inR = inL; |
2607 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2552 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2608 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2553 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2609 | inR.setOriginalExternalUID( OidS ); | 2554 | inR.setOriginalExternalUID( OidS ); |
2610 | inR.setExternalUID( idS ); | 2555 | inR.setExternalUID( idS ); |
2611 | } else { | 2556 | } else { |
2612 | inR.setIDStr( idS ); | 2557 | inR.setIDStr( idS ); |
2613 | } | 2558 | } |
2614 | inR.setResource( 0 ); | 2559 | inR.setResource( 0 ); |
2615 | remote->insertAddressee( inR , false); | 2560 | remote->insertAddressee( inR , false); |
2616 | ++changedRemote; | 2561 | ++changedRemote; |
2617 | } else { // take == 2 take remote | 2562 | } else { // take == 2 take remote |
2618 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2563 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2619 | if ( inR.revision().date().year() < 2004 ) | 2564 | if ( inR.revision().date().year() < 2004 ) |
2620 | inR.setRevision( modifiedCalendar ); | 2565 | inR.setRevision( modifiedCalendar ); |
2621 | } | 2566 | } |
2622 | idS = inL.IDStr(); | 2567 | idS = inL.IDStr(); |
2623 | local->removeAddressee( inL ); | 2568 | local->removeAddressee( inL ); |
2624 | inL = inR; | 2569 | inL = inR; |
2625 | inL.setIDStr( idS ); | 2570 | inL.setIDStr( idS ); |
2626 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2571 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2627 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2572 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2628 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2573 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2629 | } | 2574 | } |
2630 | inL.setResource( 0 ); | 2575 | inL.setResource( 0 ); |
2631 | local->insertAddressee( inL , false ); | 2576 | local->insertAddressee( inL , false ); |
2632 | ++changedLocal; | 2577 | ++changedLocal; |
2633 | } | 2578 | } |
2634 | } | 2579 | } |
2635 | } else { // no conflict | 2580 | } else { // no conflict |
2636 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2581 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2637 | QString des = addresseeLSync.note(); | 2582 | QString des = addresseeLSync.note(); |
2638 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2583 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2639 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2584 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2640 | remote->insertAddressee( inR, false ); | 2585 | remote->insertAddressee( inR, false ); |
2641 | ++deletedAddresseeR; | 2586 | ++deletedAddresseeR; |
2642 | } else { | 2587 | } else { |
2643 | inR.setRevision( modifiedCalendar ); | 2588 | inR.setRevision( modifiedCalendar ); |
2644 | remote->insertAddressee( inR, false ); | 2589 | remote->insertAddressee( inR, false ); |
2645 | inL = inR; | 2590 | inL = inR; |
2646 | inL.setResource( 0 ); | 2591 | inL.setResource( 0 ); |
2647 | local->insertAddressee( inL , false); | 2592 | local->insertAddressee( inL , false); |
2648 | ++addedAddressee; | 2593 | ++addedAddressee; |
2649 | } | 2594 | } |
2650 | } else { | 2595 | } else { |
2651 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2596 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2652 | inR.setRevision( modifiedCalendar ); | 2597 | inR.setRevision( modifiedCalendar ); |
2653 | remote->insertAddressee( inR, false ); | 2598 | remote->insertAddressee( inR, false ); |
2654 | inR.setResource( 0 ); | 2599 | inR.setResource( 0 ); |
2655 | local->insertAddressee( inR, false ); | 2600 | local->insertAddressee( inR, false ); |
2656 | ++addedAddressee; | 2601 | ++addedAddressee; |
2657 | } else { | 2602 | } else { |
2658 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2603 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2659 | remote->removeAddressee( inR ); | 2604 | remote->removeAddressee( inR ); |
2660 | ++deletedAddresseeR; | 2605 | ++deletedAddresseeR; |
2661 | } | 2606 | } |
2662 | } | 2607 | } |
2663 | } | 2608 | } |
2664 | } | 2609 | } |
2665 | ++incCounter; | 2610 | ++incCounter; |
2666 | } | 2611 | } |
2667 | er.clear(); | 2612 | er.clear(); |
2668 | QStringList el = local->uidList(); | 2613 | QStringList el = local->uidList(); |
2669 | modulo = (el.count()/10)+1; | 2614 | modulo = (el.count()/10)+1; |
2670 | 2615 | ||
2671 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2616 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2672 | incCounter = 0; | 2617 | incCounter = 0; |
2673 | while ( incCounter < el.count()) { | 2618 | while ( incCounter < el.count()) { |
2674 | qApp->processEvents(); | 2619 | qApp->processEvents(); |
2675 | if (syncManager->isProgressBarCanceled()) | 2620 | if (syncManager->isProgressBarCanceled()) |
2676 | return false; | 2621 | return false; |
2677 | if ( incCounter % modulo == 0 ) | 2622 | if ( incCounter % modulo == 0 ) |
2678 | syncManager->showProgressBar(incCounter); | 2623 | syncManager->showProgressBar(incCounter); |
2679 | uid = el[ incCounter ]; | 2624 | uid = el[ incCounter ]; |
2680 | bool skipIncidence = false; | 2625 | bool skipIncidence = false; |
2681 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2626 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2682 | skipIncidence = true; | 2627 | skipIncidence = true; |
2683 | if ( !skipIncidence ) { | 2628 | if ( !skipIncidence ) { |
2684 | inL = local->findByUid( uid ); | 2629 | inL = local->findByUid( uid ); |
2685 | inR = remote->findByUid( uid ); | 2630 | inR = remote->findByUid( uid ); |
2686 | if ( inR.isEmpty() ) { | 2631 | if ( inR.isEmpty() ) { |
2687 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2632 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2688 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2633 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2689 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2634 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2690 | local->removeAddressee( inL ); | 2635 | local->removeAddressee( inL ); |
2691 | ++deletedAddresseeL; | 2636 | ++deletedAddresseeL; |
2692 | } else { | 2637 | } else { |
2693 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2638 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2694 | inL.removeID(mCurrentSyncDevice ); | 2639 | inL.removeID(mCurrentSyncDevice ); |
2695 | ++addedAddresseeR; | 2640 | ++addedAddresseeR; |
2696 | inL.setRevision( modifiedCalendar ); | 2641 | inL.setRevision( modifiedCalendar ); |
2697 | local->insertAddressee( inL, false ); | 2642 | local->insertAddressee( inL, false ); |
2698 | inR = inL; | 2643 | inR = inL; |
2699 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2644 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2700 | inR.setResource( 0 ); | 2645 | inR.setResource( 0 ); |
2701 | remote->insertAddressee( inR, false ); | 2646 | remote->insertAddressee( inR, false ); |
2702 | } | 2647 | } |
2703 | } | 2648 | } |
2704 | } else { | 2649 | } else { |
2705 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2650 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2706 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2651 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2707 | local->removeAddressee( inL ); | 2652 | local->removeAddressee( inL ); |
2708 | ++deletedAddresseeL; | 2653 | ++deletedAddresseeL; |
2709 | } else { | 2654 | } else { |
2710 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2655 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2711 | ++addedAddresseeR; | 2656 | ++addedAddresseeR; |
2712 | inL.setRevision( modifiedCalendar ); | 2657 | inL.setRevision( modifiedCalendar ); |
2713 | local->insertAddressee( inL, false ); | 2658 | local->insertAddressee( inL, false ); |
2714 | inR = inL; | 2659 | inR = inL; |
2715 | inR.setResource( 0 ); | 2660 | inR.setResource( 0 ); |
2716 | remote->insertAddressee( inR, false ); | 2661 | remote->insertAddressee( inR, false ); |
2717 | } | 2662 | } |
2718 | } | 2663 | } |
2719 | } | 2664 | } |
2720 | } | 2665 | } |
2721 | } | 2666 | } |
2722 | ++incCounter; | 2667 | ++incCounter; |
2723 | } | 2668 | } |
2724 | el.clear(); | 2669 | el.clear(); |
2725 | syncManager->hideProgressBar(); | 2670 | syncManager->hideProgressBar(); |
2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2671 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2727 | // get rid of micro seconds | 2672 | // get rid of micro seconds |
2728 | QTime t = mLastAddressbookSync.time(); | 2673 | QTime t = mLastAddressbookSync.time(); |
2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2674 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2730 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2675 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2731 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2676 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2677 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2678 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2679 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2680 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2681 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2682 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2738 | addresseeRSync.setNote( "" ) ; | 2683 | addresseeRSync.setNote( "" ) ; |
2739 | addresseeLSync.setNote( "" ); | 2684 | addresseeLSync.setNote( "" ); |
2740 | 2685 | ||
2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2686 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2742 | remote->insertAddressee( addresseeRSync, false ); | 2687 | remote->insertAddressee( addresseeRSync, false ); |
2743 | local->insertAddressee( addresseeLSync, false ); | 2688 | local->insertAddressee( addresseeLSync, false ); |
2744 | QString mes; | 2689 | QString mes; |
2745 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2690 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2746 | if ( syncManager->mShowSyncSummary ) { | 2691 | if ( syncManager->mShowSyncSummary ) { |
2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2692 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2748 | } | 2693 | } |
2749 | qDebug( mes ); | 2694 | qDebug( mes ); |
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 |
2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2700 | bool 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 |
2831 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2776 | bool 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 | } |
2857 | void KABCore::message( QString m ) | 2803 | void 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 | } |
2863 | bool KABCore::syncPhone() | 2809 | bool 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 | } |
2898 | void KABCore::getFile( bool success ) | 2846 | void 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 | } |
2908 | void KABCore::syncFileRequest() | 2856 | void KABCore::syncFileRequest() |
2909 | { | 2857 | { |
2910 | mAddressBook->export2File( sentSyncFile() ); | 2858 | mAddressBook->export2File( sentSyncFile() ); |
2911 | } | 2859 | } |
2912 | QString KABCore::sentSyncFile() | 2860 | QString 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 | ||
2921 | void KABCore::setCaptionBack() | 2869 | void 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 | |||
@@ -1,731 +1,732 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qgroupbox.h> | 26 | #include <qgroupbox.h> |
27 | #include <qbuttongroup.h> | 27 | #include <qbuttongroup.h> |
28 | #include <qlineedit.h> | 28 | #include <qlineedit.h> |
29 | #include <qfont.h> | 29 | #include <qfont.h> |
30 | #include <qslider.h> | 30 | #include <qslider.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qhbox.h> | 36 | #include <qhbox.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qcheckbox.h> | 39 | #include <qcheckbox.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qstrlist.h> | 42 | #include <qstrlist.h> |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qscrollview.h> | 45 | #include <qscrollview.h> |
46 | 46 | ||
47 | #include <kcolorbutton.h> | 47 | #include <kcolorbutton.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <klocale.h> | 49 | #include <klocale.h> |
50 | #include <kglobal.h> | 50 | #include <kglobal.h> |
51 | #include <kfontdialog.h> | 51 | #include <kfontdialog.h> |
52 | #include <kmessagebox.h> | 52 | #include <kmessagebox.h> |
53 | #include <kcolordialog.h> | 53 | #include <kcolordialog.h> |
54 | #include <kiconloader.h> | 54 | #include <kiconloader.h> |
55 | #include <kemailsettings.h> | 55 | #include <kemailsettings.h> |
56 | #include <kstandarddirs.h> | 56 | #include <kstandarddirs.h> |
57 | #include <kfiledialog.h> | 57 | #include <kfiledialog.h> |
58 | #include <kmessagebox.h> | 58 | #include <kmessagebox.h> |
59 | 59 | ||
60 | //#include <kurlrequester.h> | 60 | //#include <kurlrequester.h> |
61 | #include <klineedit.h> | 61 | #include <klineedit.h> |
62 | #include "ksyncprofile.h" | 62 | #include "ksyncprofile.h" |
63 | 63 | ||
64 | 64 | ||
65 | //#include "koprefs.h" | 65 | //#include "koprefs.h" |
66 | 66 | ||
67 | #include "ksyncprefsdialog.h" | 67 | #include "ksyncprefsdialog.h" |
68 | //#include "koglobals.h" | 68 | //#include "koglobals.h" |
69 | 69 | ||
70 | 70 | ||
71 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : | 71 | KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : |
72 | KDialog(parent,name,true) | 72 | KDialog(parent,name,true) |
73 | { | 73 | { |
74 | 74 | ||
75 | setCaption( i18n("Synchronization Preferences")); | 75 | setCaption( i18n("Synchronization Preferences")); |
76 | 76 | ||
77 | mSyncProfiles.setAutoDelete( true ); | 77 | mSyncProfiles.setAutoDelete( true ); |
78 | setupSyncAlgTab(); | 78 | setupSyncAlgTab(); |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | KSyncPrefsDialog::~KSyncPrefsDialog() | 82 | KSyncPrefsDialog::~KSyncPrefsDialog() |
83 | { | 83 | { |
84 | } | 84 | } |
85 | 85 | ||
86 | void KSyncPrefsDialog::setupSyncAlgTab() | 86 | void KSyncPrefsDialog::setupSyncAlgTab() |
87 | { | 87 | { |
88 | QLabel * lab; | 88 | QLabel * lab; |
89 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); | 89 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); |
90 | QVBox * mainbox = new QVBox( this ); | 90 | QVBox * mainbox = new QVBox( this ); |
91 | QScrollView* sv = new QScrollView( mainbox ); | 91 | QScrollView* sv = new QScrollView( mainbox ); |
92 | QHBoxLayout * lay = new QHBoxLayout( this ); | 92 | QHBoxLayout * lay = new QHBoxLayout( this ); |
93 | lay->addWidget( mainbox ); | 93 | lay->addWidget( mainbox ); |
94 | QHBox * b_box = new QHBox( mainbox ); | 94 | QHBox * b_box = new QHBox( mainbox ); |
95 | 95 | ||
96 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); | 96 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); |
97 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); | 97 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); |
98 | button = new QPushButton( i18n("Cancel"), b_box ); | 98 | button = new QPushButton( i18n("Cancel"), b_box ); |
99 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); | 99 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); |
100 | //QBoxLayout * sl = new QVBoxLayout(this ); | 100 | //QBoxLayout * sl = new QVBoxLayout(this ); |
101 | //sl->addWidget ( sv ); | 101 | //sl->addWidget ( sv ); |
102 | sv->setResizePolicy ( QScrollView::AutoOneFit ); | 102 | sv->setResizePolicy ( QScrollView::AutoOneFit ); |
103 | QFrame *topFrame = new QFrame ( sv ); | 103 | QFrame *topFrame = new QFrame ( sv ); |
104 | sv->addChild( topFrame ); | 104 | sv->addChild( topFrame ); |
105 | mSetupSyncAlgTab = topFrame; | 105 | mSetupSyncAlgTab = topFrame; |
106 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | 106 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); |
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); |
300 | mRemoteIPPWM = new QLineEdit(temphb); | 300 | mRemoteIPPWM = new QLineEdit(temphb); |
301 | 301 | ||
302 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); | 302 | lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); |
303 | temphb = new QHBox( piWidget ); | 303 | temphb = new QHBox( piWidget ); |
304 | mRemotePort = new QLineEdit(temphb); | 304 | mRemotePort = new QLineEdit(temphb); |
305 | mRemotePortAB = new QLineEdit(temphb); | 305 | mRemotePortAB = new QLineEdit(temphb); |
306 | mRemotePortPWM = new QLineEdit(temphb); | 306 | mRemotePortPWM = new QLineEdit(temphb); |
307 | 307 | ||
308 | } | 308 | } |
309 | 309 | ||
310 | 310 | ||
311 | 311 | ||
312 | 312 | ||
313 | 313 | ||
314 | void KSyncPrefsDialog::slotOK() | 314 | void KSyncPrefsDialog::slotOK() |
315 | { | 315 | { |
316 | if ( mMyMachineName->text() == "undefined" ) { | 316 | if ( mMyMachineName->text() == "undefined" ) { |
317 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); | 317 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); |
318 | return; | 318 | return; |
319 | } | 319 | } |
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 | } |
330 | void KSyncPrefsDialog::accept() | 330 | void KSyncPrefsDialog::accept() |
331 | { | 331 | { |
332 | slotOK(); | 332 | slotOK(); |
333 | } | 333 | } |
334 | void KSyncPrefsDialog::chooseFile() | 334 | void 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 | ||
344 | void KSyncPrefsDialog::chooseFileAB() | 344 | void 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 | ||
354 | void KSyncPrefsDialog::chooseFilePWM() | 354 | void 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 | ||
364 | void KSyncPrefsDialog::textChanged( const QString & s ) | 364 | void 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 | } |
381 | void KSyncPrefsDialog::profileChanged( int item ) | 381 | void 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 | ||
471 | void KSyncPrefsDialog::fillSSH() | 472 | void 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 | } |
483 | void KSyncPrefsDialog::fillFTP() | 484 | void 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 | } |
497 | void KSyncPrefsDialog::kindChanged( bool b ) | 498 | void 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 | } |
524 | void KSyncPrefsDialog::deleteProfile() | 525 | void 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 | ||
539 | void KSyncPrefsDialog::saveProfile() | 540 | void 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 | ||
593 | void KSyncPrefsDialog::insertProfiles() | 594 | void 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 | ||
614 | void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) | 615 | void 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 | } |
626 | void KSyncPrefsDialog::newProfile() | 627 | void KSyncPrefsDialog::newProfile() |
627 | { | 628 | { |
628 | addProfile ( new KSyncProfile () ); | 629 | addProfile ( new KSyncProfile () ); |
629 | } | 630 | } |
630 | 631 | ||
631 | void KSyncPrefsDialog::cloneProfile() | 632 | void 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 | ||
639 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) | 640 | void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) |
640 | { | 641 | { |
641 | mMyMachineName->setText( name ); | 642 | mMyMachineName->setText( name ); |
642 | 643 | ||
643 | } | 644 | } |
644 | QString KSyncPrefsDialog::getLocalMachineName ( ) | 645 | QString KSyncPrefsDialog::getLocalMachineName ( ) |
645 | { | 646 | { |
646 | return mMyMachineName->text(); | 647 | return mMyMachineName->text(); |
647 | } | 648 | } |
648 | 649 | ||
649 | QStringList KSyncPrefsDialog::getSyncProfileNames() | 650 | QStringList KSyncPrefsDialog::getSyncProfileNames() |
650 | { | 651 | { |
651 | return mSyncProfileNames; | 652 | return mSyncProfileNames; |
652 | } | 653 | } |
653 | void KSyncPrefsDialog::usrReadConfig() | 654 | void 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 | ||
674 | void KSyncPrefsDialog::usrWriteConfig() | 675 | void 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 | ||
699 | void KSyncPrefsDialog::helpDevice() | 700 | void 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 | } |
716 | void KSyncPrefsDialog::helpModel() | 717 | void 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 | } |
723 | void KSyncPrefsDialog::helpConnection() | 724 | void 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 | } |