From b239860999f0f90ed7e070111a106434fb4c22d6 Mon Sep 17 00:00:00 2001 From: Shreyas Srinivasan Date: Sun, 10 Jul 2005 09:51:29 +0000 Subject: Plugin to add Disable/ Proxy Logout to a store menu on right click. 2005-07-10 Shreyas Srinivasan * plugins/mail-account-disable/*: Plugin to add Disable/ Proxy Logout to a store menu on right click. svn path=/trunk/; revision=29696 --- plugins/mail-account-disable/Makefile.am | 15 +++ .../mail-account-disable/mail-account-disable.c | 103 +++++++++++++++++++++ .../org-gnome-mail-account-disable.eplug.xml | 14 +++ 3 files changed, 132 insertions(+) create mode 100644 plugins/mail-account-disable/Makefile.am create mode 100644 plugins/mail-account-disable/mail-account-disable.c create mode 100644 plugins/mail-account-disable/org-gnome-mail-account-disable.eplug.xml (limited to 'plugins/mail-account-disable') diff --git a/plugins/mail-account-disable/Makefile.am b/plugins/mail-account-disable/Makefile.am new file mode 100644 index 0000000000..9cb5f390ac --- /dev/null +++ b/plugins/mail-account-disable/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = \ + -I$(top_srcdir) \ + $(EVOLUTION_MAIL_CFLAGS) \ + $(EVOLUTION_MAIL_CFLAGS) \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" + +@EVO_PLUGIN_RULE@ + +plugin_DATA = org-gnome-mail-account-disable.eplug +plugin_LTLIBRARIES = libmail-account-disable.la + +libmail_account_disable_la_SOURCES = mail-account-disable.c +libmail_account_disable_la_LDFLAGS = -module -avoid-version + +EXTRA_DIST = org-gnome-mail-account-disable.eplug.xml diff --git a/plugins/mail-account-disable/mail-account-disable.c b/plugins/mail-account-disable/mail-account-disable.c new file mode 100644 index 0000000000..134bb44b45 --- /dev/null +++ b/plugins/mail-account-disable/mail-account-disable.c @@ -0,0 +1,103 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: Shreyas Srinivasan + * + * Copyright 2004 Novell, Inc. (www.novell.com) + * + * 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., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ACCOUNT_DISABLE 0 +#define PROXY_LOGOUT 1 + +void mail_account_disable (EPopup *ep, EPopupItem *p, char *uri); +void org_gnome_create_mail_account_disable (EPlugin *ep, EMPopupTargetFolder *t); + +static EPopupItem popup_items[] = { + { E_POPUP_ITEM, "20.emc.04", N_("_Disable"), mail_account_disable, NULL, NULL, 0, EM_POPUP_FOLDER_STORE }, + { E_POPUP_ITEM, "20.emc.04", N_("Proxy _Logout"), mail_account_disable, NULL, NULL, 0, EM_POPUP_FOLDER_STORE } +}; + +static void +popup_free (EPopup *ep, GSList *items, void *data) +{ +g_slist_free (items); +} + +void +mail_account_disable (EPopup *ep, EPopupItem *p, char *uri) +{ + EAccount *account; + + account = mail_config_get_account_by_source_url (uri); + + if (account) { + MailComponent *component = mail_component_peek (); + + if (mail_config_has_proxies(account)) + mail_config_remove_account_proxies (account); + + account->enabled = !account->enabled; + e_account_list_change(mail_config_get_accounts(), account); + mail_component_remove_store_by_uri (component, account->source->url); + + if (account->parent_uid) + mail_config_remove_account (account); + + mail_config_save_accounts(); + } + + return ; +} + +void +org_gnome_create_mail_account_disable (EPlugin *ep, EMPopupTargetFolder *t) +{ + EAccount *account; + GSList *menus = NULL; + + account = mail_config_get_account_by_source_url (t->uri); + + if (g_strrstr (t->uri,"groupwise://") && account->parent_uid) { + popup_items[PROXY_LOGOUT].label = _(popup_items [PROXY_LOGOUT].label); + menus = g_slist_prepend (menus, &popup_items [PROXY_LOGOUT]); + } + else { + popup_items[ACCOUNT_DISABLE].label = _(popup_items [ACCOUNT_DISABLE].label); + menus = g_slist_prepend (menus, &popup_items [ACCOUNT_DISABLE]); + } + + e_popup_add_items (t->target.popup, menus, NULL, popup_free, t->uri); + + return; +} + diff --git a/plugins/mail-account-disable/org-gnome-mail-account-disable.eplug.xml b/plugins/mail-account-disable/org-gnome-mail-account-disable.eplug.xml new file mode 100644 index 0000000000..a21bfaabf3 --- /dev/null +++ b/plugins/mail-account-disable/org-gnome-mail-account-disable.eplug.xml @@ -0,0 +1,14 @@ + + + + <_description>Allows disabling of accounts. + + + + + + + -- cgit v1.2.3