Index: gnokii/gnokii.c =================================================================== RCS file: /sources/gnokii/gnokii/gnokii/gnokii.c,v retrieving revision 1.474 diff -u -r1.474 gnokii.c --- gnokii/gnokii.c 29 Nov 2006 11:14:10 -0000 1.474 +++ gnokii/gnokii.c 8 Apr 2007 10:17:44 -0000 @@ -636,7 +636,7 @@ { OPT_GETTODO, 1, 3, 0 }, { OPT_WRITETODO, 2, 2, 0 }, { OPT_GETCALENDARNOTE, 1, 3, 0 }, - { OPT_WRITECALENDARNOTE, 2, 2, 0 }, + { OPT_WRITECALENDARNOTE, 3, 3, 0 }, { OPT_DELCALENDARNOTE, 1, 2, 0 }, { OPT_GETPHONEBOOK, 2, 4, 0 }, { OPT_WRITEPHONEBOOK, 0, 10, 0 }, @@ -815,7 +815,7 @@ rc = getcalendarnote(argc, argv, data, state); break; case OPT_WRITECALENDARNOTE: - rc = writecalendarnote(argv, data, state); + rc = writecalendarnote(argc, argv, data, state); break; case OPT_DELCALENDARNOTE: rc = deletecalendarnote(argc, argv, data, state); Index: gnokii/gnokii-app.h =================================================================== RCS file: /sources/gnokii/gnokii/gnokii/gnokii-app.h,v retrieving revision 1.43 diff -u -r1.43 gnokii-app.h --- gnokii/gnokii-app.h 16 Nov 2006 21:55:17 -0000 1.43 +++ gnokii/gnokii-app.h 8 Apr 2007 10:17:44 -0000 @@ -98,7 +98,7 @@ extern void getcalendarnote_usage(FILE *f, int exitval); extern int getcalendarnote(int argc, char *argv[], gn_data *data, struct gn_statemachine *state); -extern int writecalendarnote(char *argv[], gn_data *data, struct gn_statemachine *state); +extern int writecalendarnote(int argc, char *argv[], gn_data *data, struct gn_statemachine *state); extern int deletecalendarnote(int argc, char *argv[], gn_data *data, struct gn_statemachine *state); /* TODO functions */ Index: gnokii/gnokii-calendar.c =================================================================== RCS file: /sources/gnokii/gnokii/gnokii/gnokii-calendar.c,v retrieving revision 1.8 diff -u -r1.8 gnokii-calendar.c --- gnokii/gnokii-calendar.c 19 Dec 2006 17:49:32 -0000 1.8 +++ gnokii/gnokii-calendar.c 8 Apr 2007 10:17:45 -0000 @@ -241,62 +241,77 @@ void writecalendarnote_usage(FILE *f, int exitval) { - fprintf(f, _("usage: --writecalendarnote vcalendarfile number\n" + fprintf(f, _("usage: --writecalendarnote vcalendarfile start [end]\n" " vcalendarfile - file containing calendar notes in vCal format\n" - " number - calendar note number within the file\n" + " start_number - entry number in the vcalendarfile\n" + " end_number - read to this entry in the vcalendar file\n" + " end - the string \"end\" indicates all entries from start to end\n" " NOTE: it stores the note at the first empty location.\n" )); exit(exitval); } /* Writing calendar notes. */ -int writecalendarnote(char *argv[], gn_data *data, struct gn_statemachine *state) +int writecalendarnote(int argc, char *argv[], gn_data *data, struct gn_statemachine *state) { - gn_calnote calnote; gn_error error; - int location; + int first_location,last_location,only_summary; + int i; FILE *f; - memset(&calnote, 0, sizeof(calnote)); - gn_data_clear(data); - data->calnote = &calnote; f = fopen(optarg, "r"); if (f == NULL) { fprintf(stderr, _("Can't open file %s for reading!\n"), optarg); return GN_ERR_FAILED; } - - location = gnokii_atoi(argv[optind]); - if (errno || location < 0) + first_location = gnokii_atoi(argv[3]); + if (errno || first_location < 0) writecalendarnote_usage(stderr, -1); - error = gn_ical2calnote(f, &calnote, location); + last_location = parse_end_value_option(argc, argv, 4, first_location); + + if (errno || last_location < 0) + writecalendarnote_usage(stderr, -1); + + for (i=first_location;icalnote = &calnote; + + //TODO: gn_ical2note expects the pointer to begin file to + //iterate. Fix it to not rewind the file each time + //TODO: parameter to gn_ical2note to not print vcard for + //each contact + rewind(f); + error = gn_ical2calnote(f, &calnote, i); - fclose(f); #ifndef WIN32 - if (error == GN_ERR_NOTIMPLEMENTED) { - switch (gn_vcal_file_event_read(optarg, &calnote, location)) { - case 0: - error = GN_ERR_NONE; - break; - default: - error = GN_ERR_FAILED; - break; + if (error == GN_ERR_NOTIMPLEMENTED) { + switch (gn_vcal_file_event_read(optarg, &calnote, i)) { + case 0: + error = GN_ERR_NONE; + break; + default: + error = GN_ERR_FAILED; + break; + } } - } #endif - if (error != GN_ERR_NONE) { - fprintf(stderr, _("Failed to load vCalendar file: %s\n"), gn_error_print(error)); - return error; - } + if (error != GN_ERR_NONE) { + fprintf(stderr, _("Failed to load vCalendar file: %s\n"), gn_error_print(error)); + return error; + } - error = gn_sm_functions(GN_OP_WriteCalendarNote, data, state); + error = gn_sm_functions(GN_OP_WriteCalendarNote, data, state); - if (error == GN_ERR_NONE) - fprintf(stderr, _("Successfully written!\n")); - else - fprintf(stderr, _("Failed to write calendar note: %s\n"), gn_error_print(error)); + if (error == GN_ERR_NONE) + fprintf(stderr, _("Successfully written!\n")); + else + fprintf(stderr, _("Failed to write calendar note: %s\n"), gn_error_print(error)); + } + fclose(f); return error; } Index: common/vcal.c =================================================================== RCS file: /sources/gnokii/gnokii/common/vcal.c,v retrieving revision 1.14 diff -u -r1.14 vcal.c --- common/vcal.c 20 Dec 2006 23:24:07 -0000 1.14 +++ common/vcal.c 8 Apr 2007 10:17:46 -0000 @@ -314,8 +314,10 @@ if (id < 1) id = 1; + /* iterate through the component */ + iterate_cal(comp, 0, &id, &compresult, ICAL_VEVENT_COMPONENT); if (!compresult) { @@ -332,17 +334,34 @@ switch (calnote->type) { case GN_CALNOTE_CALL: /* description goes into text */ - /* TODO: UTF8 --> ascii */ + /* TODO: UTF8 --> ascii || Done! (some lines below) */ + snprintf(calnote->phone_number, GN_CALNOTE_NUMBER_MAX_LENGTH-1, "%s", icalcomponent_get_summary(compresult)); str = icalcomponent_get_description(compresult); break; default: /* summary goes into text */ - /* TODO: UTF8 --> ascii */ + /* TODO: UTF8 --> ascii || Done! (some lines below) */ str = icalcomponent_get_summary(compresult); break; } if (str) { + //Convert from UTF8 to ascii, in same memory zone (ascii is equal or smaller) + int str_len,asciilen; + char *ascii = NULL; + + str_len = strlen(str); + + ascii = malloc(str_len + 1); + /* TODO: utf8_decode maybe doesn't decode to ASCII + (to some local settings). Do a function to + decode always to ASCII */ + utf8_decode(ascii,asciilen,str,str_len); + + memcpy(str,ascii,str_len + 1); + free(ascii); + ascii = NULL; + snprintf(calnote->text, GN_CALNOTE_MAX_LENGTH - 1, "%s", str); }