[Commits] Makefile.am NONE 1.1.2.1 address_keeper.c NONE 1.1.2.1 address_keeper.h NONE 1.1.2.1 address_keeper_prefs.c NONE 1.1.2.1 address_keeper_prefs.h NONE 1.1.2.1 claws.def NONE 1.1.2.1 placeholder.txt 1.1.2.1 NONE plugin.def NONE 1.1.2.1 version.rc NONE 1.1.2.1

colin at claws-mail.org colin at claws-mail.org
Sat Feb 16 13:59:27 CET 2013


Update of /home/claws-mail/claws/src/plugins/address_keeper
In directory srv:/tmp/cvs-serv13623/src/plugins/address_keeper

Added Files:
      Tag: gtk2
	Makefile.am address_keeper.c address_keeper.h 
	address_keeper_prefs.c address_keeper_prefs.h claws.def 
	plugin.def version.rc 
Removed Files:
      Tag: gtk2
	placeholder.txt 
Log Message:
2013-02-16 [colin]	3.9.0cvs73

	* src/plugins/Makefile.am
	* src/plugins/acpi_notifier/Makefile.am
	* src/plugins/acpi_notifier/acpi_notifier.c
	* src/plugins/acpi_notifier/placeholder.txt
	* src/plugins/address_keeper/Makefile.am
	* src/plugins/address_keeper/address_keeper.c
	* src/plugins/address_keeper/address_keeper.h
	* src/plugins/address_keeper/address_keeper_prefs.c
	* src/plugins/address_keeper/address_keeper_prefs.h
	* src/plugins/address_keeper/claws.def
	* src/plugins/address_keeper/placeholder.txt
	* src/plugins/address_keeper/plugin.def
	* src/plugins/address_keeper/version.rc
	* src/plugins/attachwarner/Makefile.am
	* src/plugins/attachwarner/attachwarner.c
	* src/plugins/attachwarner/attachwarner.h
	* src/plugins/attachwarner/attachwarner_prefs.c
	* src/plugins/attachwarner/attachwarner_prefs.h
	* src/plugins/attachwarner/claws.def
	* src/plugins/attachwarner/placeholder.txt
	* src/plugins/attachwarner/plugin.def
	* src/plugins/attachwarner/version.rc
	* src/plugins/vcalendar/libical/libical/icalversion.h
	* po/POTFILES.in
	* po/bg.po
	* po/ca.po
	* po/cs.po
	* po/de.po
	* po/en_GB.po
	* po/es.po
	* po/fi.po
	* po/fr.po
	* po/hu.po
	* po/id_ID.po
	* po/it.po
	* po/ja.po
	* po/lt.po
	* po/nl.po
	* po/pl.po
	* po/pt_BR.po
	* po/pt_PT.po
	* po/ru.po
	* po/sk.po
	* po/sr.po
	* po/sv.po
	* po/uk.po
	* po/zh_CN.po
	* po/zh_TW.po
		Now do acpi_notifier, attachwarner, address_keeper

--- NEW FILE: address_keeper_prefs.c ---
/*
 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail Team
 * Copyright (C) 2009-2010 Ricardo Mones
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#include "claws-features.h"
#endif

#include <glib.h>
#include <glib/gi18n.h>

#include "address_keeper.h"

#include <gtk/gtk.h>

#include "defs.h"
#include "address_keeper_prefs.h"
#include "prefs_common.h"
#include "prefs_gtk.h"

#define PREFS_BLOCK_NAME "AddressKeeper"

AddressKeeperPrefs addkeeperprefs;

struct AddressKeeperPrefsPage
{
	PrefsPage page;
	
	GtkWidget *addressbook_folder;
	GtkWidget *keep_to_addrs_check;
	GtkWidget *keep_cc_addrs_check;
	GtkWidget *keep_bcc_addrs_check;
};

struct AddressKeeperPrefsPage addkeeperprefs_page;

static PrefParam param[] = {
	{"addressbook_folder", "", &addkeeperprefs.addressbook_folder,
         P_STRING, NULL, NULL, NULL},
	{"keep_to_addrs", "TRUE", &addkeeperprefs.keep_to_addrs,
         P_BOOL, NULL, NULL, NULL},
	{"keep_cc_addrs", "TRUE", &addkeeperprefs.keep_cc_addrs,
         P_BOOL, NULL, NULL, NULL},
	{"keep_bcc_addrs", "FALSE", &addkeeperprefs.keep_bcc_addrs,
         P_BOOL, NULL, NULL, NULL},
	{NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
};

#ifndef USE_NEW_ADDRBOOK
static void select_addressbook_clicked_cb(GtkWidget *widget, gpointer data) {
	const gchar *folderpath = NULL;
	gchar *new_path = NULL;

	folderpath = gtk_entry_get_text(GTK_ENTRY(data));
	new_path = addressbook_folder_selection(folderpath);
	if (new_path) {
		gtk_entry_set_text(GTK_ENTRY(data), new_path);
		g_free(new_path);
	}
}
#endif

static void addkeeper_prefs_create_widget_func(PrefsPage * _page,
					       GtkWindow * window,
					       gpointer data)
{
	struct AddressKeeperPrefsPage *page = (struct AddressKeeperPrefsPage *) _page;
	GtkWidget *entry;
	GtkWidget *label;
	GtkWidget *button;
	GtkWidget *keep_to_checkbox;
	GtkWidget *keep_cc_checkbox;
	GtkWidget *keep_bcc_checkbox;
	GtkWidget *hbox;
	GtkWidget *vbox;

	vbox = gtk_vbox_new(FALSE, 6);
	hbox = gtk_hbox_new(FALSE, 6);

	label = gtk_label_new(_("Keep to folder"));
	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
	gtk_widget_show(label);

	entry = gtk_entry_new();
	gtk_entry_set_text(GTK_ENTRY(entry), addkeeperprefs.addressbook_folder);
	gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
	gtk_widget_show(entry);
	CLAWS_SET_TIP(entry, _("Address book path where addresses are kept"));

	button = gtk_button_new_with_label(_("Select..."));
	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
#ifndef USE_NEW_ADDRBOOK
	g_signal_connect(G_OBJECT (button), "clicked",
			 G_CALLBACK (select_addressbook_clicked_cb),
			 entry);
#else
	gtk_widget_set_sensitive(button, FALSE);
#endif
	gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
	gtk_widget_show(button);
	gtk_widget_show(hbox);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

	page->addressbook_folder = entry;

	keep_to_checkbox = gtk_check_button_new_with_label(_("Keep 'To' addresses"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(keep_to_checkbox), addkeeperprefs.keep_to_addrs);
	gtk_container_set_border_width(GTK_CONTAINER(keep_to_checkbox), 6);
	gtk_box_pack_start(GTK_BOX(vbox), keep_to_checkbox, FALSE, FALSE, 0);
	gtk_widget_show(keep_to_checkbox);
	CLAWS_SET_TIP(keep_to_checkbox, _("Keep addresses which appear in 'To' headers"));
	gtk_widget_show(keep_to_checkbox);

	page->keep_to_addrs_check = keep_to_checkbox;

	keep_cc_checkbox = gtk_check_button_new_with_label(_("Keep 'Cc' addresses"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(keep_cc_checkbox), addkeeperprefs.keep_cc_addrs);
	gtk_container_set_border_width(GTK_CONTAINER(keep_cc_checkbox), 6);
	gtk_box_pack_start(GTK_BOX(vbox), keep_cc_checkbox, FALSE, FALSE, 0);
	gtk_widget_show(keep_cc_checkbox);
	CLAWS_SET_TIP(keep_cc_checkbox, _("Keep addresses which appear in 'Cc' headers"));
	gtk_widget_show(keep_cc_checkbox);

	page->keep_cc_addrs_check = keep_cc_checkbox;

	keep_bcc_checkbox = gtk_check_button_new_with_label(_("Keep 'Bcc' addresses"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(keep_bcc_checkbox), addkeeperprefs.keep_bcc_addrs);
	gtk_container_set_border_width(GTK_CONTAINER(keep_bcc_checkbox), 6);
	gtk_box_pack_start(GTK_BOX(vbox), keep_bcc_checkbox, FALSE, FALSE, 0);
	gtk_widget_show(keep_bcc_checkbox);
	CLAWS_SET_TIP(keep_bcc_checkbox, _("Keep addresses which appear in 'Bcc' headers"));
	gtk_widget_show(keep_bcc_checkbox);

	page->keep_bcc_addrs_check = keep_bcc_checkbox;
	
	gtk_widget_show_all(vbox);

	page->page.widget = vbox;
}

static void addkeeper_prefs_destroy_widget_func(PrefsPage *_page)
{
}

static void addkeeper_save_config(void)
{
	PrefFile *pfile;
	gchar *rcpath;

	debug_print("Saving AddressKeeper Page\n");

	rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
	pfile = prefs_write_open(rcpath);
	g_free(rcpath);
	if (!pfile || (prefs_set_block_label(pfile, PREFS_BLOCK_NAME) < 0))
		return;

	if (prefs_write_param(param, pfile->fp) < 0) {
		g_warning("Failed to write AddressKeeper configuration to file\n");
		prefs_file_close_revert(pfile);
		return;
	}
        if (fprintf(pfile->fp, "\n") < 0) {
		FILE_OP_ERROR(rcpath, "fprintf");
		prefs_file_close_revert(pfile);
	} else
	        prefs_file_close(pfile);
}


static void addkeeper_prefs_save_func(PrefsPage * _page)
{
	struct AddressKeeperPrefsPage *page = (struct AddressKeeperPrefsPage *) _page;
	const gchar *text;
	text = gtk_entry_get_text(GTK_ENTRY(page->addressbook_folder));
	addkeeperprefs.addressbook_folder = g_strdup(text);
	addkeeperprefs.keep_to_addrs = gtk_toggle_button_get_active(
		GTK_TOGGLE_BUTTON(page->keep_to_addrs_check));
	addkeeperprefs.keep_cc_addrs = gtk_toggle_button_get_active(
		GTK_TOGGLE_BUTTON(page->keep_cc_addrs_check));
	addkeeperprefs.keep_bcc_addrs = gtk_toggle_button_get_active(
		GTK_TOGGLE_BUTTON(page->keep_bcc_addrs_check));
	addkeeper_save_config();
}

void address_keeper_prefs_init(void)
{
	static gchar *path[3];
	gchar *rcpath;
	
	path[0] = _("Plugins");
	path[1] = _("Address Keeper");
	path[2] = NULL;

	prefs_set_default(param);
	rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
	prefs_read_config(param, PREFS_BLOCK_NAME, rcpath, NULL);
	g_free(rcpath);

	addkeeperprefs_page.page.path = path;
	addkeeperprefs_page.page.create_widget = addkeeper_prefs_create_widget_func;
	addkeeperprefs_page.page.destroy_widget = addkeeper_prefs_destroy_widget_func;
	addkeeperprefs_page.page.save_page = addkeeper_prefs_save_func;

	prefs_gtk_register_page((PrefsPage *) &addkeeperprefs_page);
}

void address_keeper_prefs_done(void)
{
	prefs_gtk_unregister_page((PrefsPage *) &addkeeperprefs_page);
}

--- NEW FILE: address_keeper.h ---
/*
 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail Team
 * Copyright (C) 2009-2010 Ricardo Mones
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef __ADDRESS_KEEPER_H
#define __ADDRESS_KEEPER_H

#include <glib.h>

#include "version.h"
#include "claws.h"
#include "plugin.h"
#include "utils.h"
#include "hooks.h"
#include "compose.h"
#include "addressbook.h"

#define PLUGIN_NAME	(_("Address Keeper"))

gint 		plugin_init	  	  (gchar **error);
gboolean	plugin_done		  (void);
const gchar *	plugin_name		  (void);
const gchar *	plugin_desc		  (void);
const gchar *	plugin_type		  (void);
const gchar *	plugin_licence		  (void);
const gchar *	plugin_version		  (void);
struct PluginFeature *plugin_provides	  (void);

#endif


--- NEW FILE: version.rc ---
1 VERSIONINFO
 FILEVERSION 0, 0, 0, 0
 PRODUCTVERSION 0, 0, 0, 0
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x40004L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "000004b0"
        BEGIN
            VALUE "FileDescription", "Address Keeper Plugin\0"
            VALUE "FileVersion", "0.0.0.0\0"
            VALUE "ProductVersion", "0.0.0.0 Win32\0"
            VALUE "LegalCopyright", "GPL / © 1999-2009 Hiroyuki Yamamoto & The Claws Mail Team\0"
            VALUE "CompanyName", "GNU / Free Software Foundation\0"
            VALUE "ProductName", "Claws Mail\0"
//            VALUE "Comments", "\0"
//            VALUE "InternalName", "\0"
//            VALUE "LegalTrademarks", "\0"
//            VALUE "OriginalFilename", "\0"
//            VALUE "PrivateBuild", "\0"
//            VALUE "SpecialBuild", "\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x0, 1200
    END
END

--- NEW FILE: claws.def ---
LIBRARY CLAWS-MAIL.EXE
EXPORTS
get_locale_dir
check_plugin_version
alertpanel
conv_codeset_strdup
conv_get_locale_charset_str_no_utf8
debug_print_real
debug_srcname
get_rc_dir 
hooks_register_hook
hooks_unregister_hook
line_has_quote_char
matcherlist_free
matcherlist_match
matcherlist_new
matcherprop_new
pref_get_escaped_pref
pref_get_unescaped_pref
prefs_common
prefs_file_close
prefs_file_close_revert
prefs_gtk_register_page
prefs_gtk_unregister_page
prefs_read_config
prefs_set_block_label
prefs_set_default
prefs_write_open
prefs_write_param
prefs_common_get_prefs

--- NEW FILE: plugin.def ---
EXPORTS
        plugin_desc
        plugin_done
        plugin_init
        plugin_licence
        plugin_name
        plugin_type
	plugin_provides
        plugin_version


--- NEW FILE: address_keeper_prefs.h ---
/*
 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail Team
 * Copyright (C) 2009-2010 Ricardo Mones
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef __ADDRESS_KEEPER_PREFS__
#define __ADDRESS_KEEPER_PREFS__

#include <glib.h>

typedef struct _AddressKeeperPrefs AddressKeeperPrefs;

struct _AddressKeeperPrefs
{
	gchar		 *addressbook_folder;
	gboolean	keep_to_addrs;
	gboolean	keep_cc_addrs;
	gboolean	keep_bcc_addrs;
};

extern AddressKeeperPrefs addkeeperprefs;
void address_keeper_prefs_init(void);
void address_keeper_prefs_done(void);

#endif

--- placeholder.txt DELETED ---

--- NEW FILE: address_keeper.c ---
/*
 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
 * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail Team
 * Copyright (C) 2009-2010 Ricardo Mones
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation, 
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#include "claws-features.h"
#endif

#include <glib.h>
#include <glib/gi18n.h>

#include "version.h"
#include "address_keeper.h"
#include "address_keeper_prefs.h"
#include "addr_compl.h"
#include "addrbook.h"
#include "codeconv.h"
#include "prefs_common.h"

/** Identifier for the hook. */
static guint hook_id;

/**
 * Extracts name from an address.
 *
 * @param addr The full address.
 * @return The name found in the address as a newly allocated string, or NULL if
 * not found.
 */
gchar *get_name_from_addr(const gchar *addr)
{
	gchar *name = NULL;

	if (addr == NULL || *addr == '\0')
		return NULL;
	name = strchr(addr, '@');
	if (name == NULL)
		return NULL;
	--name;
	while (name >= addr && !g_ascii_isspace(*name)) --name;
	while (name >= addr && g_ascii_isspace(*name)) --name;
	if (name > addr) {
		++name; /* recover non-space char */
		return g_strndup(addr, name - addr);
	}
	return NULL;
}

/**
 * Extracts comment from an address.
 *
 * @param addr The full address.
 * @return The comment found in the address as a newly allocated string, or NULL if
 * not found.
 */
gchar *get_comment_from_addr(const gchar *addr)
{
	gchar *comm = NULL;

	if (addr == NULL || *addr == '\0')
		return NULL;
	comm = strchr(addr, '@');
	if (comm == NULL)
		return NULL;
	++comm;
	while (*comm && !g_ascii_isspace(*comm)) ++comm;
	while (*comm && g_ascii_isspace(*comm)) ++comm;
	if (*comm)
		return g_strdup(comm);
	return NULL;
}

/**
 * Saves an address to the configured addressbook folder if not known.
 *
 * @param abf The address book file containing target folder.
 * @param folder The address book folder where addresses are added.
 * @param addr The address to be added.
 */
void keep_if_unknown(AddressBookFile * abf, ItemFolder * folder, gchar *addr)
{
	gchar *clean_addr = NULL;
	gchar *keepto = addkeeperprefs.addressbook_folder;

	debug_print("checking addr '%s'\n", addr);
	clean_addr = g_strdup(addr);
	extract_address(clean_addr);
	start_address_completion(NULL);
	if (complete_matches_found(clean_addr) == 0) {
		gchar *a_name;
		gchar *a_comment;
		debug_print("adding addr '%s' to addressbook '%s'\n",
			    clean_addr, keepto);
		a_name = get_name_from_addr(addr);
		a_comment = get_comment_from_addr(addr);
		if (!addrbook_add_contact(abf, folder, a_name, clean_addr, a_comment)) {
			g_warning("contact could not be added\n");
		} else {
			addressbook_refresh();
		}
		if (a_name != NULL)
			g_free(a_name);
		if (a_comment != NULL)
			g_free(a_comment);
	} else {
		debug_print("found addr '%s' in addressbook '%s', skipping\n",
			    clean_addr, keepto);
	}
	end_address_completion();
	g_free(clean_addr);
}

/**
 * Callback function to be called before sending the mail.
 * 
 * @param source The composer to be checked.
 * @param data Additional data.
 *
 * @return FALSE always: we're only annotating addresses.
 */
static gboolean addrk_before_send_hook(gpointer source, gpointer data)
{
	Compose *compose = (Compose *)source;
	AddressDataSource *book = NULL;
	AddressBookFile *abf = NULL;
	ItemFolder *folder = NULL;
	gchar *keepto = addkeeperprefs.addressbook_folder;
	GSList *cur;
	const gchar *to_hdr;
	const gchar *cc_hdr;
	const gchar *bcc_hdr;

	debug_print("address_keeper invoked!\n");
	if (compose->batch)
		return FALSE;	/* do not check while queuing */

	if (keepto == NULL || *keepto == '\0') {
		g_warning("addressbook folder not configured");
		return FALSE;
	}

	if (!addressbook_peek_folder_exists(keepto, &book, &folder)) {
		g_warning("addressbook folder not found '%s'\n", keepto);
		return FALSE;
	}
	if (!book) {
		g_warning("addressbook_peek_folder_exists: NULL book\n");
		return FALSE;
	}
	abf = book->rawDataSource;

	to_hdr = prefs_common_translated_header_name("To:");
	cc_hdr = prefs_common_translated_header_name("Cc:");
	bcc_hdr = prefs_common_translated_header_name("Bcc:");

	for (cur = compose->header_list; cur != NULL; cur = cur->next) {
		gchar *header;
		gchar *entry;
		header = gtk_editable_get_chars(GTK_EDITABLE(
				gtk_bin_get_child(GTK_BIN(
					(((ComposeHeaderEntry *)cur->data)->combo)))), 0, -1);
		entry = gtk_editable_get_chars(GTK_EDITABLE(
				((ComposeHeaderEntry *)cur->data)->entry), 0, -1);
		g_strstrip(entry);
		g_strstrip(header);
		if (*entry != '\0') {
			if (!g_ascii_strcasecmp(header, to_hdr)
				&& addkeeperprefs.keep_to_addrs == TRUE) {
				keep_if_unknown(abf, folder, entry);
			}
			if (!g_ascii_strcasecmp(header, cc_hdr)
				&& addkeeperprefs.keep_cc_addrs == TRUE) {
				keep_if_unknown(abf, folder, entry);
			}
			if (!g_ascii_strcasecmp(header, bcc_hdr)
				&& addkeeperprefs.keep_bcc_addrs == TRUE) {
				keep_if_unknown(abf, folder, entry);
			}
		}
		g_free(header);
		g_free(entry);
	}	

	return FALSE;	/* continue sending */
}

/**
 * Initialize plugin.
 *
 * @param error  For storing the returned error message.
 *
 * @return 0 if initialization succeeds, -1 on failure.
 */
gint plugin_init(gchar **error)
{
	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
				  VERSION_NUMERIC, PLUGIN_NAME, error))
		return -1;

	hook_id = hooks_register_hook(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, 
				      addrk_before_send_hook, NULL);
	
	if (hook_id == -1) {
		*error = g_strdup(_("Failed to register check before send hook"));
		return -1;
	}

	address_keeper_prefs_init();

	debug_print("Address Keeper plugin loaded\n");

	return 0;
}

/**
 * Destructor for the plugin.
 * Unregister the callback function and frees matcher.
 */
gboolean plugin_done(void)
{	
	hooks_unregister_hook(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, hook_id);
	address_keeper_prefs_done();
	debug_print("Address Keeper plugin unloaded\n");
	return TRUE;
}

/**
 * Get the name of the plugin.
 *
 * @return The plugin name (maybe translated).
 */
const gchar *plugin_name(void)
{
	return PLUGIN_NAME;
}

/**
 * Get the description of the plugin.
 *
 * @return The plugin description (maybe translated).
 */
const gchar *plugin_desc(void)
{
	return _("Keeps all recipient addresses in an addressbook folder.");
}

/**
 * Get the kind of plugin.
 *
 * @return The "GTK2" constant.
 */
const gchar *plugin_type(void)
{
	return "GTK2";
}

/**
 * Get the license acronym the plugin is released under.
 *
 * @return The "GPL3+" constant.
 */
const gchar *plugin_licence(void)
{
	return "GPL3+";
}

/**
 * Get the version of the plugin.
 *
 * @return The current version string.
 */
const gchar *plugin_version(void)
{
	return VERSION;
}

/**
 * Get the features implemented by the plugin.
 *
 * @return A constant PluginFeature structure with the features.
 */
struct PluginFeature *plugin_provides(void)
{
	static struct PluginFeature features[] = 
		{ {PLUGIN_OTHER, N_("Address Keeper")},
		  {PLUGIN_NOTHING, NULL}};

	return features;
}


--- NEW FILE: Makefile.am ---
EXTRA_DIST = claws.def plugin.def version.rc

if OS_WIN32

LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RC) \
     `echo $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) | \
     sed -e 's/-I/--include-dir /g;s/-D/--define /g'`

%.lo : %.rc
	$(LTRCCOMPILE) -i $< -o $@

plugin_res = version.lo
plugin_res_ldflag = -Wl,.libs/version.o

export_symbols = -export-symbols $(srcdir)/plugin.def

plugin_deps = libclaws.a $(plugin_res) plugin.def

libclaws.a: claws.def
	$(DLLTOOL) --output-lib $@ --def $<

plugin_ldadd = -L. -lclaws

else
plugin_res =
plugin_res_ldflag =
export_symbols =
plugin_deps =
plugin_ldadd =
endif

if PLATFORM_WIN32
no_undefined = -no-undefined
else
no_undefined =
endif

if CYGWIN
cygwin_export_lib = -L$(top_builddir)/src -lclaws-mail
else
cygwin_export_lib = 
endif

plugindir = $(pkglibdir)/plugins

plugin_LTLIBRARIES = address_keeper.la

address_keeper_la_LDFLAGS = \
	$(plugin_res_ldflag) $(no_undefined) $(export_symbols) \
	-avoid-version -module \
	$(GTK_LIBS)

address_keeper_la_DEPENDENCIES = $(plugin_deps)

address_keeper_la_LIBADD = $(plugin_ldadd) $(cygwin_export_lib) \
	$(GTK_LIBS)

INCLUDES = \
	-I$(top_srcdir)/src \
	-I$(top_srcdir)/src/common \
	-I$(top_builddir)/src/common \
	-I$(top_srcdir)/src/gtk

AM_CPPFLAGS = \
	-Wall \
	$(CLAWS_MAIL_CFLAGS) \
	$(GLIB_CFLAGS) \
	$(GTK_CFLAGS) \
	-DLOCALEDIR=\""$(localedir)"\" 

address_keeper_la_SOURCES = \
	address_keeper.c address_keeper.h \
	address_keeper_prefs.c address_keeper_prefs.h




More information about the Commits mailing list