X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=filter.c;h=62394ca0cf2c1b05fca28541c600b3b1b99e4603;hb=2f465ba5e73ba05745d23f0fca9d5bdb1b350d8c;hp=1d93d62bee2fcdc9c2c493d4f56fa8ad4fd98efd;hpb=e34f84be19f4ff5c2ea7299ef9cfae0d450a6c24;p=pkg%2Fabook.git diff --git a/filter.c b/filter.c index 1d93d62..62394ca 100644 --- a/filter.c +++ b/filter.c @@ -23,6 +23,7 @@ #include "list.h" #include "misc.h" #include "options.h" +#include "ui.h" #include "xmalloc.h" #include @@ -60,6 +61,7 @@ static int mutt_alias_export(FILE *out, struct db_enumerator e); static int elm_alias_export(FILE *out, struct db_enumerator e); static int text_export_database(FILE *out, struct db_enumerator e); static int spruce_export_database(FILE *out, struct db_enumerator e); +static int wl_export_database(FILE *out, struct db_enumerator e); /* * end of function declarations @@ -84,10 +86,11 @@ struct abook_output_filter e_filters[] = { { "pine", N_("pine addressbook"), pine_export_database }, { "gcrd", N_("GnomeCard (VCard) addressbook"), gcrd_export_database }, { "csv", N_("comma separated values"), csv_export_database }, - { "allcsv", N_("comma separated all values"), allcsv_export_database }, + { "allcsv", N_("comma separated values (all fields)"), allcsv_export_database }, { "palmcsv", N_("Palm comma separated values"), palm_export_database}, { "elm", N_("elm alias"), elm_alias_export }, { "text", N_("plain text"), text_export_database }, + { "wl", N_("Wanderlust address book"), wl_export_database }, { "spruce", N_("Spruce address book"), spruce_export_database }, { "\0", NULL, NULL } }; @@ -319,17 +322,20 @@ export_database() return 1; } - mvaddstr(5+filter, 2, "->"); + mvaddstr(5 + filter, 2, "->"); if(selected_items()) { - /* TODO gettext: handle translated keypresses? */ - statusline_addstr(_("Export All/Selected/Cancel (A/s/c)?")); - switch( tolower(getch()) ) { - case 's': + switch(statusline_askchoice( + _("Export ll, export elected, or ancel?"), + S_("keybindings:all/selected/cancel|asc"), 3)) { + case 1: + break; + case 2: enum_mode = ENUM_SELECTED; break; - case 'c': - clear_statusline(); + case 0: + case 3: + refresh_screen(); return 1; } clear_statusline(); @@ -789,7 +795,7 @@ ldif_export_database(FILE *out, struct db_enumerator e) int j; get_first_email(email, e.item); - tmp = mkstr("cn=%s,mail=%s", database[e.item][NAME], email); + tmp = strdup_printf("cn=%s,mail=%s", database[e.item][NAME], email); ldif_fput_type_and_value(out, "dn", tmp); free(tmp); @@ -1810,3 +1816,34 @@ spruce_export_database (FILE *out, struct db_enumerator e) * end of Spruce export filter */ +/* + * wanderlust addressbook export filter + */ + +static int +wl_export_database(FILE *out, struct db_enumerator e) +{ + char emails[MAX_EMAILS][MAX_EMAIL_LEN]; + + fprintf (out, "# Wanderlust address book written by %s\n\n", PACKAGE); + db_enumerate_items(e) { + split_emailstr(e.item, emails); + if (**emails) { + fprintf(out, + "%s\t\"%s\"\t\"%s\"\n", + *emails, + safe_str(database[e.item][NICK]), + safe_str(database[e.item][NAME]) + ); + } + } + + fprintf (out, "\n# End of address book file.\n"); + + return 0; +} + +/* + * end of wanderlust addressbook export filter + */ +