Commit 1cf7d7b6 authored by Lucian Langa's avatar Lucian Langa
Browse files

fix proxy authentication

parent 37cabb6e
2009-04-30 Lucian Langa <lucilanga@gnome.org>
* src/network-soup.c: let evolution manage proxy authentication
* src/rss.c (create_user_pass_dialog), (web_auth_dialog),
(proxy_auth_dialog): refactory user/pass dialog
2009-04-28 Lucian Langa <lucilanga@gnome.org>
* src/network-soup.c: let evolution manage proxy connections
......
......@@ -300,16 +300,23 @@ authenticate (SoupSession *session,
#endif
{
g_print("proxy:\n");
g_print("proxy:%d\n", soup_auth_is_for_proxy(auth));
if (soup_auth_is_for_proxy(auth))
return;
if (msg->status_code == SOUP_STATUS_PROXY_UNAUTHORIZED) {
g_print("proxy:%d\n", soup_auth_is_for_proxy(auth));
SoupURI *proxy_uri;
g_object_get (G_OBJECT(session),
"proxy-uri", &proxy_uri,
NULL);
g_print("user:%s\n", proxy_uri->user);
g_print("pass:%s\n", proxy_uri->password);
//proxy_auth_dialog("Proxy Authentication", proxy_uri->user, proxy_uri->password);
//g_object_set (G_OBJECT (session), SOUP_SESSION_PROXY_URI, proxy_uri, NULL);
return;
}
gchar *user = g_hash_table_lookup(rf->hruser, data);
gchar *pass = g_hash_table_lookup(rf->hrpass, data);
if (user && pass)
{
if (user && pass) {
#if LIBSOUP_VERSION < 2003000
*username = g_strdup(user);
*password = g_strdup(pass);
......@@ -317,17 +324,13 @@ authenticate (SoupSession *session,
if (!retrying)
soup_auth_authenticate (auth, user, pass);
#endif
}
else
{
if (rf->soup_auth_retry)
{
} else {
if (rf->soup_auth_retry) {
//means we're already tested once and probably
//won't try again
rf->soup_auth_retry = FALSE;
if (!read_up(data))
{
if (create_user_pass_dialog(data))
if (!read_up(data)) {
if (web_auth_dialog(data))
rf->soup_auth_retry = FALSE;
else
rf->soup_auth_retry = TRUE;
......@@ -461,6 +464,7 @@ net_get_unblocking(const char *url,
{
SoupMessage *msg;
CallbackInfo *info = NULL;
SoupSession *soup_sess =
// soup_session_async_new_with_options(SOUP_SESSION_TIMEOUT, SS_TIMEOUT, NULL);
soup_session_async_new();
......
......@@ -548,40 +548,22 @@ textcb(NetStatusType status, gpointer statusdata, gpointer data)
}
}
gboolean
create_user_pass_dialog(gchar *url)
{
GtkWidget *dialog1;
GtkWidget *dialog_vbox1;
GtkWidget *table1;
GtkWidget *label1;
GtkWidget *label2;
GtkWidget *username;
GtkWidget *password;
GtkWidget *dialog_action_area1;
GtkWidget *cancelbutton1;
GtkWidget *okbutton1;
GtkWidget *checkbutton1;
GtkWidget *vbox1;
GtkWidget *container;
GtkWidget *container2;
guint resp;
GtkWidget *widget;
GtkWidget *action_area;
GtkWidget *content_area;
// gint type = msg->flags & E_PASSWORDS_REMEMBER_MASK;
// guint noreply = msg->noreply;
GtkDialog *
create_user_pass_dialog(RSS_AUTH *auth)
{
GtkWidget *dialog1;
GtkWidget *username;
GtkWidget *password;
GtkWidget *checkbutton1;
GtkWidget *container;
GtkWidget *container2;
GtkWidget *widget;
GtkWidget *action_area;
GtkWidget *content_area;
gboolean visible;
AtkObject *a11y;
// msg->noreply = 1;
if (!rf->hruser)
rf->hruser = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
if (!rf->hrpass)
rf->hrpass = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
widget = gtk_dialog_new_with_buttons (
_("Enter User/Pass for feed"), NULL, 0,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
......@@ -630,7 +612,7 @@ GtkWidget *dialog1;
gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
char *markup;
markup = g_markup_printf_escaped (_("Enter your username and password for:\n '%s'"), url);
markup = g_markup_printf_escaped (_("Enter your username and password for:\n '%s'"), auth->url);
gtk_label_set_markup (GTK_LABEL (widget), markup);
g_free (markup);
gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
......@@ -663,9 +645,8 @@ GtkWidget *dialog1;
gtk_table_attach (
GTK_TABLE (container2), username,
1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
gchar *user = g_hash_table_lookup(rf->hruser, url);
if (user)
gtk_entry_set_text (GTK_ENTRY (username), user);
if (auth->user)
gtk_entry_set_text (GTK_ENTRY (username), auth->user);
widget = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (widget), _("Password: "));
......@@ -684,9 +665,8 @@ GtkWidget *dialog1;
gtk_table_attach (
GTK_TABLE (container2), password,
1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 0, 0);
gchar *pass = g_hash_table_lookup(rf->hrpass, url);
if (pass)
gtk_entry_set_text (GTK_ENTRY (password), pass);
if (auth->pass)
gtk_entry_set_text (GTK_ENTRY (password), auth->pass);
/* Caps Lock Label */
widget = gtk_label_new (NULL);
......@@ -719,34 +699,65 @@ GtkWidget *dialog1;
GTK_TABLE (container), checkbutton1,
1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
gint result = gtk_dialog_run(GTK_DIALOG(password_dialog));
switch (result)
{
return password_dialog;
}
gboolean
web_auth_dialog(gchar *url)
{
GtkDialog *dialog;
guint resp;
if (!rf->hruser)
rf->hruser = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
if (!rf->hrpass)
rf->hrpass = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
RSS_AUTH *auth_info = g_new0(RSS_AUTH, 1);
auth_info->user = g_hash_table_lookup(rf->hruser, url);
auth_info->pass = g_hash_table_lookup(rf->hruser, url);
dialog = create_user_pass_dialog(auth_info);
gint result = gtk_dialog_run(GTK_DIALOG(dialog));
switch (result) {
case GTK_RESPONSE_OK:
if (user)
if (auth_info->user)
g_hash_table_remove(rf->hruser, url);
g_hash_table_insert(rf->hruser, url,
g_strdup(gtk_entry_get_text (GTK_ENTRY (username))));
if (pass)
g_strdup(gtk_entry_get_text (GTK_ENTRY (auth_info->username))));
if (auth_info->pass)
g_hash_table_remove(rf->hrpass, url);
g_hash_table_insert(rf->hrpass, url,
g_strdup(gtk_entry_get_text (GTK_ENTRY (password))));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton1)))
g_strdup(gtk_entry_get_text (GTK_ENTRY (auth_info->password))));
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (auth_info->rememberpass)))
save_up(url);
else
del_up(url);
gtk_widget_destroy (password_dialog);
gtk_widget_destroy (dialog);
resp = 0;
break;
default:
gtk_widget_destroy (password_dialog);
resp = 1;
break;
}
default:
gtk_widget_destroy (dialog);
resp = 1;
break;
}
g_free(auth_info);
return resp;
}
gboolean
proxy_auth_dialog(gchar *title, gchar *user, gchar *pass)
{
GtkDialog *dialog;
guint resp;
RSS_AUTH *auth_info = g_new0(RSS_AUTH, 1);
auth_info->user = user;
auth_info->pass = pass;
dialog = create_user_pass_dialog(auth_info);
gint result = gtk_dialog_run(GTK_DIALOG(dialog));
}
gboolean
cancel_soup_sess(gpointer key, gpointer value, gpointer user_data)
{
......
......@@ -280,6 +280,15 @@ typedef struct CREATE_FEED { /* used by create_mail function when called by unbl
GList *category; // list of categories article is posted under
} create_feed;
typedef struct rss_auth {
gchar *url;
gchar *user;
gchar *pass;
GtkWidget *username;
GtkWidget *password;
GtkWidget *rememberpass;
} RSS_AUTH;
guint upgrade = 0; // set to 2 when initailization successfull
guint count = 0;
gchar *buffer = NULL;
......@@ -287,7 +296,7 @@ guint ftotal;
guint farticle;
uint32_t gen_crc(const char *msg);
gboolean create_user_pass_dialog(gchar *url);
GtkDialog* create_user_pass_dialog(RSS_AUTH *auth);
static void start_check_cb (GtkWidget *widget, gpointer data);
static void err_destroy (GtkWidget *widget, guint response, gpointer data);
static gboolean check_if_match (gpointer key, gpointer value, gpointer user_data);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment