1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Sushma Rai <rsushma@novell.com>
* 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 <string.h>
#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include <gtk/gtk.h>
#include <gtk/gtkdialog.h>
#include <camel/camel-provider.h>
#include <camel/camel-url.h>
#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;
}
}
|