Translation update done using Pootle.
[gammu.git] / gammu / calendar.c
blob12eef0d84ed3fdc1b02313ad323b7f6248505056
1 #include "../helper/locales.h"
3 #define _GNU_SOURCE /* For strcasestr */
4 #include <string.h>
5 #include <stdarg.h>
6 #include <signal.h>
7 #include <stdlib.h>
8 #include <ctype.h>
9 #include <gammu.h>
11 #include "common.h"
12 #include "calendar.h"
14 #include "../helper/formats.h"
15 #include "../helper/cmdline.h"
17 void PrintNoteType(GSM_CalendarNoteType Type)
19 printf(LISTFORMAT, _("Note type"));
20 switch (Type) {
21 case GSM_CAL_REMINDER:
22 printf("%s\n", _("Reminder (Date)"));
23 break;
24 case GSM_CAL_CALL:
25 printf("%s\n", _("Call"));
26 break;
27 case GSM_CAL_MEETING:
28 printf("%s\n", _("Meeting"));
29 break;
30 case GSM_CAL_BIRTHDAY:
31 printf("%s\n", _("Birthday (Anniversary)"));
32 break;
33 case GSM_CAL_MEMO:
34 printf("%s\n", _("Memo (Miscellaneous)"));
35 break;
36 case GSM_CAL_TRAVEL:
37 printf("%s\n", _("Travel"));
38 break;
39 case GSM_CAL_VACATION:
40 printf("%s\n", _("Vacation"));
41 break;
42 case GSM_CAL_ALARM:
43 printf("%s\n", _("Alarm"));
44 break;
45 case GSM_CAL_SHOPPING:
46 printf("%s\n", _("Shopping"));
47 break;
48 case GSM_CAL_DAILY_ALARM:
49 printf("%s\n", _("Daily alarm"));
50 break;
51 case GSM_CAL_T_ATHL:
52 printf("%s\n", _("Training/Athletism"));
53 break;
54 case GSM_CAL_T_BALL:
55 printf("%s\n", _("Training/Ball Games"));
56 break;
57 case GSM_CAL_T_CYCL:
58 printf("%s\n", _("Training/Cycling"));
59 break;
60 case GSM_CAL_T_BUDO:
61 printf("%s\n", _("Training/Budo"));
62 break;
63 case GSM_CAL_T_DANC:
64 printf("%s\n", _("Training/Dance"));
65 break;
66 case GSM_CAL_T_EXTR:
67 printf("%s\n", _("Training/Extreme Sports"));
68 break;
69 case GSM_CAL_T_FOOT:
70 printf("%s\n", _("Training/Football"));
71 break;
72 case GSM_CAL_T_GOLF:
73 printf("%s\n", _("Training/Golf"));
74 break;
75 case GSM_CAL_T_GYM:
76 printf("%s\n", _("Training/Gym"));
77 break;
78 case GSM_CAL_T_HORS:
79 printf("%s\n", _("Training/Horse Races"));
80 break;
81 case GSM_CAL_T_HOCK:
82 printf("%s\n", _("Training/Hockey"));
83 break;
84 case GSM_CAL_T_RACE:
85 printf("%s\n", _("Training/Races"));
86 break;
87 case GSM_CAL_T_RUGB:
88 printf("%s\n", _("Training/Rugby"));
89 break;
90 case GSM_CAL_T_SAIL:
91 printf("%s\n", _("Training/Sailing"));
92 break;
93 case GSM_CAL_T_STRE:
94 printf("%s\n", _("Training/Street Games"));
95 break;
96 case GSM_CAL_T_SWIM:
97 printf("%s\n", _("Training/Swimming"));
98 break;
99 case GSM_CAL_T_TENN:
100 printf("%s\n", _("Training/Tennis"));
101 break;
102 case GSM_CAL_T_TRAV:
103 printf("%s\n", _("Training/Travels"));
104 break;
105 case GSM_CAL_T_WINT:
106 printf("%s\n", _("Training/Winter Games"));
107 break;
108 #ifndef CHECK_CASES
109 default:
110 printf("%s\n", _("unknown type!"));
111 #endif
115 void PrintCalendar(GSM_CalendarEntry * Note)
117 GSM_Error error;
118 int i_age = 0, i;
119 GSM_DateTime Alarm, DateTime;
120 GSM_MemoryEntry entry;
121 unsigned char *name;
123 gboolean repeating = FALSE;
124 int repeat_dayofweek = -1;
125 int repeat_day = -1;
126 int repeat_dayofyear = -1;
127 int repeat_weekofmonth = -1;
128 int repeat_month = -1;
129 int repeat_count = -1;
130 int repeat_frequency = -1;
131 GSM_DateTime repeat_startdate = { 0, 0, 0, 0, 0, 0, 0 };
132 GSM_DateTime repeat_stopdate = { 0, 0, 0, 0, 0, 0, 0 };
134 PrintNoteType(Note->Type);
136 Alarm.Year = 0;
137 Alarm.Month = 0;
138 Alarm.Day = 0;
139 DateTime.Year = 0;
140 DateTime.Month = 0;
141 DateTime.Day = 0;
143 repeating = FALSE;
144 repeat_dayofweek = -1;
145 repeat_day = -1;
146 repeat_dayofyear = -1;
147 repeat_weekofmonth = -1;
148 repeat_month = -1;
149 repeat_frequency = -1;
150 repeat_startdate.Day = 0;
151 repeat_stopdate.Day = 0;
153 for (i = 0; i < Note->EntriesNum; i++) {
154 switch (Note->Entries[i].EntryType) {
155 case CAL_START_DATETIME:
156 printf(LISTFORMAT "%s\n", _("Start"),
157 OSDateTime(Note->Entries[i].Date,
158 FALSE));
159 memcpy(&DateTime, &Note->Entries[i].Date,
160 sizeof(GSM_DateTime));
161 break;
162 case CAL_END_DATETIME:
163 printf(LISTFORMAT "%s\n", _("Stop"),
164 OSDateTime(Note->Entries[i].Date,
165 FALSE));
166 memcpy(&DateTime, &Note->Entries[i].Date,
167 sizeof(GSM_DateTime));
168 break;
169 case CAL_LAST_MODIFIED:
170 printf(LISTFORMAT "%s\n", _("Last modified"),
171 OSDateTime(Note->Entries[i].Date,
172 FALSE));
173 break;
174 case CAL_TONE_ALARM_DATETIME:
175 if (Note->Type == GSM_CAL_BIRTHDAY) {
176 printf(LISTFORMAT, _("Tone alarm"));
177 printf(_
178 ("forever on each %i. day of %s"),
179 Note->Entries[i].Date.Day,
180 GetMonthName(Note->Entries[i].
181 Date.Month));
182 printf(" %02i:%02i:%02i\n",
183 Note->Entries[i].Date.Hour,
184 Note->Entries[i].Date.Minute,
185 Note->Entries[i].Date.Second);
186 } else {
187 printf(LISTFORMAT "%s\n",
188 _("Tone alarm"),
189 OSDateTime(Note->Entries[i].Date,
190 FALSE));
192 memcpy(&Alarm, &Note->Entries[i].Date,
193 sizeof(GSM_DateTime));
194 break;
195 case CAL_SILENT_ALARM_DATETIME:
196 if (Note->Type == GSM_CAL_BIRTHDAY) {
197 printf(LISTFORMAT, _("Silent alarm"));
198 printf(_
199 ("forever on each %i. day of %s"),
200 Note->Entries[i].Date.Day,
201 GetMonthName(Note->Entries[i].
202 Date.Month));
203 printf(" %02i:%02i:%02i\n",
204 Note->Entries[i].Date.Hour,
205 Note->Entries[i].Date.Minute,
206 Note->Entries[i].Date.Second);
207 } else {
208 printf(LISTFORMAT "%s\n",
209 _("Silent alarm"),
210 OSDateTime(Note->Entries[i].Date,
211 FALSE));
213 memcpy(&Alarm, &Note->Entries[i].Date,
214 sizeof(GSM_DateTime));
215 break;
216 case CAL_TEXT:
217 printf(LISTFORMAT "\"%s\"\n", _("Text"),
218 DecodeUnicodeConsole(Note->Entries[i].
219 Text));
220 break;
221 case CAL_DESCRIPTION:
222 printf(LISTFORMAT "\"%s\"\n", _("Description"),
223 DecodeUnicodeConsole(Note->Entries[i].
224 Text));
225 break;
226 case CAL_LUID:
227 printf(LISTFORMAT "\"%s\"\n", _("LUID"),
228 DecodeUnicodeConsole(Note->Entries[i].
229 Text));
230 break;
231 case CAL_LOCATION:
232 printf(LISTFORMAT "\"%s\"\n", _("Location"),
233 DecodeUnicodeConsole(Note->Entries[i].
234 Text));
235 break;
236 case CAL_PHONE:
237 printf(LISTFORMAT "\"%s\"\n", _("Phone"),
238 DecodeUnicodeConsole(Note->Entries[i].
239 Text));
240 break;
241 case CAL_PRIVATE:
242 printf(LISTFORMAT "%s\n", _("Private"),
243 Note->Entries[i].Number ==
244 1 ? _("Yes") : _("No"));
245 break;
246 case CAL_CONTACTID:
247 entry.Location = Note->Entries[i].Number;
248 entry.MemoryType = MEM_ME;
249 error = GSM_GetMemory(gsm, &entry);
250 if (error == ERR_NONE) {
251 name =
252 GSM_PhonebookGetEntryName(&entry);
253 if (name != NULL) {
254 printf(LISTFORMAT
255 "\"%s\" (%d)\n",
256 _("Contact ID"),
257 DecodeUnicodeConsole
258 (name),
259 Note->Entries[i].Number);
260 } else {
261 printf(LISTFORMAT "%d\n",
262 _("Contact ID"),
263 Note->Entries[i].Number);
265 } else {
266 printf(LISTFORMAT "%d\n",
267 _("Contact ID"),
268 Note->Entries[i].Number);
270 break;
271 case CAL_REPEAT_DAYOFWEEK:
272 repeat_dayofweek = Note->Entries[i].Number;
273 repeating = TRUE;
274 break;
275 case CAL_REPEAT_DAY:
276 repeat_day = Note->Entries[i].Number;
277 repeating = TRUE;
278 break;
279 case CAL_REPEAT_DAYOFYEAR:
280 repeat_dayofyear = Note->Entries[i].Number;
281 repeating = TRUE;
282 break;
283 case CAL_REPEAT_WEEKOFMONTH:
284 repeat_weekofmonth = Note->Entries[i].Number;
285 repeating = TRUE;
286 break;
287 case CAL_REPEAT_MONTH:
288 repeat_month = Note->Entries[i].Number;
289 repeating = TRUE;
290 break;
291 case CAL_REPEAT_FREQUENCY:
292 repeat_frequency = Note->Entries[i].Number;
293 repeating = TRUE;
294 break;
295 case CAL_REPEAT_COUNT:
296 repeat_count = Note->Entries[i].Number;
297 repeating = TRUE;
298 break;
299 case CAL_REPEAT_STARTDATE:
300 repeat_startdate = Note->Entries[i].Date;
301 repeating = TRUE;
302 break;
303 case CAL_REPEAT_STOPDATE:
304 repeat_stopdate = Note->Entries[i].Date;
305 repeating = TRUE;
306 break;
309 if (repeating) {
310 printf(LISTFORMAT, _("Repeating"));
311 if (repeat_count > 0) {
312 printf(ngettext
313 ("for %d time ", "for %d times ", repeat_count),
314 repeat_count);
316 if ((repeat_startdate.Day == 0) && (repeat_stopdate.Day == 0)) {
317 printf("%s", _("forever"));
318 } else if (repeat_startdate.Day == 0) {
319 printf(_("till %s"), OSDate(repeat_stopdate));
320 } else if (repeat_stopdate.Day == 0) {
321 printf(_("since %s"), OSDate(repeat_startdate));
322 } else {
323 printf(_("since %s till %s"), OSDate(repeat_startdate),
324 OSDate(repeat_stopdate));
326 if (repeat_frequency != -1) {
327 if (repeat_frequency == 1) {
328 printf("%s", _(" on each "));
329 } else {
330 printf(_(" on each %d. "), repeat_frequency);
332 if (repeat_dayofweek > 0) {
333 printf("%s", GetDayName(repeat_dayofweek));
334 if (repeat_weekofmonth > 0) {
335 printf(_(" in %d. week of "),
336 repeat_weekofmonth);
337 } else {
338 printf("%s", _(" in "));
340 if (repeat_month > 0) {
341 printf("%s",
342 GetMonthName(repeat_month));
343 } else {
344 printf("%s", _("each month"));
346 } else if (repeat_day > 0) {
347 printf(_("%d. day of "), repeat_day);
348 if (repeat_month > 0) {
349 printf("%s",
350 GetMonthName(repeat_month));
351 } else {
352 printf("%s", _("each month"));
354 } else if (repeat_dayofyear > 0) {
355 printf(_("%d. day of year"), repeat_dayofyear);
356 } else {
357 printf("%s", _("day"));
360 printf("\n");
362 if (Note->Type == GSM_CAL_BIRTHDAY) {
363 if (Alarm.Year == 0x00)
364 GSM_GetCurrentDateTime(&Alarm);
365 if (DateTime.Year != 0) {
366 i_age = Alarm.Year - DateTime.Year;
367 if (DateTime.Month < Alarm.Month)
368 i_age++;
369 if (DateTime.Month == Alarm.Month &&
370 DateTime.Day < Alarm.Day) {
371 i_age++;
373 printf(LISTFORMAT, _("Age"));
374 PRINTYEARS(i_age);
375 printf("\n");
378 printf("\n");
381 void GetDateTime(int argc UNUSED, char *argv[]UNUSED)
383 GSM_Error error;
384 GSM_DateTime date_time;
385 GSM_Locale locale;
387 GSM_Init(TRUE);
389 error = GSM_GetDateTime(gsm, &date_time);
390 switch (error) {
391 case ERR_EMPTY:
392 printf("%s\n", _("Date and time not set in phone"));
393 break;
394 case ERR_NONE:
395 printf(_("Phone time is %s\n"),
396 OSDateTime(date_time, FALSE));
397 break;
398 default:
399 Print_Error(error);
402 error = GSM_GetLocale(gsm, &locale);
403 switch (error) {
404 case ERR_NOTSUPPORTED:
405 case ERR_NOTIMPLEMENTED:
406 break;
407 default:
408 Print_Error(error);
409 printf("%s", _("Time format is "));
410 if (locale.AMPMTime) {
411 /* l10n: AM/PM time */
412 printf("%s\n", _("12 hours"));
413 } else {
414 /* l10n: 24 hours time */
415 printf("%s\n", _("24 hours"));
417 printf("%s", _("Date format is "));
418 switch (locale.DateFormat) {
419 case GSM_Date_DDMMYYYY:
420 printf("%s", _("DD MM YYYY"));
421 break;
422 case GSM_Date_MMDDYYYY:
423 printf("%s", _("MM DD YYYY"));
424 break;
425 case GSM_Date_YYYYMMDD:
426 printf("%s", _("YYYY MM DD"));
427 break;
428 case GSM_Date_DDMMMYY:
429 printf("%s", _("DD MMM YY"));
430 break;
431 case GSM_Date_MMDDYY:
432 printf("%s", _("MM DD YY"));
433 break;
434 case GSM_Date_DDMMYY:
435 printf("%s", _("DD MM YY"));
436 break;
437 case GSM_Date_YYMMDD:
438 printf("%s", _("YY MM DD"));
439 break;
440 case GSM_Date_OFF:
441 printf("%s", _("OFF"));
442 break;
443 default:
444 break;
446 printf(_(", date separator is %c\n"),
447 locale.DateSeparator);
450 GSM_Terminate();
453 void SetDateTime(int argc, char *argv[])
455 GSM_DateTime date_time;
456 char shift, *parse, *parse2;
457 GSM_Error error;
459 GSM_Init(TRUE);
460 error = ERR_NONE;
461 if (argc < 3) {
462 /* set datetime to the current datetime in the PC */
463 printf("%s\n", _("Setting time in phone to the same time as is set in computer."));
464 GSM_GetCurrentDateTime(&date_time);
465 } else {
466 /* update only parts the user specified,
467 leave the rest in the phone as is */
468 error = GSM_GetDateTime(gsm, &date_time);
469 Print_Error(error);
471 if (error == ERR_NONE) {
472 shift = 0;
473 error = ERR_INVALIDDATETIME;
474 parse = strchr(argv[2], ':');
475 if (parse != NULL) {
476 *parse = '\0';
477 date_time.Hour = GetInt(argv[2]);
478 parse2 = strchr(parse + 1, ':');
479 if (parse2 != NULL) {
480 *parse2 = '\0';
481 date_time.Second = GetInt(parse2 + 1);
483 date_time.Minute = GetInt(parse + 1);
484 shift = 1;
485 if (CheckTime(&date_time)) {
486 error = ERR_NONE;
487 } else {
488 error = ERR_INVALIDDATETIME;
491 if (argc - 1 >= 2 + shift) {
492 parse = strchr(argv[2 + shift], '/');
493 if (parse != NULL) {
494 *parse = '\0';
495 date_time.Year = GetInt(argv[2 + shift]);
496 parse2 = strchr(parse + 1, '/');
497 if (parse2 != NULL) {
498 *parse2 = '\0';
499 date_time.Day = GetInt(parse2 + 1);
501 date_time.Month = GetInt(parse + 1);
502 if (CheckDate(&date_time)) {
503 error = ERR_NONE;
504 } else {
505 error = ERR_INVALIDDATETIME;
509 /* we got the timezone from the phone */
512 if (error == ERR_NONE) {
513 printf("%s\n", _("Updating specified parts of date and time in phone."));
514 error = GSM_SetDateTime(gsm, &date_time);
516 Print_Error(error);
518 GSM_Terminate();
521 void GetAlarm(int argc, char *argv[])
523 GSM_Alarm Alarm;
524 GSM_Error error;
526 GSM_Init(TRUE);
528 if (argc < 3) {
529 Alarm.Location = 1;
530 } else {
531 Alarm.Location = GetInt(argv[2]);
533 error = GSM_GetAlarm(gsm, &Alarm);
534 switch (error) {
535 case ERR_EMPTY:
536 printf(_("Alarm (%i) not set in phone\n"),
537 Alarm.Location);
538 break;
539 case ERR_NONE:
540 printf(_("Alarm in location %i:\n"), Alarm.Location);
541 if (Alarm.Repeating) {
542 printf(LISTFORMAT "%s\n", _("Date"),
543 _("Every day"));
544 } else if (Alarm.DateTime.Day != 0) {
545 printf(LISTFORMAT "%s\n", _("Date"),
546 OSDate(Alarm.DateTime));
548 printf(_("Time: %02d:%02d\n"), Alarm.DateTime.Hour,
549 Alarm.DateTime.Minute);
550 if (Alarm.Text[0] != 0 || Alarm.Text[1] != 0) {
551 printf(LISTFORMAT "\"%s\"\n", _("Text"),
552 DecodeUnicodeConsole(Alarm.Text));
554 break;
555 default:
556 Print_Error(error);
559 GSM_Terminate();
562 void SetAlarm(int argc UNUSED, char *argv[])
564 GSM_Alarm Alarm;
565 GSM_Error error;
567 Alarm.DateTime.Hour = GetInt(argv[2]);
568 Alarm.DateTime.Minute = GetInt(argv[3]);
569 Alarm.DateTime.Second = 0;
570 Alarm.Location = 1;
571 Alarm.Repeating = TRUE;
572 Alarm.Text[0] = 0;
573 Alarm.Text[1] = 0;
575 GSM_Init(TRUE);
577 error = GSM_SetAlarm(gsm, &Alarm);
578 Print_Error(error);
580 GSM_Terminate();
583 void GetCalendar(int argc UNUSED, char *argv[])
585 GSM_Error error;
586 GSM_CalendarEntry Note;
587 int start, stop, i;
589 GetStartStop(&start, &stop, 2, argc, argv);
591 GSM_Init(TRUE);
593 for (i = start; i <= stop; i++) {
594 Note.Location = i;
595 error = GSM_GetCalendar(gsm, &Note);
596 if (error == ERR_EMPTY)
597 continue;
598 Print_Error(error);
599 printf(LISTFORMAT "%d\n", _("Location"), Note.Location);
600 PrintCalendar(&Note);
603 GSM_Terminate();
606 void DeleteCalendar(int argc, char *argv[])
608 GSM_Error error;
609 GSM_CalendarEntry Note;
610 int start, stop, i;
612 GetStartStop(&start, &stop, 2, argc, argv);
614 GSM_Init(TRUE);
616 for (i = start; i <= stop; i++) {
617 Note.Location = i;
618 error = GSM_DeleteCalendar(gsm, &Note);
619 Print_Error(error);
622 GSM_Terminate();
625 void GetAllCalendar(int argc UNUSED, char *argv[]UNUSED)
627 GSM_Error error;
628 GSM_CalendarEntry Note;
629 gboolean refresh = TRUE;
631 signal(SIGINT, interrupt);
632 fprintf(stderr, "%s\n", _("Press Ctrl+C to break..."));
634 GSM_Init(TRUE);
636 Note.Location = 0;
638 while (!gshutdown) {
639 error = GSM_GetNextCalendar(gsm, &Note, refresh);
640 if (error == ERR_EMPTY)
641 break;
642 Print_Error(error);
643 printf(LISTFORMAT "%d\n", _("Location"), Note.Location);
644 PrintCalendar(&Note);
645 refresh = FALSE;
648 GSM_Terminate();
651 void GetCalendarSettings(int argc UNUSED, char *argv[]UNUSED)
653 GSM_Error error;
654 GSM_CalendarSettings settings;
656 GSM_Init(TRUE);
658 error = GSM_GetCalendarSettings(gsm, &settings);
659 Print_Error(error);
661 if (settings.AutoDelete == 0) {
662 printf("%s", _("Auto deleting disabled"));
663 } else {
664 printf(_("Auto deleting notes after %i day(s)"),
665 settings.AutoDelete);
667 printf("\n");
668 printf(_("Week starts on %s"), GetDayName(settings.StartDay));
669 printf("\n");
671 GSM_Terminate();
674 void DeleteToDo(int argc, char *argv[])
676 GSM_Error error;
677 GSM_ToDoEntry ToDo;
678 int i;
679 int start, stop;
681 GetStartStop(&start, &stop, 2, argc, argv);
683 GSM_Init(TRUE);
685 for (i = start; i <= stop; i++) {
686 ToDo.Location = i;
687 printf(LISTFORMAT "%i\n", _("Location"), i);
688 error = GSM_DeleteToDo(gsm, &ToDo);
689 if (error != ERR_EMPTY)
690 Print_Error(error);
692 if (error == ERR_EMPTY) {
693 printf("%s\n", _("Entry was empty"));
694 } else {
695 printf("%s\n", _("Entry was deleted"));
697 printf("\n");
700 GSM_Terminate();
703 void PrintToDo(GSM_ToDoEntry * ToDo)
705 GSM_Error error;
706 int j;
707 GSM_MemoryEntry entry;
708 unsigned char *name;
709 GSM_Category Category;
711 printf(LISTFORMAT "%i\n", _("Location"), ToDo->Location);
712 PrintNoteType(ToDo->Type);
713 printf(LISTFORMAT, _("Priority"));
714 switch (ToDo->Priority) {
715 case GSM_Priority_Low:
716 printf("%s\n", _("Low"));
717 break;
718 case GSM_Priority_Medium:
719 printf("%s\n", _("Medium"));
720 break;
721 case GSM_Priority_High:
722 printf("%s\n", _("High"));
723 break;
724 case GSM_Priority_None:
725 printf("%s\n", _("None"));
726 break;
727 #ifndef CHECK_CASES
728 default:
729 printf("%s\n", _("Unknown"));
730 break;
731 #endif
733 for (j = 0; j < ToDo->EntriesNum; j++) {
734 switch (ToDo->Entries[j].EntryType) {
735 case TODO_END_DATETIME:
736 printf(LISTFORMAT "%s\n", _("Due time"),
737 OSDateTime(ToDo->Entries[j].Date,
738 FALSE));
739 break;
740 case TODO_START_DATETIME:
741 printf(LISTFORMAT "%s\n", _("Start time"),
742 OSDateTime(ToDo->Entries[j].Date,
743 FALSE));
744 break;
745 case TODO_COMPLETED_DATETIME:
746 printf(LISTFORMAT "%s\n", _("Completed time"),
747 OSDateTime(ToDo->Entries[j].Date,
748 FALSE));
749 break;
750 case TODO_COMPLETED:
751 printf(LISTFORMAT "%s\n", _("Completed"),
752 ToDo->Entries[j].Number ==
753 1 ? "Yes" : "No");
754 break;
755 case TODO_ALARM_DATETIME:
756 printf(LISTFORMAT "%s\n", _("Alarm"),
757 OSDateTime(ToDo->Entries[j].Date,
758 FALSE));
759 break;
760 case TODO_SILENT_ALARM_DATETIME:
761 printf(LISTFORMAT "%s\n", _("Silent alarm"),
762 OSDateTime(ToDo->Entries[j].Date,
763 FALSE));
764 break;
765 case TODO_LAST_MODIFIED:
766 printf(LISTFORMAT "%s\n", _("Last modified"),
767 OSDateTime(ToDo->Entries[j].Date,
768 FALSE));
769 break;
770 case TODO_TEXT:
771 printf(LISTFORMAT "\"%s\"\n", _("Text"),
772 DecodeUnicodeConsole(ToDo->Entries[j].
773 Text));
774 break;
775 case TODO_PRIVATE:
776 printf(LISTFORMAT "%s\n", _("Private"),
777 ToDo->Entries[j].Number ==
778 1 ? "Yes" : "No");
779 break;
780 case TODO_CATEGORY:
781 Category.Location = ToDo->Entries[j].Number;
782 Category.Type = Category_ToDo;
783 error = GSM_GetCategory(gsm, &Category);
784 if (error == ERR_NONE) {
785 printf(LISTFORMAT "\"%s\" (%i)\n",
786 _("Category"),
787 DecodeUnicodeConsole(Category.
788 Name),
789 ToDo->Entries[j].Number);
790 } else {
791 printf(LISTFORMAT "%i\n", _("Category"),
792 ToDo->Entries[j].Number);
794 break;
795 case TODO_CONTACTID:
796 entry.Location = ToDo->Entries[j].Number;
797 entry.MemoryType = MEM_ME;
798 error = GSM_GetMemory(gsm, &entry);
799 if (error == ERR_NONE) {
800 name =
801 GSM_PhonebookGetEntryName(&entry);
802 if (name != NULL) {
803 printf(LISTFORMAT
804 "\"%s\" (%d)\n",
805 _("Contact ID"),
806 DecodeUnicodeConsole
807 (name),
808 ToDo->Entries[j].Number);
809 } else {
810 printf(LISTFORMAT "%d\n",
811 _("Contact ID"),
812 ToDo->Entries[j].Number);
814 } else {
815 printf(LISTFORMAT "%d\n", _("Contact"),
816 ToDo->Entries[j].Number);
818 break;
819 case TODO_PHONE:
820 printf(LISTFORMAT "\"%s\"\n", _("Phone"),
821 DecodeUnicodeConsole(ToDo->Entries[j].
822 Text));
823 break;
824 case TODO_DESCRIPTION:
825 printf(LISTFORMAT "\"%s\"\n", _("Description"),
826 DecodeUnicodeConsole(ToDo->Entries[j].
827 Text));
828 break;
829 case TODO_LOCATION:
830 printf(LISTFORMAT "\"%s\"\n", _("Location"),
831 DecodeUnicodeConsole(ToDo->Entries[j].
832 Text));
833 break;
834 case TODO_LUID:
835 printf(LISTFORMAT "\"%s\"\n", _("LUID"),
836 DecodeUnicodeConsole(ToDo->Entries[j].
837 Text));
838 break;
841 printf("\n");
844 void ListToDoCategoryEntries(int Category)
846 GSM_Error error;
847 GSM_ToDoEntry Entry;
848 gboolean start = TRUE;
849 int j;
851 Entry.Location = 0;
853 while (!gshutdown) {
854 error = GSM_GetNextToDo(gsm, &Entry, start);
855 if (error == ERR_EMPTY)
856 break;
857 Print_Error(error);
858 for (j = 0; j < Entry.EntriesNum; j++) {
859 if (Entry.Entries[j].EntryType == TODO_CATEGORY
860 && Entry.Entries[j].Number ==
861 (unsigned int)Category)
862 PrintToDo(&Entry);
864 start = FALSE;
868 void ListToDoCategory(int argc UNUSED, char *argv[])
870 GSM_Error error;
871 GSM_Category Category;
872 GSM_CategoryStatus Status;
873 int j, count;
875 unsigned char Text[(GSM_MAX_CATEGORY_NAME_LENGTH + 1) * 2];
876 int Length;
877 gboolean Number = TRUE;;
879 GSM_Init(TRUE);
881 signal(SIGINT, interrupt);
882 fprintf(stderr, "%s\n", _("Press Ctrl+C to break..."));
884 Length = strlen(argv[2]);
885 for (j = 0; j < Length; j++) {
886 if (!isdigit((int)argv[2][j])) {
887 Number = FALSE;
888 break;
892 if (Number) {
893 j = GetInt(argv[2]);
894 if (j > 0) {
895 ListToDoCategoryEntries(j);
897 } else {
898 if (Length > GSM_MAX_CATEGORY_NAME_LENGTH) {
899 printf(_
900 ("Search text too long, truncating to %d chars!\n"),
901 GSM_MAX_CATEGORY_NAME_LENGTH);
902 Length = GSM_MAX_CATEGORY_NAME_LENGTH;
904 EncodeUnicode(Text, argv[2], Length);
906 Category.Type = Category_ToDo;
907 Status.Type = Category_ToDo;
909 if (GSM_GetCategoryStatus(gsm, &Status) == ERR_NONE) {
910 for (count = 0, j = 1; count < Status.Used; j++) {
911 Category.Location = j;
912 error = GSM_GetCategory(gsm, &Category);
914 if (error != ERR_EMPTY) {
915 count++;
916 if (mywstrstr(Category.Name, Text) !=
917 NULL) {
918 ListToDoCategoryEntries(j);
924 GSM_Terminate();
927 void GetToDo(int argc, char *argv[])
929 GSM_Error error;
930 GSM_ToDoEntry ToDo;
931 int i;
932 int start, stop;
934 GetStartStop(&start, &stop, 2, argc, argv);
936 GSM_Init(TRUE);
938 for (i = start; i <= stop; i++) {
939 ToDo.Location = i;
940 error = GSM_GetToDo(gsm, &ToDo);
941 if (error == ERR_EMPTY)
942 continue;
943 Print_Error(error);
944 PrintToDo(&ToDo);
947 GSM_Terminate();
950 void GetAllToDo(int argc UNUSED, char *argv[]UNUSED)
952 GSM_Error error;
953 GSM_ToDoEntry ToDo;
954 gboolean start = TRUE;
956 signal(SIGINT, interrupt);
957 fprintf(stderr, "%s\n", _("Press Ctrl+C to break..."));
959 GSM_Init(TRUE);
961 ToDo.Location = 0;
963 while (!gshutdown) {
964 error = GSM_GetNextToDo(gsm, &ToDo, start);
965 if (error == ERR_EMPTY)
966 break;
967 Print_Error(error);
968 PrintToDo(&ToDo);
969 start = FALSE;
972 GSM_Terminate();
975 void GetAllNotes(int argc UNUSED, char *argv[]UNUSED)
977 GSM_Error error;
978 GSM_NoteEntry Note;
979 gboolean start = TRUE;
981 signal(SIGINT, interrupt);
982 fprintf(stderr, "%s\n", _("Press Ctrl+C to break..."));
984 GSM_Init(TRUE);
986 Note.Location = 0;
988 while (!gshutdown) {
989 error = GSM_GetNextNote(gsm, &Note, start);
990 if (error == ERR_EMPTY)
991 break;
992 Print_Error(error);
993 printf(LISTFORMAT "\"%s\"\n", _("Text"),
994 DecodeUnicodeConsole(Note.Text));
995 printf("\n");
996 start = FALSE;
998 GSM_Terminate();
1001 /* How should editor hadle tabs in this file? Add editor commands here.
1002 * vim: noexpandtab sw=8 ts=8 sts=8: