[Commits] Makefile.am 1.1 1.2 claws-contacts.xml 1.1 1.2 server-object.c 1.4 1.5 server-object.h 1.1 1.2
miras at claws-mail.org
miras at claws-mail.org
Mon Mar 26 00:55:16 CEST 2012
Update of /home/claws-mail/contacts/src/dbus
In directory srv:/tmp/cvs-serv12090/src/dbus
Modified Files:
Makefile.am claws-contacts.xml server-object.c server-object.h
Log Message:
2012-03-25 [mir] 0.6.0cvs80
* extensions/vcard/src/vcard-extension.c
* libversit/Makefile.am
* libversit/vcard-utils.c
* libversit/vcard-utils.h
* src/utils.c
* src/utils.h
* src/dbus/Makefile.am
* src/dbus/claws-contacts.xml
* src/dbus/server-object.c
* src/dbus/server-object.h
* xmllib/parser.c
A bunch of changes and enhancements. Also added feature
to allow users to create a vCard for each account which
is to be used for optionally added a vCard to every
send email.
Index: server-object.c
===================================================================
RCS file: /home/claws-mail/contacts/src/dbus/server-object.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- server-object.c 29 Nov 2011 07:53:27 -0000 1.4
+++ server-object.c 25 Mar 2012 22:55:13 -0000 1.5
@@ -52,6 +52,7 @@
#include "plugin.h"
#include "callbacks.h"
#include "dbus-contact.h"
+#include "vcard-utils.h"
#include "server-bindings.h"
@@ -222,42 +223,53 @@
static gchar** mail_text(Contact* contact) {
GSList* cur;
GPtrArray* array;
- gchar *firstname = NULL, *lastname = NULL;
+ gchar *firstname, *lastname, *displayname, *nickname, *text;
array = g_ptr_array_new();
+ firstname = lastname = displayname = nickname = text = NULL;
if (contact->data) {
- extract_data(contact->data, "first-name", (gpointer) &firstname);
- extract_data(contact->data, "last-name", (gpointer) &lastname);
+ extract_data(contact->data, "cn", (gpointer) &displayname);
+ if (! displayname) {
+ extract_data(contact->data, "first-name", (gpointer) &firstname);
+ extract_data(contact->data, "last-name", (gpointer) &lastname);
+ if (! firstname && ! lastname) {
+ extract_data(contact->data, "cn", (gpointer) &nickname);
+ if (nickname)
+ text = g_strdup(nickname);
+ }
+ else {
+ if (firstname && lastname)
+ text = g_strconcat(firstname, " ", lastname, NULL);
+ else if (firstname)
+ text = g_strdup(firstname);
+ else
+ text = g_strdup(lastname);
+ }
+ }
+ else
+ text = g_strdup(displayname);
+ g_free(firstname);
+ g_free(lastname);
+ g_free(displayname);
+ g_free(nickname);
}
for (cur= contact->emails; cur; cur = g_slist_next(cur)) {
Email* e = (Email *) cur->data;
if (! e->email)
continue;
- if (e->alias && strlen(e->alias) > 0) {
- g_ptr_array_add(array, g_strconcat(
- "\"", e->alias, "\" <", e->email, ">", NULL));
+ if (text) {
+ g_ptr_array_add(array, g_strconcat("\"", text, "\" <", e->email, ">", NULL));
}
- else if ((firstname && strlen(firstname) > 0) || (
- lastname && strlen(lastname) > 0)) {
- if (firstname && strlen(firstname) > 0) {
- if (lastname && strlen(lastname) > 0)
- g_ptr_array_add(array, g_strconcat("\"", firstname, " ", lastname,
- "\" <", e->email, ">", NULL));
- else
- g_ptr_array_add(array, g_strconcat(
- "\"", firstname, "\" <", e->email, ">", NULL));
- }
- else {
- g_ptr_array_add(array, g_strconcat(
- "\"", lastname, "\" <", e->email, ">", NULL));
- }
+ else if (e->alias && strlen(e->alias) > 0) {
+ g_ptr_array_add(array, g_strconcat("\"", e->alias, "\" <", e->email, ">", NULL));
}
else
g_ptr_array_add(array, g_strconcat(e->email, NULL));
}
g_ptr_array_add(array, NULL);
+ g_free(text);
return (gchar **) g_ptr_array_free(array, FALSE);
}
@@ -768,3 +780,119 @@
return response;
}
+
+gboolean abook_add_vcard(ServerObject* server,
+ gchar* book,
+ gchar* vcard,
+ GError** error) {
+ gboolean response = TRUE;
+ gchar* search_book = NULL;
+ Contact* abook_contact;
+ AddressBook* ab;
+ gchar* err = NULL;
+ ConfigFile* config;
+ GSList* default_book = NULL;
+
+ if (! book || strlen(book) < 1) {
+ config = g_new0(ConfigFile, 1);
+ gchar* home = get_self_home();
+ config->path = g_strdup_printf(
+ "%s%s%src", home, G_DIR_SEPARATOR_S, PACKAGE);
+ g_free(home);
+
+ config->key_file = g_key_file_new();
+ if (g_file_test(config->path, G_FILE_TEST_EXISTS)) {
+ g_key_file_load_from_file(config->key_file,
+ config->path, G_KEY_FILE_KEEP_COMMENTS, NULL);
+ config_get_value(config, "Settings", "default book", &default_book);
+ }
+ config_main_free(config);
+ g_free(config);
+ if (default_book) {
+ search_book = g_strdup((gchar *) default_book->data);
+ gslist_free(&default_book, g_free);
+ }
+ if (! search_book) {
+ g_set_error(error,
+ server_object_error_quark(),
+ MISSING_ADDRESS_BOOK,
+ _("Missing address book"));
+ g_message("Missing address book");
+ return FALSE;
+ }
+ }
+ else
+ search_book = g_strdup(book);
+
+ if (! vcard) {
+ g_set_error(error,
+ server_object_error_quark(),
+ MISSING_NEW_CONTACT,
+ _("Missing vCard"));
+ g_message("Missing vCard");
+ return FALSE;
+ }
+
+ Reference* reference = address_book_reference_get(search_book);
+ if (reference) {
+ ab = address_book_get(reference->plugin, search_book);
+ g_message("Adding to address book '%s' using plugin '%s'",
+ ab->abook_name, reference->plugin->name());
+
+ abook_contact = vcard_ptr2contact(reference->plugin,
+ vcard, strlen(vcard), &err);
+
+ reference->plugin->set_contact(ab, abook_contact, &err);
+ if (err) {
+ if (error) {
+ g_set_error(error,
+ server_object_error_quark(),
+ SAVING_ADDRESS_BOOK_FAIL,
+ "%s", err);
+ }
+ g_message("%s", err);
+ g_free(err);
+ response = FALSE;
+ }
+ contact_free(abook_contact);
+ g_free(abook_contact);
+ }
+ else {
+ if (error) {
+ g_set_error(error,
+ server_object_error_quark(),
+ ADDRESS_BOOK_UNKNOWN,
+ _("%s: Address book not found here"),
+ search_book);
+ }
+ g_message("%s: Address book not found here", search_book);
+ response = FALSE;
+ }
+ g_free(search_book);
+
+ return response;
+}
+
+gboolean abook_get_vcard(ServerObject* server,
+ gchar* acount,
+ gchar** vcard,
+ GError** error) {
+ gboolean response = TRUE;
+ gchar* err = NULL;
+
+ *vcard = personal_vcard_get(acount, &err);
+ if (err) {
+ if (error) {
+ g_set_error(error,
+ server_object_error_quark(),
+ NO_SUCH_VCARD,
+ _("%s: Vcard not found here"),
+ err);
+ }
+ g_message("%s: Address book not found here", err);
+ g_free(err);
+ response = FALSE;
+ }
+
+ return response;
+}
\ No newline at end of file
Index: server-object.h
===================================================================
RCS file: /home/claws-mail/contacts/src/dbus/server-object.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- server-object.h 7 Sep 2011 17:35:29 -0000 1.1
+++ server-object.h 25 Mar 2012 22:55:13 -0000 1.2
@@ -82,7 +82,8 @@
ADDRESS_BOOK_UNKNOWN,
MISSING_SEARCH_TOKEN,
MISSING_RESPONSE_STRUCTURE,
- MISSING_NEW_CONTACT
+ MISSING_NEW_CONTACT,
+ NO_SUCH_VCARD
};
GType server_get_type();
@@ -115,6 +116,14 @@
gboolean abook_book_list(ServerObject* server,
gchar*** books,
GError** error);
+gboolean abook_add_vcard(ServerObject* server,
+ gchar* book,
+ gchar* vcard,
+ GError** error);
+gboolean abook_get_vcard(ServerObject* server,
+ gchar* acount,
+ gchar** vcard,
+ GError** error);
G_END_DECLS
Index: Makefile.am
===================================================================
RCS file: /home/claws-mail/contacts/src/dbus/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.am 7 Sep 2011 17:35:29 -0000 1.1
+++ Makefile.am 25 Mar 2012 22:55:13 -0000 1.2
@@ -6,6 +6,7 @@
-I${top_srcdir} \
-I${top_builddir} \
-I${top_srcdir}/src \
+ -I${top_srcdir}/libversit \
@GLIB_CFLAGS@ \
@GTK_CFLAGS@
@@ -35,7 +36,8 @@
libdbus_la_LIBADD = \
@GLIB_LIBS@ \
- @GTK_LIBS@
+ @GTK_LIBS@ \
+ ${top_builddir}/libversit/libversit.la
EXTRA_DIST = \
claws-contacts.xml
Index: claws-contacts.xml
===================================================================
RCS file: /home/claws-mail/contacts/src/dbus/claws-contacts.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- claws-contacts.xml 7 Sep 2011 17:35:29 -0000 1.1
+++ claws-contacts.xml 25 Mar 2012 22:55:13 -0000 1.2
@@ -40,12 +40,16 @@
<arg type="a(sss)" name="contact_emails" direction="in" />
</method>
-<!--
- <method name="AddContact1">
+ <method name="AddVCard">
+ <!-- if addressbook is NULL add to default address book -->
<arg type="s" name="addressbook" direction="in" />
- <arg type="(a{ss}a(sss))" name="contact" direction="in" />
+ <arg type="s" name="vcard" direction="in" />
+ </method>
+
+ <method name="GetVCard">
+ <arg type="s" name="acount" direction="in" />
+ <arg type="s" name="vcard" direction="out" />
</method>
--->
<signal name="ContactMailTo">
<arg type="s" name="contact_add_to" direction="out" />
More information about the Commits
mailing list