Accepting request 341598 from server:mail

1

OBS-URL: https://build.opensuse.org/request/show/341598
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/abook?expand=0&rev=14
This commit is contained in:
Dominique Leuenberger 2015-10-30 12:44:01 +00:00 committed by Git OBS Bridge
commit b398e67a9f
5 changed files with 57 additions and 335 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b1e845b3443510d21d80450536066a5a11ee93045ea1f9210fca90f7c0b8e692
size 340461

3
abook-0.6.1.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f0a90df8694fb34685ecdd45d97db28b88046c15c95e7b0700596028bd8bc0f9
size 319558

View File

@ -1,3 +1,44 @@
-------------------------------------------------------------------
Mon Oct 26 23:14:46 UTC 2015 - p.drouand@gmail.com
- Update to version 0.6.1
* support for mouse
* scrolling now affects the viewport instead of the cursor
* support for a colored UI
* added "groups" as a default field
* the UI now supports merging selected entries [key M]
and removing duplicates [key U]
* a "custom" output filter allows the specification of an output
format using placeholders
* search-next is now bound to "/" too
* some output filters can now be used in the context
of --mutt-query. This is the case of "vcard" and "custom"
[ no --query option has been created and --mutt-query is fully
backward compatible ]
* ldif output filter has been fixed [output modified] in multiple
ways, does not force output to latin1 anymore and supports input
from stdin.
* vcard input/output support:
An original input filter implementation was provided soon
after 0.6.0pre2.
In 2012, an optional build-time option to link against libvformat
was added for the very same task: parsing vcard.
- It depends on the --enable-vformat ./configure switch
- It's only used as an input filter, especially useful to
deal with multi-valued fields and encoded characters.
* when the UI requests a confirmation from the user before a
destructive operation it does not treat unknown key as "yes" anymore.
* allcsv output changes:
- header line uses lowercase
- "MOBILEPHONE" column name changed to "mobile" (consistent w.r.t.
standard_fields)
- defined custom fields as well are part of the output now
- Remove abook_vcard_import.patch; fixed on upstream release
- Split out language files into their own package
- Add autoconf and automake dependencies; automake is required by
the configure script itself and autoconf is needed to run
autoreconf
-------------------------------------------------------------------
Thu Jun 18 21:16:15 UTC 2015 - crrodriguez@opensuse.org

View File

@ -17,16 +17,18 @@
Name: abook
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: gettext
BuildRequires: ncurses-devel
BuildRequires: readline-devel
Recommends: %{name}-lang
Summary: Text-based addressbook program
License: GPL-2.0+
Group: Productivity/Other
Version: 0.6.0pre2
Version: 0.6.1
Release: 0
Source: http://abook.sourceforge.net/devel/%{name}-%{version}.tar.bz2
Patch0: abook_vcard_import.patch
Source: http://abook.sourceforge.net/devel/%{name}-%{version}.tar.gz
Url: http://abook.sourceforge.net/
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -34,25 +36,29 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
Abook is a text-based addressbook program designed to
use with mutt mail client.
%lang_package
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
%build
autoreconf -fiv
export CFLAGS="%{optflags} -fgnu89-inline"
%configure
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags}
make %{?_smp_mflags}
%install
%makeinstall
%make_install
%find_lang %{name}
%files -f %{name}.lang
%files
%defattr(-,root,root)
%doc AUTHORS BUGS COPYING ChangeLog FAQ NEWS README THANKS TODO sample.abookrc
%{_bindir}/abook
%{_mandir}/man1/abook.*
%{_mandir}/man5/abookrc.*
%files lang -f %{name}.lang
%defattr(-,root,root)
%changelog

View File

@ -1,325 +0,0 @@
diff -ru a/filter.c b/filter.c
--- a/filter.c 2006-09-06 07:26:10.000000000 +0200
+++ b/filter.c 2008-05-18 20:55:12.000000000 +0200
@@ -44,6 +44,7 @@
static int csv_parse_file(FILE *in);
static int allcsv_parse_file(FILE *in);
static int palmcsv_parse_file(FILE *in);
+static int vcard_parse_file(FILE *in);
/*
* export filter prototypes
@@ -75,6 +76,7 @@
{ "csv", N_("comma separated values"), csv_parse_file },
{ "allcsv", N_("comma separated values (all fields)"), allcsv_parse_file },
{ "palmcsv", N_("Palm comma separated values"), palmcsv_parse_file },
+ { "vcard", N_("vCard file"), vcard_parse_file },
{ "\0", NULL, NULL }
};
@@ -1331,6 +1333,262 @@
*/
/*
+ * vCard import filter
+ */
+
+static char *vcard_fields[] = {
+ "FN", /* NAME */
+ "EMAIL", /* EMAIL */
+ "ADR", /* ADDRESS */
+ "ADR", /* ADDRESS2 - not used */
+ "ADR", /* CITY */
+ "ADR", /* STATE */
+ "ADR", /* ZIP */
+ "ADR", /* COUNTRY */
+ "TEL", /* PHONE */
+ "TEL", /* WORKPHONE */
+ "TEL", /* FAX */
+ "TEL", /* MOBILEPHONE */
+ "NICKNAME", /* NICK */
+ "URL", /* URL */
+ "NOTE", /* NOTES */
+ NULL /* not implemented: ANNIVERSARY, ITEM_FIELDS */
+};
+
+/*
+ * mappings between vCard ADR field and abook's ADDRESS
+ * see rfc2426 section 3.2.1
+ */
+static int vcard_address_fields[] = {
+ -1, /* vCard(post office box) - not used */
+ -1, /* vCard(the extended address) - not used */
+ 2, /* vCard(the street address) - ADDRESS */
+ 4, /* vCard(the locality) - CITY */
+ 5, /* vCard(the region) - STATE */
+ 6, /* vCard(the postal code) - ZIP */
+ 7 /* vCard(the country name) - COUNTRY */
+};
+
+enum {
+ VCARD_KEY = 0,
+ VCARD_KEY_ATTRIBUTE,
+ VCARD_VALUE,
+};
+
+static char *
+vcard_get_line_element(char *line, int element)
+{
+ int i;
+ char *line_copy = 0;
+ char *result = 0;
+ char *key = 0;
+ char *key_attr = 0;
+ char *value = 0;
+
+ line_copy = xstrdup(line);
+
+ /* make newline characters if exist end of string */
+ for(i=0; line_copy[i]; i++) {
+ if(line_copy[i] == '\r' || line_copy[i] == '\n') {
+ line_copy[i] = '\0';
+ break;
+ }
+ }
+
+ /* separate key from value */
+ for(i=0; line_copy[i]; i++) {
+ if(line_copy[i] == ':') {
+ line_copy[i] = '\0';
+ key = line_copy;
+ value = &line_copy[i+1];
+ break;
+ }
+ }
+
+ /* separate key from key attributes */
+ if (key) {
+ for(i=0; key[i]; i++) {
+ if(key[i] == ';') {
+ key[i] = '\0';
+ key_attr = &key[i+1];
+ break;
+ }
+ }
+ }
+
+ switch(element) {
+ case VCARD_KEY:
+ if(key)
+ result = xstrdup(key);
+ break;
+ case VCARD_KEY_ATTRIBUTE:
+ if(key_attr)
+ result = xstrdup(key_attr);
+ break;
+ case VCARD_VALUE:
+ if(value)
+ result = xstrdup(value);
+ break;
+ }
+
+ xfree(line_copy);
+ return result;
+}
+
+static void
+vcard_parse_email(list_item item, char *line)
+{
+ char *email;
+
+ email = vcard_get_line_element(line, VCARD_VALUE);
+
+ if(item[1]) {
+ item[1] = strconcat(item[1], ",", email, 0);
+ xfree(email);
+ }
+ else {
+ item[1] = email;
+ }
+}
+
+static void
+vcard_parse_address(list_item item, char *line)
+{
+ int i;
+ int k;
+ char *value;
+ char *address_field;
+
+ value = vcard_get_line_element(line, VCARD_VALUE);
+ if(!value)
+ return;
+
+ address_field = value;
+ for(i=k=0; value[i]; i++) {
+ if(value[i] == ';') {
+ value[i] = '\0';
+ if(vcard_address_fields[k] >= 0) {
+ item[vcard_address_fields[k]] = xstrdup(address_field);
+ }
+ address_field = &value[i+1];
+ k++;
+ if((k+1)==(sizeof(vcard_address_fields)/sizeof(*vcard_address_fields)))
+ break;
+ }
+ }
+ item[vcard_address_fields[k]] = xstrdup(address_field);
+ xfree(value);
+}
+
+static void
+vcard_parse_phone(list_item item, char *line)
+{
+ int index = 8;
+ char *type = vcard_get_line_element(line, VCARD_KEY_ATTRIBUTE);
+ char *value = vcard_get_line_element(line, VCARD_VALUE);
+
+ /* set the standard number */
+ if (!type) {
+ item[index] = value;
+ }
+
+ /*
+ * see rfc2426 section 3.3.1
+ */
+ else if (strstr(type, "TYPE=") == type){
+ if (strcasestr(type, "home")) {
+ item[index] = xstrdup(value);
+ }
+ if (strcasestr(type, "work")) {
+ item[index+1] = xstrdup(value);
+ }
+ if (strcasestr(type, "fax")) {
+ item[index+2] = xstrdup(value);
+ }
+ if (strcasestr(type, "cell")) {
+ item[index+3] = xstrdup(value);
+ }
+
+ xfree(type);
+ xfree(value);
+ }
+}
+
+static void
+vcard_parse_line(list_item item, char *line)
+{
+ int i;
+ char *key;
+
+ for(i=0; vcard_fields[i]; i++) {
+ key = vcard_fields[i];
+
+ if(!strncmp(key, line, strlen(key))) {
+ if(i == 1) {
+ vcard_parse_email(item, line);
+ }
+ else if(i == 2) {
+ vcard_parse_address(item, line);
+ }
+ else if(i == 8) {
+ vcard_parse_phone(item, line);
+ }
+ else {
+ item[i] = vcard_get_line_element(line, VCARD_VALUE);
+ }
+ break;
+ }
+ }
+}
+
+static void
+vcard_parse_item(FILE *in)
+{
+ char *line = NULL;
+ list_item item = item_create();
+
+ while(!feof(in)) {
+ line = getaline(in);
+
+ if(line && !strncmp("END:VCARD", line, 9)) {
+ xfree(line);
+ break;
+ }
+ else if(line) {
+ vcard_parse_line(item, line);
+ xfree(line);
+ }
+ }
+
+ add_item2database(item);
+ item_free(&item);
+}
+
+static int
+vcard_parse_file(FILE *in)
+{
+ char *line = NULL;
+
+ while(!feof(in)) {
+ line = getaline(in);
+
+ if(line && !strncmp("BEGIN:VCARD", line, 11)) {
+ xfree(line);
+ vcard_parse_item(in);
+ }
+ else if(line) {
+ xfree(line);
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * end of vCard import filter
+ */
+
+/*
* csv addressbook export filters
*/
diff -ru a/misc.c b/misc.c
--- a/misc.c 2006-09-04 21:24:18.000000000 +0200
+++ b/misc.c 2008-05-18 18:00:33.000000000 +0200
@@ -77,6 +77,27 @@
return 1;
}
+char *
+strcasestr(char *haystack, char *needle)
+{
+ int i;
+ int k;
+
+ assert(haystack != NULL);
+ assert(needle != NULL);
+
+ for(i=0; i<strlen(haystack)-strlen(needle)+1; i++) {
+ for(k=0; k<strlen(needle); k++, i++) {
+ if (tolower(haystack[i]) != tolower(needle[k]))
+ break;
+ else if ((k+1) == strlen(needle))
+ return &haystack[i];
+ }
+ }
+
+ return NULL;
+}
+
#ifdef HAVE_CONFIG_H
# include "config.h"
diff -ru a/misc.h b/misc.h
--- a/misc.h 2006-09-04 21:24:18.000000000 +0200
+++ b/misc.h 2008-05-18 17:55:59.000000000 +0200
@@ -18,6 +18,8 @@
int is_number(char *s);
+char *strcasestr(char *haystack, char *needle);
+
char *strdup_printf(const char *format, ... );
char *strconcat(const char *str, ...);