wrong character in the GSM 03.38 table (ç for Ç)
[gammu.git] / helper / memory-display.c
blobf512f75d2e6d48af3182d540fe5b74cca2693d0a
1 #include <string.h>
2 #include <stdarg.h>
3 #include <signal.h>
4 #include <stdlib.h>
5 #include <ctype.h>
7 #include <gammu.h>
9 #include "locales.h"
11 #include "memory-display.h"
12 #include "formats.h"
14 #define GAMMU_CALLER_GROUPS 20
16 static GSM_Bitmap caller[GAMMU_CALLER_GROUPS];
17 GSM_AllRingtonesInfo ringtones_info = {0, NULL};
18 static gboolean callerinit[GAMMU_CALLER_GROUPS] = {FALSE, FALSE, FALSE, FALSE, FALSE};
19 static gboolean ringinit = FALSE;
21 GSM_Error PrintMemorySubEntry(GSM_SubMemoryEntry *entry, GSM_StateMachine *sm)
23 GSM_Category Category;
24 int z;
25 GSM_Error error;
26 gboolean show_location = TRUE;
28 switch (entry->EntryType) {
29 case PBK_CallLength:
30 printf(LISTFORMAT, _("Call length"));
31 /* l10n: Call length format string hour:minute:second*/
32 printf(_("%02i:%02i:%02i\n"),
33 entry->CallLength / (60 * 60),
34 entry->CallLength / 60,
35 entry->CallLength % 60);
36 return ERR_NONE;
37 case PBK_Date:
38 printf(LISTFORMAT "%s\n", _("Date and time"),OSDateTime(entry->Date,FALSE));
39 return ERR_NONE;
40 case PBK_LastModified:
41 printf(LISTFORMAT "%s\n", _("Last modified"), OSDateTime(entry->Date,FALSE));
42 return ERR_NONE;
43 case PBK_Category:
44 if (entry->Number == -1) {
45 printf(LISTFORMAT "\"%s\"\n", _("Category"), DecodeUnicodeConsole(entry->Text));
46 } else {
47 if (sm == NULL) {
48 error = ERR_NOTSUPPORTED;
49 } else {
50 Category.Location = entry->Number;
51 Category.Type = Category_Phonebook;
52 error=GSM_GetCategory(sm, &Category);
54 if (error == ERR_NONE) {
55 printf(LISTFORMAT "\"%s\" (%i)\n", _("Category"), DecodeUnicodeConsole(Category.Name), entry->Number);
56 } else {
57 printf(LISTFORMAT "%i\n", _("Category"), entry->Number);
60 return ERR_NONE;
61 case PBK_Private:
62 printf(LISTFORMAT "%s\n", _("Private"), entry->Number == 1 ? "Yes" : "No");
63 return ERR_NONE;
64 case PBK_Caller_Group :
65 if (sm == NULL) {
66 printf(LISTFORMAT "\"%d\"\n", _("Caller group"),entry->Number);
67 return ERR_NONE;
69 if (entry->Number >= GAMMU_CALLER_GROUPS) {
70 printf(LISTFORMAT "\"%d\"\n", _("Caller group"),entry->Number);
71 fprintf(stderr, "%s\n", _("Caller group number too high, please increase buffer in sources!"));
72 return ERR_MOREMEMORY;
74 if (!callerinit[entry->Number-1]) {
75 caller[entry->Number-1].Type = GSM_CallerGroupLogo;
76 caller[entry->Number-1].Location = entry->Number;
77 error=GSM_GetBitmap(sm,&caller[entry->Number-1]);
78 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
79 printf(LISTFORMAT "\"%d\"\n", _("Caller group"), entry->Number);
80 return ERR_NONE;
82 if (error != ERR_NONE) {
83 return error;
85 if (caller[entry->Number-1].DefaultName) {
86 NOKIA_GetDefaultCallerGroupName(&caller[entry->Number-1]);
88 callerinit[entry->Number-1]=TRUE;
90 printf(LISTFORMAT "\"%s\"\n", _("Caller group"),DecodeUnicodeConsole(caller[entry->Number-1].Text));
91 return ERR_NONE;
92 case PBK_RingtoneID :
93 if (!ringinit && sm != NULL) {
94 error=GSM_GetRingtonesInfo(sm,&ringtones_info);
95 if (error != ERR_NOTSUPPORTED) return error;
96 if (error == ERR_NONE) ringinit = TRUE;
98 if (ringinit) {
99 for (z=0;z<ringtones_info.Number;z++) {
100 if (ringtones_info.Ringtone[z].ID == entry->Number) {
101 printf(LISTFORMAT "\"%s\"\n", _("Ringtone"),DecodeUnicodeConsole(ringtones_info.Ringtone[z].Name));
102 break;
105 } else {
106 printf(LISTFORMAT "%i\n", _("Ringtone ID"),entry->Number);
108 return ERR_NONE;
109 case PBK_Text_UserID:
110 printf(LISTFORMAT "%s\n", _("User ID"),DecodeUnicodeString(entry->Text));
111 return ERR_NONE;
112 case PBK_Text_PictureName:
113 printf(LISTFORMAT "%s\n", _("Picture name"),DecodeUnicodeString(entry->Text));
114 return ERR_NONE;
115 case PBK_PictureID :
116 printf(LISTFORMAT "0x%x\n", _("Picture ID"),entry->Number);
117 return ERR_NONE;
118 case PBK_Photo:
119 printf(LISTFORMAT "%s\n", _("Photo"), _("Displaying not supported"));
120 return ERR_NONE;
121 case PBK_Number_Messaging : printf(LISTFORMAT, _("Favorite messaging number")); break;
122 case PBK_Number_General :
123 show_location = FALSE;
124 switch (entry->Location) {
125 case PBK_Location_Home:
126 printf(LISTFORMAT, _("Home number"));
127 break;
128 case PBK_Location_Work:
129 printf(LISTFORMAT, _("Work number"));
130 break;
131 case PBK_Location_Unknown:
132 printf(LISTFORMAT, _("General number"));
133 break;
135 break;
136 case PBK_Number_Video : printf(LISTFORMAT, _("Video number")); break;
137 case PBK_Number_Mobile :
138 show_location = FALSE;
139 switch (entry->Location) {
140 case PBK_Location_Home:
141 printf(LISTFORMAT, _("Home mobile number"));
142 break;
143 case PBK_Location_Work:
144 printf(LISTFORMAT, _("Work mobile number"));
145 break;
146 case PBK_Location_Unknown:
147 printf(LISTFORMAT, _("Mobile number"));
148 break;
150 break;
151 case PBK_Number_Fax :
152 show_location = FALSE;
153 switch (entry->Location) {
154 case PBK_Location_Home:
155 printf(LISTFORMAT, _("Home fax number"));
156 break;
157 case PBK_Location_Work:
158 printf(LISTFORMAT, _("Work fax number"));
159 break;
160 case PBK_Location_Unknown:
161 printf(LISTFORMAT, _("Fax number"));
162 break;
164 break;
165 case PBK_Number_Pager : printf(LISTFORMAT, _("Pager number")); break;
166 case PBK_Number_Other : printf(LISTFORMAT, _("Other number")); break;
167 case PBK_Text_Note : printf(LISTFORMAT, _("Text")); break;
168 case PBK_Text_Postal :
169 show_location = FALSE;
170 switch (entry->Location) {
171 case PBK_Location_Home:
172 printf(LISTFORMAT, _("Home address"));
173 break;
174 case PBK_Location_Work:
175 printf(LISTFORMAT, _("Work address"));
176 break;
177 case PBK_Location_Unknown:
178 printf(LISTFORMAT, _("Address"));
179 break;
181 break;
182 case PBK_Text_Email :
183 show_location = FALSE;
184 switch (entry->Location) {
185 case PBK_Location_Home:
186 printf(LISTFORMAT, _("Home email"));
187 break;
188 case PBK_Location_Work:
189 printf(LISTFORMAT, _("Work email"));
190 break;
191 case PBK_Location_Unknown:
192 printf(LISTFORMAT, _("Email"));
193 break;
195 break;
196 case PBK_Text_Email2 : printf(LISTFORMAT, _("Email address 2")); break;
197 case PBK_Text_URL :
198 show_location = FALSE;
199 switch (entry->Location) {
200 case PBK_Location_Home:
201 printf(LISTFORMAT, _("Home website"));
202 break;
203 case PBK_Location_Work:
204 printf(LISTFORMAT, _("Work website"));
205 break;
206 case PBK_Location_Unknown:
207 printf(LISTFORMAT, _("Website"));
208 break;
210 break;
211 case PBK_Text_LUID : printf(LISTFORMAT, _("LUID")); break;
212 case PBK_Text_VOIP : printf(LISTFORMAT, _("VOIP")); break;
213 case PBK_Text_SWIS : printf(LISTFORMAT, _("SWIS")); break;
214 case PBK_Text_WVID : printf(LISTFORMAT, _("WVID")); break;
215 case PBK_Text_SIP : printf(LISTFORMAT, _("SIP")); break;
216 case PBK_Text_DTMF : printf(LISTFORMAT, _("DTMF")); break;
217 case PBK_Text_Name : printf(LISTFORMAT, _("Name")); break;
218 case PBK_Text_LastName : printf(LISTFORMAT, _("Last name")); break;
219 case PBK_Text_FirstName : printf(LISTFORMAT, _("First name")); break;
220 case PBK_Text_SecondName : printf(LISTFORMAT, _("Second name")); break;
221 case PBK_Text_FormalName : printf(LISTFORMAT, _("Formal name")); break;
222 case PBK_Text_NamePrefix : printf(LISTFORMAT, _("Name prefix")); break;
223 case PBK_Text_NameSuffix : printf(LISTFORMAT, _("Name suffix")); break;
224 case PBK_Text_NickName : printf(LISTFORMAT, _("Nick name")); break;
225 case PBK_Text_Company : printf(LISTFORMAT, _("Company")); break;
226 case PBK_Text_JobTitle : printf(LISTFORMAT, _("Job title")); break;
227 case PBK_Text_StreetAddress : printf(LISTFORMAT, _("Street address")); break;
228 case PBK_Text_City : printf(LISTFORMAT, _("City")); break;
229 case PBK_Text_State : printf(LISTFORMAT, _("State")); break;
230 case PBK_Text_Zip : printf(LISTFORMAT, _("Zip code")); break;
231 case PBK_Text_Country : printf(LISTFORMAT, _("Country")); break;
232 case PBK_Text_Custom1 : printf(LISTFORMAT, _("Custom text 1")); break;
233 case PBK_Text_Custom2 : printf(LISTFORMAT, _("Custom text 2")); break;
234 case PBK_Text_Custom3 : printf(LISTFORMAT, _("Custom text 3")); break;
235 case PBK_Text_Custom4 : printf(LISTFORMAT, _("Custom text 4")); break;
236 case PBK_PushToTalkID : printf(LISTFORMAT, _("Push to talk ID")); break;
237 #ifndef CHECK_CASES
238 default:
239 printf("%s\n", _("unknown field type"));
240 return ERR_NONE;
241 #endif
243 if (show_location) {
244 switch (entry->Location) {
245 case PBK_Location_Home:
246 printf("[%s]", _("home"));
247 break;
248 case PBK_Location_Work:
249 printf("[%s]", _("work"));
250 break;
251 case PBK_Location_Unknown:
252 break;
255 printf("\"%s\"\n", DecodeUnicodeConsole(entry->Text));
256 return ERR_NONE;
259 GSM_Error PrintMemoryEntry(GSM_MemoryEntry *entry, GSM_StateMachine *sm)
261 int i;
262 GSM_Error error;
264 for (i = 0; i < entry->EntriesNum; i++) {
265 error = PrintMemorySubEntry(&entry->Entries[i], sm);
266 if (error != ERR_NONE) return error;
268 printf("\n");
269 return ERR_NONE;
272 GSM_Error PrintMemoryEntryLocation(GSM_MemoryEntry *entry, GSM_StateMachine *sm)
274 printf(_("Memory %s, Location %i\n"), GSM_MemoryTypeToString(entry->MemoryType), entry->Location);
275 return PrintMemoryEntry(entry, sm);
278 /* How should editor hadle tabs in this file? Add editor commands here.
279 * vim: noexpandtab sw=8 ts=8 sts=8: