]> git.deb.at Git - pkg/abook.git/commitdiff
mutt import filter changes
authorJaakko Heinonen <jheinonen@users.sourceforge.net>
Mon, 29 Sep 2003 13:08:27 +0000 (13:08 +0000)
committerJaakko Heinonen <jheinonen@users.sourceforge.net>
Mon, 29 Sep 2003 13:08:27 +0000 (13:08 +0000)
12 files changed:
BUGS
ChangeLog
configure
configure.in
database.c
database.h
filter.c
help.h
options.c
options.h
sample.abookrc
ui.c

diff --git a/BUGS b/BUGS
index f583e90d3a8160aa3fba9738c20d8ac035bd98f6..7b4c3be8548df7a93a50dfd75f37d53cc7fdc19d 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -16,3 +16,4 @@ misc:
 * Cursor disappears in some cases with abook_readline() on Solaris. If
   you have problems it is recommended to use ncurses library
 * fseek in ldif import filter should be eliminated
 * Cursor disappears in some cases with abook_readline() on Solaris. If
   you have problems it is recommended to use ncurses library
 * fseek in ldif import filter should be eliminated
+* mutt import filter imports only first e-mail address
index 9c9d0710e1a45c25c222eb0159dfdff1029fb128..b48c953fcaa8e807c1ed66bfdf3a6641c0f5477a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 0.5.1
  - minor filter fixes
 0.5.1
  - minor filter fixes
+ - tried to fix \" quotation problem with mutt import filter
+ - removed obsolete filesel_sort option from abookrc manual page
  - added bbdb2xx translator source to contrib
 
 0.5.0
  - added bbdb2xx translator source to contrib
 
 0.5.0
index 3f526085beb361fedf4077616e141e34e18afbdb..6111671809682c10907eccd686ede782d576d713 100755 (executable)
--- a/configure
+++ b/configure
@@ -1527,7 +1527,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE=abook
 
 # Define the identity of the package.
  PACKAGE=abook
- VERSION=0.5.0
+ VERSION=0.5.1pre
 
 
 cat >>confdefs.h <<_ACEOF
 
 
 cat >>confdefs.h <<_ACEOF
index fd01f99403567aeebd37b772fb48e39de236693e..a278a3fe745561e1a2c938cb1110237423100e6f 100644 (file)
@@ -1,7 +1,7 @@
 dnl abook configure.in
 
 AC_INIT(abook.c)
 dnl abook configure.in
 
 AC_INIT(abook.c)
-AM_INIT_AUTOMAKE(abook, 0.5.0)
+AM_INIT_AUTOMAKE(abook, 0.5.1pre)
 AM_CONFIG_HEADER(config.h)
 
 AC_DEFINE(HAVE_SNPRINTF, 0, [Define if snprintf is available.])
 AM_CONFIG_HEADER(config.h)
 
 AC_DEFINE(HAVE_SNPRINTF, 0, [Define if snprintf is available.])
index 70e5a1ccfb00942e076ca2797fc8e0eb1be18072..c17adae62b7da64a6d4e19d83040b05729b83ae2 100644 (file)
@@ -351,21 +351,53 @@ surnamecmp(const void *i1, const void *i2)
        return ret;
 }
 
        return ret;
 }
 
+static int sort_field = -1;
+
 static int
 namecmp(const void *i1, const void *i2)
 {
        list_item a, b;
 
 static int
 namecmp(const void *i1, const void *i2)
 {
        list_item a, b;
 
+       assert(sort_field >= 0 && sort_field <= LAST_FIELD);
+
        itemcpy(a, i1);
        itemcpy(b, i2);
        
        itemcpy(a, i1);
        itemcpy(b, i2);
        
-       return safe_strcoll( a[NAME], b[NAME] );
+       return safe_strcoll( a[sort_field], b[sort_field] );
+}
+
+static int
+name2field(char *name)
+{
+       int i, ret = -1;
+
+       for(i = 0; i < ITEM_FIELDS; i++) {
+               if(!strcasecmp(name, abook_fields[i].key)) {
+                       ret = i;
+                       break;
+               }
+       }
+
+       return ret;
 }
 
 void
 }
 
 void
-sort_database()
+sort_by_field(int field)
 {
        select_none();
 {
        select_none();
+
+       assert(field <= LAST_FIELD);
+
+       if(field < 0) {
+               field = name2field(opt_get_str(STR_SORT_FIELD));
+               if(field < 0) {
+                       statusline_msg("Not valid field value defined "
+                               "in configuration");
+                       return;
+               }
+       }
+
+       sort_field = field;
        
        qsort((void *)database, items, sizeof(list_item), namecmp);
 
        
        qsort((void *)database, items, sizeof(list_item), namecmp);
 
index 10b31f85a669a1c1f9377ec379d3bca4fa765237..43b733817a06827d8ba848c91b25d4fc4c26d4cc 100644 (file)
@@ -55,7 +55,7 @@ int           add_item2database(list_item item);
 void           free_list_item(list_item item);
 void           remove_selected_items();
 void           sort_surname();
 void           free_list_item(list_item item);
 void           remove_selected_items();
 void           sort_surname();
-void           sort_database();
+void           sort_by_field(int field);
 char           *get_surname(char *s);
 int            find_item(char *str, int start, int search_fields[]);
 int            is_selected(int item);
 char           *get_surname(char *s);
 int            find_item(char *str, int start, int search_fields[]);
 int            is_selected(int item);
index 880213a7d00a352d5ae08a55b8b7388991dfd6e9..9a18975faff485c6bdf25fe9cb67a7da746839a1 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -657,14 +657,38 @@ mutt_read_line(FILE *in, char **alias, char **rest)
        return 0;
 }
 
        return 0;
 }
 
+static void
+mutt_fix_quoting(char *p)
+{
+       char *escape = 0;
+
+       for(; *p; p++) {
+               switch(*p) {
+                       case '\"':
+                               if(escape)
+                                       *escape = ' ';
+                               break;
+                       case '\\':
+                               escape = p;
+                               break;
+                       default:
+                               escape = 0;
+               }
+       }
+}
+
 static void
 mutt_parse_email(list_item item)
 {
        char *line = item[NAME];
 static void
 mutt_parse_email(list_item item)
 {
        char *line = item[NAME];
-       char *start = line, *tmp;
+       char *tmp;
        char *name, *email;
        char *name, *email;
+#if 0
+       char *start = line;
        int i = 0;
        int i = 0;
+#endif
 
 
+       mutt_fix_quoting(line);
        tmp = strconcat("From: ", line, NULL);
        getname(tmp, &name, &email);
        free(tmp);
        tmp = strconcat("From: ", line, NULL);
        getname(tmp, &name, &email);
        free(tmp);
@@ -678,6 +702,10 @@ mutt_parse_email(list_item item)
        else
                return;
 
        else
                return;
 
+       /*
+        * this is completely broken
+        */
+#if 0
        while( (start = strchr(start, ',')) && i++ < MAX_EMAILS - 1) {
                tmp = strconcat("From: ", ++start, NULL);
                getname(tmp, &name, &email);
        while( (start = strchr(start, ',')) && i++ < MAX_EMAILS - 1) {
                tmp = strconcat("From: ", ++start, NULL);
                getname(tmp, &name, &email);
@@ -693,6 +721,7 @@ mutt_parse_email(list_item item)
                        }
                }
        }
                        }
                }
        }
+#endif
 }
 
 static int
 }
 
 static int
diff --git a/help.h b/help.h
index abb040e85e54e69bf578263589d94321c45b3bcd..f9058bb517d5f78d57e0610fc682f5261b137cb3 100644 (file)
--- a/help.h
+++ b/help.h
@@ -32,6 +32,7 @@ static char *mainhelp[] = {
 "\n",
 "      s               sort database\n",
 "      S               \"surname sort\"\n",
 "\n",
 "      s               sort database\n",
 "      S               \"surname sort\"\n",
+"      F               sort by field (defined in configuration file)\n",
 "\n",
 "      /               find\n",
 "      \\              find next\n",
 "\n",
 "      /               find\n",
 "      \\              find next\n",
index e9885a98aa9b8e1d5b0e86e70aa60753f390027a..fe75878abb225b056e950f0c2a34cceaba7f9d72 100644 (file)
--- a/options.c
+++ b/options.c
@@ -65,6 +65,7 @@ static struct option abook_vars[] = {
        { "use_ascii_only", OT_BOOL, BOOL_USE_ASCII_ONLY, FALSE },
 
        { "add_email_prevent_duplicates", OT_BOOL, BOOL_ADD_EMAIL_PREVENT_DUPLICATES, FALSE },
        { "use_ascii_only", OT_BOOL, BOOL_USE_ASCII_ONLY, FALSE },
 
        { "add_email_prevent_duplicates", OT_BOOL, BOOL_ADD_EMAIL_PREVENT_DUPLICATES, FALSE },
+       { "sort_field", OT_STR, STR_SORT_FIELD, UL "nick" },
 
        { NULL }
 };
 
        { NULL }
 };
index 5d83f985f687254920b62230833b8f146317ebe3..cfdaa6c5c0dbee61730314708db5ad36ffe91a97 100644 (file)
--- a/options.h
+++ b/options.h
@@ -42,6 +42,7 @@ enum str_opts {
        STR_PRINT_COMMAND,
        STR_WWW_COMMAND,
        STR_ADDRESS_STYLE,
        STR_PRINT_COMMAND,
        STR_WWW_COMMAND,
        STR_ADDRESS_STYLE,
+       STR_SORT_FIELD,
        STR_MAX
 };
 
        STR_MAX
 };
 
index a5359df81ed84fd10c28a3dcab18f76f5ff78094..a8fb45208135b9dcc467ef3cc649deadf55a597c 100644 (file)
@@ -48,3 +48,5 @@ set address_style=eu
 set use_ascii_only=false
 
 set add_email_prevent_duplicates=false
 set use_ascii_only=false
 
 set add_email_prevent_duplicates=false
+
+set sort_field=nick
diff --git a/ui.c b/ui.c
index 4d4150e1006e5c9883121494af99cf3784ca115f..023f20667b730f5a25dbae7f3640d71ccf013440 100644 (file)
--- a/ui.c
+++ b/ui.c
@@ -420,8 +420,9 @@ get_commands()
 
                        case 'o': ui_open_datafile();   break;
 
 
                        case 'o': ui_open_datafile();   break;
 
-                       case 's': sort_database();      break;
+                       case 's': sort_by_field(NAME);  break;
                        case 'S': sort_surname();       break;
                        case 'S': sort_surname();       break;
+                       case 'F': sort_by_field(-1);    break;
 
                        case '/': ui_find(0);           break;
                        case '\\': ui_find(1);          break;
 
                        case '/': ui_find(0);           break;
                        case '\\': ui_find(1);          break;