aboutsummaryrefslogtreecommitdiff
path: root/src/addressadd.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-01-26 09:41:32 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-01-26 09:41:32 +0000
commitaf7c0d4c4d5f20cc09dc7f709cd88c43dab567b8 (patch)
treefa65c5b918669eb161f6367f20fbdbeaea755452 /src/addressadd.c
parent80ea2c6808e3820773e774d3bca1233bcc9aa87f (diff)
implemented auto-registration of new recipients.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2442 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/addressadd.c')
-rw-r--r--src/addressadd.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/addressadd.c b/src/addressadd.c
index cb5e3ae7..03d79c96 100644
--- a/src/addressadd.c
+++ b/src/addressadd.c
@@ -51,6 +51,7 @@
#include "addrindex.h"
#include "editaddress.h"
#include "manage_window.h"
+#include "utils.h"
typedef struct {
AddressBookFile *book;
@@ -361,6 +362,9 @@ gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name, const
if( remarks )
gtk_label_set_text( GTK_LABEL(addressadd_dlg.label_remarks ), remarks );
+ if( ! name )
+ name = "";
+
gtk_main();
gtk_widget_hide( addressadd_dlg.window );
@@ -382,6 +386,53 @@ gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name, const
return retVal;
}
+gboolean addressadd_autoreg(AddressIndex *addrIndex, const gchar *name,
+ const gchar *address, const gchar *remarks)
+{
+ ItemPerson *person = NULL;
+ AddressInterface *interface = NULL;
+ AddressDataSource *ds = NULL;
+ AddressBookFile *abf = NULL;
+ GList *node_ds;
+ const gchar *ds_name;
+
+ g_return_val_if_fail(address != NULL, FALSE);
+
+ if (!name)
+ name = "";
+
+ interface = addrindex_get_interface(addrIndex, ADDR_IF_BOOK);
+ if (!interface)
+ return FALSE;
+
+ for (node_ds = interface->listSource; node_ds != NULL;
+ node_ds = node_ds->next) {
+ ds = node_ds->data;
+ ds_name = addrindex_ds_get_name(ds);
+ if (!ds_name)
+ continue;
+ if (strcmp(ds_name, ADDR_DS_AUTOREG) != 0)
+ continue;
+ debug_print("addressadd_autoreg: AddressDataSource: %s found\n", ds_name);
+
+ if (!addrindex_ds_get_read_flag(ds))
+ addrindex_ds_read_data(ds);
+ abf = ds->rawDataSource;
+ }
+
+ if (!abf)
+ return FALSE;
+
+ person = addrbook_add_contact(abf, NULL, name, address, remarks);
+ if (person) {
+ debug_print("addressadd_autoreg: person added: %s <%s>\n",
+ name, address);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
/*
* End of Source.
*/