From b9d38cc653c017dcb78a67a0660a9a18e0f326b5 Mon Sep 17 00:00:00 2001 From: Sushma Rai Date: Sun, 9 Jan 2005 13:15:33 +0000 Subject: Authentication for exchange account svn path=/trunk/; revision=28296 --- plugins/exchange-account-setup/ChangeLog | 7 ++ plugins/exchange-account-setup/Makefile.am | 3 +- .../exchange-account-setup/exchange-ask-password.c | 113 +++++++++++++++++++++ .../org-gnome-exchange-account-setup.eplug.in | 21 ++++ 4 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 plugins/exchange-account-setup/exchange-ask-password.c diff --git a/plugins/exchange-account-setup/ChangeLog b/plugins/exchange-account-setup/ChangeLog index 8c9375546b..61e0b4b7b0 100644 --- a/plugins/exchange-account-setup/ChangeLog +++ b/plugins/exchange-account-setup/ChangeLog @@ -1,3 +1,10 @@ +2005-01-09 Sushma Rai + + * exchange-ask-password.c: Pops up password dialog and validates + user credentials once owa url and user name are entered. + + * org-gnome-exchange-account-setup.eplug.in: Added page check plugin. + 2005-01-09 Sushma Rai * Intial ckeckin, Plugin for Exchange account specific settings diff --git a/plugins/exchange-account-setup/Makefile.am b/plugins/exchange-account-setup/Makefile.am index 516a6ba016..47d5f1cddc 100644 --- a/plugins/exchange-account-setup/Makefile.am +++ b/plugins/exchange-account-setup/Makefile.am @@ -9,7 +9,8 @@ plugin_DATA = org-gnome-exchange-account-setup.eplug plugin_LTLIBRARIES = liborg-gnome-exchange-account-settings.la liborg_gnome_exchange_account_settings_la_SOURCES = \ - exchange-account-setup.c + exchange-account-setup.c \ + exchange-ask-password.c liborg_gnome_exchange_account_settings_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ diff --git a/plugins/exchange-account-setup/exchange-ask-password.c b/plugins/exchange-account-setup/exchange-ask-password.c new file mode 100644 index 0000000000..1474613959 --- /dev/null +++ b/plugins/exchange-account-setup/exchange-ask-password.c @@ -0,0 +1,113 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Sushma Rai + * Copyright (C) 2004 Novell, Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "mail/em-account-editor.h" +#include "mail/em-config.h" +#include "e-util/e-account.h" +#include "e-util/e-passwords.h" +#include "e-util/e-config.h" + +int e_plugin_lib_enable (EPluginLib *ep, int enable); + +gboolean org_gnome_exchange_ask_password (EPlugin *epl, EConfigHookPageCheckData *data); + +static gboolean +validate_exchange_user (EConfig *ec, const char *pageid, void *data) +{ + EMConfigTargetAccount *target_account = data; + CamelURL *url=NULL; + CamelProvider *provider = NULL; + gboolean valid = TRUE; + char *account_url, *url_string; + static int count = 0; + + if (count) + return valid; + + account_url = g_strdup (target_account->account->source->url); + url = camel_url_new_with_base (NULL, account_url); + provider = camel_provider_get (account_url, NULL); + g_free (account_url); + if (!provider) { + return FALSE; /* This should never happen */ + } + + valid = camel_provider_validate_user (provider, url, NULL); + if (valid) { + count ++; + url_string = camel_url_to_string (url, 0); + target_account->account->source->url = url_string; + } + return valid; +} + +#if 0 +int +e_plugin_lib_enable (EPluginLib *ep, int enable) +{ + if (enable) { + } + return 0; +} +#endif + +gboolean +org_gnome_exchange_ask_password(EPlugin *epl, EConfigHookPageCheckData *data) +{ + EMConfigTargetAccount *target_account; + EConfig *config; + char *account_url = NULL, *exchange_url = NULL; + GtkWidget *page; + + if (strcmp (data->pageid, "10.receive")) + return TRUE; + + config = data->config; + target_account = (EMConfigTargetAccount *)data->config->target; + account_url = g_strdup (target_account->account->source->url); + exchange_url = g_strrstr (account_url, "exchange"); + + /* On page next signal, authenticate user and allow + * to go to receive options page only if user is a valid user */ + + if (exchange_url) { + page = e_config_get_druid_page (config); + g_signal_connect (page, "next", G_CALLBACK(validate_exchange_user), target_account); + g_free (account_url); + return TRUE; + } + else { + g_free (account_url); + return TRUE; + } +} diff --git a/plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug.in b/plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug.in index 3d264b7f0c..bb5c3a4f99 100644 --- a/plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug.in +++ b/plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug.in @@ -19,4 +19,25 @@ + + + + + + + + + + + -- cgit v1.2.3