diff options
author | Shreyas Srinivasan <sshreyas@novell.com> | 2005-07-10 17:47:05 +0800 |
---|---|---|
committer | Shreyas Srinivasan <shres@src.gnome.org> | 2005-07-10 17:47:05 +0800 |
commit | 9d1e7081e297f5b582c3c3257fb2635696701e42 (patch) | |
tree | a7faae859234cccd527df9b3616743757c39ffae /plugins | |
parent | a5c812f96334d17b3f781204495c24573cdc6240 (diff) | |
download | gsoc2013-evolution-9d1e7081e297f5b582c3c3257fb2635696701e42.tar.gz gsoc2013-evolution-9d1e7081e297f5b582c3c3257fb2635696701e42.tar.zst gsoc2013-evolution-9d1e7081e297f5b582c3c3257fb2635696701e42.zip |
Plugin to implement Proxy Login on a groupwise account.
2005-07-10 Shreyas Srinivasan <sshreyas@novell.com>
* plugins/proxy-login/*: Plugin to implement Proxy Login on a
groupwise account.
svn path=/trunk/; revision=29694
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/proxy-login/Makefile.am | 23 | ||||
-rw-r--r-- | plugins/proxy-login/org-gnome-proxy-login-errors.xml | 10 | ||||
-rw-r--r-- | plugins/proxy-login/org-gnome-proxy-login.eplug.xml | 14 | ||||
-rw-r--r-- | plugins/proxy-login/proxy-login-dialog.glade | 207 | ||||
-rw-r--r-- | plugins/proxy-login/proxy-login-dialog.gladep | 7 | ||||
-rw-r--r-- | plugins/proxy-login/proxy-login.c | 511 | ||||
-rw-r--r-- | plugins/proxy-login/proxy-login.h | 67 |
7 files changed, 839 insertions, 0 deletions
diff --git a/plugins/proxy-login/Makefile.am b/plugins/proxy-login/Makefile.am new file mode 100644 index 0000000000..6a4e6c7327 --- /dev/null +++ b/plugins/proxy-login/Makefile.am @@ -0,0 +1,23 @@ +INCLUDES = \ + -I$(top_srcdir) \ + $(EVOLUTION_MAIL_CFLAGS) \ + $(EVOLUTION_MAIL_CFLAGS) \ + $(EVOLUTION_CALENDAR_CFLAGS) \ + $(EVOLUTION_ADDRESSBOOK_CFLAGS) \ + $(CAMEL_GROUPWISE_CFLAGS) \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" + +@EVO_PLUGIN_RULE@ + +plugin_DATA = org-gnome-proxy-login.eplug +plugin_LTLIBRARIES = libproxy-login.la + +libproxy_login_la_SOURCES = proxy-login.c +libproxy_login_la_LDFLAGS = -module -avoid-version + +glade_DATA = proxy-login-dialog.glade + +error_DATA = org-gnome-proxy-login-errors.xml +errordir = $(privdatadir)/errors + +EXTRA_DIST = org-gnome-proxy-login.eplug.xml diff --git a/plugins/proxy-login/org-gnome-proxy-login-errors.xml b/plugins/proxy-login/org-gnome-proxy-login-errors.xml new file mode 100644 index 0000000000..75162f4f21 --- /dev/null +++ b/plugins/proxy-login/org-gnome-proxy-login-errors.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<error-list domain="org.gnome.evolution.proxy-login"> +<error id="invalid-user" type="error"> +<primary>Invalid user</primary> +<secondary> +Proxy login as "{0}" was unsuccessful. Please check Email Id and try again; +</secondary> +</error> +</error-list> + diff --git a/plugins/proxy-login/org-gnome-proxy-login.eplug.xml b/plugins/proxy-login/org-gnome-proxy-login.eplug.xml new file mode 100644 index 0000000000..20c8a1907f --- /dev/null +++ b/plugins/proxy-login/org-gnome-proxy-login.eplug.xml @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<e-plugin-list> + <e-plugin id="org.gnome.proxy.login" + type="shlib" domain="evolution" _name="Disable Account" + location="@PLUGINDIR@/libproxy-login.so"> + <_description>Allows disabling of accounts.</_description> + <author name="Shreyas Srinivasan" email="sshreyas@novell.com"/> + <hook class="org.gnome.evolution.mail.popup:1.0"> + <menu id="org.gnome.evolution.mail.foldertree.popup" target="folder" +factory = "org_gnome_create_proxy_login_option"> + </menu> + </hook> + </e-plugin> +</e-plugin-list> diff --git a/plugins/proxy-login/proxy-login-dialog.glade b/plugins/proxy-login/proxy-login-dialog.glade new file mode 100644 index 0000000000..ada43bc446 --- /dev/null +++ b/plugins/proxy-login/proxy-login-dialog.glade @@ -0,0 +1,207 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> +<requires lib="gnome"/> + +<widget class="GtkDialog" id="proxy_login_dialog"> + <property name="visible">True</property> + <property name="title" translatable="yes">Proxy Login</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">True</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="has_separator">True</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area2"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="proxy_help"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-help</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-11</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="proxy_cancel"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-6</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="proxy_login"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-ok</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-5</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkFrame" id="frame3"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + + <child> + <widget class="GtkVBox" id="vd1"> + <property name="border_width">4</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkHBox" id="auto_complete"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkEntry" id="account_name"> + <property name="width_request">250</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">*</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">5</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTreeView" id="proxy_login_treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">False</property> + <property name="rules_hint">False</property> + <property name="reorderable">False</property> + <property name="enable_search">True</property> + <property name="fixed_height_mode">False</property> + <property name="hover_selection">False</property> + <property name="hover_expand">False</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Account Name</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">5</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/plugins/proxy-login/proxy-login-dialog.gladep b/plugins/proxy-login/proxy-login-dialog.gladep new file mode 100644 index 0000000000..7012234d59 --- /dev/null +++ b/plugins/proxy-login/proxy-login-dialog.gladep @@ -0,0 +1,7 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd"> + +<glade-project> + <name></name> + <program_name></program_name> +</glade-project> diff --git a/plugins/proxy-login/proxy-login.c b/plugins/proxy-login/proxy-login.c new file mode 100644 index 0000000000..8aa921f07a --- /dev/null +++ b/plugins/proxy-login/proxy-login.c @@ -0,0 +1,511 @@ + +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Authors: + * Shreyas Srinivasan <sshreyas@novell.com> + * Sankar P <psankar@novell.com> + * + * 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 <config.h> +#endif + +#include <glib.h> +#include <string.h> +#include <glib/gi18n.h> +#include <glade/glade.h> +#include <glib/gmain.h> +#include <gtk/gtktreemodel.h> +#include <gtk/gtkliststore.h> +#include <gtk/gtktreeselection.h> +#include <gtk/gtktreeview.h> +#include <gtk/gtkdialog.h> +#include <gtk/gtkbutton.h> +#include <gtk/gtk.h> +#include <gtk/gtktogglebutton.h> +#include <gtk/gtkcellrenderertoggle.h> +#include <gtk/gtkcellrenderertext.h> + +#include <libedataserverui/e-passwords.h> +#include <mail/mail-component.h> +#include <mail/em-folder-tree.h> +#include <mail/mail-config.h> +#include <mail/em-folder-selector.h> +#include <mail/em-popup.h> +#include <mail/em-account-editor.h> +#include <camel/camel-url.h> +#include <camel/camel-store.h> +#include <mail/mail-ops.h> +#include <e-util/e-account.h> +#include <e-util/e-error.h> +#include <e-util/e-icon-factory.h> + +#include <e-gw-container.h> +#include <e-gw-connection.h> +#include <e-gw-message.h> +#include <libedataserverui/e-name-selector.h> +#include <proxy-login.h> + +#define GW(name) glade_xml_get_widget (priv->xml, name) + +#define ACCOUNT_PICTURE 0 +#define ACCOUNT_NAME 1 + +void org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, char *uri); + +proxyLogin *pld = NULL; +static GObjectClass *parent_class = NULL; + +struct _proxyLoginPrivate { + /* Glade XML data for the Add/Edit Proxy dialog*/ + GladeXML *xml; + /* Widgets */ + GtkWidget *main; + + /*Tree Store*/ + GtkTreeStore *store; + /*Tree View*/ + GtkTreeView *tree; + + char *help_section; +}; + +static void +proxy_login_finalize (GObject *object) +{ + proxyLogin *prd = (proxyLogin *) object; + proxyLoginPrivate *priv; + + g_return_if_fail (IS_PROXY_LOGIN (prd)); + priv = prd->priv; + g_list_foreach (prd->proxy_list, (GFunc)g_free, NULL); + g_list_free (prd->proxy_list); + prd->proxy_list = NULL; + g_object_unref (priv->xml); + g_free (priv->help_section); + + if (prd->priv) { + g_free (prd->priv); + prd->priv = NULL; + } + + if (parent_class->finalize) + (* parent_class->finalize) (object); +} + +static void +proxy_login_dispose (GObject *object) +{ + proxyLogin *prd = (proxyLogin *) object; + + g_return_if_fail (IS_PROXY_LOGIN (prd)); + + if (parent_class->dispose) + (* parent_class->dispose) (object); +} + +/* Class initialization function for the Send Options */ +static void +proxy_login_class_init (GObjectClass *object) +{ + proxyLoginClass *klass; + GObjectClass *object_class; + + klass = PROXY_LOGIN_CLASS (object); + parent_class = g_type_class_peek_parent (klass); + object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = proxy_login_finalize; + object_class->dispose = proxy_login_dispose; +} + +static void +proxy_login_init (GObject *object) +{ + proxyLogin *prd; + proxyLoginPrivate *priv; + + prd = PROXY_LOGIN (object); + priv = g_new0 (proxyLoginPrivate, 1); + prd->priv = priv; + + prd->permissions = 0; + prd->proxy_list = NULL; + priv->xml = NULL; + priv->main = NULL; + priv->store = NULL; + priv->tree = NULL; +} + +GType +proxy_login_get_type (void) +{ + static GType type = 0; + + if (type == 0) { + static const GTypeInfo info = { + sizeof (proxyLoginClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) proxy_login_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (proxyLogin), + 0, /* n_preallocs */ + (GInstanceInitFunc) proxy_login_init, + NULL /* instance_init */ + }; + type = g_type_register_static (G_TYPE_OBJECT, + "proxyLoginType", + &info, 0); + } + + return type; +} + +proxyLogin * +proxy_login_new (void) +{ + proxyLogin *prd; + + prd = g_object_new (TYPE_PROXY_LOGIN, NULL); + + return prd; +} + +static int +proxy_get_password (EAccount *account, char **user_name, char **password) +{ + char *uri, *failed_auth, *key, *prompt; + CamelURL *url; + const char *poa_address, *use_ssl, *soap_port; + + url = camel_url_new (account->source->url, NULL); + if (url == NULL) + return NULL; + *user_name = g_strdup (url->user); + poa_address = url->host; + if (!poa_address || strlen (poa_address) ==0) + return NULL; + + soap_port = camel_url_get_param (url, "soap_port"); + if (!soap_port || strlen (soap_port) == 0) + soap_port = "7191"; + use_ssl = camel_url_get_param (url, "use_ssl"); + + key = g_strdup_printf ("groupwise://%s@%s/", url->user, poa_address); + + if (!g_str_equal (use_ssl, "never")) + uri = g_strdup_printf ("https://%s:%s/soap", poa_address, soap_port); + else + uri = g_strdup_printf ("http://%s:%s/soap", poa_address, soap_port); + + failed_auth = ""; + + prompt = g_strdup_printf (_("%sEnter password for %s (user %s)"), + failed_auth, poa_address, url->user); + + *password = e_passwords_get_password ("Groupwise", key); + + g_free (key); + g_free (prompt); + g_free (uri); + camel_url_free (url); + + return 1; +} + +static EGwConnection * +proxy_login_get_cnc (EAccount *account) +{ + EGwConnection *cnc; + CamelURL *url; + url = camel_url_new (account->source->url, NULL); + char *uri = NULL, *failed_auth = NULL, *key = NULL, *prompt = NULL, *password = NULL; + const char *use_ssl, *soap_port; + + url = camel_url_new (account->source->url, NULL); + if (url == NULL) + return NULL; + if (!url->host || strlen (url->host) ==0) + return NULL; + + soap_port = camel_url_get_param (url, "soap_port"); + if (!soap_port || strlen (soap_port) == 0) + soap_port = "7191"; + use_ssl = camel_url_get_param (url, "use_ssl"); + + key = g_strdup_printf ("groupwise://%s@%s/", url->user, url->host); + if (!g_str_equal (use_ssl, "never")) + uri = g_strdup_printf ("https://%s:%s/soap", url->host, soap_port); + else + uri = g_strdup_printf ("http://%s:%s/soap", url->host, soap_port); + + failed_auth = ""; + cnc = NULL; + + prompt = g_strdup_printf (_("%sEnter password for %s (user %s)"), + failed_auth, url->host, url->user); + + password = e_passwords_get_password ("Groupwise", key); + + cnc = e_gw_connection_new (uri, url->user, password); + if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) { + char *http_uri = g_strconcat ("http://", uri + 8, NULL); + cnc = e_gw_connection_new (http_uri, url->user, password); + g_free (http_uri); + } + + g_free (prompt); + g_free (key); + g_free (password); + g_free (uri); + camel_url_free (url); + + return cnc; +} + + +static void +proxy_login_cb (GtkDialog *dialog, gint state) +{ + GtkWidget *account_name_tbox; + proxyLoginPrivate *priv; + char *proxy_name; + + priv = pld->priv; + account_name_tbox = glade_xml_get_widget (priv->xml, "account_name"); + proxy_name = g_strdup ((char *) gtk_entry_get_text ((GtkEntry *) account_name_tbox)); + + switch (state) { + case GTK_RESPONSE_OK: + gtk_widget_destroy (priv->main); + proxy_soap_login (proxy_name); + g_object_unref (pld); + break; + case GTK_RESPONSE_CANCEL: + gtk_widget_destroy (priv->main); + g_object_unref (pld); + break; + case GTK_RESPONSE_HELP: + break; + } + + g_free (proxy_name); +} + +static void +proxy_soap_login (char *email) +{ + EAccountList *accounts = mail_config_get_accounts(); + EAccount *srcAccount; + EAccount *dstAccount; + EGwConnection *proxy_cnc, *cnc; + CamelURL *uri = NULL, *parent = NULL ; + char *password = NULL, *user_name = NULL; + char *proxy_source_url = NULL, *parent_source_url = NULL ; + char *name; + int i; + + for (i=0; email[i]!='\0' && email[i]!='@' ; i++); + if (email[i]=='@') + name = g_strndup(email, i); + else { + e_error_run (NULL, "org.gnome.evolution.proxy-login:invalid-user",email ,NULL); + return; + } + + srcAccount = pld->account; + cnc = proxy_login_get_cnc(srcAccount); + proxy_get_password (srcAccount, &user_name, &password); + pld->permissions = 0; + proxy_cnc = e_gw_connection_get_proxy_connection (cnc, user_name, password, email, &pld->permissions); + + if (proxy_cnc) { + parent = camel_url_new (e_account_get_string(srcAccount, E_ACCOUNT_SOURCE_URL), NULL); + parent_source_url = camel_url_to_string (parent, CAMEL_URL_HIDE_PASSWORD); + uri = camel_url_copy (parent); + camel_url_set_user (uri, name); + proxy_source_url = camel_url_to_string (uri, CAMEL_URL_HIDE_PASSWORD); + dstAccount = e_account_new(); + e_account_set_string(dstAccount, E_ACCOUNT_ID_ADDRESS, email); + dstAccount->enabled = TRUE; + e_account_set_string(dstAccount, E_ACCOUNT_SOURCE_URL, proxy_source_url); + e_account_set_string (dstAccount, E_ACCOUNT_TRANSPORT_URL, proxy_source_url); + e_account_set_string (dstAccount, E_ACCOUNT_NAME, email); + e_account_set_string (dstAccount, E_ACCOUNT_ID_NAME, name); + e_account_set_string (dstAccount, E_ACCOUNT_PROXY_PARENT_UID, srcAccount->uid); + e_account_list_add(accounts, dstAccount); + e_account_list_change (accounts, srcAccount); + e_account_list_save(accounts); + mail_get_store(e_account_get_string(dstAccount, E_ACCOUNT_SOURCE_URL), NULL, proxy_login_add_new_store, dstAccount); + + g_free (proxy_source_url); + g_free (parent_source_url); + camel_url_free (parent); + } else { + e_error_run (NULL, "org.gnome.evolution.proxy-login:invalid-user",email ,NULL); + return; + } + + g_free (name); + g_free (user_name); + g_free (password); +} + + +static void +proxy_login_add_new_store (char *uri, CamelStore *store, void *user_data) +{ + MailComponent *component = mail_component_peek (); + EAccount *account = user_data; + if (store == NULL) + return; + if (pld->permissions & E_GW_PROXY_MAIL_READ) + store->permissions |= CAMEL_PROXY_STORE_READ; + + if (pld->permissions & E_GW_PROXY_MAIL_WRITE) + store->permissions |= CAMEL_PROXY_STORE_WRITE; + + store->permissions = pld->permissions; + store->flags |= CAMEL_STORE_PROXY; + mail_component_add_store (component, store, account->name); +} + +static void +proxy_login_tree_view_changed_cb(GtkDialog *dialog) +{ + proxyLoginPrivate *priv = pld->priv; + GtkTreeSelection* account_select; + GtkTreeIter iter; + GtkWidget *account_name_tbox; + GtkTreeModel *model; + char *account_mailid; + + account_select = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->tree)); + gtk_tree_selection_get_selected (account_select, &model, &iter); + gtk_tree_model_get (model, &iter, ACCOUNT_NAME, &account_mailid, -1); + account_mailid = g_strrstr (account_mailid, "\n") + 1; + account_name_tbox = glade_xml_get_widget (priv->xml, "account_name"); + gtk_entry_set_text((GtkEntry*) account_name_tbox,account_mailid); +} + +static void +proxy_login_setup_tree_view (void) +{ + proxyLoginPrivate *priv; + GtkTreeSelection *selection; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + + priv = pld->priv; + renderer = g_object_new (GTK_TYPE_CELL_RENDERER_PIXBUF, + "xpad", 4, + "ypad", 4, + NULL); + column = gtk_tree_view_column_new_with_attributes ("Picture", renderer, "pixbuf", ACCOUNT_PICTURE, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree), column); + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("Name", renderer, "text", ACCOUNT_NAME, NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree), column); + gtk_tree_view_set_model (priv->tree, GTK_TREE_MODEL (priv->store)); + selection = gtk_tree_view_get_selection (priv->tree); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); + g_signal_connect (G_OBJECT (selection), "changed", proxy_login_tree_view_changed_cb, NULL); +} + +static void +proxy_login_update_tree (void) +{ + GtkTreeIter iter; + int i,n; + GdkPixbuf *broken_image = NULL; + GList *proxy_list = NULL; + char *proxy_name; + char *proxy_email; + EGwConnection *cnc; + proxyLoginPrivate *priv = pld->priv; + gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", 48); + broken_image = gdk_pixbuf_new_from_file (file_name, NULL); + + cnc = proxy_login_get_cnc(pld->account); + e_gw_connection_get_proxy_list (cnc, &proxy_list); + + gtk_tree_store_clear (priv->store); + if (proxy_list != NULL) { + n = g_list_length(proxy_list); + for (i=0;i<n;i=i+2) { + proxy_name = g_list_nth_data(proxy_list,i); + proxy_email = g_list_nth_data(proxy_list,i+1); + gtk_tree_store_append (priv->store, &iter, NULL); + gtk_tree_store_set (priv->store, &iter, 0, broken_image, 1, g_strconcat(proxy_name, "\n", proxy_email, NULL), -1); + } + gtk_tree_view_set_model (GTK_TREE_VIEW(priv->tree),GTK_TREE_MODEL (priv->store)); + } +} + +void +org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, char *uri) +{ + proxyLoginPrivate *priv; + + pld = proxy_login_new(); + priv = pld->priv; + priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/proxy-login-dialog.glade", NULL, NULL); + priv->main = glade_xml_get_widget (priv->xml, "proxy_login_dialog"); + pld->account = mail_config_get_account_by_source_url (uri); + priv->tree = GTK_TREE_VIEW (glade_xml_get_widget (priv->xml, "proxy_login_treeview")); + priv->store = gtk_tree_store_new (2, + GDK_TYPE_PIXBUF, + G_TYPE_STRING + ); + proxy_login_setup_tree_view (); + proxy_login_update_tree (); + g_signal_connect (GTK_DIALOG (priv->main), "response", G_CALLBACK(proxy_login_cb), NULL); + gtk_widget_show (GTK_WIDGET (priv->main)); + } + +static EPopupItem popup_items[] = { +{ E_POPUP_ITEM, "20.emc.04", N_("_Proxy Login..."), org_gnome_proxy_account_login, NULL, NULL, 0, EM_POPUP_FOLDER_STORE } +}; + +static void +popup_free (EPopup *ep, GSList *items, void *data) +{ +g_slist_free (items); +} + +void +org_gnome_create_proxy_login_option (EPlugin *ep, EMPopupTargetFolder *t) +{ + EAccount *account; + GSList *menus = NULL; + int i; + + account = mail_config_get_account_by_source_url (t->uri); + if (g_strrstr (t->uri,"groupwise://") && !account->parent_uid) { + popup_items[0].label = _(popup_items[0].label); + for (i = 0; i < sizeof (popup_items) / sizeof (popup_items[0]); i++) + menus = g_slist_prepend (menus, &popup_items[i]); + e_popup_add_items (t->target.popup, menus, NULL, popup_free, t->uri); + } + return; + +} diff --git a/plugins/proxy-login/proxy-login.h b/plugins/proxy-login/proxy-login.h new file mode 100644 index 0000000000..87e516d9c1 --- /dev/null +++ b/plugins/proxy-login/proxy-login.h @@ -0,0 +1,67 @@ + /* Evolution calendar - Timezone selector dialog + * + * Copyright (C) 2005 Novell, Inc. + * + * Authors: Shreyas Srinivasan <sshreyas@novell.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * 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 Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <gtk/gtkwidget.h> +#include <gtk/gtk.h> + +#define TYPE_PROXY_LOGIN (proxy_login_get_type ()) +#define PROXY_LOGIN(obj) (GTK_CHECK_CAST ((obj), TYPE_PROXY_LOGIN, proxyLogin)) +#define PROXY_LOGIN_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), TYPE_PROXY_LOGIN, proxyLoginClass)) +#define IS_PROXY_LOGIN(obj) (GTK_CHECK_TYPE ((obj), TYPE_PROXY_LOGIN)) +#define IS_PROXY_LOGIN_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), TYPE_PROXY_LOGIN)) + +typedef struct _proxyLogin proxyLogin; +typedef struct _proxyLoginClass proxyLoginClass; +typedef struct _proxyLoginPrivate proxyLoginPrivate; + +struct _proxyLogin{ + GObject object; + + /*Account*/ + EAccount *account; + + /*List of proxies*/ + GList *proxy_list; + + /* Private Dialog Information*/ + proxyLoginPrivate *priv; + + /*Permissions on the login*/ + int permissions; +}; + +struct _proxyLoginClass { + GObjectClass parent_class; +}; + +GType proxy_login_get_type (void); +proxyLogin * proxy_login_new (void); +static void proxy_login_cb (GtkDialog *dialog, gint state); +static void proxy_login_add_new_store (char *uri, CamelStore *store, void *user_data); +static void proxy_login_setup_tree_view (void); +void org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, char *uri); +proxyLogin* proxy_dialog_new (void); +static void proxy_soap_login (char *email); +char *parse_email_for_name (char *email); +static void proxy_login_update_tree (void); +static void proxy_login_tree_view_changed_cb(GtkDialog *dialog); +void org_gnome_create_proxy_login_option(EPlugin *ep, EMPopupTargetFolder *t); +static int proxy_get_password (EAccount *account, char **user_name, char **password); |