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 --- .../exchange-account-setup/exchange-ask-password.c | 113 +++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 plugins/exchange-account-setup/exchange-ask-password.c (limited to 'plugins/exchange-account-setup/exchange-ask-password.c') 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; + } +} -- cgit v1.2.3