changeset 2768:8a918df1a5ed

[gaim-migrate @ 2781] you can change your registered email address committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 19 Nov 2001 16:37:32 +0000
parents e5e78d42e49e
children a5ad38b70145
files src/gaim.h src/protocols/oscar/oscar.c src/server.c
diffstat 3 files changed, 110 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/gaim.h	Mon Nov 19 15:25:36 2001 +0000
+++ b/src/gaim.h	Mon Nov 19 16:37:32 2001 +0000
@@ -383,6 +383,7 @@
 extern void serv_chat_leave(struct gaim_connection *, int);
 extern void serv_chat_whisper(struct gaim_connection *, int, char *, char *);
 extern int  serv_chat_send(struct gaim_connection *, int, char *);
+extern void serv_got_popup(char *, char *, int, int);
 
 /* Functions in util.c */
 extern char *normalize(const char *);
--- a/src/protocols/oscar/oscar.c	Mon Nov 19 15:25:36 2001 +0000
+++ b/src/protocols/oscar/oscar.c	Mon Nov 19 16:37:32 2001 +0000
@@ -87,6 +87,8 @@
 
 	gboolean conf;
 	gboolean reqemail;
+	gboolean setemail;
+	char *email;
 	gboolean chpass;
 	char *oldp;
 	char *newp;
@@ -243,6 +245,7 @@
 static int gaim_offlinemsg       (aim_session_t *, aim_frame_t *, ...);
 static int gaim_offlinemsgdone   (aim_session_t *, aim_frame_t *, ...);
 static int gaim_simpleinfo       (aim_session_t *, aim_frame_t *, ...);
+static int gaim_popup            (aim_session_t *, aim_frame_t *, ...);
 
 static int gaim_directim_initiate(aim_session_t *, aim_frame_t *, ...);
 static int gaim_directim_incoming(aim_session_t *, aim_frame_t *, ...);
@@ -519,6 +522,8 @@
 	}
 	if (odata->create_name)
 		g_free(odata->create_name);
+	if (odata->email)
+		g_free(odata->email);
 	if (odata->newp)
 		g_free(odata->newp);
 	if (odata->oldp)
@@ -658,6 +663,7 @@
 	aim_conn_addhandler(sess, bosconn, 0x0001, 0x000f, gaim_selfinfo, 0);
 	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG, gaim_offlinemsg, 0);
 	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE, gaim_offlinemsgdone, 0);
+	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_POP, 0x0002, gaim_popup, 0);
 	aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_SIMPLEINFO, gaim_simpleinfo, 0);
 
 	((struct oscar_data *)gc->proto_data)->conn = bosconn;
@@ -1927,7 +1933,9 @@
 		debug_printf("changing password\n");
 		aim_admin_changepasswd(sess, fr->conn, od->newp, od->oldp);
 		g_free(od->oldp);
+		od->oldp = NULL;
 		g_free(od->newp);
+		od->newp = NULL;
 		od->chpass = FALSE;
 	}
 	if (od->conf) {
@@ -1940,6 +1948,12 @@
 		aim_admin_getinfo(sess, fr->conn, 0x0011);
 		od->reqemail = FALSE;
 	}
+	if (od->setemail) {
+		debug_printf("setting email\n");
+		aim_admin_setemail(sess, fr->conn, od->email);
+		g_free(od->email);
+		od->setemail = FALSE;
+	}
 
 	return 1;
 }
@@ -2056,6 +2070,25 @@
 	return 1;
 }
 
+static int gaim_popup(aim_session_t *sess, aim_frame_t *fr, ...)
+{
+	char *msg, *url;
+	fu16_t wid, hei, delay;
+	va_list ap;
+
+	va_start(ap, fr);
+	msg = va_arg(ap, char *);
+	url = va_arg(ap, char *);
+	wid = (fu16_t)va_arg(ap, int);
+	hei = (fu16_t)va_arg(ap, int);
+	delay = (fu16_t)va_arg(ap, int);
+	va_end(ap);
+
+	serv_got_popup(msg, url, wid, hei);
+
+	return 1;
+}
+
 static int gaim_parse_searchreply(aim_session_t *sess, aim_frame_t *fr, ...) {
 	va_list ap;
 	char *address, *SNs;
@@ -2771,6 +2804,20 @@
 	return m;
 }
 
+static void oscar_change_email(struct gaim_connection *gc, char *email)
+{
+	struct oscar_data *od = gc->proto_data;
+	aim_conn_t *conn = aim_getconn_type(od->sess, AIM_CONN_TYPE_AUTH);
+
+	if (conn) {
+		aim_admin_setemail(od->sess, conn, email);
+	} else {
+		od->setemail = TRUE;
+		od->email = g_strdup(email);
+		aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH);
+	}
+}
+
 static void oscar_do_action(struct gaim_connection *gc, char *act)
 {
 	struct oscar_data *od = gc->proto_data;
@@ -2786,13 +2833,14 @@
 			aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH);
 		} else
 			aim_admin_reqconfirm(od->sess, conn);
-	} else if (!strcmp(act, "Change Email")) {
 	} else if (!strcmp(act, "Display Current Registered Address")) {
 		if (!conn) {
 			od->reqemail = TRUE;
 			aim_reqservice(od->sess, od->conn, AIM_CONN_TYPE_AUTH);
 		} else
 			aim_admin_getinfo(od->sess, conn, 0x11);
+	} else if (!strcmp(act, "Change Current Registered Address")) {
+		do_prompt_dialog("Change Address To: ", NULL, gc, oscar_change_email, NULL);
 	} else if (!strcmp(act, "Search for Buddy by Email")) {
 		show_find_email(gc);
 	}
@@ -2806,10 +2854,8 @@
 	m = g_list_append(m, NULL);
 	m = g_list_append(m, "Change Password");
 	m = g_list_append(m, "Confirm Account");
-	/*
-	m = g_list_append(m, "Change Email");
-	*/
 	m = g_list_append(m, "Display Current Registered Address");
+	m = g_list_append(m, "Change Current Registered Address");
 	m = g_list_append(m, NULL);
 	m = g_list_append(m, "Search for Buddy by Email");
 
--- a/src/server.c	Mon Nov 19 15:25:36 2001 +0000
+++ b/src/server.c	Mon Nov 19 16:37:32 2001 +0000
@@ -31,6 +31,7 @@
 #include <sys/time.h>
 #include <unistd.h>
 #include <errno.h>
+#include "gtkimhtml.h"
 #include "prpl.h"
 #include "multi.h"
 #include "gaim.h"
@@ -40,6 +41,7 @@
 
 #include "pixmaps/ok.xpm"
 #include "pixmaps/cancel.xpm"
+#include "pixmaps/tb_search.xpm"
 
 void serv_login(struct aim_user *user)
 {
@@ -950,3 +952,60 @@
 	chat_write(b, who, w, buf, mtime);
 	g_free(buf);
 }
+
+static void des_popup(GtkWidget *w, GtkWidget *window)
+{
+	if (w == window) {
+		char *u = gtk_object_get_user_data(GTK_OBJECT(window));
+		g_free(u);
+	}
+	gtk_widget_destroy(window);
+}
+
+void serv_got_popup(char *msg, char *u, int wid, int hei)
+{
+	GtkWidget *window;
+	GtkWidget *vbox;
+	GtkWidget *sw;
+	GtkWidget *text;
+	GtkWidget *hbox;
+	GtkWidget *button;
+	char *url = g_strdup(u);
+
+	GAIM_DIALOG(window);
+	gtk_window_set_wmclass(GTK_WINDOW(window), "popup", "Gaim");
+	gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE);
+	gtk_window_set_title(GTK_WINDOW(window), "Gaim - Popup");
+	gtk_container_set_border_width(GTK_CONTAINER(window), 5);
+	gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(des_popup), window);
+	gtk_object_set_user_data(GTK_OBJECT(window), url);
+	gtk_widget_realize(window);
+	aol_icon(window->window);
+
+	vbox = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(window), vbox);
+
+	sw = gtk_scrolled_window_new(NULL, NULL);
+	gtk_widget_set_usize(sw, wid, hei);
+	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+	gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 5);
+
+	text = gtk_imhtml_new(NULL, NULL);
+	gtk_container_add(GTK_CONTAINER(sw), text);
+	gaim_setup_imhtml(text);
+
+	hbox = gtk_hbox_new(FALSE, 5);
+	gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+
+	button = picture_button(window, _("Close"), cancel_xpm);
+	gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(des_popup), window);
+
+	button = picture_button(window, _("More Info"), tb_search_xpm);
+	gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(open_url_nw), url);
+
+	gtk_widget_show_all(window);
+
+	gtk_imhtml_append_text(GTK_IMHTML(text), msg, GTK_IMHTML_NO_NEWLINE);
+}