[evolution-patches] Proxy Login Patches
- From: Shreyas <sshreyas novell com>
- To: psankar novell com, Evolution Patches <evolution-patches lists ximian com>
- Cc:
- Subject: [evolution-patches] Proxy Login Patches
- Date: Wed, 06 Jul 2005 11:51:04 +0530
Hey,
Attaching a list of patches which implement the proxy login feature on a
Groupwise Account.
I created multiple patches hoping that it would be easier to review as
the code transcends multiple regions. Pardon me if that's a wrong
assumption. There are Changlelog entries within the patches as per
rules
proxy-login-enablers.diff : contains changes to
-EAccount structure
- New API's to EAccountList to handle proxy removal/ handling parent's
deletion
etc
- A permissions variable on a CamelStore which checks for ReadOnly/
Writeable Stores at proxy login.
- e-msg-composer-hdrs.c: Disable loading e-mail id's in the from
section whose
store's dont have write permissions
proxy-camel-groupwise.diff: contains changes to
- camel-groupwise-folder.c: Use GetItems instead of GetQM
- camel-groupwise-store.c: Dont ask password for proxy login.
proxy-login.diff: Is the plugin which implements the actual login ui and
calls suitable API.
Cheers,
Shreyas
Index: e-util/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.544
diff -u -p -w -r1.544 ChangeLog
--- e-util/ChangeLog 18 Jun 2005 15:59:56 -0000 1.544
+++ e-util/ChangeLog 5 Jul 2005 09:31:12 -0000
@@ -1,3 +1,9 @@
+2005-07-05 Shreyas Srinivasan
+
+ * e-util/e-account.[ch]: Add structures to handle proxies.
+ * e-util/e-account-list.[ch]: Add functions to remove proxy
+ accounts and account's proxies.
+
2005-06-18 Tor Lillqvist <tml novell com>
* Makefile.am (WIN32_BOOTSTRAP_LIBS): Use bootstrap library for
Index: e-util/e-account.h
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-account.h,v
retrieving revision 1.9
diff -u -p -w -r1.9 e-account.h
--- e-util/e-account.h 8 Apr 2005 04:34:04 -0000 1.9
+++ e-util/e-account.h 5 Jul 2005 09:31:29 -0000
@@ -69,6 +69,9 @@ typedef enum _e_account_item_t {
E_ACCOUNT_SMIME_ENCRYPT_TO_SELF,
E_ACCOUNT_SMIME_ENCRYPT_DEFAULT,
+ E_ACCOUNT_PROXY_PARENT_URL,
+ E_ACCOUNT_PROXY_PARENT_UID,
+
E_ACCOUNT_ITEM_LAST
} e_account_item_t;
@@ -98,6 +101,11 @@ typedef struct _EAccountService {
gboolean save_passwd;
} EAccountService;
+typedef struct _EAccountProxyInfo {
+ char *parent_url;
+ char *parent_uid;
+} EAccountProxyInfo;
+
typedef struct _EAccount {
GObject parent_object;
@@ -109,6 +117,7 @@ typedef struct _EAccount {
EAccountIdentity *id;
EAccountService *source;
EAccountService *transport;
+ EAccountProxyInfo *proxy_account;
char *drafts_folder_uri, *sent_folder_uri;
@@ -130,6 +139,7 @@ typedef struct _EAccount {
gboolean smime_sign_default;
gboolean smime_encrypt_to_self;
gboolean smime_encrypt_default;
+ GList *proxy_children;
} EAccount;
typedef struct {
Index: e-util/e-account.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-account.c,v
retrieving revision 1.15
diff -u -p -w -r1.15 e-account.c
--- e-util/e-account.c 8 Apr 2005 04:34:04 -0000 1.15
+++ e-util/e-account.c 5 Jul 2005 09:32:58 -0000
@@ -107,6 +107,10 @@ e_account_init (EAccount *account)
account->id = g_new0 (EAccountIdentity, 1);
account->source = g_new0 (EAccountService, 1);
account->transport = g_new0 (EAccountService, 1);
+ account->proxy_account = g_new0 (EAccountProxyInfo, 1);
+
+ account->proxy_account->parent_url = NULL;
+ account->proxy_account->parent_uid = NULL;
account->source->auto_check = FALSE;
account->source->auto_check_time = 10;
@@ -139,6 +143,17 @@ service_destroy (EAccountService *servic
}
static void
+proxy_destroy (EAccountProxyInfo *proxy_info)
+{
+ if (proxy_info->parent_url)
+ g_free (proxy_info->parent_url);
+ if (proxy_info->parent_uid)
+ g_free (proxy_info->parent_uid);
+
+ g_free (proxy_info);
+}
+
+static void
e_account_finalize (GObject *object)
{
EAccount *account = E_ACCOUNT (object);
@@ -149,7 +164,11 @@ e_account_finalize (GObject *object)
identity_destroy (account->id);
service_destroy (account->source);
service_destroy (account->transport);
+ proxy_destroy (account->proxy_account);
+ g_list_foreach (account->proxy_children, (GFunc) g_free, NULL);
+ g_list_free (account->proxy_children);
+ account->proxy_children = NULL;
g_free (account->drafts_folder_uri);
g_free (account->sent_folder_uri);
@@ -486,6 +505,17 @@ e_account_set_from_xml (EAccount *accoun
}
}
}
+ } else if (!strcmp (node->name, "proxy")) {
+ if (node->children) {
+ for (cur = node->children; cur; cur = cur->next) {
+ if (!strcmp (cur->name, "parent-source-url")) {
+ changed |= xml_set_content (cur, &account->proxy_account->parent_url);
+ } else if (!strcmp (cur->name, "parent-uid")) {
+ changed |= xml_set_content (cur, &account->proxy_account->parent_uid);
+ break;
+ }
+ }
+ }
}
}
@@ -564,6 +594,7 @@ e_account_import (EAccount *dest, EAccou
g_free (dest->smime_encrypt_key);
dest->smime_encrypt_key = g_strdup (src->smime_encrypt_key);
+ dest->proxy_children = g_list_copy(src->proxy_children);
g_signal_emit(dest, signals[CHANGED], 0, -1);
}
@@ -652,6 +683,12 @@ e_account_to_xml (EAccount *account)
if (account->smime_encrypt_key)
xmlNewTextChild (node, NULL, "encrypt-key-id", account->smime_encrypt_key);
+ if (account->proxy_account && account->proxy_account->parent_url) {
+ node = xmlNewChild (root, NULL, "proxy", NULL);
+ xmlNewTextChild (node, NULL, "parent-source-url", account->proxy_account->parent_url);
+ xmlNewTextChild (node, NULL, "parent-uid", account->proxy_account->parent_uid);
+ }
+
xmlDocDumpMemory (doc, &xmlbuf, &n);
xmlFreeDoc (doc);
@@ -778,6 +815,9 @@ static struct _account_info {
{ /* E_ACCOUNT_SMIME_SIGN_DEFAULT */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, smime_sign_default) },
{ /* E_ACCOUNT_SMIME_ENCRYPT_TO_SELF */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, smime_encrypt_to_self) },
{ /* E_ACCOUNT_SMIME_ENCRYPT_DEFAULT */ 0, TYPE_BOOL, G_STRUCT_OFFSET(EAccount, smime_encrypt_default) },
+
+ { /* E_ACCOUNT_PROXY_PARENT_URL, */ 0, TYPE_STRING|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, proxy_account), G_STRUCT_OFFSET(EAccountProxyInfo, parent_url) },
+ { /* E_ACCOUNT_PROXY_PARENT_UID, */ 0, TYPE_STRING|TYPE_STRUCT, G_STRUCT_OFFSET(EAccount, proxy_account), G_STRUCT_OFFSET(EAccountProxyInfo, parent_uid) },
};
static GHashTable *ea_option_table;
Index: e-util/e-account-list.h
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-account-list.h,v
retrieving revision 1.4
diff -u -p -w -r1.4 e-account-list.h
--- e-util/e-account-list.h 31 Mar 2004 10:08:38 -0000 1.4
+++ e-util/e-account-list.h 5 Jul 2005 09:33:13 -0000
@@ -71,5 +71,7 @@ void e_account_list_remove
const EAccount *e_account_list_get_default(EAccountList *);
void e_account_list_set_default(EAccountList *, EAccount *);
const EAccount *e_account_list_find (EAccountList *, e_account_find_t type, const char *key);
+void e_account_list_prune_proxies (EAccountList *);
+void e_account_list_update_parent (EAccountList *, EAccount *);
#endif /* __E_ACCOUNT_LIST__ */
Index: e-util/e-account-list.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-account-list.c,v
retrieving revision 1.10
diff -u -p -w -r1.10 e-account-list.c
--- e-util/e-account-list.c 21 Dec 2004 15:50:38 -0000 1.10
+++ e-util/e-account-list.c 5 Jul 2005 09:33:32 -0000
@@ -293,6 +293,56 @@ e_account_list_save (EAccountList *accou
gconf_client_suggest_sync (account_list->priv->gconf, NULL);
}
+void
+e_account_list_prune_proxies (EAccountList *account_list)
+{
+ EAccount *account;
+ EIterator *iter;
+
+ for (iter = e_list_get_iterator (E_LIST (account_list));
+ e_iterator_is_valid (iter);
+ e_iterator_next (iter)) {
+ account = (EAccount *)e_iterator_get (iter);
+ if (account->proxy_account->parent_url) {
+ e_account_list_remove (account_list, account);
+ e_account_list_save (account_list);
+ }
+ }
+ g_object_unref (iter);
+}
+
+void
+e_account_list_update_parent (EAccountList *accounts, EAccount *account)
+{
+ char *parent = NULL;
+ EAccount *parent_account;
+
+ parent = e_account_get_string (account, E_ACCOUNT_PROXY_PARENT_URL);
+ parent_account = e_account_list_find (accounts, E_ACCOUNT_FIND_UID, account->proxy_account->parent_uid);
+ if (parent_account) {
+ parent_account->proxy_children = g_list_remove (parent_account->proxy_children, account->uid);
+ e_account_list_change (accounts, parent_account);
+ }
+}
+
+void
+e_account_list_remove_account_proxies (EAccountList *accounts, EAccount *account)
+{
+ int i,n;
+ EAccount *child_account;
+ char *uid;
+
+ n = g_list_length (account->proxy_children);
+ for (i=0; i<n; i++) {
+ uid = g_list_nth_data(account->proxy_children, i);
+ child_account = e_account_list_find (accounts, E_ACCOUNT_FIND_UID, uid);
+ e_account_list_remove (accounts, child_account);
+ e_account_list_save (accounts);
+ account->proxy_children = g_list_remove (account->proxy_children, uid);
+ }
+ g_list_free (account->proxy_children);
+ e_account_list_save (accounts);
+}
/**
* e_account_list_add:
* @accounts:
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3649
diff -u -p -w -r1.3649 ChangeLog
--- mail/ChangeLog 1 Jul 2005 03:29:22 -0000 1.3649
+++ mail/ChangeLog 5 Jul 2005 10:33:10 -0000
@@ -1,3 +1,13 @@
+2005-07-05 Shreyas Srinivasan <sshreyas novell com>
+
+ * mail-config.[ch]: Add new functions to remove proxy accounts and
+ proxies created by the account.
+ * mail-compnent.c: Remove proxy accounts at startup
+ * mail.error.xml: Add warnings for proxy disable and removal of a
+ proxy when its parents are removed.
+ * em-account-prefs.c: Add checks not to display proxies and
+ handling of parent removal/ disabling.
+
2005-06-24 Matt Brown <matt mattb net nz>
* em-inline-filter.c: implement extraction of inline signed/encrypted pgp
Index: mail/mail-config.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-config.h,v
retrieving revision 1.119
diff -u -p -w -r1.119 mail-config.h
--- mail/mail-config.h 19 Oct 2004 06:35:44 -0000 1.119
+++ mail/mail-config.h 5 Jul 2005 10:33:42 -0000
@@ -133,6 +133,9 @@ struct _EAccountList *mail_config_get_ac
void mail_config_add_account (struct _EAccount *account);
void mail_config_remove_account (struct _EAccount *account);
void mail_config_set_default_account (struct _EAccount *account);
+void mail_config_update_parent (struct _EAccount *account);
+void mail_config_remove_account_proxies (struct _EAccount *account);
+void mail_config_prune_proxies (void);
struct _EAccountIdentity *mail_config_get_default_identity (void);
struct _EAccountService *mail_config_get_default_transport (void);
Index: mail/mail-config.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-config.c,v
retrieving revision 1.317
diff -u -p -w -r1.317 mail-config.c
--- mail/mail-config.c 23 Jun 2005 09:11:06 -0000 1.317
+++ mail/mail-config.c 5 Jul 2005 10:33:53 -0000
@@ -671,6 +671,25 @@ mail_config_get_account_by_transport_url
return NULL;
}
+
+void
+mail_config_update_parent (EAccount *account)
+{
+ e_account_list_update_parent (config->accounts, account);
+}
+
+void
+mail_config_remove_account_proxies (EAccount *account)
+{
+ e_account_list_remove_account_proxies (config->accounts, account);
+}
+
+void
+mail_config_prune_proxies (void)
+{
+ e_account_list_prune_proxies (config->accounts);
+}
+
EAccountList *
mail_config_get_accounts (void)
{
Index: mail/mail-component.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-component.c,v
retrieving revision 1.120
diff -u -p -w -r1.120 mail-component.c
--- mail/mail-component.c 23 Jun 2005 09:11:06 -0000 1.120
+++ mail/mail-component.c 5 Jul 2005 10:34:12 -0000
@@ -359,6 +359,7 @@ mc_startup(MailComponent *mc)
started = 1;
mc_setup_local_store(mc);
+ mail_config_prune_proxies ();
load_accounts(mc, mail_config_get_accounts());
vfolder_load_storage();
}
Index: mail/mail.error.xml
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail.error.xml,v
retrieving revision 1.3
diff -u -p -w -r1.3 mail.error.xml
--- mail/mail.error.xml 7 Jun 2005 05:05:43 -0000 1.3
+++ mail/mail.error.xml 5 Jul 2005 10:34:29 -0000
@@ -249,6 +249,25 @@ The message is stored in the Outbox fold
<button stock="gtk-no" _label="Don't delete" response="GTK_RESPONSE_NO"/>
</error>
+<error id="ask-delete-account-with-proxies" type="question" default="GTK_RESPONSE_NO" modal="true">
+ <_title>Delete account?</_title>
+ <_primary>Are you sure you want to delete this account and all its proxies?</_primary>
+ <_secondary xml:space="preserve">If you proceed, the account information and
+all proxy information will be deleted permanently.</_secondary>
+ <button stock="gtk-delete" response="GTK_RESPONSE_YES"/>
+ <button stock="gtk-no" _label="Don't delete" response="GTK_RESPONSE_NO"/>
+ </error>
+
+<error id="ask-delete-proxy-accounts" type="question" default="GTK_RESPONSE_NO" modal="true">
+ <_title>Disable account and log out all proxies?</_title>
+ <_primary>Are you sure you want to disable?</_primary>
+ <_secondary xml:space="preserve">If you proceed, the account will be disabled
+and all its proxies will be logged out.</_secondary>
+ <button stock="gtk-ok" response="GTK_RESPONSE_YES"/>
+ <button stock="gtk-cancel" response="GTK_RESPONSE_NO"/>
+ </error>
+
+
<error id="no-save-signature" type="error">
<_primary>Could not save signature file.</_primary>
<_secondary xml:space="preserve">Because "{0}".</_secondary>
Index: mail/em-account-prefs.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-account-prefs.c,v
retrieving revision 1.19
diff -u -p -w -r1.19 em-account-prefs.c
--- mail/em-account-prefs.c 16 May 2005 06:15:37 -0000 1.19
+++ mail/em-account-prefs.c 5 Jul 2005 10:34:50 -0000
@@ -192,7 +192,7 @@ account_edit_clicked (GtkButton *button,
if (gtk_tree_selection_get_selected (selection, &model, &iter))
gtk_tree_model_get (model, &iter, 3, &account, -1);
- if (account) {
+ if (account && !account->proxy_account->parent_url && !g_list_length(account->proxy_children)) {
EMAccountEditor *emae;
/** @HookPoint-EMConfig: Mail Account Editor
@@ -227,6 +227,7 @@ account_delete_clicked (GtkButton *butto
GtkTreeModel *model;
GtkTreeIter iter;
int ans;
+ gboolean has_spawned_proxies = FALSE;
selection = gtk_tree_view_get_selection (prefs->table);
if (gtk_tree_selection_get_selected (selection, &model, &iter))
@@ -236,7 +237,11 @@ account_delete_clicked (GtkButton *butto
if (account == NULL || prefs->editor != NULL)
return;
+ if (g_list_length(account->proxy_children))
+ ans = e_error_run(PREFS_WINDOW(prefs), "mail:ask-delete-account-with-proxies",NULL);
+ else
ans = e_error_run(PREFS_WINDOW(prefs), "mail:ask-delete-account", NULL);
+
if (ans == GTK_RESPONSE_YES) {
int len;
@@ -244,6 +249,12 @@ account_delete_clicked (GtkButton *butto
if (account->enabled && account->source && account->source->url)
mail_component_remove_store_by_uri (mail_component_peek (), account->source->url);
+ /* remove all the proxies you created*/
+ if (g_list_length (account->proxy_children)) {
+ has_spawned_proxies = TRUE;
+ mail_config_remove_account_proxies(account);
+ }
+
/* remove it from the config file */
mail_config_remove_account (account);
accounts = mail_config_get_accounts ();
@@ -252,6 +263,8 @@ account_delete_clicked (GtkButton *butto
gtk_list_store_remove ((GtkListStore *) model, &iter);
+ if (has_spawned_proxies)
+ mail_accounts_load (prefs);
len = e_list_length ((EList *) accounts);
if (len > 0) {
gtk_tree_selection_select_iter (selection, &iter);
@@ -344,17 +357,30 @@ account_able_toggled (GtkCellRendererTog
if (gtk_tree_model_get_iter (model, &iter, path)) {
gtk_tree_model_get (model, &iter, 3, &account, -1);
+
+ if (g_list_length (account->proxy_children)) {
+ char *ans;
+ ans = e_error_run(PREFS_WINDOW(prefs), "mail:ask-delete-proxy-accounts",NULL);
+ if (ans == GTK_RESPONSE_YES) {
account->enabled = !account->enabled;
+ e_account_list_change(mail_config_get_accounts(), account);
gtk_list_store_set ((GtkListStore *) model, &iter, 0, account->enabled, -1);
-
if (gtk_tree_selection_iter_is_selected (selection, &iter))
gtk_button_set_label (prefs->mail_able, account->enabled ? _("Disable") : _("Enable"));
-
- /* let the rest of the application know it changed */
+ mail_config_remove_account_proxies (account);
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), 1);
+ account_able_changed (account);
+ }
+ } else {
+ account->enabled = !account->enabled;
e_account_list_change(mail_config_get_accounts(), account);
+ gtk_list_store_set ((GtkListStore *) model, &iter, 0, account->enabled, -1);
+ if (gtk_tree_selection_iter_is_selected (selection, &iter))
+ gtk_button_set_label (prefs->mail_able, account->enabled ? _("Disable") : _("Enable"));
+ /* let the rest of the application know it changed */
account_able_changed(account);
}
-
+ }
gtk_tree_path_free (path);
}
@@ -371,13 +397,17 @@ account_cursor_change (GtkTreeSelection
EAccount *account = NULL;
GtkTreeModel *model;
GtkTreeIter iter;
+ char *url = NULL;
int state;
+/* This function needs to get the account variable rather than parse for stupid proxy = yes*/
+
state = gconf_client_key_is_writable(mail_config_get_gconf_client(), "/apps/evolution/mail/accounts", NULL);
if (state) {
state = gtk_tree_selection_get_selected (selection, &model, &iter);
if (state) {
gtk_tree_model_get (model, &iter, 3, &account, -1);
+ url = e_account_get_string (account, E_ACCOUNT_SOURCE_URL);
if (account->source && account->enabled)
gtk_button_set_label (prefs->mail_able, _("Disable"));
else
@@ -390,7 +420,12 @@ account_cursor_change (GtkTreeSelection
gtk_widget_set_sensitive (GTK_WIDGET (prefs), FALSE);
}
+ if( url != NULL ) {
+ if( g_list_length(account->proxy_children))
+ gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), 0);
+ else
gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_edit), state);
+ }
gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_delete), state);
gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_default), state);
gtk_widget_set_sensitive (GTK_WIDGET (prefs->mail_able), state);
@@ -420,6 +455,7 @@ mail_accounts_load (EMAccountPrefs *pref
account = (EAccount *) e_iterator_get (node);
+ if (!account->proxy_account->parent_url) {
url = account->source && account->source->url ? camel_url_new (account->source->url, NULL) : NULL;
gtk_list_store_append (model, &iter);
@@ -443,6 +479,7 @@ mail_accounts_load (EMAccountPrefs *pref
camel_url_free (url);
row++;
+ }
e_iterator_next (node);
}
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.700
diff -u -p -w -r1.700 ChangeLog
--- composer/ChangeLog 3 Jun 2005 09:52:02 -0000 1.700
+++ composer/ChangeLog 5 Jul 2005 11:37:48 -0000
@@ -1,3 +1,8 @@
+2005-07-05 Shreyas Srinivasan <sshreyas novell com>
+
+ * e-msg-composer-hdrs.c: Take into account store
+ permissions (Read Only). These are proxy specific as of now.
+
2005-06-03 Srinivasa Ragavan <sragavan novell com>
* e-msg-composer.c (e_msg_composer_attach): Fixed to show the
Index: composer/e-msg-composer-hdrs.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-hdrs.c,v
retrieving revision 1.137
diff -u -p -w -r1.137 e-msg-composer-hdrs.c
--- composer/e-msg-composer-hdrs.c 17 Jun 2005 15:20:28 -0000 1.137
+++ composer/e-msg-composer-hdrs.c 5 Jul 2005 13:06:55 -0000
@@ -56,6 +56,9 @@
#include "e-util/e-error.h"
#include <camel/camel.h>
+#include <camel/camel-store.h>
+#include <camel/camel-session.h>
+#include <libedataserver/e-proxy.h>
#include "e-msg-composer-hdrs.h"
#include "mail/mail-config.h"
/*#include "mail/em-folder-selection-button.h"*/
@@ -65,6 +68,7 @@
/*#include "mail/mail-component.h"*/
struct _MailComponent *mail_component_peek(void);
extern struct _EMFolderTreeModel *mail_component_peek_tree_model(struct _MailComponent *);
+CamelSession *session;
#include "mail/em-folder-tree.h"
@@ -228,6 +232,8 @@ account_added_cb (EAccountList *accounts
omenu = e_msg_composer_hdrs_get_from_omenu (hdrs);
menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
+ if (account_can_write_mails (account))
+ {
label = g_strdup_printf ("%s <%s>", account->id->name, account->id->address);
item = gtk_menu_item_new_with_label (label);
gtk_widget_show (item);
@@ -245,6 +251,7 @@ account_added_cb (EAccountList *accounts
toplevel = gtk_widget_get_toplevel ((GtkWidget *) hdrs);
gtk_widget_set_sensitive (toplevel, TRUE);
}
+}
static void
account_changed_cb (EAccountList *accounts, EAccount *account, EMsgComposerHdrs *hdrs)
@@ -316,6 +323,26 @@ account_removed_cb (EAccountList *accoun
}
}
+gboolean
+account_can_write_mails (EAccount *account)
+{
+ static CamelStore *store;
+ CamelException ex;
+
+ if (!account->proxy_account->parent_url)
+ return TRUE;
+
+ if (!(store = (CamelStore *) camel_session_get_service (session, account->source->url, CAMEL_PROVIDER_STORE, &ex))) {
+ camel_exception_clear (&ex);
+ return FALSE;
+ }
+
+ if (store->permissions & PROXY_MAIL_WRITE)
+ return TRUE;
+
+ return FALSE;
+}
+
static GtkWidget *
create_from_optionmenu (EMsgComposerHdrs *hdrs)
{
@@ -341,7 +368,7 @@ create_from_optionmenu (EMsgComposerHdrs
while (e_iterator_is_valid (iter)) {
account = (EAccount *) e_iterator_get (iter);
- if (account->id->address)
+ if (account->id->address && account_can_write_mails (account))
g_ptr_array_add (addresses, account->id->address);
e_iterator_next (iter);
@@ -360,7 +387,7 @@ create_from_optionmenu (EMsgComposerHdrs
continue;
}
- if (account->id->address && *account->id->address) {
+ if (account->id->address && *account->id->address && account_can_write_mails (account)) {
/* If the account has a unique email address, just
* show that. Otherwise include the account name.
*/
@@ -1104,6 +1131,8 @@ e_msg_composer_hdrs_set_from_account (EM
item = l->data;
account = g_object_get_data ((GObject *) item, "account");
+ if (account_can_write_mails (account))
+ {
if (account_name) {
if (account->name && !strcmp (account_name, account->name)) {
/* set the correct optionlist item */
@@ -1121,7 +1150,7 @@ e_msg_composer_hdrs_set_from_account (EM
return;
}
-
+ }
l = l->next;
i++;
}
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/ChangeLog,v
retrieving revision 1.2451
diff -u -p -w -r1.2451 ChangeLog
--- ChangeLog 1 Jul 2005 03:30:35 -0000 1.2451
+++ ChangeLog 5 Jul 2005 14:14:48 -0000
@@ -1,3 +1,8 @@
+2005-07-05 Shreyas Srinivasan <sshreyas novell com>
+
+ * camel-store.h: Add a new #define to identify proxy stores
+ and a new data member permissions to hold store specific permissions.
+
2005-06-24 Matt Brown <matt mattb net nz>
* camel-gpg-context.c: Extend verify and decrypt functions to support
Index: camel-store.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-store.h,v
retrieving revision 1.75
diff -u -p -w -r1.75 camel-store.h
--- camel-store.h 9 May 2005 20:13:13 -0000 1.75
+++ camel-store.h 5 Jul 2005 14:15:13 -0000
@@ -112,6 +112,7 @@ typedef struct _CamelRenameInfo {
#define CAMEL_STORE_VTRASH (1 << 1)
#define CAMEL_STORE_FILTER_INBOX (1 << 2)
#define CAMEL_STORE_VJUNK (1 << 3)
+#define CAMEL_STORE_PROXY (1 << 4)
struct _CamelStore {
CamelService parent_object;
@@ -120,6 +121,7 @@ struct _CamelStore {
CamelObjectBag *folders;
int flags;
+ gint16 permissions;
};
/* open mode for folder */
Index: camel-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/camel-store.c,v
retrieving revision 1.163
diff -u -p -w -r1.163 camel-store.c
--- camel-store.c 9 Jun 2005 07:00:23 -0000 1.163
+++ camel-store.c 5 Jul 2005 14:15:40 -0000
@@ -138,6 +138,7 @@ camel_store_init (void *o)
/* set vtrash and vjunk on by default */
store->flags = CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK;
+ store->permissions = 0;
store->priv = g_malloc0 (sizeof (*store->priv));
store->priv->folder_lock = e_mutex_new (E_MUTEX_REC);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/ChangeLog,v
retrieving revision 1.1494
diff -u -p -w -r1.1494 ChangeLog
--- ChangeLog 27 Jun 2005 00:36:06 -0000 1.1494
+++ ChangeLog 5 Jul 2005 14:28:36 -0000
@@ -1,3 +1,7 @@
+2005-07-05 Shreyas Srinivasan <sshreyas novell com>
+
+ *plugins/proxy-login/*: Plugin to allow proxy login
+
2005-06-27 Tor Lillqvist <tml novell com>
* configure.in: Drop local mail file lock method tests and the
--- /dev/null 2005-03-20 01:06:14.000000000 +0530
+++ plugins/proxy-login/Makefile.am 2005-07-04 16:14:54.000000000 +0530
@@ -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
--- /dev/null 2005-03-20 01:06:14.000000000 +0530
+++ plugins/proxy-login/org-gnome-proxy-login.eplug.xml 2005-07-04 16:14:54.000000000 +0530
@@ -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>
--- /dev/null 2005-03-20 01:06:14.000000000 +0530
+++ plugins/proxy-login/org-gnome-proxy-login-errors.xml 2005-07-04 16:14:54.000000000 +0530
@@ -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>
+
--- /dev/null 2005-03-20 01:06:14.000000000 +0530
+++ plugins/proxy-login/proxy-login-dialog.glade 2005-07-04 16:14:54.000000000 +0530
@@ -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>
--- /dev/null 2005-03-20 01:06:14.000000000 +0530
+++ plugins/proxy-login/proxy-login.h 2005-07-05 20:06:20.000000000 +0530
@@ -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);
--- /dev/null 2005-03-20 01:06:14.000000000 +0530
+++ plugins/proxy-login/proxy-login.c 2005-07-05 20:16:47.000000000 +0530
@@ -0,0 +1,507 @@
+
+/* -*- 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_proxy_connection_new (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);
+ dstAccount->proxy_account->parent_url = g_strdup(parent_source_url);
+ dstAccount->proxy_account->parent_uid = g_strdup(srcAccount->uid);
+ srcAccount->proxy_children = g_list_append(srcAccount->proxy_children, dstAccount->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;
+ 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->proxy_account->parent_url) {
+ 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;
+
+}
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/ChangeLog,v
retrieving revision 1.59
diff -u -p -w -r1.59 ChangeLog
--- ChangeLog 16 Jun 2005 06:49:16 -0000 1.59
+++ ChangeLog 5 Jul 2005 13:33:39 -0000
@@ -1,3 +1,10 @@
+2005-07-05 Shreyas Srinivasan <sshreyas novell com>
+
+ * camel-groupwise-store.c: Add check that uses parents password
+ for a proxy.
+ * camel-groupwise-folder.c: Use GetItems as GetQM is not valid on
+ proxy login.
+
2005-06-16 Parthasarathi Susarla <sparthasarathi novell com>
* came-groupwise-folder.c:
(gw_update_summary): make appointments appear the
Index: camel-groupwise-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-store.c,v
retrieving revision 1.46
diff -u -p -w -r1.46 camel-groupwise-store.c
--- camel-groupwise-store.c 14 Jun 2005 07:06:45 -0000 1.46
+++ camel-groupwise-store.c 5 Jul 2005 13:34:00 -0000
@@ -338,6 +338,7 @@ groupwise_auth_loop (CamelService *servi
{
CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (service);
CamelSession *session = camel_service_get_session (service);
+ CamelStore *store = CAMEL_STORE (service);
CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
char *errbuf = NULL;
gboolean authenticated = FALSE;
@@ -358,7 +359,7 @@ groupwise_auth_loop (CamelService *servi
service->url->passwd = NULL;
}
- if (!service->url->passwd) {
+ if (!service->url->passwd && !(store->flags & CAMEL_STORE_PROXY)) {
char *prompt;
prompt = g_strdup_printf (_("%sPlease enter the GroupWise "
Index: camel-groupwise-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-folder.c,v
retrieving revision 1.54
diff -u -p -w -r1.54 camel-groupwise-folder.c
--- camel-groupwise-folder.c 16 Jun 2005 06:49:16 -0000 1.54
+++ camel-groupwise-folder.c 5 Jul 2005 13:35:52 -0000
@@ -805,6 +805,7 @@ groupwise_refresh_info(CamelFolder *fold
CamelGroupwiseSummary *summary = (CamelGroupwiseSummary *)folder->summary;
EGwConnection *cnc = cnc_lookup (priv);
CamelSession *session = ((CamelService *)folder->parent_store)->session;
+ gboolean is_proxy = folder->parent_store->flags & CAMEL_STORE_PROXY;
int status;
GList *list = NULL;
GSList *slist = NULL, *sl;
@@ -835,7 +836,7 @@ groupwise_refresh_info(CamelFolder *fold
groupwise_sync (folder, FALSE, ex);
/*Done....should refresh now.....*/
- if (!g_ascii_strncasecmp (folder->full_name, "Trash", 5)) {
+ if (!g_ascii_strncasecmp (folder->full_name, "Trash", 5) || is_proxy) {
status = e_gw_connection_get_items (cnc, container_id, "recipient distribution created attachments subject status size", NULL, &list);
if (status != E_GW_CONNECTION_STATUS_OK) {
camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]