]> git.deb.at Git - pkg/abook.git/commitdiff
Implemented launch_lynx for single address
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Mon, 11 Jun 2001 19:10:46 +0000 (19:10 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Mon, 11 Jun 2001 19:10:46 +0000 (19:10 +0000)
abook.c

diff --git a/abook.c b/abook.c
index 6147aeeadcd28fabb98d341222e614e397e0cf4a..57db4e46be931493510da3f2e981595020e126ad 100644 (file)
--- a/abook.c
+++ b/abook.c
@@ -273,44 +273,52 @@ quit_mutt_query(int status)
 }
 
 
+static char *
+make_mailstr(int item)
+{
+       char email[MAX_EMAIL_LEN];
+       char *ret;
+       char *name = mkstr("\"%s\"", database[item][NAME]);
+
+       get_first_email(email, item);
+
+       ret = *database[item][EMAIL] ?
+               mkstr("%s <%s>", name, email) :
+               name;
+
+       free(name);
+       
+       return ret;
+}
+
 void
 launch_mutt(int item)
 {
+       char *cmd = NULL, *mailstr = NULL;
+
+       if( is_valid_item(item) )
+               mailstr = make_mailstr(item);
+
        /*
-        * This is _broken_
+        * need to implement for multiple addresses
         */
-#if 0
-       struct db_enumerator e = init_db_enumerator(ENUM_ALL);
-       char email[MAX_EMAIL_LEN];
-       char *cmd;
-       char *tmp = options_get_str("mutt_command");
-
-       cmd = strconcat(tmp, " '", NULL );
-
-       db_enumerate_items(e) {
-               if( e.item != item );
-               get_first_email(email, e.item);
-               tmp = mkstr("%s, \"%s\"", cmd, database[e.item][NAME]);
-               my_free(cmd);
-               if( *database[e.item][EMAIL] ) {
-                       cmd = mkstr("%s <%s>", tmp, email);
-                       free(tmp);
-                       tmp = cmd;
-               }
-               cmd = strconcat(tmp, " ", NULL);
-               free(tmp);
-       }
-
-       tmp = strconcat(cmd, "\'", NULL);
-       free(cmd);
-       cmd = tmp;
+               /*
+       } else {
+               struct db_enumerator e = init_db_enumerator(ENUM_SELECTED);
+               db_enumerate_items(e) {
+                       tmp = mailstr;
+                       mailstr = strconcat(tmp, make_mailstr(e.item);
+                       
+       }*/
+
+       cmd = strconcat(options_get_str("mutt_command"), " \'", mailstr,
+                               "\'", NULL);
+       free(mailstr);
 #ifdef DEBUG
        fprintf(stderr, "cmd: %s\n", cmd);
 #endif
        system(cmd);    
-
        free(cmd);
-#endif
 }
 
 void