Mercurial > pidgin.yaz
annotate src/multi.c @ 988:9523b772e546
[gaim-migrate @ 998]
progress meters for signing in. UI should be changed but at least there's something there now
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 13 Oct 2000 19:56:11 +0000 |
parents | 7ec6b092f227 |
children | eacd93d0089a |
rev | line source |
---|---|
960 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
22 #include <gtk/gtk.h> | |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
23 #include "prpl.h" |
960 | 24 #include "multi.h" |
25 #include "gaim.h" | |
966
f7886476f9d9
[gaim-migrate @ 976]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
960
diff
changeset
|
26 #include "gnome_applet_mgr.h" |
960 | 27 #include "aim.h" |
28 | |
29 #include "pixmaps/gnome_add.xpm" | |
30 #include "pixmaps/gnome_preferences.xpm" | |
31 #include "pixmaps/join.xpm" | |
32 #include "pixmaps/gnome_remove.xpm" | |
33 #include "pixmaps/gnome_close.xpm" | |
34 #include "pixmaps/cancel.xpm" | |
35 #include "pixmaps/ok.xpm" | |
36 | |
37 GSList *connections; | |
38 | |
39 static GtkWidget *acctedit = NULL; | |
40 static GtkWidget *list = NULL; /* the clist of names in the accteditor */ | |
41 static GtkWidget *newmod = NULL; /* the dialog for creating a new account */ | |
42 static struct aim_user tmpusr; | |
43 | |
44 struct mod_usr_opt { | |
45 struct aim_user *user; | |
46 int opt; | |
47 }; | |
48 | |
49 struct gaim_connection *new_gaim_conn(int proto, char *username, char *password) | |
50 { | |
51 struct gaim_connection *gc = g_new0(struct gaim_connection, 1); | |
52 gc->protocol = proto; | |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
53 gc->prpl = find_prpl(proto); |
960 | 54 g_snprintf(gc->username, sizeof(gc->username), "%s", username); |
55 g_snprintf(gc->password, sizeof(gc->password), "%s", password); | |
56 gc->keepalive = -1; | |
57 | |
58 switch(proto) { | |
59 case PROTO_TOC: | |
60 gc->toc_fd = -1; | |
61 gc->seqno = 0; | |
62 gc->state = 0; | |
63 gc->inpa = -1; | |
64 break; | |
65 case PROTO_OSCAR: | |
66 gc->oscar_sess = NULL; | |
67 gc->oscar_conn = NULL; | |
68 gc->inpa = -1; | |
69 gc->cnpa = -1; | |
70 gc->paspa = -1; | |
71 gc->create_exchange = 0; | |
72 gc->create_name = NULL; | |
73 gc->oscar_chats = NULL; | |
74 break; | |
75 default: /* damn plugins */ | |
76 /* PRPL */ | |
77 break; | |
78 } | |
79 | |
80 connections = g_slist_append(connections, gc); | |
81 | |
82 return gc; | |
83 } | |
84 | |
85 void destroy_gaim_conn(struct gaim_connection *gc) | |
86 { | |
87 connections = g_slist_remove(connections, gc); | |
88 g_free(gc); | |
89 redo_convo_menus(); | |
988
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
90 if (!connections && mainwindow) |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
91 gtk_widget_show(mainwindow); |
960 | 92 } |
93 | |
94 struct gaim_connection *find_gaim_conn_by_name(char *name) { | |
95 char *who = g_strdup(normalize(name)); | |
96 GSList *c = connections; | |
97 struct gaim_connection *g = NULL; | |
98 | |
99 while (c) { | |
100 g = (struct gaim_connection *)c->data; | |
101 if (!strcmp(normalize(g->username), who)) { | |
102 g_free(who); | |
103 return g; | |
104 } | |
105 c = c->next; | |
106 } | |
107 | |
108 g_free(who); | |
109 return NULL; | |
110 } | |
111 | |
112 static void delete_acctedit(GtkWidget *w, gpointer d) | |
113 { | |
114 if (acctedit) { | |
115 save_prefs(); | |
116 gtk_widget_destroy(acctedit); | |
117 } | |
118 acctedit = NULL; | |
119 } | |
120 | |
121 static gint acctedit_close(GtkWidget *w, gpointer d) | |
122 { | |
123 gtk_widget_destroy(acctedit); | |
124 return FALSE; | |
125 } | |
126 | |
127 static char *proto_name(int proto) | |
128 { | |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
129 struct prpl *p = find_prpl(proto); |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
130 if (p && p->name) |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
131 return (*p->name)(); |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
132 else |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
133 return "Unknown"; |
960 | 134 } |
135 | |
136 static GtkWidget *generate_list() | |
137 { | |
138 GtkWidget *win; | |
139 char *titles[4] = {"Screenname", "Currently Online", "Auto-login", "Protocol"}; | |
140 GList *u = aim_users; | |
141 struct aim_user *a; | |
142 int i; | |
143 | |
144 win = gtk_scrolled_window_new(0, 0); | |
145 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(win), GTK_POLICY_AUTOMATIC, | |
146 GTK_POLICY_ALWAYS); | |
147 | |
148 list = gtk_clist_new_with_titles(4, titles); | |
149 gtk_clist_set_column_width(GTK_CLIST(list), 0, 90); | |
150 gtk_clist_set_selection_mode(GTK_CLIST(list), GTK_SELECTION_BROWSE); | |
151 gtk_clist_column_titles_passive(GTK_CLIST(list)); | |
152 gtk_container_add(GTK_CONTAINER(win), list); | |
153 gtk_widget_show(list); | |
154 | |
155 while (u) { | |
156 a = (struct aim_user *)u->data; | |
157 titles[0] = a->username; | |
977
e5eac6b236f1
[gaim-migrate @ 987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
969
diff
changeset
|
158 titles[1] = find_gaim_conn_by_name(a->username) ? "Yes" : "No"; |
960 | 159 titles[2] = (a->options & OPT_USR_AUTO) ? "True" : "False"; |
160 titles[3] = proto_name(a->protocol); | |
161 i = gtk_clist_append(GTK_CLIST(list), titles); | |
162 gtk_clist_set_row_data(GTK_CLIST(list), i, a); | |
163 u = u->next; | |
164 } | |
165 | |
166 gtk_widget_show(win); | |
167 return win; | |
168 } | |
169 | |
170 static void delmod(GtkWidget *w, struct aim_user *u) | |
171 { | |
172 gtk_widget_destroy(w); | |
173 if (u) { | |
174 u->mod = NULL; | |
175 } else { | |
176 newmod = NULL; | |
177 } | |
178 } | |
179 | |
180 static void mod_opt(GtkWidget *b, struct mod_usr_opt *m) | |
181 { | |
182 if (m->user) { | |
183 m->user->tmp_options = m->user->tmp_options ^ m->opt; | |
184 } else { | |
185 tmpusr.options = tmpusr.options ^ m->opt; | |
186 } | |
187 } | |
188 | |
189 static GtkWidget *acct_button(const char *text, struct aim_user *u, int option, GtkWidget *box) | |
190 { | |
191 GtkWidget *button; | |
192 struct mod_usr_opt *muo = g_new0(struct mod_usr_opt, 1); | |
193 button = gtk_check_button_new_with_label(text); | |
194 if (u) { | |
195 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (u->options & option)); | |
196 } else { | |
197 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (tmpusr.options & option)); | |
198 } | |
199 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); | |
200 muo->user = u; muo->opt = option; | |
201 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(mod_opt), muo); | |
202 gtk_widget_show(button); | |
203 return button; | |
204 } | |
205 | |
206 static void ok_mod(GtkWidget *w, struct aim_user *u) | |
207 { | |
208 char *txt; | |
209 int i; | |
210 if (u) { | |
211 u->options = u->tmp_options; | |
212 u->protocol = u->tmp_protocol; | |
213 txt = gtk_entry_get_text(GTK_ENTRY(u->pass)); | |
214 if (u->options & OPT_USR_REM_PASS) | |
215 g_snprintf(u->password, sizeof(u->password), "%s", txt); | |
216 else | |
217 u->password[0] = '\0'; | |
218 gtk_widget_destroy(u->mod); | |
219 i = gtk_clist_find_row_from_data(GTK_CLIST(list), u); | |
220 gtk_clist_set_text(GTK_CLIST(list), i, 2, (u->options & OPT_USR_AUTO) ? "True" : "False"); | |
221 gtk_clist_set_text(GTK_CLIST(list), i, 3, proto_name(u->protocol)); | |
222 } else { | |
223 char *titles[4]; | |
224 txt = gtk_entry_get_text(GTK_ENTRY(tmpusr.name)); | |
968
10d8133ffab9
[gaim-migrate @ 978]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
966
diff
changeset
|
225 if (find_user(txt)) { |
960 | 226 /* PRPL: also need to check protocol. remember TOC and Oscar are both AIM */ |
227 gtk_widget_destroy(newmod); | |
228 return; | |
229 } | |
230 u = g_new0(struct aim_user, 1); | |
231 g_snprintf(u->username, sizeof(u->username), "%s", txt); | |
232 txt = gtk_entry_get_text(GTK_ENTRY(tmpusr.pass)); | |
233 g_snprintf(u->password, sizeof(u->password), "%s", txt); | |
234 u->options = tmpusr.options; | |
235 u->protocol = tmpusr.protocol; | |
236 gtk_widget_destroy(newmod); | |
237 titles[0] = u->username; | |
977
e5eac6b236f1
[gaim-migrate @ 987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
969
diff
changeset
|
238 titles[1] = find_gaim_conn_by_name(u->username) ? "Yes" : "No"; |
960 | 239 titles[2] = (u->options & OPT_USR_AUTO) ? "True" : "False"; |
240 titles[3] = proto_name(u->protocol); | |
241 i = gtk_clist_append(GTK_CLIST(list), titles); | |
242 gtk_clist_set_row_data(GTK_CLIST(list), i, u); | |
984
7ec6b092f227
[gaim-migrate @ 994]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
982
diff
changeset
|
243 aim_users = g_list_append(aim_users, u); |
960 | 244 } |
245 save_prefs(); | |
246 } | |
247 | |
248 static void cancel_mod(GtkWidget *w, struct aim_user *u) | |
249 { | |
250 if (u) { | |
251 gtk_widget_destroy(u->mod); | |
252 } else { | |
253 gtk_widget_destroy(newmod); | |
254 } | |
255 } | |
256 | |
257 static void set_prot(GtkWidget *opt, int proto) | |
258 { | |
259 struct aim_user *u = gtk_object_get_user_data(GTK_OBJECT(opt)); | |
260 if (u) { | |
261 u->tmp_protocol = proto; | |
262 } else { | |
263 tmpusr.protocol = proto; | |
264 } | |
265 } | |
266 | |
267 static GtkWidget *make_protocol_menu(GtkWidget *box, struct aim_user *u) | |
268 { | |
269 GtkWidget *optmenu; | |
270 GtkWidget *menu; | |
271 GtkWidget *opt; | |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
272 GSList *p = protocols; |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
273 struct prpl *e; |
960 | 274 |
275 /* PRPL: should we set some way to update these when new protocols get added? */ | |
276 optmenu = gtk_option_menu_new(); | |
277 gtk_box_pack_start(GTK_BOX(box), optmenu, FALSE, FALSE, 5); | |
278 gtk_widget_show(optmenu); | |
279 | |
280 menu = gtk_menu_new(); | |
281 | |
981
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
282 while (p) { |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
283 e = (struct prpl *)p->data; |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
284 if (e->name) |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
285 opt = gtk_menu_item_new_with_label((*e->name)()); |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
286 else |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
287 opt = gtk_menu_item_new_with_label("Unknown"); |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
288 gtk_object_set_user_data(GTK_OBJECT(opt), u); |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
289 gtk_signal_connect(GTK_OBJECT(opt), "activate", |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
290 GTK_SIGNAL_FUNC(set_prot), (void *)e->protocol); |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
291 gtk_menu_append(GTK_MENU(menu), opt); |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
292 gtk_widget_show(opt); |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
293 p = p->next; |
7e231bc0018a
[gaim-migrate @ 991]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
980
diff
changeset
|
294 } |
960 | 295 |
296 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); | |
297 if (u) { | |
298 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), u->protocol); | |
982
09e5065fe22c
[gaim-migrate @ 992]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
299 u->tmp_protocol = u->protocol; |
960 | 300 } else { |
301 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), PROTO_TOC); | |
302 } | |
303 | |
304 return optmenu; | |
305 } | |
306 | |
307 static void show_acct_mod(struct aim_user *u) | |
308 { | |
309 /* here we can have all the aim_user options, including ones not shown in the main acctedit | |
310 * window. this can keep the size of the acctedit window small and readable, and make this | |
311 * one the powerful editor. this is where things like name/password are edited, but can | |
312 * also have toggles (and even more complex options) like whether to autologin or whether | |
313 * to send keepalives or whatever. this would be the perfect place to specify which protocol | |
314 * to use. make sure to account for the possibility of protocol plugins. */ | |
315 GtkWidget *mod; | |
316 GtkWidget *frame; | |
317 GtkWidget *vbox; | |
318 GtkWidget *hbox; | |
319 GtkWidget *label; | |
320 GtkWidget *name; | |
321 GtkWidget *pass; | |
322 GtkWidget *button; | |
323 | |
324 if (!u && newmod) { | |
325 gtk_widget_show(newmod); | |
326 return; | |
327 } | |
328 if (u && u->mod) { | |
329 gtk_widget_show(u->mod); | |
330 return; | |
331 } | |
332 | |
333 mod = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
334 gtk_window_set_wmclass(GTK_WINDOW(mod), "account", "Gaim"); | |
335 gtk_widget_realize(mod); | |
336 aol_icon(mod->window); | |
337 gtk_container_border_width(GTK_CONTAINER(mod), 10); | |
338 gtk_window_set_title(GTK_WINDOW(mod), _("Gaim - Modify Account")); | |
339 gtk_signal_connect(GTK_OBJECT(mod), "destroy", | |
340 GTK_SIGNAL_FUNC(delmod), u); | |
341 | |
342 frame = gtk_frame_new(_("Modify Account")); | |
343 gtk_container_add(GTK_CONTAINER(mod), frame); | |
344 gtk_widget_show(frame); | |
345 | |
346 vbox = gtk_vbox_new(FALSE, 0); | |
347 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
348 gtk_widget_show(vbox); | |
349 | |
350 hbox = gtk_hbox_new(FALSE, 0); | |
351 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
352 gtk_widget_show(hbox); | |
353 | |
354 label = gtk_label_new(_("Screenname:")); | |
355 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
356 gtk_widget_show(label); | |
357 | |
358 name = gtk_entry_new(); | |
359 gtk_box_pack_start(GTK_BOX(hbox), name, FALSE, FALSE, 5); | |
360 gtk_widget_show(name); | |
361 | |
362 hbox = gtk_hbox_new(FALSE, 5); | |
363 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
364 gtk_widget_show(hbox); | |
365 | |
366 label = gtk_label_new(_("Password:")); | |
367 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
368 gtk_widget_show(label); | |
369 | |
370 pass = gtk_entry_new(); | |
371 gtk_box_pack_start(GTK_BOX(hbox), pass, FALSE, FALSE, 5); | |
372 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); | |
373 gtk_widget_show(pass); | |
374 | |
375 hbox = gtk_hbox_new(FALSE, 5); | |
376 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
377 gtk_widget_show(hbox); | |
378 | |
379 make_protocol_menu(hbox, u); | |
380 | |
381 acct_button(_("Remember Password"), u, OPT_USR_REM_PASS, vbox); | |
382 acct_button(_("Auto-Login"), u, OPT_USR_AUTO, vbox); | |
383 acct_button(_("Send KeepAlive packet (6 bytes/second)"), u, OPT_USR_KEEPALV, vbox); | |
384 | |
385 hbox = gtk_hbox_new(FALSE, 5); | |
386 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
387 gtk_widget_show(hbox); | |
388 | |
389 button = picture_button(mod, _("Cancel"), cancel_xpm); | |
390 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5); | |
391 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_mod), u); | |
392 gtk_widget_show(button); | |
393 | |
394 button = picture_button(mod, _("OK"), ok_xpm); | |
395 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5); | |
396 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(ok_mod), u); | |
397 gtk_widget_show(button); | |
398 | |
399 if (u) { | |
400 u->mod = mod; | |
401 u->name = name; | |
402 u->pass = pass; | |
403 u->tmp_options = u->options; | |
404 gtk_entry_set_text(GTK_ENTRY(name), u->username); | |
405 gtk_entry_set_text(GTK_ENTRY(pass), u->password); | |
406 gtk_entry_set_editable(GTK_ENTRY(name), FALSE); | |
407 } else { | |
408 newmod = mod; | |
409 tmpusr.name = name; | |
410 tmpusr.pass = pass; | |
411 } | |
412 | |
413 gtk_widget_show(mod); | |
414 } | |
415 | |
416 static void add_acct(GtkWidget *w, gpointer d) | |
417 { | |
418 show_acct_mod(NULL); | |
419 } | |
420 | |
421 static void mod_acct(GtkWidget *w, gpointer d) | |
422 { | |
423 int row = -1; | |
424 char *name; | |
425 struct aim_user *u; | |
426 if (GTK_CLIST(list)->selection) | |
427 row = (int)GTK_CLIST(list)->selection->data; | |
428 if (row != -1) { | |
429 gtk_clist_get_text(GTK_CLIST(list), row, 0, &name); | |
430 u = find_user(name); | |
431 if (u) | |
432 show_acct_mod(u); | |
433 } | |
434 } | |
435 | |
436 static void pass_des(GtkWidget *w, struct aim_user *u) | |
437 { | |
438 gtk_widget_destroy(w); | |
439 u->passprmt = NULL; | |
440 } | |
441 | |
442 static void pass_cancel(GtkWidget *w, struct aim_user *u) | |
443 { | |
444 gtk_widget_destroy(u->passprmt); | |
445 u->passprmt = NULL; | |
446 } | |
447 | |
448 static void pass_signon(GtkWidget *w, struct aim_user *u) | |
449 { | |
450 char *txt = gtk_entry_get_text(GTK_ENTRY(u->passentry)); | |
980
82c5865f7cfe
[gaim-migrate @ 990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
977
diff
changeset
|
451 g_snprintf(u->password, sizeof(u->password), "%s", txt); |
960 | 452 #ifdef USE_APPLET |
453 set_user_state(signing_on); | |
454 #endif | |
455 gtk_widget_destroy(u->passprmt); | |
456 u->passprmt = NULL; | |
980
82c5865f7cfe
[gaim-migrate @ 990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
977
diff
changeset
|
457 serv_login(u); |
960 | 458 } |
459 | |
460 static void do_pass_dlg(struct aim_user *u) | |
461 { | |
462 /* we can safely assume that u is not NULL */ | |
463 GtkWidget *frame; | |
464 GtkWidget *vbox; | |
465 GtkWidget *hbox; | |
466 char buf[96]; | |
467 GtkWidget *label; | |
468 GtkWidget *button; | |
469 | |
470 if (u->passprmt) { gtk_widget_show(u->passprmt); return; } | |
471 u->passprmt = gtk_window_new(GTK_WINDOW_DIALOG); | |
472 gtk_window_set_wmclass(GTK_WINDOW(u->passprmt), "password", "Gaim"); | |
473 gtk_container_border_width(GTK_CONTAINER(u->passprmt), 5); | |
474 gtk_signal_connect(GTK_OBJECT(u->passprmt), "destroy", GTK_SIGNAL_FUNC(pass_des), u); | |
475 gtk_widget_realize(u->passprmt); | |
476 aol_icon(u->passprmt->window); | |
477 | |
478 frame = gtk_frame_new(_("Enter Password")); | |
479 gtk_container_add(GTK_CONTAINER(u->passprmt), frame); | |
480 gtk_widget_show(frame); | |
481 | |
482 vbox = gtk_vbox_new(FALSE, 5); | |
483 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
484 gtk_widget_show(vbox); | |
485 | |
486 hbox = gtk_hbox_new(FALSE, 5); | |
487 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
488 gtk_widget_show(hbox); | |
489 | |
490 g_snprintf(buf, sizeof(buf), "Password for %s:", u->username); | |
491 label = gtk_label_new(buf); | |
492 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
493 gtk_widget_show(label); | |
494 | |
495 u->passentry = gtk_entry_new(); | |
496 gtk_entry_set_visibility(GTK_ENTRY(u->passentry), FALSE); | |
497 gtk_box_pack_start(GTK_BOX(hbox), u->passentry, FALSE, FALSE, 5); | |
498 gtk_signal_connect(GTK_OBJECT(u->passentry), "activate", GTK_SIGNAL_FUNC(pass_signon), u); | |
499 gtk_widget_grab_focus(u->passentry); | |
500 gtk_widget_show(u->passentry); | |
501 | |
502 hbox = gtk_hbox_new(FALSE, 5); | |
503 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
504 gtk_widget_show(hbox); | |
505 | |
506 button = picture_button(u->passprmt, _("Cancel"), cancel_xpm); | |
507 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(pass_cancel), u); | |
508 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5); | |
509 | |
510 button = picture_button(u->passprmt, _("Signon"), ok_xpm); | |
511 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(pass_signon), u); | |
512 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5); | |
513 | |
514 gtk_widget_show(u->passprmt); | |
515 } | |
516 | |
517 static void acct_signin(GtkWidget *w, gpointer d) | |
518 { | |
519 int row = -1; | |
520 char *name; | |
521 struct aim_user *u; | |
522 struct gaim_connection *gc; | |
523 if (GTK_CLIST(list)->selection) | |
524 row = (int)GTK_CLIST(list)->selection->data; | |
525 if (row != -1) { | |
526 gtk_clist_get_text(GTK_CLIST(list), row, 0, &name); | |
527 u = find_user(name); | |
528 gc = find_gaim_conn_by_name(name); | |
529 if (!gc) { | |
530 if (!u->password[0]) { | |
531 do_pass_dlg(u); | |
532 } else { | |
533 #ifdef USE_APPLET | |
534 set_user_state(signing_on); | |
535 #endif /* USE_APPLET */ | |
980
82c5865f7cfe
[gaim-migrate @ 990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
977
diff
changeset
|
536 serv_login(u); |
960 | 537 } |
538 } else { | |
539 signoff(gc); | |
540 } | |
541 } | |
542 } | |
543 | |
544 static void del_acct(GtkWidget *w, gpointer d) | |
545 { | |
546 int row = -1; | |
547 char *name; | |
548 struct aim_user *u; | |
549 if (GTK_CLIST(list)->selection) | |
550 row = (int)GTK_CLIST(list)->selection->data; | |
551 if (row != -1) { | |
552 gtk_clist_get_text(GTK_CLIST(list), row, 0, &name); | |
553 u = find_user(name); | |
554 if (u) { | |
555 aim_users = g_list_remove(aim_users, u); | |
556 save_prefs(); | |
557 } | |
558 gtk_clist_remove(GTK_CLIST(list), row); | |
559 } | |
560 } | |
561 | |
562 void account_editor(GtkWidget *w, GtkWidget *W) | |
563 { | |
564 /* please kill me */ | |
565 GtkWidget *frame; | |
566 GtkWidget *box; | |
567 GtkWidget *list; | |
568 GtkWidget *hbox; | |
569 GtkWidget *button; /* used for many things */ | |
570 | |
571 if (acctedit) { gtk_widget_show(acctedit); return; } | |
572 | |
573 acctedit = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
574 gtk_window_set_title(GTK_WINDOW(acctedit), _("Gaim - Account Editor")); | |
575 gtk_window_set_wmclass(GTK_WINDOW(acctedit), "accounteditor", "Gaim"); | |
576 gtk_widget_realize(acctedit); | |
577 aol_icon(acctedit->window); | |
578 gtk_container_border_width(GTK_CONTAINER(acctedit), 10); | |
579 gtk_widget_set_usize(acctedit, -1, 200); | |
580 gtk_signal_connect(GTK_OBJECT(acctedit), "destroy", | |
581 GTK_SIGNAL_FUNC(delete_acctedit), NULL); | |
582 | |
583 frame = gtk_frame_new(_("Account Editor")); | |
584 gtk_container_add(GTK_CONTAINER(acctedit), frame); | |
585 gtk_widget_show(frame); | |
586 | |
587 box = gtk_vbox_new(FALSE, 5); | |
588 gtk_container_add(GTK_CONTAINER(frame), box); | |
589 gtk_widget_show(box); | |
590 | |
591 list = generate_list(); | |
592 gtk_box_pack_start(GTK_BOX(box), list, TRUE, TRUE, 5); | |
593 | |
594 hbox = gtk_hbox_new(TRUE, 5); | |
595 gtk_box_pack_end(GTK_BOX(box), hbox, FALSE, FALSE, 5); | |
596 gtk_widget_show(hbox); | |
597 | |
598 button = picture_button(acctedit, _("Add"), gnome_add_xpm); | |
599 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5); | |
600 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(add_acct), NULL); | |
601 | |
602 button = picture_button(acctedit, _("Modify"), gnome_preferences_xpm); | |
603 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5); | |
604 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(mod_acct), NULL); | |
605 | |
606 button = picture_button(acctedit, _("Sign On/Off"), join_xpm); | |
607 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5); | |
608 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(acct_signin), NULL); | |
609 | |
610 button = picture_button(acctedit, _("Delete"), gnome_remove_xpm); | |
611 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5); | |
612 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(del_acct), NULL); | |
613 | |
614 button = picture_button(acctedit, _("Close"), gnome_close_xpm); | |
615 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 5); | |
616 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(acctedit_close), NULL); | |
617 | |
618 gtk_widget_show(acctedit); | |
619 } | |
620 | |
621 void account_online(struct gaim_connection *gc) | |
622 { | |
623 struct aim_user *u; | |
624 int i; | |
988
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
625 if (gc->meter) |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
626 gtk_widget_destroy(gc->meter); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
627 gc->meter = NULL; |
960 | 628 if (!acctedit) return; |
629 u = find_user(gc->username); | |
630 i = gtk_clist_find_row_from_data(GTK_CLIST(list), u); | |
977
e5eac6b236f1
[gaim-migrate @ 987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
969
diff
changeset
|
631 gtk_clist_set_text(GTK_CLIST(list), i, 1, "Yes"); |
960 | 632 gtk_clist_set_text(GTK_CLIST(list), i, 3, proto_name(gc->protocol)); |
633 redo_convo_menus(); | |
634 } | |
635 | |
636 void account_offline(struct gaim_connection *gc) | |
637 { | |
638 struct aim_user *u; | |
639 int i; | |
640 if (!acctedit) return; | |
641 u = find_user(gc->username); | |
642 i = gtk_clist_find_row_from_data(GTK_CLIST(list), u); | |
977
e5eac6b236f1
[gaim-migrate @ 987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
969
diff
changeset
|
643 gtk_clist_set_text(GTK_CLIST(list), i, 1, "No"); |
960 | 644 } |
645 | |
646 void auto_login() | |
647 { | |
648 GList *u = aim_users; | |
649 struct aim_user *a = NULL; | |
650 | |
651 while (u) { | |
652 a = (struct aim_user *)u->data; | |
653 if ((a->options & OPT_USR_AUTO) && (a->options & OPT_USR_REM_PASS)) { | |
654 #ifdef USE_APPLET | |
655 set_user_state(signing_on); | |
656 #endif /* USE_APPLET */ | |
980
82c5865f7cfe
[gaim-migrate @ 990]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
977
diff
changeset
|
657 serv_login(a); |
960 | 658 } |
659 u = u->next; | |
660 } | |
661 } | |
988
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
662 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
663 static void meter_destroy(GtkWidget *meter, struct gaim_connection *gc) { |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
664 gtk_widget_destroy(meter); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
665 gc->meter = NULL; |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
666 } |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
667 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
668 void set_login_progress(struct gaim_connection *gc, float howfar, char *message) { |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
669 if (mainwindow) |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
670 gtk_widget_hide(mainwindow); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
671 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
672 if (!gc->meter) { |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
673 GtkWidget *box, *label; |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
674 char buf[256]; |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
675 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
676 gc->meter = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
677 gtk_window_set_policy(GTK_WINDOW(gc->meter), 0, 0, 1); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
678 gtk_window_set_wmclass(GTK_WINDOW(gc->meter), "signon", "Gaim"); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
679 gtk_container_set_border_width(GTK_CONTAINER(gc->meter), 5); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
680 g_snprintf(buf, sizeof(buf), "%s Signing On", gc->username); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
681 gtk_window_set_title(GTK_WINDOW(gc->meter), buf); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
682 gtk_signal_connect(GTK_OBJECT(gc->meter), "destroy", |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
683 GTK_SIGNAL_FUNC(meter_destroy), gc); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
684 gtk_widget_realize(gc->meter); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
685 aol_icon(gc->meter->window); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
686 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
687 box = gtk_vbox_new(FALSE, 5); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
688 gtk_container_add(GTK_CONTAINER(gc->meter), box); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
689 gtk_widget_show(box); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
690 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
691 label = gtk_label_new(buf); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
692 gtk_box_pack_start(GTK_BOX(box), label, 0, 0, 5); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
693 gtk_widget_show(label); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
694 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
695 gc->progress = gtk_progress_bar_new(); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
696 gtk_widget_set_usize(gc->progress, 150, 0); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
697 gtk_box_pack_start(GTK_BOX(box), gc->progress, 0, 0, 5); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
698 gtk_widget_show(gc->progress); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
699 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
700 gc->status = gtk_statusbar_new(); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
701 gtk_widget_set_usize(gc->status, 150, 0); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
702 gtk_box_pack_start(GTK_BOX(box), gc->status, 0, 0, 5); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
703 gtk_widget_show(gc->status); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
704 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
705 gtk_widget_show(gc->meter); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
706 } |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
707 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
708 gtk_progress_bar_update(GTK_PROGRESS_BAR(gc->progress), howfar / 5); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
709 gtk_statusbar_pop(GTK_STATUSBAR(gc->status), 1); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
710 gtk_statusbar_push(GTK_STATUSBAR(gc->status), 1, message); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
711 } |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
712 |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
713 void hide_login_progress(struct gaim_connection *gc, char *why) |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
714 { |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
715 char buf[2048]; |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
716 sprintf(buf, _("%s was unable to sign on: %s"), gc->username, why); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
717 do_error_dialog(buf, _("Signon Error")); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
718 if (gc->meter) |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
719 gtk_widget_destroy(gc->meter); |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
720 gc->meter = NULL; |
9523b772e546
[gaim-migrate @ 998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
984
diff
changeset
|
721 } |